wjc
2025-04-09 20d84ebd9ad20d2b2bdd3a82de2a968f38898294
2025年04月09日21:08:06
14个文件已修改
610 ■■■■■ 已修改文件
app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsMoveActivity.java 80 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/DeviceSearchActivity.java 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_device_search.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_house_search.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_message_center_list.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_power_stations_list.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_power_stations_move.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_search_messge.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/fragment_message.xml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/item_message_c.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java
@@ -3,7 +3,10 @@
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -31,6 +34,8 @@
import com.hdl.photovoltaic.ui.adapter.SearchMessageAdapter;
import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.utils.KeyboardStateObserverUtils;
import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
import java.util.ArrayList;
import java.util.Collections;
@@ -40,6 +45,9 @@
 * 消息搜索界面
 */
public class SearchMessageActivity extends CustomBaseActivity {
    private Handler handler;
    private Runnable delayedRunnable;
    private ActivitySearchMessgeBinding viewBinding;
@@ -90,6 +98,53 @@
        }
    }
    /**
     * 下拉刷新的逻辑
     */
    protected void pullToRefresh() {
        viewBinding.listSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
            @Override
            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
                handler = new Handler(Looper.getMainLooper());
                delayedRunnable = new Runnable() {
                    @Override
                    public void run() {
                        viewBinding.listSrl.endRefreshing();
                        loadNextPageMessageList(true, 1, viewBinding.messageSearchEt.getText().toString(), 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.listSrl.endLoadingMore();
                        if (!isLoadingMore) {
                            // 滑动到了底部,执行相应的操作
                            loadNextPageMessageList(false, ++mCurrentPage, viewBinding.messageSearchEt.getText().toString(), false);
                        }
                    }
                };
                // 延迟 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.listSrl.setRefreshViewHolder(hdlRefreshViewHolder);
    }
    private void initEvent() {
@@ -117,38 +172,6 @@
                viewBinding.listParent.setVisibility(View.VISIBLE);
                addSearchTextToList();
                loadNextPageMessageList(true, 1, viewBinding.messageSearchEt.getText().toString(), true);
            }
        });
        //下拉箭头颜色
        viewBinding.listSrl.setColorSchemeResources(R.color.text_FF245EC3);
        //下拉读取
        viewBinding.listSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                viewBinding.listSrl.setRefreshing(false);
                loadNextPageMessageList(true, 1, viewBinding.messageSearchEt.getText().toString(), true);
            }
        });
        //上拉读取
        viewBinding.listRcv.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
                if (layoutManager == null) {
                    return;
                }
                int visibleItemCount = layoutManager.getChildCount();
                int totalItemCount = layoutManager.getItemCount();
                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
                    if (!isLoadingMore) {
                        // 滑动到了底部,执行相应的操作
                        HdlLogLogic.print("--->滑动到了底部");
                        loadNextPageMessageList(false, ++mCurrentPage, viewBinding.messageSearchEt.getText().toString(), false);
                    }
                }
            }
        });
        //清除
@@ -246,6 +269,7 @@
                viewBinding.messageSearchEt.requestFocus();
            }
        });
        pullToRefresh();
        //在界面中使用
        KeyboardStateObserverUtils.getKeyboardStateObserver(_mActivity).setKeyboardVisibilityListener(new KeyboardStateObserverUtils.OnKeyboardVisibilityListener() {
@@ -321,6 +345,9 @@
        if (searchHistoryTitleList.size() > 0) {
            HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
            HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(searchHistoryTitleList));
        }
        if (handler != null && delayedRunnable != null) {
            handler.removeCallbacks(delayedRunnable);
        }
        super.onDestroy();
    }
@@ -471,4 +498,6 @@
    public String getHistoryFileNamePath() {
        return HdlFileLogic.getInstance().getCurrentUserRootPath() + "/message.txt";
    }
}
app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java
@@ -4,6 +4,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.TextView;
@@ -34,6 +36,8 @@
import com.hdl.photovoltaic.ui.newC.adapter.MessageCenterListAdapter;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.widget.TypeTitleListDialog;
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;
@@ -48,6 +52,9 @@
 * C端消息中心列表
 */
