From 59340c0b9107c813d6b3a5c953d693212485ad11 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 20 八月 2025 13:31:22 +0800
Subject: [PATCH] 2025年08月20日13:31:14
---
app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java | 102 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 69 insertions(+), 33 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java
index bc89327..944fd6d 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java
+++ b/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;
@@ -66,6 +74,7 @@
@Override
public void onBindView(Bundle savedInstanceState) {
setStatusBarTranslucent();
+ getWindow().setNavigationBarColor(getColor(R.color.text_FF000000));
mMessageStateType = getIntent().getStringExtra("MessageStateType");
//鍘嗗彶璁板綍鏂囦欢澶瑰垱寤�
HdlFileLogic.getInstance().createFileDir(HdlFileLogic.getInstance().getCurrentUserRootPath());
@@ -89,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(false, 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() {
@@ -110,42 +166,12 @@
HdlThreadLogic.toast(_mActivity, R.string.search_content_null);
return;
}
+ viewBinding.messageSearchEt.clearFocus();
+ hideSoftInputFromWindow();
viewBinding.historyListParent.setVisibility(View.GONE);
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);
- }
- }
}
});
//娓呴櫎
@@ -167,6 +193,8 @@
viewBinding.messageDelIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ viewBinding.messageSearchEt.clearFocus();
+ hideSoftInputFromWindow();
searchHistoryTitleList = new ArrayList<>();
searchHistoryAdapter.setList(searchHistoryTitleList);
viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE);
@@ -184,6 +212,8 @@
HdlThreadLogic.toast(_mActivity, R.string.search_content_null);
return;
}
+ viewBinding.messageSearchEt.clearFocus();
+ hideSoftInputFromWindow();
viewBinding.historyListParent.setVisibility(View.GONE);
viewBinding.listParent.setVisibility(View.VISIBLE);
addSearchTextToList();
@@ -239,13 +269,14 @@
viewBinding.messageSearchEt.requestFocus();
}
});
+ pullToRefresh();
//鍦ㄧ晫闈腑浣跨敤
KeyboardStateObserverUtils.getKeyboardStateObserver(_mActivity).setKeyboardVisibilityListener(new KeyboardStateObserverUtils.OnKeyboardVisibilityListener() {
@Override
public void onKeyboardShow(int h) {
//Toast.makeText(MainActivity.this,"閿洏寮瑰嚭",Toast.LENGTH_SHORT).show();
- viewBinding.messageSearchEt.requestFocus();
+// viewBinding.messageSearchEt.requestFocus();
}
@@ -314,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();
}
@@ -464,4 +498,6 @@
public String getHistoryFileNamePath() {
return HdlFileLogic.getInstance().getCurrentUserRootPath() + "/message.txt";
}
+
+
}
\ No newline at end of file
--
Gitblit v1.8.0