!13 添加记录页面的筛选功能和‘其他’页面的部分布局

Merge pull request !13 from Amdi/master
This commit is contained in:
肖岩 2021-06-21 18:17:55 +08:00 committed by Gitee
commit a66e28efdb
10 changed files with 276 additions and 55 deletions

View File

@ -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"

View File

@ -33,31 +33,27 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
private List<PoiEntity> allRoad = new ArrayList<>();
private Context context;
public StaySubmitAdapter(Context context) {
this.context = context;
}
public void setAllRoad(List<PoiEntity> allRoad) {
if (this.allRoad!=null) {
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,6 +83,7 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
PoiEntity poiEntity = allRoad.get(position);
holder.tvName.setText(poiEntity.getName());
holder.tvDay.setText(poiEntity.getCreateTime());
//获取checkBox点击的记录
holder.cbUnSubmit.setChecked(allRoad.get(position).isChecked());
holder.cbUnSubmit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -94,6 +91,8 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
allRoad.get(position).setChecked(isChecked);
}
});
}
@Override

View File

@ -0,0 +1,39 @@
package com.navinfo.outdoor.fragment;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.base.BaseFragment;
/**
* 寻宝-上报-其他的fragment
*/
public class OtherFragment extends BaseFragment implements View.OnClickListener{
@Override
protected int getLayout() {
return R.layout.fragment_other;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
@Override
public void onClick(View v) {
}
}

View File

@ -58,6 +58,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
private RoadExtend roadExtend;
private PoiDatabase poiDatabase;
private PoiDao poiDao;
private PoiEntity showPoiEntity;
public static RoadFragment newInstance(Bundle bundle) {
RoadFragment fragment = new RoadFragment();
@ -182,12 +183,17 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
poiEntity.setCreateTime(format);
poiEntity.setType(1);
new Thread(new Runnable() {
@Override
public void run() {
if (showPoiEntity!=null){
poiDao.updatePoiEntity(poiEntity);
}
poiDao.insertPoiEntity(poiEntity);
}
}).start();
onBackPressed();
}
}

View File

@ -1,5 +1,6 @@
package com.navinfo.outdoor.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@ -18,12 +19,17 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.jcodecraeer.xrecyclerview.ProgressStyle;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.BottomMenu;
import com.kongzue.dialog.v3.MessageDialog;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.adapter.StaySubmitAdapter;
import com.navinfo.outdoor.api.UserApplication;
@ -44,16 +50,17 @@ import java.util.List;
* 记录-待提交的fragment
*/
public class StaySubmitFragment extends BaseFragment implements View.OnClickListener {
private XRecyclerView stayXrv;
private RecyclerView stayXrv;
private CheckBox cbSelect;
private TextView tvDelete;
private Button btnStaySubmit;
private StaySubmitAdapter staySubmitAdapter;
private PoiDatabase poiDatabase;
private PoiDao poiDao;
private PoiDatabase roadDatabase;
private PoiDao roadDao;
private TextView tvStayType;
private TextView tvStayResult;
private List<PoiEntity> poiEntities;
private List<PoiEntity> roadEntities;
private ArrayList<PoiEntity> 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<PoiEntity> 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<PoiEntity> 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<PoiEntity> poiEntities = initRoadWord(0);
staySubmitAdapter.setAllRoad(poiEntities);
// Toast.makeText(getContext(), "poi类型的数据"+poiEntities.toString(), Toast.LENGTH_SHORT).show();
break;
case 1:
List<PoiEntity> 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:
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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#fff"/>
<stroke android:width="1dp"
android:color="@color/black"/>
</shape>

View File

@ -0,0 +1,155 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.OtherFragment">
<LinearLayout
android:id="@+id/rl_other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1BA5F1"
android:orientation="horizontal"
android:paddingTop="@dimen/top_pind_sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_other_final"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="15dp"
android:src="@drawable/icon_arrow" />
<TextView
android:id="@+id/tv_other"
style="@style/text_style_toolbar_title"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/iv_find_task"
android:text="我的等级" />
</LinearLayout>
<ImageView
android:id="@+id/iv_bg01"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/bg_01"
app:layout_constraintTop_toBottomOf="@+id/rl_other" />
<TextView
android:id="@+id/tv_select_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="01.选择情报类型"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_bg01" />
<LinearLayout
android:id="@+id/ll_text"
android:layout_width="350dp"
android:layout_height="200dp"
app:layout_constraintLeft_toLeftOf="@id/tv_select_type"
app:layout_constraintTop_toBottomOf="@id/tv_select_type">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/other_text">
<TextView
android:id="@+id/tv_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="下拉选择"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/other_dawn"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/arrow_black"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_data"
android:layout_width="match_parent"
android:layout_height="160dp"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/ll_text">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="02.基本资料填写"
android:textStyle="bold" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/other_text">
<TextView
android:id="@+id/tv_indeo"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="点位*"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_position"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:background="@null"
app:layout_constraintLeft_toRightOf="@id/tv_indeo"
app:layout_constraintTop_toTopOf="@id/tv_indeo" />
<ImageView
android:id="@+id/iv_other_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="@drawable/icon_location"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/other_text"
android:layout_margin="20dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="名称*"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -72,7 +72,7 @@
android:layout_width="match_parent"
android:layout_height="300dp">
<com.jcodecraeer.xrecyclerview.XRecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/stay_xrv"
android:layout_width="match_parent"
android:layout_height="0dp"