From 5f4c3669ddd8fe27449b04a4b9db12b2ca4b3688 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期二, 14 一月 2025 16:27:29 +0800
Subject: [PATCH] 1.文件上传和显示添加缩略图功能。

---
 app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java |   94 +++++++++++++++++------------------------------
 1 files changed, 34 insertions(+), 60 deletions(-)

diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java
index 92c61ba..036ca77 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java
@@ -1,5 +1,7 @@
 package com.dayu.pipirrapp.fragment;
 
+import static androidx.core.content.ContextCompat.getSystemService;
+
 import android.app.Notification;
 import android.app.NotificationChannel;
 import android.app.NotificationManager;
@@ -9,6 +11,8 @@
 import android.graphics.Typeface;
 import android.os.Build;
 import android.os.Bundle;
+import android.os.VibrationEffect;
+import android.os.Vibrator;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -24,6 +28,7 @@
 
 import com.dayu.pipirrapp.MyApplication;
 import com.dayu.pipirrapp.R;
+import com.dayu.pipirrapp.activity.MainActivity;
 import com.dayu.pipirrapp.activity.OrderDetailActivity;
 import com.dayu.pipirrapp.adapter.OrderAdapter;
 import com.dayu.pipirrapp.bean.net.OrderDetailResult;
@@ -55,7 +60,7 @@
  */
 public class OrderFragment extends BaseFragment {
     public static final int RESULT_REFRESH = 1001;
-    private static final String CHANNEL_ID = "order_channel";
+
     private final int STATE_DONE = 2;
     private final int STATE_UNDONE = 1;
 
@@ -65,8 +70,8 @@
     int page = 1;
     int pageSize = 10;
     int state = 1;
-    List<OrderListResult.Data> recordsListDone = new ArrayList<>();
-    List<OrderListResult.Data> recordsList = new ArrayList<>();
+    List<OrderDetailResult> recordsListDone = new ArrayList<>();
+    List<OrderDetailResult> recordsList = new ArrayList<>();
     RefreshLayout myRefreshLayout;
     //鏈�鍚庡埛鏂扮殑鏃堕棿
     long lastRefreshDate;
@@ -114,7 +119,7 @@
             @Override
             public void onChanged(Object o) {
                 showRedlotDate = new Date().getTime();
-                binding.redDotImg.setVisibility(View.VISIBLE);
+//                binding.redDotImg.setVisibility(View.VISIBLE);
                 getMarkerData((String) o);
             }
         });
