From 43c0a28db7e43959561036dbde0eb5cb37a7e324 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 10 五月 2024 18:25:40 +0800 Subject: [PATCH] 2024年05月10日18:25:29 --- app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/CustomStyleChartComposer.java | 10 app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java | 7 app/src/main/AndroidManifest.xml | 3 app/src/main/res/layout/activity_device_search.xml | 4 app/src/main/res/layout/activity_house_search.xml | 4 app/src/main/java/com/hdl/photovoltaic/ui/adapter/SearchMessageAdapter.java | 115 ++++++ /dev/null | 259 --------------- app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java | 392 +++++++++++++++++++++++ app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/AAChartSymbolConst.java | 2 app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java | 18 + app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java | 3 app/src/main/res/layout/activity_search_messge.xml | 167 +++++++++ app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/BasicChartComposer.java | 2 13 files changed, 709 insertions(+), 277 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f6c3993..e0c48cf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -77,6 +77,9 @@ android:supportsRtl="true" android:theme="@style/Theme.PhotovoltaicDebug"> <activity + android:name=".ui.message.SearchMessageActivity" + android:exported="false" /> + <activity android:name=".ui.powerstation.DeviceSearchActivity" android:exported="false" /> <activity diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/adapter/SearchMessageAdapter.java b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/SearchMessageAdapter.java new file mode 100644 index 0000000..da3d0b1 --- /dev/null +++ b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/SearchMessageAdapter.java @@ -0,0 +1,115 @@ +package com.hdl.photovoltaic.ui.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.hdl.photovoltaic.R; +import com.hdl.photovoltaic.ui.bean.DeviceBean; +import com.hdl.photovoltaic.widget.SwipeLayout; + +import java.util.ArrayList; +import java.util.List; + +/** + * 鎼滅储娑堟伅閫傞厤鍣� + */ +public class SearchMessageAdapter extends RecyclerView.Adapter<SearchMessageAdapter.MyViewHolder> { + + List<DeviceBean> mList; + + Context mContext; + + OnClickListener mOnclickListener; + + public SearchMessageAdapter(Context context) { + + this.mContext = context; + } + + @NonNull + @Override + public SearchMessageAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View contentItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_device_details, parent, false); + return new SearchMessageAdapter.MyViewHolder(contentItem); + } + + @Override + public void onBindViewHolder(@NonNull SearchMessageAdapter.MyViewHolder holder, int position) { + DeviceBean deviceBean = this.mList.get(position); + holder.itemView.setTag(position); + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + if (mOnclickListener != null) { + mOnclickListener.onClick((int) holder.itemView.getTag(), deviceBean); + } + } catch (Exception ignored) { + } + } + }); + + } + + @Override + public int getItemCount() { + return this.mList == null ? 0 : this.mList.size(); + } + + public void setOnclickListener(OnClickListener onClickListener) { + this.mOnclickListener = onClickListener; + } + + public void setList(List<DeviceBean> newData) { + if (this.mList == null) { + this.mList = new ArrayList<>(); + } else { + this.mList.clear(); + } + + this.mList.addAll(newData); + notifyDataSetChanged(); + } + + /** + * 涓�琛屽竷灞�瀹瑰櫒 + */ + static class MyViewHolder extends RecyclerView.ViewHolder { + + public ImageView homeIconIv;//浣忓畢鍥剧墖 + public TextView homeNameTv;//浣忓畢鍚嶇О + public TextView capacityTv;//瑁呮満瀹归噺 + public TextView powerTv;//鍙戠數鍔熺巼 + public TextView stateTv;//鐢电珯鐘舵��(杩炴帴涓�,杩愯,绂荤嚎,鏁呴殰); + public RelativeLayout item_parent_rl;//鏉$洰鐖跺鍣� + public ImageView move_home_iv;//绉诲姩鐢电珯浣嶇疆 + public ImageView del_home_iv;//鍒犻櫎鐢电珯 + public SwipeLayout item_parent_swipeLayout;//鐖跺鍣� + + public MyViewHolder(@NonNull View itemView) { + super(itemView); + homeIconIv = itemView.findViewById(R.id.device_details_image_iv); + homeNameTv = itemView.findViewById(R.id.device_details_name_tv); + capacityTv = itemView.findViewById(R.id.device_details_sn_tv); + powerTv = itemView.findViewById(R.id.power_type_tv); + stateTv = itemView.findViewById(R.id.fragment_house_list_line_state_tv); + item_parent_rl = itemView.findViewById(R.id.item_parent_rl); + move_home_iv = itemView.findViewById(R.id.move_home_iv); + del_home_iv = itemView.findViewById(R.id.del_home_iv); + item_parent_swipeLayout = itemView.findViewById(R.id.item_parent_swipeLayout); + } + } + + public interface OnClickListener { + void onClick(int position, DeviceBean deviceBean); + + } +} diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java index b13c13a..58309c2 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java @@ -1,7 +1,7 @@ package com.hdl.photovoltaic.ui.home; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulColumnChart; +import static com.hdl.photovoltaic.ui.powerstation.aachart.CustomStyleChartComposer.configureColorfulColumnChart; import android.os.Bundle; import android.text.TextUtils; @@ -33,6 +33,7 @@ import com.hdl.photovoltaic.ui.bean.DataOverBean; import com.hdl.photovoltaic.ui.bean.SocialContributionBean; import com.hdl.photovoltaic.ui.bean.StatisticsBean; +import com.hdl.photovoltaic.ui.powerstation.aachart.BasicChartComposer; import com.hdl.photovoltaic.utils.TimeUtils; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java index 3c1e038..7d4221d 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java @@ -41,7 +41,7 @@ import java.util.Map; /** - * 娑堟伅 + * 娑堟伅妯″潡鐣岄潰 */ public class MessageFragment extends CustomBaseFragment { @@ -84,6 +84,7 @@ private void initEvent() { + //鍙戠敓涓� viewBinding.messageTabNascentTitleTv.setOnClickListener(new View.OnClickListener() { @Override @@ -110,6 +111,15 @@ viewBinding.messageTabRecoverTitleTv.setTextAppearance(R.style.Text20Style); viewBinding.allClearTv.setVisibility(View.GONE); loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true); + } + }); + //鎼滅储娑堟伅 + viewBinding.messageSearchCl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(); + intent.setClass(_mActivity, SearchMessageActivity.class); + startActivity(intent); } }); @@ -284,6 +294,12 @@ HdlLogLogic.print("姝e湪鐐瑰嚮銆愭秷鎭��"); } + } else if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { + if (eventBus.getType().equals(MessageStateType.untreated)) { + updateListData(); + }/* else if (eventBus.getType().equals(MessageStateType.processed)) { + updateListData(); + }*/ } } diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java index c0b0223..4cf04f1 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java @@ -1,7 +1,6 @@ package com.hdl.photovoltaic.ui.message; -import android.annotation.SuppressLint; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; @@ -91,8 +90,8 @@ type = _mActivity.getString(R.string.message_alarm); drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_ffb300); } else if (mMessageBean.getType().equals(MessageAlarmStateType.event)) { - type = _mActivity.getString(R.string.event); - drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_ffb300); + type = _mActivity.getString(R.string.loading_title_tip); + drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.state_b9b9b9); } viewBinding.messageInfoAlarmStateTv.setText(type); viewBinding.messageInfoAlarmStateTv.setBackground(drawable); @@ -186,8 +185,6 @@ sendEventBus(); } finish(); - - } @Override diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/RecoverMessageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/RecoverMessageFragment.java deleted file mode 100644 index 0c39ece..0000000 --- a/app/src/main/java/com/hdl/photovoltaic/ui/message/RecoverMessageFragment.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.hdl.photovoltaic.ui.message; - -import android.content.Intent; -import android.os.Bundle; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - -import com.google.gson.Gson; -import com.hdl.linkpm.sdk.core.exception.HDLException; -import com.hdl.photovoltaic.R; -import com.hdl.photovoltaic.base.CustomBaseFragment; -import com.hdl.photovoltaic.config.ConstantManage; -import com.hdl.photovoltaic.databinding.FragmentRecoverMessageBinding; -import com.hdl.photovoltaic.enums.MessageFunctionTabSwitch; -import com.hdl.photovoltaic.enums.MessageStateType; -import com.hdl.photovoltaic.listener.CloudCallBeak; -import com.hdl.photovoltaic.other.HdlCommonLogic; -import com.hdl.photovoltaic.other.HdlLogLogic; -import com.hdl.photovoltaic.other.HdlMessageLogic; -import com.hdl.photovoltaic.other.HdlThreadLogic; -import com.hdl.photovoltaic.ui.adapter.MessageAdapter; -import com.hdl.photovoltaic.ui.bean.BUserInfo; -import com.hdl.photovoltaic.ui.bean.MessageBean; -import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; - -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.ArrayList; -import java.util.List; - -/** - * 娑堟伅-宸叉仮澶� - */ -public class RecoverMessageFragment extends CustomBaseFragment { - - FragmentRecoverMessageBinding viewBinding; - - private MessageAdapter messageRecoverAdapter; - private int currentPage = 0; // 褰撳墠椤电爜 - private int currentTotal = 0; // 鎬婚〉鐮� - - private int totalCount = 0;//娑堟伅鏁伴噺鎬绘暟 - - private boolean isLoadingMore = false; // 鏍囪姝e湪鍔犺浇鏇村鏁版嵁 - - private final List<MessageBean> mList = new ArrayList<>(); - - @Override - public Object getContentView() { - viewBinding = FragmentRecoverMessageBinding.inflate(getLayoutInflater()); - return viewBinding.getRoot(); - } - - @Override - public void onBindView(Bundle savedInstanceState) { - //鍒濆鍖栫晫闈� - initView(); - //鍒濆鍖栫洃鍚櫒 - initEvent(); - //杩涙潵璇诲彇涓�娆℃暟鎹�(涓轰簡鏇存柊currentPage锛宑urrentTotal杩欎釜鍊�) - loadNextPageRecoverMessageList(1, true); - } - - /** - * 鏇存柊鏈湴缂撳瓨鏁版嵁 - */ - private void updatelocalityCacheData() { - mList.clear(); - mList.addAll(HdlMessageLogic.getInstance().getRecoverMessageMemoryList()); - - } - - private void initEvent() { - //璁剧疆涓嬫媺绠ご棰滆壊 - viewBinding.messageRecoverSrl.setColorSchemeResources(R.color.text_FF245EC3); - viewBinding.messageRecoverSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - viewBinding.messageRecoverSrl.setRefreshing(false); - mList.clear();//琛ㄧず寮哄埗閲嶆柊璇锋眰绗竴椤垫秷鎭垪琛� - HdlMessageLogic.getInstance().clearListMessage();//琛ㄧず寮哄埗娓呯┖鎵�鏈夌紦瀛樹俊鎭� - loadNextPageRecoverMessageList(1, true); - } - }); -// messageRecoverAdapter.setNoOnclickListener(new MessageAdapter.OnclickListener() { -// @Override -// public void onClick(int position, MessageBean item) { -// if (position < 0 || position > mList.size()) { -// return; -// } -// Intent intent = new Intent(); -// intent.putExtra("msgId", item.getMsgId().toString()); -// intent.setClass(_mActivity, MessageInfoActivity.class); -// startActivity(intent); -// } -// }); - - viewBinding.messageRecoverRecyclerview.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("--->婊戝姩鍒颁簡搴曢儴"); - loadNextPageRecoverMessageList(++currentPage, false); - } - } - } - }); - } - - - private void initView() { - viewBinding.messageRecoverRecyclerview.setLayoutManager(new LinearLayoutManager(_mActivity)); - messageRecoverAdapter = new MessageAdapter(_mActivity); - viewBinding.messageRecoverRecyclerview.setAdapter(messageRecoverAdapter); - } - - - /** - * 鍒锋柊鍒楄〃鏁版嵁 - */ - private void updateListData() { - - HdlThreadLogic.runMainThread(new Runnable() { - @Override - public void run() { - //鏇存柊鏈湴缂撳瓨鏁版嵁 - updatelocalityCacheData(); - //鍒锋柊鍒楄〃 - if (messageRecoverAdapter != null) { - messageRecoverAdapter.setList(mList); - messageRecoverAdapter.notifyDataSetChanged(); - } - //鍒锋柊銆愬凡鎭㈠銆戜俊鎭暟閲忔�绘暟 - refreshRecoverCount(); - //鏄剧ず娌℃暟鎹甎i鏍峰紡 - nullDataUpdateUi(); - } - }); - - } - - - @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) - public void onEventMessage(BaseEventBus eventBus) { - super.onEventMessage(eventBus); - if (eventBus == null) { - return; - } - //鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢 - if (eventBus.getTopic().equals(ConstantManage.message_function_tab_switch)) { - if (eventBus.getType().equals(MessageFunctionTabSwitch.recover.toString())) { - // 鍙栨秷绮樻�т簨浠� - EventBus.getDefault().removeStickyEvent(eventBus); - } - } else if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { - if (eventBus.getType().equals(MessageStateType.processed)) { - //娑堟伅璇︽儏鍥炶皟 - updatelocalityCacheData(); - ++totalCount; - updateListData(); - - } - } - } - - /** - * 鍔犺浇涓�椤垫暟鎹� - * - * @param pageNo 椤垫暟 - * @param isShowLoading 鏄惁鍚姩鍔犺浇妗� true鍚姩 - */ - private void loadNextPageRecoverMessageList(int pageNo, boolean isShowLoading) { - //绗竴椤佃鍙栨暟鎹己鍒惰 - if (pageNo > 1 && currentPage > currentTotal) { - --currentPage; - //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁� - return; - } - isLoadingMore = true;//鏍囪璇诲彇鐘舵�� - if (isShowLoading) { - showLoading(); - } - HdlMessageLogic.getInstance().getPageNoMessageList(pageNo, MessageStateType.processed, new CloudCallBeak<HdlMessageLogic.MessageListClass>() { - @Override - public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) { - if (messageListClass != null) { - currentTotal = (int) messageListClass.getTotalPage(); - currentPage = (int) messageListClass.getPageNo(); - totalCount = (int) messageListClass.getTotalCount(); - updateListData(); - } - isLoadingMore = false; - if (isShowLoading) { - hideLoading(); - } - } - - @Override - public void onFailure(HDLException e) { - if (currentPage > 1) { - --currentPage; - } - isLoadingMore = false; - if (isShowLoading) { - hideLoading(); - } - } - }); - } - - - /** - * 鍒锋柊銆愬凡鎭㈠銆戜俊鎭暟閲忔�绘暟 - */ - private void refreshRecoverCount() { - HdlThreadLogic.runMainThread(new Runnable() { - @Override - public void run() { - TextView textView = _mActivity.findViewById(R.id.message_tab_recover_title_tv); - if (textView != null) { - textView.setText(getText(R.string.message_recover)); - if (mList.size() > 0) { - String s = getText(R.string.message_recover) + "(" + totalCount + ")"; - textView.setText(s); - } - } - - } - }); - } - - /** - * 娌℃湁鐢电珯鍒楄〃鐨勬牱寮� - */ - private void nullDataUpdateUi() { - HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, - viewBinding.nullDataIc.getRoot(), - viewBinding.nullDataIc.nullDataGifAnimationIv, - viewBinding.nullDataIc.nullDataTv, getString(R.string.message_alarm_data_null), mList.size() > 0); - } - -} 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 new file mode 100644 index 0000000..aecfe33 --- /dev/null +++ b/app/src/main/java/com/hdl/photovoltaic/ui/message/SearchMessageActivity.java @@ -0,0 +1,392 @@ +package com.hdl.photovoltaic.ui.message; + + +import android.os.Bundle; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.photovoltaic.R; +import com.hdl.photovoltaic.base.CustomBaseActivity; +import com.hdl.photovoltaic.bean.PageNumberObject; +import com.hdl.photovoltaic.databinding.ActivitySearchMessgeBinding; +import com.hdl.photovoltaic.enums.ShowErrorMode; +import com.hdl.photovoltaic.listener.CloudCallBeak; +import com.hdl.photovoltaic.other.HdlDeviceLogic; +import com.hdl.photovoltaic.other.HdlFileLogic; +import com.hdl.photovoltaic.other.HdlLogLogic; +import com.hdl.photovoltaic.other.HdlThreadLogic; +import com.hdl.photovoltaic.ui.adapter.SearchHistoryAdapter; +import com.hdl.photovoltaic.ui.adapter.SearchMessageAdapter; +import com.hdl.photovoltaic.ui.bean.DeviceBean; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 娑堟伅鎼滅储鐣岄潰 + */ +public class SearchMessageActivity extends CustomBaseActivity { + + private ActivitySearchMessgeBinding viewBinding; + + SearchMessageAdapter searchMessageAdapter;//璁惧閫傞厤鍣� + SearchHistoryAdapter searchHistoryAdapter;//鍘嗗彶璁板綍閫傞厤鍣� + + private List<DeviceBean> deviceList = new ArrayList<>(); + + private int currentHouseListPage = 0; // 褰撳墠鐢电珯鍒楄〃椤电爜 + private int currentHouseListTotal = 0; // 鐢电珯鍒楄〃鎬婚〉鐮� + private boolean isHouseLoadingMore = false; // 鏍囪鐢电珯鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁 + + private String currSearchText; + + List<String> searchHistoryTitleList = new ArrayList<>(); + + @Override + public Object getContentView() { + viewBinding = ActivitySearchMessgeBinding.inflate(getLayoutInflater()); + return viewBinding.getRoot(); + } + + @Override + public void onBindView(Bundle savedInstanceState) { + setStatusBarTranslucent(); + //鍘嗗彶璁板綍鏂囦欢澶瑰垱寤� + HdlFileLogic.getInstance().createFileDir(HdlFileLogic.getInstance().getCurrentUserRootPath()); + //鍒濆鍖栨暟鎹� + initData(); + //鍒濆鍖� + initView(); + //鍒濆鍖栫晫闈㈢洃鍚櫒 + initEvent(); + } + + private void initData() { + try { + String json = HdlFileLogic.getInstance().readFile(getHistoryFileNamePath()); + if (TextUtils.isEmpty(json)) { + return; + } + searchHistoryTitleList = new Gson().fromJson(json, new TypeToken<List<String>>() { + }.getType()); + } catch (Exception ignored) { + } + } + + + private void initEvent() { + + //鍚庨�� + viewBinding.backRl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + viewBinding.messageSearchEt.addTextChangedListener(textWatcher); + + + //鎼滅储 + viewBinding.powerStationSearchTv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //鎼滅储鍏抽敭瀛� + currSearchText = viewBinding.messageSearchEt.getText().toString().replace(" ", ""); + if (TextUtils.isEmpty(currSearchText)) { + HdlThreadLogic.toast(_mActivity, R.string.search_content_null); + return; + } + viewBinding.historyListParent.setVisibility(View.GONE); + viewBinding.listParent.setVisibility(View.VISIBLE); + addSearchTextToList(); + loadNextPageHouseList(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 + public void onClick(View v) { + currSearchText = ""; + viewBinding.messageSearchEt.setText(""); + viewBinding.historyListParent.setVisibility(View.VISIBLE); + viewBinding.listParent.setVisibility(View.GONE); + searchHistoryAdapter.setList(searchHistoryTitleList); + clearData(); + } + }); + //鍒犻櫎 + viewBinding.messageDelIv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + searchHistoryTitleList = new ArrayList<>(); + searchHistoryAdapter.setList(searchHistoryTitleList); + HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath()); + } + }); + //鍘嗗彶璁板綍鐐瑰嚮浜嬩欢 + searchHistoryAdapter.setOnclickListener(new SearchHistoryAdapter.OnClickListener() { + @Override + public void onClick(int position, String title) { + viewBinding.messageSearchEt.setText(title); + } + }); + //鐢电珯鐐瑰嚮鏄簨浠� + searchMessageAdapter.setOnclickListener(new SearchMessageAdapter.OnClickListener() { + @Override + public void onClick(int position, DeviceBean deviceBean) { + + } + }); + + } + + private void initView() { + viewBinding.historyListParent.setVisibility(View.VISIBLE); + viewBinding.listParent.setVisibility(View.GONE); + viewBinding.powerStationClearIv.setVisibility(View.GONE); + //鍒濆鍖栧巻鍙茶褰曢�傞厤鍣� + searchHistoryAdapter = new SearchHistoryAdapter(_mActivity); + viewBinding.historyListRcv.setLayoutManager(new LinearLayoutManager(_mActivity)); + viewBinding.historyListRcv.setAdapter(searchHistoryAdapter); + searchHistoryAdapter.setList(searchHistoryTitleList); + //鍒濆鍖栫數绔欓�傞厤鍣� + searchMessageAdapter = new SearchMessageAdapter(_mActivity); + viewBinding.listRcv.setLayoutManager(new LinearLayoutManager(_mActivity)); + viewBinding.listRcv.setAdapter(searchMessageAdapter); + } + + + /** + * 杈撳叆鐢电珯鍚嶇О杩涜杩囨护 + */ + private final TextWatcher textWatcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void afterTextChanged(Editable s) { + String et = viewBinding.messageSearchEt.getText().toString().replace(" ", ""); + if (TextUtils.isEmpty(et)) { + viewBinding.powerStationClearIv.setVisibility(View.GONE); + } else { + viewBinding.powerStationClearIv.setVisibility(View.VISIBLE); + } + viewBinding.messageSearchEt.setSelection(viewBinding.messageSearchEt.length()); + + } + }; + + /** + * 鐗╃悊鎸夐敭杩斿洖浜嬩欢 + */ + @Override + public void onBackPressed() { + super.onBackPressed(); + } + + @Override + protected void onDestroy() { + viewBinding.messageSearchEt.removeTextChangedListener(textWatcher); + if (searchHistoryTitleList.size() > 0) { + HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath()); + HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(searchHistoryTitleList)); + } + super.onDestroy(); + } + + /** + * 鍒锋柊UI锛堣澶囷級 + * + * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑 + */ + private void loadNextPageHouseList(boolean isRefreshing, long pageNo, boolean isClear) { + + //鎼滅储鍏抽敭瀛� + if (TextUtils.isEmpty(currSearchText)) { + return; + } + + if (isClear) { + clearData(); + } + //绗竴椤佃鍙栨暟鎹己鍒惰鍙� + if (pageNo > 1 && currentHouseListPage > currentHouseListTotal) { + --currentHouseListPage; + //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁� + return; + } + isHouseLoadingMore = true;//鏍囪璇诲彇鐘舵�� + if (isRefreshing) { + showLoading(); + } + + //鑾峰彇浜戠涓婅澶囧垪琛� + HdlDeviceLogic.getInstance().getPowerStationDeviceList(currSearchText, pageNo, 20, new CloudCallBeak<PageNumberObject<DeviceBean>>() { + @Override + public void onSuccess(PageNumberObject<DeviceBean> deviceClass) { + HdlThreadLogic.runMainThread(new Runnable() { + @Override + public void run() { + if (isRefreshing) { + hideLoading(); + } + isHouseLoadingMore = false; + if (deviceClass != null) { + currentHouseListTotal = (int) deviceClass.getTotalPage(); + currentHouseListPage = (int) deviceClass.getPageNo(); + //鏇存柊缂撳瓨 + setDeviceList(deviceClass.getList()); + if (searchMessageAdapter != null) { + initData(); + //鏇存柊UI + searchMessageAdapter.setList(deviceList); + } + } + } + }, _mActivity, ShowErrorMode.YES); + + } + + @Override + public void onFailure(HDLException e) { + HdlThreadLogic.runMainThread(new Runnable() { + @Override + public void run() { + if (currentHouseListPage > 1) { + --currentHouseListPage; + } + isHouseLoadingMore = false; + if (isRefreshing) { + hideLoading(); + } + + } + }, _mActivity, ShowErrorMode.YES); + } + }); + } + + private void clearData() { + if (deviceList != null && deviceList.size() > 0) { + deviceList.clear(); + } + } + + public void setDeviceList(List<DeviceBean> list) { + if (list == null || list.size() == 0) { + return; + } + if (this.deviceList.size() == 0) { + this.deviceList.addAll(list); + return; + } + for (int i = 0; i < list.size(); i++) { + this.setSingleDevice(list.get(i)); + } + } + + /** + * 娣诲姞璁惧鍒板垪琛ㄩ噷闈� + * + * @param deviceBean -璁惧瀵硅薄 + */ + public void setSingleDevice(DeviceBean deviceBean) { + try { + if (deviceBean == null) { + return; + } + boolean if_boolean = false; + for (int i = 0; i < deviceList.size(); i++) { + if (deviceList.get(i).getHomeId().equals(deviceBean.getHomeId())) { + //瀛樺湪鏇挎崲 + deviceList.remove(i); + deviceList.add(i, deviceBean); + if_boolean = true; + break; + } + } + if (!if_boolean) { + //娌℃湁娣诲姞 + this.deviceList.add(deviceBean); + } + } catch (Exception e) { + String mes = e.getMessage(); + HdlLogLogic.print("--->" + mes); + } + } + + /** + * 娣诲姞鍘嗗彶璁板綍 + */ + private void addSearchTextToList() { + for (int i = 0; i < searchHistoryTitleList.size(); i++) { + if (searchHistoryTitleList.get(i).equals(currSearchText)) { + searchHistoryTitleList.remove(searchHistoryTitleList.get(i)); + } + } + searchHistoryTitleList.add(currSearchText); + // 鍊掑簭鎺掑垪鏁版嵁(鎼滅储鏈�鍚庢帓鍦ㄥ墠闈�) + Collections.reverse(searchHistoryTitleList); + if (searchHistoryTitleList.size() > 10) { + //鍘嗗彶璁板綍涓嶈兘瓒呭嚭10 + searchHistoryTitleList.remove(searchHistoryTitleList.get(11)); + } + + } + + /** + * 鑾峰彇銆愭悳绱㈠巻鍙茶褰曟枃浠躲�戝叏璺緞 + */ + public String getHistoryFileNamePath() { + return HdlFileLogic.getInstance().getCurrentUserRootPath() + "/message.txt"; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/AAChartSymbolConst.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/AAChartSymbolConst.java similarity index 98% rename from app/src/main/java/com/hdl/photovoltaic/ui/home/AAChartSymbolConst.java rename to app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/AAChartSymbolConst.java index de81366..8018af9 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/AAChartSymbolConst.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/AAChartSymbolConst.java @@ -1,4 +1,4 @@ -package com.hdl.photovoltaic.ui.home; +package com.hdl.photovoltaic.ui.powerstation.aachart; import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType; diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/BasicChartComposer.java similarity index 99% rename from app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java rename to app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/BasicChartComposer.java index 54fbb8a..2c53e76 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/BasicChartComposer.java @@ -1,4 +1,4 @@ -package com.hdl.photovoltaic.ui.home; +package com.hdl.photovoltaic.ui.powerstation.aachart; import static com.github.AAChartModel.AAChartCore.AATools.AAColor.AARgba; diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/CustomStyleChartComposer.java similarity index 99% rename from app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java rename to app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/CustomStyleChartComposer.java index 891401c..3dfc464 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/CustomStyleChartComposer.java @@ -1,10 +1,10 @@ -package com.hdl.photovoltaic.ui.home; +package com.hdl.photovoltaic.ui.powerstation.aachart; import static com.github.AAChartModel.AAChartCore.AATools.AAColor.AARgba; -import static com.hdl.photovoltaic.ui.home.AAChartSymbolConst.base64Symbol; -import static com.hdl.photovoltaic.ui.home.AAChartSymbolConst.imageSymbol; -import static com.hdl.photovoltaic.ui.home.AAChartSymbolConst.predefinedSymbol1; -import static com.hdl.photovoltaic.ui.home.AAChartSymbolConst.predefinedSymbol2; +import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.base64Symbol; +import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.imageSymbol; +import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.predefinedSymbol1; +import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.predefinedSymbol2; import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel; import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement; diff --git a/app/src/main/res/layout/activity_device_search.xml b/app/src/main/res/layout/activity_device_search.xml index bf4544d..9ee799d 100644 --- a/app/src/main/res/layout/activity_device_search.xml +++ b/app/src/main/res/layout/activity_device_search.xml @@ -91,7 +91,7 @@ </RelativeLayout> - + <!--鍘嗗彶璁板綍--> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/history_list_parent" android:layout_width="match_parent" @@ -136,7 +136,7 @@ app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> - + <!--鎼滅储鏁版嵁--> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/list_parent" android:layout_width="match_parent" diff --git a/app/src/main/res/layout/activity_house_search.xml b/app/src/main/res/layout/activity_house_search.xml index 977d256..f404390 100644 --- a/app/src/main/res/layout/activity_house_search.xml +++ b/app/src/main/res/layout/activity_house_search.xml @@ -90,7 +90,7 @@ </RelativeLayout> - + <!--鍘嗗彶璁板綍--> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/history_list_parent" android:layout_width="match_parent" @@ -135,7 +135,7 @@ app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> - + <!--鎼滅储鏁版嵁--> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/list_parent" android:layout_width="match_parent" diff --git a/app/src/main/res/layout/activity_search_messge.xml b/app/src/main/res/layout/activity_search_messge.xml new file mode 100644 index 0000000..9377c5d --- /dev/null +++ b/app/src/main/res/layout/activity_search_messge.xml @@ -0,0 +1,167 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.constraintlayout.widget.ConstraintLayout 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" + android:background="@color/text_F5F7FA" + tools:context=".ui.message.SearchMessageActivity"> + <!--鎼滅储--> + <RelativeLayout + android:id="@+id/message_search_cl" + android:layout_width="match_parent" + android:layout_height="@dimen/dp_35" + android:layout_marginTop="@dimen/dp_48" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <RelativeLayout + android:id="@+id/back_rl" + android:layout_width="@dimen/dp_50" + android:layout_height="match_parent"> + + <ImageView + android:id="@+id/message_back_iv" + android:layout_width="@dimen/dp_10" + android:layout_height="@dimen/dp_17" + android:layout_alignParentStart="true" + android:layout_centerVertical="true" + android:layout_marginStart="@dimen/dp_16" + android:src="@drawable/search_back" /> + </RelativeLayout> + + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginStart="@dimen/dp_7" + android:layout_marginEnd="@dimen/dp_21" + android:layout_toStartOf="@+id/power_station_search_tv" + android:layout_toEndOf="@+id/back_rl" + android:background="@drawable/search_bj_ff05000000"> + + <ImageView + android:id="@+id/message_search_iv" + android:layout_width="@dimen/dp_18" + android:layout_height="@dimen/dp_18" + android:layout_alignParentStart="true" + android:layout_centerVertical="true" + android:layout_marginStart="@dimen/dp_13" + android:src="@drawable/search_path" /> + + <EditText + android:id="@+id/message_search_et" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:layout_marginStart="@dimen/dp_11" + android:layout_marginEnd="@dimen/dp_40" + android:layout_toEndOf="@+id/message_search_iv" + android:background="@null" + android:gravity="start|center_vertical" + android:hint="Search the power station" + android:textColor="@color/text_90000000" + android:textColorHint="@color/text_40000000" + android:textSize="@dimen/text_14" /> + + <ImageView + android:id="@+id/power_station_clear_iv" + android:layout_width="@dimen/dp_20" + android:layout_height="@dimen/dp_20" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:layout_marginEnd="@dimen/dp_13" + android:src="@drawable/clear" /> + </RelativeLayout> + + <TextView + android:id="@+id/power_station_search_tv" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:layout_marginEnd="@dimen/dp_21" + android:gravity="center" + android:text="@string/search" + android:textColor="@color/text_90000000" + android:textSize="@dimen/text_16" /> + + + </RelativeLayout> + <!--鍘嗗彶璁板綍--> + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/history_list_parent" + android:layout_width="match_parent" + android:layout_height="0dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/message_search_cl"> + + <TextView + android:id="@+id/history_list_title_tv" + android:layout_width="wrap_content" + android:layout_height="@dimen/dp_23" + android:layout_marginStart="@dimen/dp_16" + android:layout_marginTop="@dimen/dp_23" + android:layout_marginEnd="@dimen/dp_21" + android:text="@string/history_search" + android:textColor="@color/text_90000000" + android:textSize="@dimen/text_16" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <ImageView + android:id="@+id/message_del_iv" + android:layout_width="@dimen/dp_26" + android:layout_height="@dimen/dp_26" + android:layout_marginTop="@dimen/dp_21" + android:layout_marginEnd="@dimen/dp_16" + android:src="@drawable/history_del" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/history_list_rcv" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginTop="67dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + <!--鎼滅储鏁版嵁--> + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/list_parent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginTop="@dimen/dp_30" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/message_search_cl"> + + <androidx.swiperefreshlayout.widget.SwipeRefreshLayout + android:id="@+id/list_srl" + android:layout_width="match_parent" + android:layout_height="0dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/list_rcv" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> + + </androidx.constraintlayout.widget.ConstraintLayout> + +</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file -- Gitblit v1.8.0