public class MessageCenterList extends CustomBaseActivity {
    private Handler handler;
    private Runnable delayedRunnable;
    private ActivityMessageCenterListBinding viewBinding;
@@ -106,6 +113,14 @@
        super.onResume();
        //进来读取一次数据(为了更新currentPage,currentTotal这个值)
//        loadNextPageMessageList(1, true, mFilterKye, mFilterValue);
    }
    @Override
    protected void onDestroy() {
        if (handler != null && delayedRunnable != null) {
            handler.removeCallbacks(delayedRunnable);
        }
        super.onDestroy();
    }
    private void initEvent() {
@@ -281,38 +296,6 @@
            }
        });
        //下拉按钮
        viewBinding.messageContentSrl.setColorSchemeResources(R.color.text_FF245EC3);
        viewBinding.messageContentSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                viewBinding.messageContentSrl.setRefreshing(false);
                loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
            }
        });
        //上拉按钮
        viewBinding.messageContentRl.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
//                super.onScrolled(recyclerView, dx, dy);
                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
                if (layoutManager == null) {
                    return;
                }
                int visibleItemCount = layoutManager.getChildCount();
                int totalItemCount = layoutManager.getItemCount();
                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
                    if (!isLoadingMore) {
                        // 滑动到了底部,执行相应的操作
                        HdlLogLogic.print("--->滑动到了底部");
                        loadNextPageMessageList(++mCurrentPage, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
                    }
                }
            }
        });
        if (messageCenterListAdapter != null) {
            messageCenterListAdapter.setNoOnclickListener(new MessageCenterListAdapter.OnclickListener() {
                @Override
@@ -343,7 +326,9 @@
        viewBinding.messageContentRl.setAdapter(messageCenterListAdapter);
        messageCenterListAdapter.setList(mList);
//        this.nullDataUpdateUi();
        pullToRefresh();
    }
    private void initData() {
        try {
@@ -366,6 +351,55 @@
    }
    /**
     * 下拉刷新的逻辑
     */
    protected void pullToRefresh() {
        viewBinding.messageContentSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
            @Override
            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
                handler = new Handler(Looper.getMainLooper());
                delayedRunnable = new Runnable() {
                    @Override
                    public void run() {
                        viewBinding.messageContentSrl.endRefreshing();
                        loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
                    }
                };
                // 延迟 5 秒执行
                handler.postDelayed(delayedRunnable, 1000);
            }
            @Override
            public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
                handler = new Handler(Looper.getMainLooper());
                delayedRunnable = new Runnable() {
                    @Override
                    public void run() {
                        viewBinding.messageContentSrl.endLoadingMore();
                        if (!isLoadingMore) {
                            // 滑动到了底部,执行相应的操作
                            HdlLogLogic.print("--->滑动到了底部");
                            loadNextPageMessageList(++mCurrentPage, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
                        }
                    }
                };
                // 延迟 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.messageContentSrl.setRefreshViewHolder(hdlRefreshViewHolder);
    }
    /**
     * 加载一页数据
     *
     * @param pageNo                  页数
app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java
@@ -5,6 +5,8 @@
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;
@@ -37,6 +39,8 @@
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;
@@ -50,6 +54,8 @@
 * C端电站列表编辑
 */
public class PowerStationsListEdit extends CustomBaseActivity {
    private Handler handler;
    private Runnable delayedRunnable;
    private ActivityPowerStationsListBinding viewBinding;//是否在编辑状态
    private HouseListAdapter houseListAdapter;
@@ -101,15 +107,6 @@
            }
        });
        //设置下拉箭头颜色
        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
@@ -165,6 +162,52 @@
        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);
    }
    /**
@@ -173,6 +216,9 @@
     * @param isRefreshing 表示是下拉刷新的
     */
    private void downReadData(boolean isRefreshing) {
        if (isRefreshing) {
            showLoading();
        }
        //获取住宅(电站)ID列表
        HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() {
            @Override
@@ -182,7 +228,7 @@
                    public void run() {
                        if (isRefreshing) {
                            //关闭下拉刷新的圈圈
                            viewBinding.fragmentHouseSrl.setRefreshing(false);
                            hideLoading();
                        }
                        if (list != null && !list.isEmpty()) {
                            if (!comparableList(houseListBeanIDList, list)) {
@@ -214,7 +260,7 @@
                    public void run() {
                        if (isRefreshing) {
                            //关闭下拉刷新的圈圈
                            viewBinding.fragmentHouseSrl.setRefreshing(false);
                            hideLoading();
                        }
                        HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
@@ -410,4 +456,12 @@
        } catch (Exception e) {
        }
    }
    @Override
    protected void onDestroy() {
        if (handler != null && delayedRunnable != null) {
            handler.removeCallbacks(delayedRunnable);
        }
        super.onDestroy();
    }
}
app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsMoveActivity.java
@@ -2,6 +2,8 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -19,6 +21,8 @@
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.newC.adapter.HouseMoveAdapter;
import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
import java.util.ArrayList;
import java.util.List;
@@ -27,6 +31,8 @@
 * C端电站列表移动位置
 */
public class PowerStationsMoveActivity extends CustomBaseActivity {
    private Handler handler;
    private Runnable delayedRunnable;
    private ActivityPowerStationsMoveBinding viewBinding;//是否在编辑状态
    private HouseMoveAdapter houseMoveAdapter;
@@ -56,6 +62,52 @@
        this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
    }
    /**
     * 下拉刷新的逻辑
     */
    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();
                        HdlResidenceLogic.getInstance().clearHouseList();
                        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);
    }
    private void initEvent() {
        //返回按钮
        viewBinding.toolbarTopRl.topBackLl.setOnClickListener(new View.OnClickListener() {
@@ -65,17 +117,6 @@
            }
        });
        //设置下拉箭头颜色
        viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3);
        //列表下拉按钮
        viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                HdlResidenceLogic.getInstance().clearHouseList();
                downReadData(true);
            }
        });
        if (houseMoveAdapter != null) {
            //电站移动位置按钮
            houseMoveAdapter.setMoveOnclickListener(new HouseMoveAdapter.OnMoveClickListener() {
@@ -125,6 +166,7 @@
        viewBinding.fragmentHouseSrlListRc.setAdapter(houseMoveAdapter);
        houseMoveAdapter.setList(this.houseListBeanIDList);
        this.nullDataUpdateUi(houseListBeanIDList);
        pullToRefresh();
    }
    /**
@@ -133,6 +175,10 @@
     * @param isRefreshing 表示是下拉刷新的
     */
    private void downReadData(boolean isRefreshing) {
        if (isRefreshing) {
            //关闭下拉刷新的圈圈
            showLoading();
        }
        //获取住宅(电站)ID列表
        HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() {
            @Override
@@ -142,7 +188,7 @@
                    public void run() {
                        if (isRefreshing) {
                            //关闭下拉刷新的圈圈
                            viewBinding.fragmentHouseSrl.setRefreshing(false);
                            hideLoading();
                        }
                        if (list != null && list.size() > 0) {
                            //更新缓存
@@ -167,7 +213,7 @@
                    public void run() {
                        if (isRefreshing) {
                            //关闭下拉刷新的圈圈
                            viewBinding.fragmentHouseSrl.setRefreshing(false);
                            hideLoading();
                        }
                        HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
@@ -184,5 +230,13 @@
        HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), list != null && list.size() > 0);
    }
    @Override
    protected void onDestroy() {
        if (handler != null && delayedRunnable != null) {
            handler.removeCallbacks(delayedRunnable);
        }
        super.onDestroy();
    }
}
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/DeviceSearchActivity.java
@@ -6,7 +6,10 @@
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -36,6 +39,8 @@
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.KeyboardStateObserverUtils;
import com.hdl.photovoltaic.utils.URLEncodingUtils;
import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
@@ -49,7 +54,8 @@
 */
public class DeviceSearchActivity extends CustomBaseActivity {
    private Handler handler;
    private Runnable delayedRunnable;
    private ActivityDeviceSearchBinding viewBinding;
    SearchDeviceAdapter searchDeviceAdapter;//设备适配器
@@ -57,9 +63,9 @@
    private List<CloudInverterDeviceBean> deviceList = new ArrayList<>();
    private int currentHouseListPage = 0; // 当前电站列表页码
    private int currentHouseListTotal = 0; // 电站列表总页码
    private boolean isHouseLoadingMore = false; // 标记电站列表正在加载更多数据
    private int currentDeviceListPage = 0; // 当前电站列表页码
    private int currentDeviceListTotal = 0; // 电站列表总页码
    private boolean isDeviceLoadingMore = false; // 标记电站列表正在加载更多数据
    private String currSearchText;
@@ -97,6 +103,54 @@
        }
    }
    /**
     * 下拉刷新的逻辑
     */
    protected void pullToRefresh() {
        viewBinding.listSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
            @Override
            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
                handler = new Handler(Looper.getMainLooper());
                delayedRunnable = new Runnable() {
                    @Override
                    public void run() {
                        viewBinding.listSrl.endRefreshing();
                        loadNextPageDeviceList(true, 1, 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.listSrl.endLoadingMore();
                        if (!isDeviceLoadingMore) {
                            // 滑动到了底部,执行相应的操作
                            HdlLogLogic.print("--->滑动到了底部");
                            loadNextPageDeviceList(false, ++currentDeviceListPage, false);
                        }
                    }
                };
                // 延迟 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.listSrl.setRefreshViewHolder(hdlRefreshViewHolder);
    }
    private void initEvent() {
@@ -125,41 +179,10 @@
                viewBinding.historyListParent.setVisibility(View.GONE);
                viewBinding.listParent.setVisibility(View.VISIBLE);
                addSearchTextToList();
                loadNextPageHouseList(true, 1, true);
                loadNextPageDeviceList(true, 1, true);
            }
        });
        //下拉箭头颜色
        viewBinding.listSrl.setColorSchemeResources(R.color.text_FF245EC3);
        //下拉读取
        viewBinding.listSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                viewBinding.listSrl.setRefreshing(false);
                loadNextPageHouseList(true, 1, true);
            }
        });
        //上拉读取
        viewBinding.listRcv.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
                if (layoutManager == null) {
                    return;
                }
                int visibleItemCount = layoutManager.getChildCount();
                int totalItemCount = layoutManager.getItemCount();
                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
                    if (!isHouseLoadingMore) {
                        // 滑动到了底部,执行相应的操作
                        HdlLogLogic.print("--->滑动到了底部");
                        loadNextPageHouseList(false, ++currentHouseListPage, false);
                    }
                }
            }
        });
        //清除
        viewBinding.powerStationClearIv.setOnClickListener(new View.OnClickListener() {
            @Override
@@ -204,7 +227,7 @@
                viewBinding.historyListParent.setVisibility(View.GONE);
                viewBinding.listParent.setVisibility(View.VISIBLE);
                addSearchTextToList();
                loadNextPageHouseList(true, 1, true);
                loadNextPageDeviceList(true, 1, true);
            }
        });
        //设备点击是事件
