diff --git a/app/build.gradle b/app/build.gradle index c297aae..b48ec2e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.0" - //ndkVersion '23.0.7123448' + ndkVersion '23.0.7123448' defaultConfig { applicationId "com.navinfo.outdoor" diff --git a/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java b/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java index ea1198b..70e8c43 100644 --- a/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java +++ b/app/src/main/java/com/navinfo/outdoor/adapter/StaySubmitAdapter.java @@ -33,31 +33,27 @@ public class StaySubmitAdapter extends RecyclerView.Adapter allRoad = new ArrayList<>(); private Context context; - - public StaySubmitAdapter(Context context) { this.context = context; - } - - public void setAllRoad(List allRoad) { - if (this.allRoad!=null) { - this.allRoad.clear(); - this.allRoad.addAll(allRoad); - } + + this.allRoad.clear(); + this.allRoad.addAll(allRoad); notifyDataSetChanged(); } public void setAllDataChecked(boolean isChecked) { - if (this.allRoad!=null) { - for (PoiEntity entity: this.allRoad) { + if (this.allRoad != null) { + for (PoiEntity entity : this.allRoad) { entity.setChecked(isChecked); } } } - public void setAllCheckedDelete(){ + + //条目删除 + public void setAllCheckedDelete() { new Thread(new Runnable() { @Override public void run() { @@ -87,13 +83,16 @@ public class StaySubmitAdapter extends RecyclerView.Adapter poiEntities; + private List roadEntities; + private ArrayList newEntities; public static StaySubmitFragment newInstance(Bundle bundle) { @@ -70,26 +77,17 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList @Override protected void initView() { super.initView(); - poiDatabase = PoiDatabase.getInstance(getContext()); - poiDao = poiDatabase.getPoiDao(); ConstraintLayout clStayType = findViewById(R.id.cl_stay_type); clStayType.setOnClickListener(this::onClick); - tvStayType = findViewById(R.id.tv_stay_type); - tvStayResult = findViewById(R.id.tv_stay_result); - tvStayResult.setOnClickListener(this::onClick); - stayXrv = (XRecyclerView) findViewById(R.id.stay_xrv); + stayXrv = (RecyclerView) findViewById(R.id.stay_xrv); cbSelect = (CheckBox) findViewById(R.id.cb_select); cbSelect.setOnClickListener(this::onClick); tvDelete = (TextView) findViewById(R.id.tv_delete); tvDelete.setOnClickListener(this::onClick); + tvStayType = findViewById(R.id.tv_stay_type); btnStaySubmit = (Button) findViewById(R.id.btn_stay_submit); stayXrv.setLayoutManager(new LinearLayoutManager(getActivity())); stayXrv.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); - stayXrv.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader); - stayXrv.setLoadingMoreProgressStyle(ProgressStyle.BallRotate); - //取消上拉加载,刷新功能。 - stayXrv.setPullRefreshEnabled(false); - stayXrv.setLoadingMoreEnabled(false); staySubmitAdapter = new StaySubmitAdapter(getContext()); stayXrv.setAdapter(staySubmitAdapter); cbSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @@ -99,64 +97,82 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList staySubmitAdapter.notifyDataSetChanged(); } }); - stayXrv.getDefaultFootView().setNoMoreHint("加载完毕"); - stayXrv.setLoadingListener(new XRecyclerView.LoadingListener() { - @Override - public void onRefresh() { - - } - - @Override - public void onLoadMore() { - - } - }); } @Override protected void initData() { super.initData(); - poiDatabase = PoiDatabase.getInstance(getContext()); - poiDao = poiDatabase.getPoiDao(); - poiEntities = new ArrayList<>(); + roadDatabase = PoiDatabase.getInstance(getContext()); + roadDao = roadDatabase.getPoiDao(); + roadEntities = new ArrayList<>(); + newEntities = new ArrayList<>(); new Thread(new Runnable() { @Override public void run() { - poiEntities = poiDao.getAllPoi(); + List roadAll = roadDao.getAllPoi(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { - Log.d("TAG", "run: " + poiEntities.toString()); - staySubmitAdapter.setAllRoad(poiEntities); - staySubmitAdapter.notifyDataSetChanged(); + Log.d("TAG", "run: " + roadEntities.toString()); + roadEntities.clear(); + roadEntities.addAll(roadAll); + staySubmitAdapter.setAllRoad(roadEntities); } }); } - }).start(); + } + public List initRoadWord(int type){ + newEntities.clear(); + for (int i = 0; i < roadEntities.size(); i++) { + PoiEntity poiEntity = roadEntities.get(i); + if (poiEntity.getType()==type){ + newEntities.add(poiEntity); + } + } + return newEntities; } @Override public void onClick(View v) { switch (v.getId()) { - case R.id.tv_stay_result: - Toast.makeText(getContext(), "点击了", Toast.LENGTH_SHORT).show(); - break; case R.id.cl_stay_type: BottomMenu.show((AppCompatActivity) getContext(), new String[]{"poi", "道路", "充电站", "其他"}, new OnMenuItemClickListener() { @Override public void onClick(String text, int index) { + switch (index){ + case 0: + List poiEntities = initRoadWord(0); + staySubmitAdapter.setAllRoad(poiEntities); + // Toast.makeText(getContext(), "poi类型的数据"+poiEntities.toString(), Toast.LENGTH_SHORT).show(); + break; + case 1: + List poiEntitiesList = initRoadWord(1); + staySubmitAdapter.setAllRoad(poiEntitiesList); + // Toast.makeText(getContext(), "道路类型的数据"+poiEntitiesList.toString(), Toast.LENGTH_SHORT).show(); + break; + } tvStayType.setText(text); } }); break; case R.id.tv_delete: - staySubmitAdapter.setAllCheckedDelete(); + DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; + MessageDialog.show((AppCompatActivity) getContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() { + @Override + public boolean onClick(BaseDialog baseDialog, View v) { + staySubmitAdapter.setAllCheckedDelete(); + return false; + } + }); break; } } + + + } \ No newline at end of file diff --git a/app/src/main/res/drawable/arrow_black.png b/app/src/main/res/drawable/arrow_black.png new file mode 100644 index 0000000..cefb821 Binary files /dev/null and b/app/src/main/res/drawable/arrow_black.png differ diff --git a/app/src/main/res/drawable/icon_location.png b/app/src/main/res/drawable/icon_location.png new file mode 100644 index 0000000..a8a726c Binary files /dev/null and b/app/src/main/res/drawable/icon_location.png differ diff --git a/app/src/main/res/drawable/other_text.xml b/app/src/main/res/drawable/other_text.xml new file mode 100644 index 0000000..aab4f66 --- /dev/null +++ b/app/src/main/res/drawable/other_text.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_other.xml b/app/src/main/res/layout/fragment_other.xml new file mode 100644 index 0000000..05381c2 --- /dev/null +++ b/app/src/main/res/layout/fragment_other.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_stay_submit.xml b/app/src/main/res/layout/fragment_stay_submit.xml index a65d94b..9422413 100644 --- a/app/src/main/res/layout/fragment_stay_submit.xml +++ b/app/src/main/res/layout/fragment_stay_submit.xml @@ -72,7 +72,7 @@ android:layout_width="match_parent" android:layout_height="300dp"> -