upload progress bar

chengzhenyu 8 年之前
父節點
當前提交
42809e3fde

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

@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
7 7
 import android.view.View;
8 8
 import android.view.ViewGroup;
9 9
 import android.widget.ImageView;
10
+import android.widget.ProgressBar;
10 11
 import android.widget.TextView;
11 12
 
12 13
 import com.android.common.utils.DeviceUtils;
@@ -39,16 +40,6 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
39 40
         options = ImageLoaderUtils.getOptions(R.drawable.default_img);
40 41
     }
41 42
 
42
-    public synchronized void addSessionBean(SessionBean item){
43
-        if(sessionList==null){
44
-            sessionList = new ArrayList<>();
45
-        }
46
-        if(!sessionList.contains(item)){
47
-            sessionList.add(0,item);
48
-            notifyItemInserted(0);
49
-        }
50
-    }
51
-
52 43
     public synchronized void addSessionBeans(ArrayList<SessionBean> items){
53 44
         if(sessionList==null){
54 45
             sessionList = new ArrayList<>();
@@ -62,10 +53,6 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
62 53
     }
63 54
 
64 55
 
65
-    public ArrayList<SessionBean> getSessionList(){
66
-        return sessionList;
67
-    }
68
-
69 56
     public void clear(){
70 57
         if(sessionList==null){
71 58
             sessionList = new ArrayList<>();
@@ -86,10 +73,19 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
86 73
             return;
87 74
         }
88 75
         final SessionBean item = sessionList.get(position);
89
-        if(item.sessionPhotos!=null && item.sessionPhotos.size()>0){
90
-            String path =  Constants.APP_IMAGE_DIR + File.separator+item.sessionId+File.separator+Constants.THUMBNAIL_DIR_NAME+File.separator+item.sessionPhotos.get(0).photoName;
76
+        ArrayList<PhotoBean> photoList = item.sessionPhotos;
77
+        if(photoList!=null && photoList.size()>0){
78
+            String path =  Constants.APP_IMAGE_DIR + File.separator+item.sessionId+File.separator
79
+                    +Constants.THUMBNAIL_DIR_NAME+File.separator+item.sessionPhotos.get(0).photoName;
91 80
             ImageLoaderUtils.displayLocalImage(path, holder.photo, options);
92
-            holder.uploadedCount.setText(getUploadedText(item.sessionPhotos));
81
+            int uploaded = 0;
82
+            for(PhotoBean bean : photoList){
83
+                if(bean.isUploaded){
84
+                    uploaded++;
85
+                }
86
+            }
87
+            holder.uploadStatus.setText(getUploadStatusText(item.sessionPhotos));
88
+            holder.uploadProgressBar.setProgress(100*uploaded/photoList.size());
93 89
         }
94 90
         int height = width;
95 91
         ViewGroup.LayoutParams lp=holder.photo.getLayoutParams();
@@ -115,7 +111,7 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
115 111
         return sessionList.size();
116 112
     }
117 113
 
118
-    private String getUploadedText(ArrayList<PhotoBean> photoList){
114
+    private String getUploadStatusText(ArrayList<PhotoBean> photoList){
119 115
         int uploaded = 0;
120 116
         for(PhotoBean bean : photoList){
121 117
             if(bean.isUploaded){
@@ -134,7 +130,9 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler
134 130
 
135 131
         @BindView(R.id.tv_session_seq) TextView sesseionSeq;
136 132
 
137
-        @BindView(R.id.tv_session_uploaded_count) TextView uploadedCount;
133
+        @BindView(R.id.tv_session_upload_status) TextView uploadStatus;
134
+
135
+        @BindView(R.id.pb_session_upload)  ProgressBar uploadProgressBar;
138 136
 
139 137
         public MyViewHolder(View view){
140 138
             super(view);

二進制
app/src/main/res/drawable-xhdpi/progress_bg.png


二進制
app/src/main/res/drawable-xhdpi/progress_drawable.png


二進制
app/src/main/res/drawable-xhdpi/progress_fail_drawable.png


+ 15 - 2
app/src/main/res/layout/session_item.xml

@@ -35,11 +35,24 @@
35 35
             android:textColor="@color/text_white"
36 36
             android:textSize="60sp" />
37 37
 
38
+        <ProgressBar
39
+            android:id="@+id/pb_session_upload"
40
+            android:layout_width="match_parent"
41
+            android:layout_height="4dp"
42
+            android:progressDrawable="@drawable/progress_drawable"
43
+            style="?android:attr/progressBarStyleHorizontal"
44
+            android:background="@drawable/progress_bg"
45
+            android:layout_marginLeft="10dp"
46
+            android:layout_marginRight="10dp"
47
+            android:layout_marginBottom="8dp"
48
+            android:layout_alignParentBottom="true"
49
+            />
50
+
38 51
         <TextView
39
-            android:id="@+id/tv_session_uploaded_count"
52
+            android:id="@+id/tv_session_upload_status"
40 53
             android:layout_width="wrap_content"
41 54
             android:layout_height="wrap_content"
42
-            android:layout_alignParentBottom="true"
55
+            android:layout_above="@id/pb_session_upload"
43 56
             android:layout_centerHorizontal="true"
44 57
             android:textColor="@color/text_white"
45 58
             android:textSize="16sp" />