@@ -260,6 +283,7 @@
                viewBinding.powerStationSearchEt.requestFocus();
            }
        });
        pullToRefresh();
        //在界面中使用
        KeyboardStateObserverUtils.getKeyboardStateObserver(_mActivity).setKeyboardVisibilityListener(new KeyboardStateObserverUtils.OnKeyboardVisibilityListener() {
@@ -337,6 +361,9 @@
            HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
            HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(searchHistoryTitleList));
        }
        if (handler != null && delayedRunnable != null) {
            handler.removeCallbacks(delayedRunnable);
        }
        super.onDestroy();
    }
@@ -345,7 +372,7 @@
     *
     * @param isRefreshing 表示是下拉刷新的
     */
    private void loadNextPageHouseList(boolean isRefreshing, long pageNo, boolean isClear) {
    private void loadNextPageDeviceList(boolean isRefreshing, long pageNo, boolean isClear) {
        //搜索关键字
        if (TextUtils.isEmpty(currSearchText)) {
@@ -356,12 +383,12 @@
            clearData();
        }
        //第一页读取数据强制读取
        if (pageNo > 1 && currentHouseListPage > currentHouseListTotal) {
            --currentHouseListPage;
        if (pageNo > 1 && currentDeviceListPage > currentDeviceListTotal) {
            --currentDeviceListPage;
            //当前页不能大于总页数
            return;
        }
        isHouseLoadingMore = true;//标记读取状态
        isDeviceLoadingMore = true;//标记读取状态
        if (isRefreshing) {
            showLoading();
        }
@@ -376,10 +403,10 @@
                        if (isRefreshing) {
                            hideLoading();
                        }
                        isHouseLoadingMore = false;
                        isDeviceLoadingMore = false;
                        if (deviceClass != null) {
                            currentHouseListTotal = (int) deviceClass.getTotalPage();
                            currentHouseListPage = (int) deviceClass.getPageNo();
                            currentDeviceListTotal = (int) deviceClass.getTotalPage();
                            currentDeviceListPage = (int) deviceClass.getPageNo();
                            //更新缓存
                            setDeviceList(deviceClass.getList());
                            if (searchDeviceAdapter != null) {
@@ -398,10 +425,10 @@
                HdlThreadLogic.runMainThread(new Runnable() {
                    @Override
                    public void run() {
                        if (currentHouseListPage > 1) {
                            --currentHouseListPage;
                        if (currentDeviceListPage > 1) {
                            --currentDeviceListPage;
                        }
                        isHouseLoadingMore = false;
                        isDeviceLoadingMore = false;
                        if (isRefreshing) {
                            hideLoading();
                        }
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java
@@ -2,7 +2,10 @@
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -34,6 +37,8 @@
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.KeyboardStateObserverUtils;
import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
import java.util.ArrayList;
import java.util.Collections;
@@ -43,7 +48,8 @@
 * 电站搜索界面
 */
public class HouseSearchActivity extends CustomBaseActivity {
    private Handler handler;
    private Runnable delayedRunnable;
    private ActivityHouseSearchBinding viewBinding;
    SearchHistoryAdapter searchHistoryAdapter;
@@ -79,6 +85,8 @@
        initEvent();
    }
    private void initData() {
        try {
            String json = HdlFileLogic.getInstance().readFile(getHistoryFileNamePath());
@@ -90,6 +98,57 @@
        } catch (Exception ignored) {
        }
    }
    /**
     * 下拉刷新的逻辑
     */
    protected void pullToRefresh() {
        viewBinding.listSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
            @Override
            public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
                handler = new Handler(Looper.getMainLooper());
                delayedRunnable = new Runnable() {
                    @Override
                    public void run() {
                        viewBinding.listSrl.endRefreshing();
                        loadNextPageHouseList(true, 1, 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.listSrl.endLoadingMore();
                        //加载最新数据完成
                        if (!isHouseLoadingMore) {
                            // 滑动到了底部,执行相应的操作
                            loadNextPageHouseList(false, ++currentHouseListPage, false);
                        }
                    }
                };
                // 延迟 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.listSrl.setRefreshViewHolder(hdlRefreshViewHolder);
    }
    private void initEvent() {
@@ -123,38 +182,6 @@
            }
        });
        //下拉箭头颜色
        viewBinding.listSrl.setColorSchemeResources(R.color.text_FF245EC3);
        //下拉读取
        viewBinding.listSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                viewBinding.listSrl.setRefreshing(false);
                loadNextPageHouseList(true, 1, true);
            }
        });
        //上拉读取
        viewBinding.listRcv.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
                if (layoutManager == null) {
                    return;
                }
                int visibleItemCount = layoutManager.getChildCount();
                int totalItemCount = layoutManager.getItemCount();
                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
                    if (!isHouseLoadingMore) {
                        // 滑动到了底部,执行相应的操作
                        HdlLogLogic.print("---滑动到了底部");
                        loadNextPageHouseList(false, ++currentHouseListPage, false);
                    }
                }
            }
        });
        //清除
        viewBinding.powerStationClearIv.setOnClickListener(new View.OnClickListener() {
            @Override
@@ -254,6 +281,8 @@
            }
        });
        pullToRefresh();
        //在界面中使用
        KeyboardStateObserverUtils.getKeyboardStateObserver(_mActivity).setKeyboardVisibilityListener(new KeyboardStateObserverUtils.OnKeyboardVisibilityListener() {
            @Override
@@ -270,6 +299,8 @@
            }
        });
    }
