Jelajahi Sumber

修改消息盒子页面样式

Pq 1 tahun lalu
induk
melakukan
ce2d4466ed

+ 30 - 0
BaseLibrary/src/main/java/com/cooleshow/base/utils/DateUtil.java

@@ -277,6 +277,36 @@ public class DateUtil {
         return new SimpleDateFormat(FORMAT).format(date);
     }
 
+    public static String formatMessageTime(String timeStr) {
+        try {
+            boolean isToday = isToday(timeStr);
+            Date date = DateUtil.str2Date(timeStr);
+            long now = System.currentTimeMillis();
+            long span = now - date.getTime();
+            if (span < 600000) {
+                return "刚刚";
+            }
+            String curYearStr = getCurYearStr(null);
+            String targetYearStr = getCurYearStr(date);
+            boolean isCurrentYear = TextUtils.equals(curYearStr, targetYearStr);
+            String format = "yyyy-MM-dd";
+            if (isCurrentYear) {
+                if (isToday) {
+                    format = "HH:mm";
+                } else {
+                    format = "MM-dd";
+                }
+            } else {
+                format = "yyyy-MM-dd";
+            }
+            String result = date2Str(date, format);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
     public static String dateFormatMMdd(String dateStr) {
         if (TextUtils.isEmpty(dateStr)) {
             return "";

+ 3 - 8
institution/src/main/java/com/cooleshow/institution/stu/adapter/MessageBoxAdapter.java

@@ -8,6 +8,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.module.BaseLoadMoreModule;
 import com.chad.library.adapter.base.module.LoadMoreModule;
 import com.chad.library.adapter.base.viewholder.BaseViewHolder;
+import com.cooleshow.base.utils.DateUtil;
 import com.cooleshow.base.utils.GlideImageLoaderUtils;
 import com.cooleshow.base.utils.TimeUtils;
 import com.cooleshow.institution.stu.R;
@@ -21,7 +22,7 @@ import androidx.annotation.NonNull;
  * @author Ryan
  * 类说明:
  */
-public class MessageBoxAdapter extends BaseQuickAdapter<SystemMessageBean.RowsBean, BaseViewHolder> implements LoadMoreModule {
+public class MessageBoxAdapter extends BaseQuickAdapter<SystemMessageBean.RowsBean, BaseViewHolder> {
 
     public MessageBoxAdapter() {
         super(R.layout.jg_layout_message_nox_item);
@@ -36,7 +37,7 @@ public class MessageBoxAdapter extends BaseQuickAdapter<SystemMessageBean.RowsBe
         TextView tv_content = helper.getView(R.id.tv_content);
         tv_content.setText(item.content);
         TextView tv_date = helper.getView(R.id.tv_date);
-        tv_date.setText(TimeUtils.date2String(TimeUtils.string2Date(item.sendTime), "yyyy-MM-dd"));
+        tv_date.setText(DateUtil.formatMessageTime(item.sendTime));
         View view_unread = helper.getView(R.id.view_unread);
         if (item.readStatus == 0) {
             view_unread.setVisibility(View.VISIBLE);
@@ -45,10 +46,4 @@ public class MessageBoxAdapter extends BaseQuickAdapter<SystemMessageBean.RowsBe
         }
         GlideImageLoaderUtils.getInstance().loadImage(getContext(),item.img,im_type,R.drawable.icon_message_other);
     }
-
-    @NonNull
-    @Override
-    public BaseLoadMoreModule addLoadMoreModule(@NonNull BaseQuickAdapter<?, ?> baseQuickAdapter) {
-        return new BaseLoadMoreModule(baseQuickAdapter);
-    }
 }

+ 13 - 12
institution/src/main/java/com/cooleshow/institution/stu/ui/message/MessageBoxActivity.java

@@ -27,6 +27,7 @@ import com.cooleshow.institution.stu.contract.MessageBoxContract;
 import com.cooleshow.institution.stu.databinding.JgActivityMessageBoxBinding;
 import com.cooleshow.institution.stu.presenter.MessageBoxPresenter;
 import com.cooleshow.institution.stu.utils.JGJumpUtils;
+import com.scwang.smart.refresh.footer.ClassicsFooter;
 import com.scwang.smart.refresh.layout.api.RefreshLayout;
 import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
 
@@ -68,14 +69,13 @@ public class MessageBoxActivity extends BaseMVPActivity<JgActivityMessageBoxBind
     protected void initView() {
         initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "消息盒子");
         viewBinding.toolbarInclude.tvRightText.setVisibility(View.VISIBLE);
-        viewBinding.toolbarInclude.tvRightText.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_999999));
-        viewBinding.toolbarInclude.tvRightText.setTextSize(11);
+        viewBinding.toolbarInclude.tvRightText.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_333333));
+        viewBinding.toolbarInclude.tvRightText.setTextSize(14);
         viewBinding.toolbarInclude.tvRightText.setText("全部已读");
         viewBinding.toolbarInclude.tvRightText.setOnClickListener(this);
-        viewBinding.toolbarInclude.tvRightText.setPadding(0,0, SizeUtils.dp2px(5),0);
-        viewBinding.toolbarInclude.tvRight.setVisibility(View.VISIBLE);
-        viewBinding.toolbarInclude.tvRight.setBackgroundResource(R.drawable.jg_icon_message_box_clear);
-        viewBinding.toolbarInclude.tvRight.setOnClickListener(this);
+        viewBinding.toolbarInclude.tvRightText.setPadding(0,0, SizeUtils.dp2px(13),0);
+        viewBinding.toolbarInclude.tvRightText.setCompoundDrawablePadding(SizeUtils.dp2px(3));
+        viewBinding.toolbarInclude.tvRightText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.jg_icon_message_box_clear,0,0,0);
 
         RecyclerView rvAddress = viewBinding.recyclerView;
         LinearLayoutManager manager = new LinearLayoutManager(this);
