人口基础信息添加筛选条件、人口基础信息必填字段修改
This commit is contained in:
parent
7a5efec614
commit
fa14565968
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
</component>
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -19,3 +19,6 @@
|
||||
|
||||
## 2022-2-16
|
||||
> 1 人口信息列表修改 人口新录入时基础信息回显修改
|
||||
>
|
||||
## 2022-3-29
|
||||
> 1 人口基础信息添加条件筛选 ,基础信息录入必填字段修改
|
@ -92,4 +92,7 @@ dependencies {
|
||||
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'
|
||||
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,9 +9,13 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.jcodecraeer.xrecyclerview.ProgressStyle;
|
||||
import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
||||
import com.sucstepsoft.cm_utils.constant.PathConfig;
|
||||
import com.sucstepsoft.cm_utils.core.retrofit_net.RetrofitManager;
|
||||
import com.sucstepsoft.cm_utils.core.widget.base.BaseActivity;
|
||||
import com.sucstepsoft.cm_utils.utils.ToastUtils;
|
||||
@ -19,10 +23,12 @@ import com.sucstepsoft.cm_utils.utils.UIUtil;
|
||||
import com.sucstepsoft.cm_utils.utils.UserLgUtils;
|
||||
import com.sucstepsoft.realtimelocation.R;
|
||||
import com.sucstepsoft.realtimelocation.adapters.CensusPersonAdapter;
|
||||
import com.sucstepsoft.realtimelocation.beans.DicBean;
|
||||
import com.sucstepsoft.realtimelocation.beans.SuccessBean;
|
||||
import com.sucstepsoft.realtimelocation.beans.person.CensusPersonBean;
|
||||
import com.sucstepsoft.realtimelocation.net.LocationApiService;
|
||||
import com.sucstepsoft.realtimelocation.utils.ExceptionHandler;
|
||||
import com.sucstepsoft.realtimelocation.widget.ConditionPopup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -48,6 +54,24 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
Button mBtnSearch;
|
||||
@BindView(R.id.xlv_content)
|
||||
XRecyclerView mXlvItems;
|
||||
@BindView(R.id.tv_nation)
|
||||
TextView mTvNation;
|
||||
@BindView(R.id.tv_faith)
|
||||
TextView mTvFaith;
|
||||
@BindView(R.id.tv_political)
|
||||
TextView mTvPolitical;
|
||||
@BindView(R.id.tv_marr)
|
||||
TextView mTvMarr;
|
||||
@BindView(R.id.tv_edu)
|
||||
TextView mTvEdu;
|
||||
@BindView(R.id.ll_empty)
|
||||
LinearLayout mLlEmpty;
|
||||
@BindView(R.id.iv_empty)
|
||||
ImageView mIvAEmpty;
|
||||
@BindView(R.id.pb_loading)
|
||||
ProgressBar mPbALoading;
|
||||
@BindView(R.id.tv_hint)
|
||||
TextView mTvAHint;
|
||||
private Unbinder mBind;
|
||||
private String mRows = "20";
|
||||
private int mCurPage = 1;
|
||||
@ -57,6 +81,22 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
|
||||
private String mKeywords = "";
|
||||
|
||||
private List<DicBean> mNations = new ArrayList<>();
|
||||
private DicBean mSelNation;
|
||||
|
||||
private List<DicBean> mFaiths;
|
||||
private DicBean mSelFaith;
|
||||
|
||||
private List<DicBean> mPoliticals;
|
||||
private DicBean mSelPolitical;
|
||||
|
||||
private List<DicBean> mMarrays;
|
||||
private DicBean mSelMarray;
|
||||
|
||||
private List<DicBean> mEdus;
|
||||
private DicBean mSelEdu;
|
||||
|
||||
|
||||
@Override
|
||||
protected int setLayoutId() {
|
||||
return R.layout.activity_census_base;
|
||||
@ -68,12 +108,13 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
mTvBaseTitle.setText("基础信息");
|
||||
mTvPublish.setVisibility(View.VISIBLE);
|
||||
mTvPublish.setText("新增");
|
||||
refreshView(STATE_LOAD_SUCCESS);
|
||||
mTvPublish.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(mActivity, CensusEnterActivity.class);
|
||||
intent.putExtra("title", "人员基础信息录入");
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
mEtSearchContent.setHint("请输入要查询的关键字");
|
||||
mBtnSearch.setOnClickListener(v -> doSearch());
|
||||
mIvClear.setOnClickListener(v -> {
|
||||
mKeywords = "";
|
||||
@ -113,6 +154,203 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
doEditBean(bean, pos);
|
||||
}
|
||||
});
|
||||
mTvNation.setOnClickListener(v -> {
|
||||
if (mNations != null && mNations.size() > 0) {
|
||||
onShowNationPopup();
|
||||
} else {
|
||||
getDicListByType(PathConfig.DIC_NATION, 2);
|
||||
}
|
||||
});//民族
|
||||
mTvFaith.setOnClickListener(v -> {
|
||||
if (mFaiths != null && mFaiths.size() > 0) {
|
||||
onShowFaith();
|
||||
} else {
|
||||
getDicListByType(PathConfig.DIC_FAITH, 6);
|
||||
}
|
||||
});//宗教
|
||||
mTvPolitical.setOnClickListener(v -> {
|
||||
if (mPoliticals != null && mPoliticals.size() > 0) {
|
||||
onShowPolitical();
|
||||
} else {
|
||||
getDicListByType(PathConfig.DIC_POLITICS, 4);
|
||||
}
|
||||
});//政治
|
||||
mTvMarr.setOnClickListener(v -> {
|
||||
if (mMarrays != null && mMarrays.size() > 0) {
|
||||
onShowMarray();
|
||||
} else {
|
||||
getDicListByType(PathConfig.DIC_MARRIAGE, 3);
|
||||
}
|
||||
});//婚姻
|
||||
mTvEdu.setOnClickListener(v -> {
|
||||
if (mEdus != null && mEdus.size() > 0) {
|
||||
onShowEdu();
|
||||
} else {
|
||||
getDicListByType(PathConfig.DIC_EDU, 5);
|
||||
}
|
||||
});//学历
|
||||
}
|
||||
|
||||
/**
|
||||
* 名族弹窗
|
||||
*/
|
||||
private void onShowNationPopup() {
|
||||
ConditionPopup conditionPopup = new ConditionPopup(mActivity, mNations);
|
||||
conditionPopup.setOnListPopupItemClickListener((bean, isCheck, pos) -> {
|
||||
if (isCheck) {
|
||||
//选中了
|
||||
mSelNation = bean;
|
||||
mTvNation.setText(mSelNation.getDictionaryName());
|
||||
} else {
|
||||
//清除了选项
|
||||
mSelNation = null;
|
||||
mTvNation.setText("民族");
|
||||
}
|
||||
conditionPopup.dismiss();
|
||||
});
|
||||
conditionPopup.showPopupWindow(mTvNation);
|
||||
}
|
||||
// private String[] tabs = {"民族", "宗教信仰", "政治面貌", "婚姻情况", "学历"};
|
||||
|
||||
/**
|
||||
* 宗教信仰
|
||||
*/
|
||||
private void onShowFaith() {
|
||||
ConditionPopup conditionPopup = new ConditionPopup(mActivity, mFaiths);
|
||||
conditionPopup.setOnListPopupItemClickListener((bean, isCheck, pos) -> {
|
||||
if (isCheck) {
|
||||
//选中了
|
||||
mSelFaith = bean;
|
||||
mTvFaith.setText(mSelFaith.getDictionaryName());
|
||||
} else {
|
||||
//清除了选项
|
||||
mSelFaith = null;
|
||||
mTvFaith.setText("宗教信仰");
|
||||
}
|
||||
conditionPopup.dismiss();
|
||||
});
|
||||
conditionPopup.showPopupWindow(mTvFaith);
|
||||
}
|
||||
|
||||
/**
|
||||
* 政治面貌
|
||||
*/
|
||||
private void onShowPolitical() {
|
||||
ConditionPopup conditionPopup = new ConditionPopup(mActivity, mPoliticals);
|
||||
conditionPopup.setOnListPopupItemClickListener((bean, isCheck, pos) -> {
|
||||
if (isCheck) {
|
||||
//选中了
|
||||
mSelPolitical = bean;
|
||||
mTvPolitical.setText(mSelPolitical.getDictionaryName());
|
||||
} else {
|
||||
//清除了选项
|
||||
mSelPolitical = null;
|
||||
mTvPolitical.setText("政治面貌");
|
||||
}
|
||||
conditionPopup.dismiss();
|
||||
});
|
||||
conditionPopup.showPopupWindow(mTvPolitical);
|
||||
}
|
||||
|
||||
/**
|
||||
* 婚姻状况
|
||||
*/
|
||||
private void onShowMarray() {
|
||||
ConditionPopup conditionPopup = new ConditionPopup(mActivity, mMarrays);
|
||||
conditionPopup.setOnListPopupItemClickListener((bean, isCheck, pos) -> {
|
||||
if (isCheck) {
|
||||
//选中了
|
||||
mSelMarray = bean;
|
||||
mTvMarr.setText(mSelMarray.getDictionaryName());
|
||||
} else {
|
||||
//清除了选项
|
||||
mSelMarray = null;
|
||||
mTvMarr.setText("婚姻状况");
|
||||
}
|
||||
conditionPopup.dismiss();
|
||||
});
|
||||
conditionPopup.showPopupWindow(mTvMarr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 学历
|
||||
*/
|
||||
private void onShowEdu() {
|
||||
ConditionPopup conditionPopup = new ConditionPopup(mActivity, mEdus);
|
||||
conditionPopup.setOnListPopupItemClickListener((bean, isCheck, pos) -> {
|
||||
if (isCheck) {
|
||||
//选中了
|
||||
mSelEdu = bean;
|
||||
mTvEdu.setText(mSelEdu.getDictionaryName());
|
||||
} else {
|
||||
//清除了选项
|
||||
mSelEdu = null;
|
||||
mTvEdu.setText("学历");
|
||||
}
|
||||
conditionPopup.dismiss();
|
||||
});
|
||||
conditionPopup.showPopupWindow(mTvEdu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*/
|
||||
private void getDicListByType(String pId, int i) {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(LocationApiService.class)
|
||||
.getDictListAllByPid(pId, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<DicBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<DicBean> typeListBeans) {
|
||||
dialog.dismiss();
|
||||
if (typeListBeans.size() > 0) {
|
||||
switch (i) {
|
||||
case 2://名族
|
||||
mNations = typeListBeans;
|
||||
onShowNationPopup();
|
||||
break;
|
||||
case 3://婚姻状况
|
||||
mMarrays = typeListBeans;
|
||||
onShowMarray();
|
||||
break;
|
||||
case 4://政治面貌
|
||||
mPoliticals = typeListBeans;
|
||||
onShowPolitical();
|
||||
break;
|
||||
case 5://学历
|
||||
mEdus = typeListBeans;
|
||||
onShowEdu();
|
||||
break;
|
||||
case 6://宗教信仰
|
||||
mFaiths = typeListBeans;
|
||||
onShowFaith();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("暂无数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -121,14 +359,10 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
*/
|
||||
private void doSearch() {
|
||||
String searchContent = mEtSearchContent.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(searchContent)) {
|
||||
hideSoftKeyboard();
|
||||
mKeywords = searchContent;
|
||||
mCurPage = 1;
|
||||
getUpcomingList(mCurPage);
|
||||
} else {
|
||||
ToastUtils.showShort("请输入要查询的内容");
|
||||
}
|
||||
hideSoftKeyboard();
|
||||
mKeywords = searchContent;
|
||||
mCurPage = 1;
|
||||
getUpcomingList(mCurPage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,45 +374,45 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
private void doDelBean(CensusPersonBean.RowsBean bean, int pos) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||
builder.setTitle("提示")
|
||||
.setMessage("确定要删除该条信息吗?")
|
||||
.setPositiveButton("确定", (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
ProgressDialog dialog1 = UIUtil.initDialog(mActivity, "删除中...");
|
||||
dialog1.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(LocationApiService.class)
|
||||
.doDelBaseInfo(bean.getBasePopulationInfoId(), UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<SuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
.setMessage("确定要删除该条信息吗?")
|
||||
.setPositiveButton("确定", (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
ProgressDialog dialog1 = UIUtil.initDialog(mActivity, "删除中...");
|
||||
dialog1.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(LocationApiService.class)
|
||||
.doDelBaseInfo(bean.getBasePopulationInfoId(), UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<SuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull SuccessBean successBean) {
|
||||
ToastUtils.showShort("删除成功");
|
||||
mDatas.remove(bean);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
dialog1.dismiss();
|
||||
}
|
||||
@Override
|
||||
public void onNext(@NonNull SuccessBean successBean) {
|
||||
ToastUtils.showShort("删除成功");
|
||||
mDatas.remove(bean);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
dialog1.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog1.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog1.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
});
|
||||
})
|
||||
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,66 +454,105 @@ public class CensusBaseActivity extends BaseActivity {
|
||||
*/
|
||||
private void getUpcomingList(int page) {
|
||||
mCurPage = page;
|
||||
String nation = mSelNation == null ? "" : mSelNation.getDictionaryId();
|
||||
String faith = mSelFaith == null ? "" : mSelFaith.getDictionaryId();
|
||||
String polition = mSelPolitical == null ? "" : mSelPolitical.getDictionaryId();
|
||||
String marry = mSelMarray == null ? "" : mSelMarray.getDictionaryId();
|
||||
String edu = mSelEdu == null ? "" : mSelEdu.getDictionaryId();
|
||||
RetrofitManager.getInstance()
|
||||
.create(LocationApiService.class)
|
||||
.getBaseInfoList(page + "", mKeywords, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<CensusPersonBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
.create(LocationApiService.class)
|
||||
.getBaseInfoList(page + "", mKeywords, nation, faith, polition, marry, edu, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<CensusPersonBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CensusPersonBean leaveListBean) {
|
||||
if (leaveListBean != null && leaveListBean.getRows() != null && leaveListBean.getRows().size() > 0) {
|
||||
++mCurPage;
|
||||
if (page == 1) {
|
||||
mDatas.clear();
|
||||
mDatas.addAll(leaveListBean.getRows());
|
||||
} else {
|
||||
mDatas.addAll(leaveListBean.getRows());
|
||||
}
|
||||
refreshView(STATE_LOAD_SUCCESS);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mXlvItems.refreshComplete();
|
||||
if (mDatas.size() >= leaveListBean.getTotal()) {
|
||||
mXlvItems.loadMoreComplete();
|
||||
mXlvItems.setNoMore(true);
|
||||
} else {
|
||||
mXlvItems.loadMoreComplete();
|
||||
mXlvItems.setNoMore(false);
|
||||
}
|
||||
@Override
|
||||
public void onNext(CensusPersonBean leaveListBean) {
|
||||
if (leaveListBean != null && leaveListBean.getRows() != null && leaveListBean.getRows().size() > 0) {
|
||||
++mCurPage;
|
||||
if (page == 1) {
|
||||
mDatas.clear();
|
||||
mDatas.addAll(leaveListBean.getRows());
|
||||
} else {
|
||||
if (page > 1) {
|
||||
mXlvItems.loadMoreComplete();
|
||||
mXlvItems.setNoMore(true);
|
||||
refreshView(STATE_LOAD_SUCCESS);
|
||||
mDatas.addAll(leaveListBean.getRows());
|
||||
}
|
||||
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mXlvItems.refreshComplete();
|
||||
if (mDatas.size() >= leaveListBean.getTotal()) {
|
||||
mXlvItems.loadMoreComplete();
|
||||
mXlvItems.setNoMore(true);
|
||||
} else {
|
||||
mXlvItems.loadMoreComplete();
|
||||
mXlvItems.setNoMore(false);
|
||||
}
|
||||
setStateView(STATE_LOAD_SUCCESS);
|
||||
} else {
|
||||
if (page > 1) {
|
||||
mXlvItems.loadMoreComplete();
|
||||
mXlvItems.setNoMore(true);
|
||||
setStateView(STATE_LOAD_SUCCESS);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(mKeywords)) {
|
||||
//无数据
|
||||
setStateView(STATE_LOAD_EMPTY);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(mKeywords)) {
|
||||
//无数据
|
||||
refreshView(STATE_LOAD_EMPTY);
|
||||
} else {
|
||||
ToastUtils.showShort("未查询到相关内容");
|
||||
}
|
||||
ToastUtils.showShort("未查询到相关内容");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
ToastUtils.showShort("数据加载失,请稍后重试");
|
||||
refreshView(STATE_LOAD_ERROR);
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
ToastUtils.showShort("数据加载失,请稍后重试");
|
||||
setStateView(STATE_LOAD_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setStateView(int state) {
|
||||
switch (state) {
|
||||
case STATE_LOAD_LOADING://加载中
|
||||
mPbALoading.setVisibility(View.VISIBLE);
|
||||
mIvAEmpty.setVisibility(View.GONE);
|
||||
mTvAHint.setVisibility(View.VISIBLE);
|
||||
mTvAHint.setText(getResources().getString(com.sucstepsoft.cm_utils.R.string.loading));
|
||||
mXlvItems.setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
case STATE_LOAD_SUCCESS://加载成功
|
||||
mPbALoading.setVisibility(View.GONE);
|
||||
mIvAEmpty.setVisibility(View.GONE);
|
||||
mTvAHint.setVisibility(View.GONE);
|
||||
mXlvItems.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case STATE_LOAD_EMPTY://空数据
|
||||
mPbALoading.setVisibility(View.GONE);
|
||||
mIvAEmpty.setVisibility(View.VISIBLE);
|
||||
mTvAHint.setVisibility(View.VISIBLE);
|
||||
mTvAHint.setText(getResources().getString(com.sucstepsoft.cm_utils.R.string.empty_data));
|
||||
mXlvItems.setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
case STATE_LOAD_ERROR:
|
||||
mPbALoading.setVisibility(View.GONE);
|
||||
mIvAEmpty.setVisibility(View.VISIBLE);
|
||||
mTvAHint.setVisibility(View.VISIBLE);
|
||||
mTvAHint.setText(getResources().getString(com.sucstepsoft.cm_utils.R.string.loading_error));
|
||||
mXlvItems.setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mDisposable != null && !mDisposable.isDisposed()) {
|
||||
|
@ -351,6 +351,47 @@ public class CensusEnterActivity extends BaseActivity {
|
||||
ToastUtils.showShort("请输入姓名");
|
||||
return false;
|
||||
}
|
||||
if (mSelNation == null) {
|
||||
ToastUtils.showShort("请选择民族");
|
||||
return false;
|
||||
}
|
||||
String nativeStr = mEtNative.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(nativeStr)) {
|
||||
ToastUtils.showShort("请输入籍贯");
|
||||
return false;
|
||||
}
|
||||
if (mSelMarry == null) {
|
||||
ToastUtils.showShort("请选择婚姻状况");
|
||||
return false;
|
||||
}
|
||||
if (mSelPolitical == null) {
|
||||
ToastUtils.showShort("请选择政治面貌");
|
||||
return false;
|
||||
}
|
||||
if (mSelEdu == null) {
|
||||
ToastUtils.showShort("请选择学历");
|
||||
return false;
|
||||
}
|
||||
if (mSelReligion == null) {
|
||||
ToastUtils.showShort("请选择宗教信仰");
|
||||
return false;
|
||||
}
|
||||
String work = mTvWork.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(work)) {
|
||||
ToastUtils.showShort("请输入职业");
|
||||
return false;
|
||||
}
|
||||
String workSpace = mEtWorkSpace.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(workSpace)) {
|
||||
ToastUtils.showShort("请输入工作单位");
|
||||
return false;
|
||||
}
|
||||
String phone = mEtPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phone)) {
|
||||
ToastUtils.showShort("请输入联系方式");
|
||||
return false;
|
||||
}
|
||||
|
||||
String curLoc = mTvCurLoc.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(curLoc)) {
|
||||
ToastUtils.showShort("请选择现住地");
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.sucstepsoft.realtimelocation.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.sucstepsoft.cm_utils.core.widget.base.BaseRecyclerAdapter;
|
||||
import com.sucstepsoft.realtimelocation.R;
|
||||
import com.sucstepsoft.realtimelocation.adapters.holders.ConditionViewHolder;
|
||||
import com.sucstepsoft.realtimelocation.beans.DicBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 作者: adam
|
||||
* 日期: 2022/3/30 - 11:00 上午
|
||||
* 邮箱: itgaojian@163.com
|
||||
* 描述:
|
||||
*/
|
||||
public class ConditionAdapter extends BaseRecyclerAdapter<DicBean, ConditionViewHolder> {
|
||||
public List<DicBean> mSelBeans = new ArrayList<>();
|
||||
public ConditionAdapter(Context ctx, List<DicBean> list) {
|
||||
super(ctx, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionViewHolder createHolder(ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_condition_dic, parent, false);
|
||||
return new ConditionViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindHolder(ConditionViewHolder holder, int i) {
|
||||
DicBean bean = mData.get(i);
|
||||
holder.mTvName.setText(bean.getDictionaryName());
|
||||
holder.mTvName.setTextColor(bean.isCheck() ? Color.parseColor("#1296db") : Color.BLACK);
|
||||
if (bean.isCheck()) {
|
||||
holder.mIvCheck.setVisibility(View.VISIBLE);
|
||||
holder.mIvCheck.setImageResource(R.drawable.ic_check_blue);
|
||||
} else {
|
||||
holder.mIvCheck.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
holder.itemView.setOnClickListener(v -> mLis.onItemCheckChange(bean, !bean.isCheck(), i));
|
||||
}
|
||||
|
||||
private OnItemCheckChange mLis;
|
||||
|
||||
public void addOnitemCheckChange(OnItemCheckChange lis) {
|
||||
this.mLis = lis;
|
||||
}
|
||||
|
||||
public interface OnItemCheckChange {
|
||||
void onItemCheckChange(DicBean bean, boolean isCheck, int pos);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.sucstepsoft.realtimelocation.adapters.holders;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.sucstepsoft.realtimelocation.R;
|
||||
|
||||
/**
|
||||
* 作者: adam
|
||||
* 日期: 2022/3/30 - 10:55 上午
|
||||
* 邮箱: itgaojian@163.com
|
||||
* 描述:
|
||||
*/
|
||||
public class ConditionViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView mTvName;
|
||||
public ImageView mIvCheck;
|
||||
|
||||
public ConditionViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mTvName = itemView.findViewById(R.id.tv_name);
|
||||
mIvCheck = itemView.findViewById(R.id.iv_icon);
|
||||
}
|
||||
}
|
@ -1385,7 +1385,14 @@ public interface LocationApiService {
|
||||
*/
|
||||
@Headers({"base_url_name:person", "Content-Type: application/json", "Accept: application/json"})
|
||||
@GET("app/basepopulationinfo/listpagebasepopulationinfo")
|
||||
Observable<CensusPersonBean> getBaseInfoList(@Query("page") String page, @Query("keywords") String keywords, @Header("token") String token);
|
||||
Observable<CensusPersonBean> getBaseInfoList(@Query("page") String page,
|
||||
@Query("keywords") String keywords,
|
||||
@Query("nation") String nation,
|
||||
@Query("religion") String faith,
|
||||
@Query("politicalStatus") String political,
|
||||
@Query("maritalStatus") String marry,
|
||||
@Query("education") String edu,
|
||||
@Header("token") String token);
|
||||
/*===========================================工作日志===========================================*/
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.sucstepsoft.realtimelocation.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import com.sucstepsoft.realtimelocation.R;
|
||||
import com.sucstepsoft.realtimelocation.adapters.ConditionAdapter;
|
||||
import com.sucstepsoft.realtimelocation.beans.DicBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import razerdp.basepopup.BasePopupWindow;
|
||||
|
||||
/**
|
||||
* 作者: adam
|
||||
* 日期: 2022/3/30 - 10:12 上午
|
||||
* 邮箱: itgaojian@163.com
|
||||
* 描述:
|
||||
*/
|
||||
public class ConditionPopup extends BasePopupWindow {
|
||||
private List<DicBean> mDatas;
|
||||
private final RecyclerView mRlvConditions;
|
||||
private OnListPopupItemClickListener mOnListPopupItemClickListener;
|
||||
|
||||
public ConditionPopup(Context context, List<DicBean> data) {
|
||||
super(context);
|
||||
this.mDatas = data;
|
||||
mRlvConditions = findViewById(R.id.rlv_conditions);
|
||||
mRlvConditions.setLayoutManager(new LinearLayoutManager(context));
|
||||
ConditionAdapter adapter = new ConditionAdapter(context, mDatas);
|
||||
mRlvConditions.setAdapter(adapter);
|
||||
adapter.addOnitemCheckChange((bean, isCheck, pos) -> {
|
||||
if (isCheck) {
|
||||
adapter.mSelBeans.clear();
|
||||
adapter.mSelBeans.add(bean);
|
||||
} else {
|
||||
adapter.mSelBeans.remove(bean);
|
||||
}
|
||||
bean.setCheck(isCheck);
|
||||
mOnListPopupItemClickListener.onItemClick(bean, isCheck, pos);
|
||||
if (isCheck) {
|
||||
if (true) {
|
||||
for (int i = 0; i < adapter.getData().size(); i++) {
|
||||
if (!adapter.getData().get(i).getDictionaryId().equals(bean.getDictionaryId())) {
|
||||
adapter.getData().get(i).setCheck(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateContentView() {
|
||||
return createPopupById(R.layout.popup_condition_layout);
|
||||
}
|
||||
|
||||
public OnListPopupItemClickListener getOnListPopupItemClickListener() {
|
||||
return mOnListPopupItemClickListener;
|
||||
}
|
||||
|
||||
public void setOnListPopupItemClickListener(OnListPopupItemClickListener onListPopupItemClickListener) {
|
||||
mOnListPopupItemClickListener = onListPopupItemClickListener;
|
||||
}
|
||||
|
||||
public interface OnListPopupItemClickListener {
|
||||
void onItemClick(DicBean bean, boolean isCheck, int pos);
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-xhdpi/ic_arrow_sort_gray.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_arrow_sort_gray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 211 B |
BIN
app/src/main/res/drawable-xhdpi/ic_check_blue.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_check_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 737 B |
@ -1,16 +1,168 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout 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">
|
||||
|
||||
<include layout="@layout/item_search" />
|
||||
|
||||
<com.jcodecraeer.xrecyclerview.XRecyclerView
|
||||
android:id="@+id/xlv_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_condition"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/ll_search_content"
|
||||
android:layout_marginTop="5dp" />
|
||||
android:background="@color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_sort_gray"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="民族"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="15dp"
|
||||
android:background="@color/gray_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_faith"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_sort_gray"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="宗教信仰"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="15dp"
|
||||
android:background="@color/gray_line" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_political"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_sort_gray"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="政治面貌"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="15dp"
|
||||
android:background="@color/gray_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_marr"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_sort_gray"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="婚姻情况"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="15dp"
|
||||
android:background="@color/gray_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edu"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_sort_gray"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="学历"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/item_search" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/ll_condition"
|
||||
android:layout_marginTop="5dp">
|
||||
|
||||
<com.jcodecraeer.xrecyclerview.XRecyclerView
|
||||
android:id="@+id/xlv_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_empty"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:src="@drawable/ic_empty_data" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminateBehavior="repeat"
|
||||
android:indeterminateDrawable="@drawable/anim_loading" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="暂无数据"
|
||||
android:textColor="@color/gray_text" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
@ -130,7 +130,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -150,7 +150,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -169,7 +169,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -188,7 +188,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -207,7 +207,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -226,7 +226,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -262,7 +262,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -280,7 +280,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
@ -299,7 +299,7 @@
|
||||
|
||||
<ImageView
|
||||
style="@style/style_hint_star"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
|
26
app/src/main/res/layout/item_condition_dic.xml
Normal file
26
app/src/main/res/layout/item_condition_dic.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
tools:text="学历" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_icon"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
tools:src="@drawable/ic_check_blue" />
|
||||
</LinearLayout>
|
13
app/src/main/res/layout/popup_condition_layout.xml
Normal file
13
app/src/main/res/layout/popup_condition_layout.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/rlv_conditions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shp_rectangle_white_nora"
|
||||
android:padding="5dp" />
|
||||
</LinearLayout>
|
@ -10,15 +10,15 @@ import com.sucstepsoft.cm_utils.constant.PathConfig;
|
||||
public class BaseUrlApi {
|
||||
|
||||
public static final String IP = "http://219.147.99.164:8082/usercenter/"; /*正式统一用户*/
|
||||
// public static final String IP = "http://192.168.0.109:7001/usercenter/"; /*测试统一用户*/
|
||||
// public static final String IP = "http://192.168.0.109:7001/usercenter/"; /*测试统一用户*/
|
||||
public static final String BASE_URL = IP;
|
||||
public static final String APP_VERSION = BASE_URL + "appCmVersionManagement/getAppVersion";
|
||||
public static final String PRISON_PLAN = BASE_URL + "appPlan/goPlan";
|
||||
public static final String FIELD_SAFETY = BASE_URL + "appFieldSafety/goFloorPlan";
|
||||
public static final int PHOTO_REQUEST = 233;
|
||||
public static final int CAMERA_REQUEST = 123;
|
||||
public static final String BASE_IP_P = "http://219.147.99.164:8082/"; /*正式IP*/
|
||||
// public static final String BASE_IP_P = "http://192.168.0.109:8080/"; /*测试IP*/
|
||||
public static final String BASE_IP_P = "http://219.147.99.164:8082/"; /*正式IP*/
|
||||
// public static final String BASE_IP_P = "http://192.168.0.109:8080/"; /*测试IP*/
|
||||
public static final String BASE_IP = BASE_IP_P + "servicecity/";/*网格系统*/
|
||||
public static final String BASE_POPULATION_IP = BASE_IP_P + "population/";/*人口系统*/
|
||||
public static final String BASE_IMG_URL = BASE_IP + "route/file/downloadfile/true/";
|
||||
|
@ -0,0 +1,263 @@
|
||||
package com.sucstepsoft.cm_utils.core.widget.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.sucstepsoft.cm_utils.R;
|
||||
import com.sucstepsoft.cm_utils.utils.ScreenUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Created by dongjunkun on 2015/6/17.
|
||||
*/
|
||||
public class DropDownMenu extends LinearLayout {
|
||||
|
||||
//顶部菜单布局
|
||||
private LinearLayout tabMenuView;
|
||||
//底部容器,包含popupMenuViews,maskView
|
||||
private FrameLayout containerView;
|
||||
//弹出菜单父布局
|
||||
private FrameLayout popupMenuViews;
|
||||
//遮罩半透明View,点击可关闭DropDownMenu
|
||||
private View maskView;
|
||||
//tabMenuView里面选中的tab位置,-1表示未选中
|
||||
private int current_tab_position = -1;
|
||||
|
||||
//分割线颜色
|
||||
private int dividerColor = 0xffcccccc;
|
||||
//tab选中颜色
|
||||
private int textSelectedColor = 0xff890c85;
|
||||
//tab未选中颜色
|
||||
private int textUnselectedColor = 0xff111111;
|
||||
//遮罩颜色
|
||||
private int maskColor = 0x88888888;
|
||||
//tab字体大小
|
||||
private int menuTextSize = 14;
|
||||
|
||||
//tab选中图标
|
||||
private int menuSelectedIcon;
|
||||
//tab未选中图标
|
||||
private int menuUnselectedIcon;
|
||||
|
||||
private float menuHeighPercent = 0.5f;
|
||||
|
||||
|
||||
public DropDownMenu(Context context) {
|
||||
super(context, null);
|
||||
}
|
||||
|
||||
public DropDownMenu(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
|
||||
//为DropDownMenu添加自定义属性
|
||||
int menuBackgroundColor = 0xffffffff;
|
||||
int underlineColor = 0xffcccccc;
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DropDownMenu);
|
||||
underlineColor = a.getColor(R.styleable.DropDownMenu_ddunderlineColor, underlineColor);
|
||||
dividerColor = a.getColor(R.styleable.DropDownMenu_dddividerColor, dividerColor);
|
||||
textSelectedColor = a.getColor(R.styleable.DropDownMenu_ddtextSelectedColor, textSelectedColor);
|
||||
textUnselectedColor = a.getColor(R.styleable.DropDownMenu_ddtextUnselectedColor, textUnselectedColor);
|
||||
menuBackgroundColor = a.getColor(R.styleable.DropDownMenu_ddmenuBackgroundColor, menuBackgroundColor);
|
||||
maskColor = a.getColor(R.styleable.DropDownMenu_ddmaskColor, maskColor);
|
||||
menuTextSize = a.getDimensionPixelSize(R.styleable.DropDownMenu_ddmenuTextSize, menuTextSize);
|
||||
menuSelectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuSelectedIcon, menuSelectedIcon);
|
||||
menuUnselectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuUnselectedIcon, menuUnselectedIcon);
|
||||
menuHeighPercent = a.getFloat(R.styleable.DropDownMenu_ddmenuMenuHeightPercent, menuHeighPercent);
|
||||
a.recycle();
|
||||
|
||||
//初始化tabMenuView并添加到tabMenuView
|
||||
tabMenuView = new LinearLayout(context);
|
||||
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
tabMenuView.setOrientation(HORIZONTAL);
|
||||
tabMenuView.setBackgroundColor(menuBackgroundColor);
|
||||
tabMenuView.setLayoutParams(params);
|
||||
addView(tabMenuView, 0);
|
||||
|
||||
//为tabMenuView添加下划线
|
||||
View underLine = new View(getContext());
|
||||
underLine.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpTpPx(1.0f)));
|
||||
underLine.setBackgroundColor(underlineColor);
|
||||
addView(underLine, 1);
|
||||
|
||||
//初始化containerView并将其添加到DropDownMenu
|
||||
containerView = new FrameLayout(context);
|
||||
containerView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
addView(containerView, 2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化DropDownMenu
|
||||
*
|
||||
* @param tabTexts
|
||||
* @param popupViews
|
||||
* @param contentView
|
||||
*/
|
||||
public void setDropDownMenu(@NonNull List<String> tabTexts, @NonNull List<View> popupViews, @NonNull View contentView) {
|
||||
if (tabTexts.size() != popupViews.size()) {
|
||||
throw new IllegalArgumentException("params not match, tabTexts.size() should be equal popupViews.size()");
|
||||
}
|
||||
|
||||
for (int i = 0; i < tabTexts.size(); i++) {
|
||||
addTab(tabTexts, i);
|
||||
}
|
||||
containerView.addView(contentView, 0);
|
||||
|
||||
maskView = new View(getContext());
|
||||
maskView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
maskView.setBackgroundColor(maskColor);
|
||||
maskView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
closeMenu();
|
||||
}
|
||||
});
|
||||
containerView.addView(maskView, 1);
|
||||
maskView.setVisibility(GONE);
|
||||
if (containerView.getChildAt(2) != null) {
|
||||
containerView.removeViewAt(2);
|
||||
}
|
||||
|
||||
popupMenuViews = new FrameLayout(getContext());
|
||||
popupMenuViews.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (ScreenUtils.getScreenSize(getContext()).y * menuHeighPercent)));
|
||||
popupMenuViews.setVisibility(GONE);
|
||||
containerView.addView(popupMenuViews, 2);
|
||||
|
||||
for (int i = 0; i < popupViews.size(); i++) {
|
||||
popupViews.get(i).setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
popupMenuViews.addView(popupViews.get(i), i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addTab(@NonNull List<String> tabTexts, int i) {
|
||||
final TextView tab = new TextView(getContext());
|
||||
tab.setSingleLine();
|
||||
tab.setEllipsize(TextUtils.TruncateAt.END);
|
||||
tab.setGravity(Gravity.CENTER);
|
||||
tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, menuTextSize);
|
||||
tab.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));
|
||||
tab.setTextColor(textUnselectedColor);
|
||||
tab.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(menuUnselectedIcon), null);
|
||||
tab.setText(tabTexts.get(i));
|
||||
tab.setPadding(dpTpPx(5), dpTpPx(12), dpTpPx(5), dpTpPx(12));
|
||||
//添加点击事件
|
||||
tab.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchMenu(tab);
|
||||
}
|
||||
});
|
||||
tabMenuView.addView(tab);
|
||||
//添加分割线
|
||||
if (i < tabTexts.size() - 1) {
|
||||
View view = new View(getContext());
|
||||
view.setLayoutParams(new LayoutParams(dpTpPx(0.5f), ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
view.setBackgroundColor(dividerColor);
|
||||
tabMenuView.addView(view);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变tab文字
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void setTabText(String text) {
|
||||
if (current_tab_position != -1) {
|
||||
((TextView) tabMenuView.getChildAt(current_tab_position)).setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTabClickable(boolean clickable) {
|
||||
for (int i = 0; i < tabMenuView.getChildCount(); i = i + 2) {
|
||||
tabMenuView.getChildAt(i).setClickable(clickable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭菜单
|
||||
*/
|
||||
public void closeMenu() {
|
||||
if (current_tab_position != -1) {
|
||||
((TextView) tabMenuView.getChildAt(current_tab_position)).setTextColor(textUnselectedColor);
|
||||
((TextView) tabMenuView.getChildAt(current_tab_position)).setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
getResources().getDrawable(menuUnselectedIcon), null);
|
||||
popupMenuViews.setVisibility(View.GONE);
|
||||
popupMenuViews.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_menu_out));
|
||||
maskView.setVisibility(GONE);
|
||||
maskView.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_mask_out));
|
||||
current_tab_position = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DropDownMenu是否处于可见状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isShowing() {
|
||||
return current_tab_position != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换菜单
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
private void switchMenu(View target) {
|
||||
System.out.println(current_tab_position);
|
||||
for (int i = 0; i < tabMenuView.getChildCount(); i = i + 2) {
|
||||
if (target == tabMenuView.getChildAt(i)) {
|
||||
if (current_tab_position == i) {
|
||||
closeMenu();
|
||||
} else {
|
||||
if (current_tab_position == -1) {
|
||||
popupMenuViews.setVisibility(View.VISIBLE);
|
||||
popupMenuViews.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_menu_in));
|
||||
maskView.setVisibility(VISIBLE);
|
||||
maskView.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_mask_in));
|
||||
popupMenuViews.getChildAt(i / 2).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
popupMenuViews.getChildAt(i / 2).setVisibility(View.VISIBLE);
|
||||
}
|
||||
current_tab_position = i;
|
||||
((TextView) tabMenuView.getChildAt(i)).setTextColor(textSelectedColor);
|
||||
((TextView) tabMenuView.getChildAt(i)).setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
getResources().getDrawable(menuSelectedIcon), null);
|
||||
}
|
||||
} else {
|
||||
((TextView) tabMenuView.getChildAt(i)).setTextColor(textUnselectedColor);
|
||||
((TextView) tabMenuView.getChildAt(i)).setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
getResources().getDrawable(menuUnselectedIcon), null);
|
||||
popupMenuViews.getChildAt(i / 2).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int dpTpPx(float value) {
|
||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm) + 0.5);
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import android.provider.Settings;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.RequiresPermission;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@ -378,4 +379,16 @@ public final class ScreenUtils {
|
||||
final DisplayMetrics appDm = Utils.getApp().getResources().getDisplayMetrics();
|
||||
return systemDm.density != appDm.density;
|
||||
}
|
||||
|
||||
public static Point getScreenSize(Context context){
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = windowManager.getDefaultDisplay();
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2){
|
||||
return new Point(display.getWidth(), display.getHeight());
|
||||
}else{
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
return point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
cm_utils/src/main/res/anim/dd_mask_in.xml
Normal file
8
cm_utils/src/main/res/anim/dd_mask_in.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="250">
|
||||
<alpha
|
||||
android:fromAlpha="0"
|
||||
android:toAlpha="1"/>
|
||||
|
||||
</set>
|
8
cm_utils/src/main/res/anim/dd_mask_out.xml
Normal file
8
cm_utils/src/main/res/anim/dd_mask_out.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="250">
|
||||
<alpha
|
||||
android:fromAlpha="1"
|
||||
android:toAlpha="0"/>
|
||||
|
||||
</set>
|
8
cm_utils/src/main/res/anim/dd_menu_in.xml
Normal file
8
cm_utils/src/main/res/anim/dd_menu_in.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="250">
|
||||
<translate
|
||||
android:fromYDelta="-100%p"
|
||||
android:toYDelta="0"/>
|
||||
|
||||
</set>
|
8
cm_utils/src/main/res/anim/dd_menu_out.xml
Normal file
8
cm_utils/src/main/res/anim/dd_menu_out.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="250">
|
||||
<translate
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="-100%p"/>
|
||||
|
||||
</set>
|
6
cm_utils/src/main/res/drawable/shp_rectangle_white_nora.xml
Executable file
6
cm_utils/src/main/res/drawable/shp_rectangle_white_nora.xml
Executable 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="@color/white" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
@ -91,4 +91,17 @@
|
||||
<attr name="h_textsize" format="dimension" />
|
||||
<attr name="h_pro_step" format="integer" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="DropDownMenu">
|
||||
|
||||
<attr name="ddunderlineColor" format="color"/>
|
||||
<attr name="dddividerColor" format="color"/>
|
||||
<attr name="ddtextSelectedColor" format="color"/>
|
||||
<attr name="ddtextUnselectedColor" format="color"/>
|
||||
<attr name="ddmenuBackgroundColor" format="color"/>
|
||||
<attr name="ddmaskColor" format="color"/>
|
||||
<attr name="ddmenuTextSize" format="dimension"/>
|
||||
<attr name="ddmenuSelectedIcon" format="reference"/>
|
||||
<attr name="ddmenuUnselectedIcon" format="reference"/>
|
||||
<attr name="ddmenuMenuHeightPercent" format="float"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
@ -174,4 +174,11 @@
|
||||
<color name="btn_blue">#AA1BAAE2</color>
|
||||
<color name="btn_green">#AA37B54A</color>
|
||||
<color name="btn_purple">#AA6B6FD2</color>
|
||||
|
||||
<color name="drop_down_selected">#7B1FA2</color>
|
||||
<color name="drop_down_unselected">#111111</color>
|
||||
|
||||
<color name="mask_color">#88888888</color>
|
||||
<color name="check_bg">#f2f2f2</color>
|
||||
<color name="un_press_color">#9C27B0</color>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user