@@ -314,6 +345,9 @@
            HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
            HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(searchHistoryTitleList));
        }
        if (handler != null && delayedRunnable != null) {
            handler.removeCallbacks(delayedRunnable);
        }
        super.onDestroy();
    }
app/src/main/res/layout/activity_device_search.xml
@@ -147,7 +147,7 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/power_station_search_cl">
        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        <com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout
            android:id="@+id/list_srl"
            android:layout_width="match_parent"
            android:layout_height="0dp"
@@ -160,7 +160,7 @@
                android:id="@+id/list_rcv"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
        </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
app/src/main/res/layout/activity_house_search.xml
@@ -146,7 +146,7 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/power_station_search_cl">
        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        <com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout
            android:id="@+id/list_srl"
            android:layout_width="match_parent"
            android:layout_height="0dp"
@@ -159,7 +159,7 @@
                android:id="@+id/list_rcv"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
        </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
    <!--没有数据显示样式-->
app/src/main/res/layout/activity_message_center_list.xml
@@ -21,7 +21,8 @@
    <RelativeLayout
        android:id="@+id/message_rl"
        android:layout_width="0dp"
        android:layout_height="@dimen/dp_60"
        android:layout_height="@dimen/dp_22"
        android:layout_marginTop="@dimen/dp_20"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar_top_message_center_list_rl">