@@ -124,6 +124,7 @@ public class MessageBoxActivity extends BaseMVPActivity<JgActivityMessageBoxBind
     @Override
     public void initData() {
         super.initData();
+        viewBinding.refreshLayout.setRefreshFooter(new ClassicsFooter(this));
         viewBinding.refreshLayout.setOnRefreshListener(new OnRefreshListener() {
             @Override
             public void onRefresh(@NonNull RefreshLayout refreshLayout) {
@@ -131,15 +132,15 @@ public class MessageBoxActivity extends BaseMVPActivity<JgActivityMessageBoxBind
                 queryList(true);
             }
         });
-        messageBoxAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
+        viewBinding.refreshLayout.setOnLoadMoreListener(new com.scwang.smart.refresh.layout.listener.OnLoadMoreListener() {
             @Override
-            public void onLoadMore() {
+            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                 //上拉加载
                 if (hasNext) {
                     currentPage++;
                     queryList(false);
                 } else {
-                    messageBoxAdapter.getLoadMoreModule().loadMoreEnd();
+                    viewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
                 }
             }
         });
@@ -162,11 +163,11 @@ public class MessageBoxActivity extends BaseMVPActivity<JgActivityMessageBoxBind
                 }
             } else {
                 if (data.rows != null && data.rows.size() > 0) {
+                    viewBinding.refreshLayout.finishLoadMore();
                     messageBoxAdapter.addData(data.rows);
-                    messageBoxAdapter.getLoadMoreModule().loadMoreComplete();
                     checkHasNext(data.rows.size());
                 } else {
-                    messageBoxAdapter.getLoadMoreModule().loadMoreEnd();
+                    viewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
                 }
             }
         }
@@ -195,7 +196,7 @@ public class MessageBoxActivity extends BaseMVPActivity<JgActivityMessageBoxBind
         } else {
             if (messageBoxAdapter != null) {
                 currentPage--;
-                messageBoxAdapter.getLoadMoreModule().loadMoreFail();
+                viewBinding.refreshLayout.finishLoadMore(false);
             }
         }
     }

+ 7 - 0
institution/src/main/res/drawable/jg_bg_red_ovil2.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+    <solid android:color="#ff1036" />
+    <corners android:radius="15dp"/>
+    <stroke android:color="@color/white" android:width="1dp"/>
+</shape>

+ 2 - 0
institution/src/main/res/layout/jg_activity_message_box.xml

@@ -14,6 +14,8 @@
 
     <com.scwang.smart.refresh.layout.SmartRefreshLayout
         android:id="@+id/refreshLayout"
+        app:srlEnableLoadMore="true"
+        app:srlEnableRefresh="true"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 

+ 6 - 4
institution/src/main/res/layout/jg_layout_message_nox_item.xml

@@ -3,7 +3,9 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tool="http://schemas.android.com/tools"
     android:layout_width="match_parent"
+    xmlns:tools="http://schemas.android.com/tools"
     android:paddingTop="15dp"
+    android:paddingBottom="15dp"
     android:layout_height="wrap_content">
 
 
@@ -28,11 +30,11 @@
 
     <View
         android:id="@+id/view_unread"
-        android:layout_width="@dimen/dp_6"
-        android:layout_height="@dimen/dp_6"
+        android:layout_width="@dimen/dp_11"
+        android:layout_height="@dimen/dp_11"
         android:visibility="gone"
-        android:background="@drawable/jg_bg_red_ovil"
-        app:layout_constraintLeft_toRightOf="@+id/tv_title"
+        android:background="@drawable/jg_bg_red_ovil2"
+        app:layout_constraintRight_toRightOf="@+id/im_type"
         app:layout_constraintTop_toTopOf="@+id/im_type" />