| | |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Looper; |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.PermissionExplanationDialog; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | |
| | | * C端电站列表编辑 |
| | | */ |
| | | public class PowerStationsListEdit extends CustomBaseActivity { |
| | | private Handler handler; |
| | | private Runnable delayedRunnable; |
| | | private ActivityPowerStationsListBinding viewBinding;//是否在编辑状态 |
| | | |
| | | private HouseListAdapter houseListAdapter; |
| | |
| | | } |
| | | }); |
| | | |
| | | //设置下拉箭头颜色 |
| | | viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3); |
| | | //列表下拉按钮 |
| | | viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | downReadData(true); |
| | | } |
| | | }); |
| | | if (houseListAdapter != null) { |
| | | houseListAdapter.setOnItemClickListener(new HouseListAdapter.OnItemClickListener() { |
| | | @Override |
| | |
| | | viewBinding.fragmentHouseSrlListRc.setAdapter(houseListAdapter); |
| | | houseListAdapter.setList(this.houseListBeanIDList); |
| | | this.nullDataUpdateUi(houseListBeanIDList); |
| | | pullToRefresh(); |
| | | } |
| | | |
| | | /** |
| | | * 下拉刷新的逻辑 |
| | | */ |
| | | protected void pullToRefresh() { |
| | | viewBinding.fragmentHouseSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() { |
| | | @Override |
| | | public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) { |
| | | handler = new Handler(Looper.getMainLooper()); |
| | | |
| | | delayedRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | viewBinding.fragmentHouseSrl.endRefreshing(); |
| | | downReadData(true); |
| | | } |
| | | }; |
| | | // 延迟 5 秒执行 |
| | | handler.postDelayed(delayedRunnable, 1000); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) { |
| | | |
| | | handler = new Handler(Looper.getMainLooper()); |
| | | delayedRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | viewBinding.fragmentHouseSrl.endLoadingMore(); |
| | | |
| | | } |
| | | }; |
| | | // 延迟 5 秒执行 |
| | | handler.postDelayed(delayedRunnable, 10); |
| | | |
| | | return true; |
| | | } |
| | | }); |
| | | HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true); |
| | | hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44); |
| | | hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh); |
| | | hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end); |
| | | viewBinding.fragmentHouseSrl.setRefreshViewHolder(hdlRefreshViewHolder); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param isRefreshing 表示是下拉刷新的 |
| | | */ |
| | | private void downReadData(boolean isRefreshing) { |
| | | if (isRefreshing) { |
| | | showLoading(); |
| | | } |
| | | //获取住宅(电站)ID列表 |
| | | HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { |
| | | @Override |
| | |
| | | public void run() { |
| | | if (isRefreshing) { |
| | | //关闭下拉刷新的圈圈 |
| | | viewBinding.fragmentHouseSrl.setRefreshing(false); |
| | | hideLoading(); |
| | | } |
| | | if (list != null && !list.isEmpty()) { |
| | | if (!comparableList(houseListBeanIDList, list)) { |
| | |
| | | public void run() { |
| | | if (isRefreshing) { |
| | | //关闭下拉刷新的圈圈 |
| | | viewBinding.fragmentHouseSrl.setRefreshing(false); |
| | | hideLoading(); |
| | | } |
| | | |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | if (handler != null && delayedRunnable != null) { |
| | | handler.removeCallbacks(delayedRunnable); |
| | | } |
| | | super.onDestroy(); |
| | | } |
| | | } |