@@ -129,10 +130,11 @@
    </RelativeLayout>
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    <com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout
        android:id="@+id/message_content_srl"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="@dimen/dp_10"
        app:layout_constraintBottom_toTopOf="@+id/message_bottom_cl"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
@@ -141,8 +143,10 @@
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/message_content_rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:paddingBottom="@dimen/dp_10" />
    </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    <!--没有数据显示样式-->
    <include
app/src/main/res/layout/activity_power_stations_list.xml
@@ -18,11 +18,11 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    <com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout
        android:id="@+id/fragment_house_srl"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="@dimen/dp_12"
        android:layout_marginTop="@dimen/dp_10"
        app:layout_constraintBottom_toTopOf="@+id/add_power_station_rl"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
@@ -34,7 +34,7 @@
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:paddingBottom="@dimen/dp_16" />
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
    </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    <RelativeLayout
        android:id="@+id/add_power_station_rl"
app/src/main/res/layout/activity_power_stations_move.xml
@@ -17,7 +17,7 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    <com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout
        android:id="@+id/fragment_house_srl"
        android:layout_width="match_parent"
        android:layout_height="0dp"
@@ -32,8 +32,8 @@
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:paddingBottom="@dimen/dp_16" />
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
            android:paddingBottom="@dimen/dp_10" />
    </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    <!--没有数据显示样式-->
app/src/main/res/layout/activity_search_messge.xml
@@ -146,7 +146,7 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/message_search_cl">
        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        <com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout
            android:id="@+id/list_srl"
            android:layout_width="match_parent"
            android:layout_height="0dp"
@@ -159,7 +159,7 @@
                android:id="@+id/list_rcv"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
        </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
app/src/main/res/layout/fragment_message.xml
@@ -223,7 +223,10 @@
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/message_rcv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:paddingBottom="@dimen/dp_10"
            />
    </com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout>
    <!--没有数据显示样式-->
app/src/main/res/layout/item_message_c.xml
@@ -8,6 +8,7 @@
        android:layout_width="0dp"
        android:layout_height="107.5dp"
        android:layout_marginStart="@dimen/dp_16"
        android:layout_marginTop="@dimen/dp_10"
        android:layout_marginEnd="@dimen/dp_16"
        android:background="@drawable/bj_ff1c1c1e"
        app:layout_constraintEnd_toEndOf="parent"