| | |
| | | package com.application.zhangshi_app_android.ui.function; |
| | | |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.view.KeyEvent; |
| | |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.inputmethod.EditorInfo; |
| | | import android.widget.Button; |
| | | import android.widget.PopupWindow; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.IdRes; |
| | | import androidx.annotation.LayoutRes; |
| | | import androidx.appcompat.app.AlertDialog; |
| | | import androidx.databinding.DataBindingUtil; |
| | | import androidx.databinding.ViewDataBinding; |
| | | import androidx.drawerlayout.widget.DrawerLayout; |
| | | import androidx.lifecycle.Observer; |
| | | |
| | | import com.android.app_base.base.BaseConfig; |
| | | import com.android.app_base.base.dialog.BaseDialog; |
| | | import com.android.app_base.base.dialog.UIDialog; |
| | | import com.android.app_base.base.view.BaseActivity; |
| | | import com.android.app_base.manager.AppManager; |
| | | import com.android.app_base.utils.ScreenSizeUtils; |
| | | import com.android.app_base.widget.LinearItemDecoration; |
| | |
| | | import com.application.zhangshi_app_android.databinding.ActivityFamilyMemorabiliaBinding; |
| | | import com.application.zhangshi_app_android.databinding.PopSearchBinding; |
| | | import com.application.zhangshi_app_android.ui.DLBaseActivity; |
| | | import com.hjq.bar.TitleBar; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void initView() { |
| | | binding.refreshLayout.setEnableRefresh(false); |
| | | binding.refreshLayout.setEnableLoadMore(true); |
| | | binding.refreshLayout.setEnableOverScrollDrag(true); |
| | | binding.refreshLayout.setOnLoadMoreListener(refreshLayout -> { |
| | | viewModel.getMoreFamilyMemorabilia(); |
| | | }); |
| | | |
| | | adapter = new FamilyMemorabiliaRvAdapter(this,viewModel); |
| | | LinearItemDecoration itemDecoration = new LinearItemDecoration(); |
| | | itemDecoration.setBottomSpace((int) getResources().getDimension(com.android.app_base.R.dimen.dp_12)); |
| | |
| | | }); |
| | | |
| | | binding.ivSearchType.setOnClickListener(v -> { |
| | | hideSoftKeyboard(); |
| | | mSearchPopupWindow.setWidth(binding.layoutSearch.getMeasuredWidth()); |
| | | mSearchPopupWindow.showAsDropDown(binding.layoutSearch,0,0); |
| | | }); |
| | |
| | | return; |
| | | } |
| | | if (familyMemorabiliaBeans.isEmpty()){ |
| | | viewModel.getOperateTypeLiveData().postValue(1); |
| | | viewModel.getOperateTypeLiveData().setValue(1); |
| | | }else{ |
| | | viewModel.getOperateTypeLiveData().postValue(2); |
| | | viewModel.getOperateTypeLiveData().setValue(2); |
| | | } |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void onChanged(List<FamilyMemorabiliaBean> familyMemorabiliaBeans) { |
| | | adapter.setData(familyMemorabiliaBeans); |
| | | } |
| | | }); |
| | | viewModel.getMoreListLiveData().observe(this, new Observer<List<FamilyMemorabiliaBean>>() { |
| | | @Override |
| | | public void onChanged(List<FamilyMemorabiliaBean> familyMemorabiliaBeans) { |
| | | adapter.addData(familyMemorabiliaBeans); |
| | | } |
| | | }); |
| | | viewModel.getOperateTypeLiveData().observe(this, integer -> { |
| | |
| | | adapter.setCheckable(true); |
| | | }else if (integer == 2){ |
| | | binding.ivOperate.setBackgroundResource(R.drawable.ic_delete_white); |
| | | new UIDialog.Builder(this) |
| | | .setTitle("您确定要删除项目吗") |
| | | .setContent("项目删除后将无法恢复") |
| | | .setConfirm("确定") |
| | | .setCancel("取消") |
| | | .setListener(new UIDialog.OnListener() { |
| | | @Override |
| | | public void onConfirm(BaseDialog dialog) { |
| | | viewModel.delete(); |
| | | } |
| | | }) |
| | | .show(); |
| | | adapter.setCheckable(true); |
| | | binding.ivOperate.setOnClickListener(v -> { |
| | | new UIDialog.Builder(this) |
| | | .setTitle("您确定要删除项目吗") |
| | | .setContent("项目删除后将无法恢复") |
| | | .setConfirm("确定") |
| | | .setCancel("取消") |
| | | .setListener(new UIDialog.OnListener() { |
| | | @Override |
| | | public void onConfirm(BaseDialog dialog) { |
| | | viewModel.delete(); |
| | | } |
| | | }) |
| | | .show(); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | |
| | | // 设置pop透明效果 |
| | | popupWindow.setBackgroundDrawable(new ColorDrawable(0x0000)); |
| | | // 设置pop出入动画 |
| | | popupWindow.setAnimationStyle(com.android.app_base.R.style.pop_add); |
| | | // 设置pop获取焦点,如果为false点击返回按钮会退出当前Activity,如果pop中有Editor的话,focusable必须要为true |
| | | popupWindow.setAnimationStyle(com.android.app_base.R.style.pop_operate); |
| | | // // 设置pop获取焦点,如果为false点击返回按钮会退出当前Activity,如果pop中有Editor的话,focusable必须要为true |
| | | popupWindow.setFocusable(true); |
| | | // 设置pop可点击,为false点击事件无效,默认为true |
| | | // // 设置pop可点击,为false点击事件无效,默认为true |
| | | popupWindow.setTouchable(true); |
| | | // 设置点击pop外侧消失,默认为false;在focusable为true时点击外侧始终消失 |
| | | popupWindow.setOutsideTouchable(false); |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected void dataFinish() { |
| | | super.dataFinish(); |
| | | binding.refreshLayout.finishLoadMore(); |
| | | } |
| | | |
| | | @Override |
| | | protected void hide() { |
| | | super.hide(); |
| | | binding.layoutDataNull.setVisibility(View.GONE); |
| | | binding.recyclerView.setVisibility(View.VISIBLE); |
| | | binding.refreshLayout.finishLoadMore(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | mOperatePopupWindow.dismiss(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if (mSearchPopupWindow != null){ |
| | | mSearchPopupWindow.dismiss(); |
| | | } |
| | | if (mOperatePopupWindow != null){ |
| | | mOperatePopupWindow.dismiss(); |
| | | } |
| | | } |
| | | } |