refresh UI when uploaded

chengzhenyu 8 anni fa
parent
commit
6b09c5c3c1

+ 17 - 0
app/src/main/java/ai/pai/lensman/upload/SessionRecyclerAdapter.java

@@ -16,6 +16,7 @@ import java.io.File;
16 16
 import java.util.ArrayList;
17 17
 
18 18
 import ai.pai.lensman.R;
19
+import ai.pai.lensman.bean.PhotoBean;
19 20
 import ai.pai.lensman.bean.SessionBean;
20 21
 import ai.pai.lensman.session.SessionActivity;
21 22
 import ai.pai.lensman.utils.Constants;
@@ -88,6 +89,7 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
88 89
         if(item.sessionPhotos!=null && item.sessionPhotos.size()>0){
89 90
             String path =  Constants.APP_IMAGE_DIR + File.separator+item.sessionId+File.separator+Constants.THUMBNAIL_DIR_NAME+File.separator+item.sessionPhotos.get(0).photoName;
90 91
             ImageLoaderUtils.displayLocalImage(path, holder.photo, options);
92
+            holder.uploadedCount.setText(getUploadedText(item.sessionPhotos));
91 93
         }
92 94
         int height = width;
93 95
         ViewGroup.LayoutParams lp=holder.photo.getLayoutParams();
@@ -113,12 +115,27 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
113 115
         return sessionList.size();
114 116
     }
115 117
 
118
+    private String getUploadedText(ArrayList<PhotoBean> photoList){
119
+        int uploaded = 0;
120
+        for(PhotoBean bean : photoList){
121
+            if(bean.isUploaded){
122
+                uploaded++;
123
+            }
124
+        }
125
+        String uploadStr = uploaded+"/"+photoList.size();
126
+
127
+        return uploadStr;
128
+    }
129
+
130
+
116 131
     class MyViewHolder extends RecyclerView.ViewHolder{
117 132
 
118 133
         @BindView(R.id.iv_session_item) ImageView photo;
119 134
 
120 135
         @BindView(R.id.tv_session_seq) TextView sesseionSeq;
121 136
 
137
+        @BindView(R.id.tv_session_uploaded_count) TextView uploadedCount;
138
+
122 139
         public MyViewHolder(View view){
123 140
             super(view);
124 141
             ButterKnife.bind(this, view);

+ 17 - 8
app/src/main/res/layout/session_item.xml

@@ -9,7 +9,7 @@
9 9
         android:id="@+id/iv_session_item"
10 10
         android:layout_width="wrap_content"
11 11
         android:layout_height="wrap_content"
12
-        android:scaleType="centerCrop"/>
12
+        android:scaleType="centerCrop" />
13 13
 
14 14
     <RelativeLayout
15 15
         android:layout_width="wrap_content"
@@ -21,19 +21,28 @@
21 21
         android:alpha="0.4"
22 22
         android:background="@color/black">
23 23
 
24
-    <ImageView
25
-        android:layout_width="103dp"
26
-        android:layout_height="103dp"
27
-        android:src="@drawable/cover_border"
28
-        android:layout_centerInParent="true"/>
24
+        <ImageView
25
+            android:layout_width="103dp"
26
+            android:layout_height="103dp"
27
+            android:layout_centerInParent="true"
28
+            android:src="@drawable/cover_border" />
29 29
 
30 30
         <TextView
31 31
             android:id="@+id/tv_session_seq"
32 32
             android:layout_width="wrap_content"
33 33
             android:layout_height="wrap_content"
34
-            android:textColor="@color/text_white"
35 34
             android:layout_centerInParent="true"
36
-            android:textSize="60dp"/>
35
+            android:textColor="@color/text_white"
36
+            android:textSize="60sp" />
37
+
38
+        <TextView
39
+            android:id="@+id/tv_session_uploaded_count"
40
+            android:layout_width="wrap_content"
41
+            android:layout_height="wrap_content"
42
+            android:layout_alignParentBottom="true"
43
+            android:layout_centerHorizontal="true"
44
+            android:textColor="@color/text_white"
45
+            android:textSize="16sp" />
37 46
 
38 47
     </RelativeLayout>
39 48