From a348232621ef35ca313db3284553e9327aa466ff Mon Sep 17 00:00:00 2001 From: md Date: Mon, 21 Jun 2021 18:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=B0=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E7=AD=9B=E9=80=89=E5=8A=9F=E8=83=BD=E5=92=8C?= =?UTF-8?q?=20=E5=85=B6=E4=BB=96=E9=A1=B5=E9=9D=A2=E7=9A=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../outdoor/adapter/StaySubmitAdapter.java | 27 ++- .../outdoor/fragment/OtherFragment.java | 39 +++++ .../outdoor/fragment/RoadFragment.java | 6 + .../outdoor/fragment/StaySubmitFragment.java | 94 ++++++----- app/src/main/res/drawable/arrow_black.png | Bin 0 -> 376 bytes app/src/main/res/drawable/icon_location.png | Bin 0 -> 369 bytes app/src/main/res/drawable/other_text.xml | 6 + app/src/main/res/layout/fragment_other.xml | 155 ++++++++++++++++++ .../main/res/layout/fragment_stay_submit.xml | 2 +- 10 files changed, 276 insertions(+), 55 deletions(-) create mode 100644 app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java create mode 100644 app/src/main/res/drawable/arrow_black.png create mode 100644 app/src/main/res/drawable/icon_location.png create mode 100644 app/src/main/res/drawable/other_text.xml create mode 100644 app/src/main/res/layout/fragment_other.xml 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 0000000000000000000000000000000000000000..cefb8219d9832b2b5fcb7eee43f914171aca0777 GIT binary patch literal 376 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!asqrpT!FMP3>X<1!I;LTrlxQ< zG6SdvqRha+04NS&BP#&1O~3#m2v!a?cJ+Y`SAq5^mjw9*GyHh>#p^-8GSBZ9*LPNw zraM}SupgcqZloi9{>OFVdQ&MBb@ E0D1I*UjP6A literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a8a726cb01bcadd6b27e4aa6b60630f5ed2db02a GIT binary patch literal 369 zcmeAS@N?(olHy`uVBq!ia0vp^{6H+s!3-oTWR}kWQuzTsA+A7Lr{$+b|9{=)AG)nS zfNY)SpCA&9bX$Jvw*55k`tLCRzfQ{!-4>t%u$tDNx-GwSTYu_+7{B#eetS;(@3!ba zM6WK$1duYl=3ja(zYKs1+I|_f0A+vNF1w=$v{I!c$S;`T4bP#%U*A67ygFA?h~w$K z9sL#A;l9rH?98W*ES}Sv9B*YV-}zJ`9H_q6)5S4F;&Sd;cd^3?JS-PB7P2QD*Db4h z_%HnohuoS!;**{QvYg_cI<@w@Yk}p?1)J@r=}DEvos*fm#)L^Z+BEkbP0l+XkK$*P{e literal 0 HcmV?d00001 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"> -