@@ -124,7 +129,7 @@
 
     void initView() {
         //鏈畬鎴�
-        binding.manageStateProgress.setOnClickListener(v -> {
+        binding.manageStateProgressRL.setOnClickListener(v -> {
             chooseStateView(true);
             state = STATE_UNDONE;//1 鏈紑濮� 2 宸插畬鎴�
 
@@ -145,7 +150,7 @@
             if (lastRefreshDate > showRedlotDate) {
                 //娑堥櫎绾㈢偣
                 LiveEventBus.get(CommonKeyName.RedLotRefresh).post(true);
-                binding.redDotImg.setVisibility(View.GONE);
+//                binding.redDotImg.setVisibility(View.GONE);
             }
             recordsList.clear();
             page = 0;
@@ -162,11 +167,10 @@
         binding.recyclerView.setAdapter(mAdapter);
         getMarkerData(myRefreshLayout, true, STATE_UNDONE);
         //宸插畬鎴�
-        RefreshLayout myRefreshLayoutDone = (RefreshLayout) binding.refreshLayoutDone;
+        RefreshLayout myRefreshLayoutDone = binding.refreshLayoutDone;
         myRefreshLayoutDone.setRefreshHeader(new ClassicsHeader(this.getContext()));
         myRefreshLayoutDone.setRefreshFooter(new ClassicsFooter(this.getContext()));
         myRefreshLayoutDone.setOnRefreshListener(refreshlayout -> {
-//                refreshlayout.finishRefresh(2000/*,false*/);//浼犲叆false琛ㄧず鍒锋柊澶辫触
             recordsListDone.clear();
             page = 0;
             getMarkerData(refreshlayout, true, STATE_DONE);
@@ -187,11 +191,11 @@
     public void onResume() {
         super.onResume();
         MyLog.d("OrderFragment>>onResume");
-        if (showRedlotDate > lastRefreshDate) {
-            binding.redDotImg.setVisibility(View.VISIBLE);
-        } else {
-            binding.redDotImg.setVisibility(View.GONE);
-        }
+//        if (showRedlotDate > lastRefreshDate) {
+//            binding.redDotImg.setVisibility(View.VISIBLE);
+//        } else {
+//            binding.redDotImg.setVisibility(View.GONE);
+//        }
     }
 
     @Override
@@ -223,19 +227,17 @@
             @Override
             public void onNext(BaseResponse<OrderListResult> t) {
                 if (t.isSuccess()) {
-                    if (t.isSuccess()) {
-                        if (t.getContent().getObj() != null && t.getContent().getObj().size() > 0) {
-                            if (state == STATE_UNDONE) {
-                                recordsList.addAll(t.getContent().getObj());
-                            } else {
-                                recordsListDone.addAll(t.getContent().getObj());
-                            }
-                            if (t.getContent().getPageTotal() == page) {
-                                refreshlayout.finishLoadMoreWithNoMoreData();
-                            }
+                    if (t.getContent().getObj() != null && t.getContent().getObj().size() > 0) {
+                        if (state == STATE_UNDONE) {
+                            recordsList.addAll(t.getContent().getObj());
                         } else {
+                            recordsListDone.addAll(t.getContent().getObj());
+                        }
+                        if (t.getContent().getPageTotal() == page) {
                             refreshlayout.finishLoadMoreWithNoMoreData();
                         }
+                    } else {
+                        refreshlayout.finishLoadMoreWithNoMoreData();
                     }
                 } else {
                     ToastUtil.showToast(OrderFragment.this.getContext(), t.getMsg());
@@ -276,59 +278,27 @@
         if (state) {
             binding.manageStateProgress.setTextColor(getResources().getColor(R.color.title_color, null));
             binding.manageStateProgress.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit, null));
+            binding.manageStateProgressRL.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit, null));
             binding.manageStateProgress.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
             binding.manageStateFinish.setTextColor(getResources().getColor(R.color.black, null));
             binding.manageStateFinish.setBackground(getResources().getDrawable(R.color.title_choose_bg, null));
             binding.manageStateFinish.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
             binding.refreshLayout.setVisibility(View.VISIBLE);
             binding.refreshLayoutDone.setVisibility(View.GONE);
+
         } else {
             binding.manageStateFinish.setTextColor(getResources().getColor(R.color.title_color, null));
             binding.manageStateFinish.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit, null));
             binding.manageStateFinish.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
             binding.manageStateProgress.setTextColor(getResources().getColor(R.color.black, null));
             binding.manageStateProgress.setBackground(getResources().getDrawable(R.color.title_choose_bg, null));
+            binding.manageStateProgressRL.setBackground(getResources().getDrawable(R.color.title_choose_bg, null));
             binding.manageStateProgress.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
             binding.refreshLayout.setVisibility(View.GONE);
             binding.refreshLayoutDone.setVisibility(View.VISIBLE);
         }
     }
 
-
-    /**
-     * 鍒涘缓宸ュ崟鎻愮ず閫氱煡
-     *
-     * @param notifucId
-     * @param data
-     */
-    private void creatOrderNotification(int notifucId, String data, String workOrderId) {
-        NotificationManager notificationManager = (NotificationManager) requireContext().getSystemService(Context.NOTIFICATION_SERVICE);
-        // 鍒涘缓NotificationChannel锛堜粎閽堝Android O鍙婁互涓婄増鏈級
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-            CharSequence name = getString(R.string.channel_name);
-            String description = getString(R.string.channel_description);
-            int importance = NotificationManager.IMPORTANCE_DEFAULT;
-            NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
-            channel.setDescription(description);
-            // 娉ㄥ唽閫氶亾
-            notificationManager.createNotificationChannel(channel);
-        }
-
-        Intent notificationIntent = new Intent(this.getContext(), OrderDetailActivity.class);
-        notificationIntent.putExtra("workOrderId", workOrderId);
-        int requestCode = workOrderId.hashCode(); // 浣跨敤workOrderId鐨勫搱甯岀爜浣滀负requestCode
-        PendingIntent pendingIntent = PendingIntent.getActivity(this.getContext(), requestCode, notificationIntent, PendingIntent.FLAG_MUTABLE);
-        Notification notification = new NotificationCompat.Builder(this.getContext(), CHANNEL_ID)
-                .setContentTitle("鏂板伐鍗�")
-                .setContentText(data)
-                .setSmallIcon(R.mipmap.ic_launcher)
-                .setContentIntent(pendingIntent)
-                .setAutoCancel(true) // 鐐瑰嚮閫氱煡鍚庤嚜鍔ㄦ秷澶�
-                .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)// 浣跨敤榛樿鐨勯煶鏁堝拰闇囧姩
-                .build();
-        notificationManager.notify(notifucId, notification);
-
-    }
 
     /**
      * 鑾峰彇宸ュ崟璇︽儏
@@ -340,8 +310,12 @@
             @Override
             public void onNext(BaseResponse<OrderDetailResult> t) {
                 if (t.isSuccess()) {
-                    if (t.isSuccess()) {
-                        creatOrderNotification(workOrderId.hashCode(), t.getContent().getTaskType(), workOrderId);
+                    if (MainActivity.workerIddata != null) {
+                        if (!MainActivity.workerIddata.containsKey(workOrderId)) {
+                            LiveEventBus.get(CommonKeyName.CreateNotification).post(t.getContent());
+                            recordsList.add(0, t.getContent());
+                            mAdapter.notifyItemInserted(0);
+                        }
                     }
                 }
             }

--
Gitblit v1.8.0