@@ -5,7 +5,7 @@ |
||
5 | 5 |
<GradleProjectSettings> |
6 | 6 |
<option name="distributionType" value="LOCAL" /> |
7 | 7 |
<option name="externalProjectPath" value="$PROJECT_DIR$" /> |
8 |
- <option name="gradleHome" value="C:\Android\android-studio\gradle\gradle-2.14.1" /> |
|
8 |
+ <option name="gradleHome" value="C:\Android\android-studio-2.2\gradle\gradle-2.14.1" /> |
|
9 | 9 |
<option name="modules"> |
10 | 10 |
<set> |
11 | 11 |
<option value="$PROJECT_DIR$" /> |
@@ -1,11 +1,13 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 | 3 |
import android.content.Context; |
4 |
+import android.content.Intent; |
|
4 | 5 |
import android.support.v7.widget.RecyclerView; |
5 | 6 |
import android.view.LayoutInflater; |
6 | 7 |
import android.view.View; |
7 | 8 |
import android.view.ViewGroup; |
8 | 9 |
import android.widget.ImageView; |
10 |
+import android.widget.Toast; |
|
9 | 11 |
|
10 | 12 |
import com.android.common.utils.DeviceUtils; |
11 | 13 |
import com.nostra13.universalimageloader.core.DisplayImageOptions; |
@@ -13,8 +15,10 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions; |
||
13 | 15 |
import java.io.File; |
14 | 16 |
import java.util.ArrayList; |
15 | 17 |
|
18 |
+import ai.pai.lensman.App; |
|
16 | 19 |
import ai.pai.lensman.R; |
17 | 20 |
import ai.pai.lensman.bean.PhotoBean; |
21 |
+import ai.pai.lensman.service.UploadService; |
|
18 | 22 |
import ai.pai.lensman.utils.Constants; |
19 | 23 |
import ai.pai.lensman.utils.ImageLoaderUtils; |
20 | 24 |
import butterknife.BindView; |
@@ -22,12 +26,14 @@ import butterknife.ButterKnife; |
||
22 | 26 |
|
23 | 27 |
public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdapter.MyViewHolder> { |
24 | 28 |
|
25 |
- private LayoutInflater mInflater; |
|
26 |
- private ArrayList<PhotoBean> photoList; |
|
27 | 29 |
private int width; |
30 |
+ private Context context; |
|
31 |
+ private LayoutInflater mInflater; |
|
28 | 32 |
private DisplayImageOptions options; |
33 |
+ private ArrayList<PhotoBean> photoList; |
|
29 | 34 |
|
30 | 35 |
public PhotoRecyclerAdapter(Context context){ |
36 |
+ this.context = context; |
|
31 | 37 |
width = DeviceUtils.getScreenWidth(context); |
32 | 38 |
mInflater = LayoutInflater.from(context); |
33 | 39 |
options = ImageLoaderUtils.getOptions(R.drawable.default_img); |
@@ -57,7 +63,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
57 | 63 |
} |
58 | 64 |
|
59 | 65 |
@Override |
60 |
- public void onBindViewHolder(MyViewHolder holder, int position) { |
|
66 |
+ public void onBindViewHolder(final MyViewHolder holder, final int position) { |
|
61 | 67 |
if(photoList==null){ |
62 | 68 |
return; |
63 | 69 |
} |
@@ -70,8 +76,19 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
70 | 76 |
lp.width = width; |
71 | 77 |
lp.height = height; |
72 | 78 |
holder.photo.setLayoutParams(lp); |
73 |
- if(item.uploadStatus== PhotoBean.UploadStatus.STATUS_ERROR){ |
|
79 |
+ if(item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR){ |
|
74 | 80 |
holder.errorLayout.setVisibility(View.VISIBLE); |
81 |
+ holder.retryImg.setOnClickListener(new View.OnClickListener(){ |
|
82 |
+ @Override |
|
83 |
+ public void onClick(View view) { |
|
84 |
+ Intent intent = new Intent(App.getAppContext(), UploadService.class); |
|
85 |
+ intent.putExtra("photo",item); |
|
86 |
+ App.getAppContext().startService(intent); |
|
87 |
+ item.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN; |
|
88 |
+ notifyItemChanged(position); |
|
89 |
+ Toast.makeText(context,R.string.add_to_upload_queue,Toast.LENGTH_SHORT).show(); |
|
90 |
+ } |
|
91 |
+ }); |
|
75 | 92 |
}else{ |
76 | 93 |
holder.errorLayout.setVisibility(View.GONE); |
77 | 94 |
} |
@@ -89,6 +106,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
89 | 106 |
|
90 | 107 |
@BindView(R.id.iv_session_photo_item) ImageView photo; |
91 | 108 |
@BindView(R.id.layout_upload_fail) View errorLayout; |
109 |
+ @BindView(R.id.iv_upload_retry) ImageView retryImg; |
|
92 | 110 |
|
93 | 111 |
public MyViewHolder(View view){ |
94 | 112 |
super(view); |
@@ -20,22 +20,22 @@ |
||
20 | 20 |
android:layout_alignTop="@+id/iv_session_photo_item" |
21 | 21 |
android:layout_alignRight="@+id/iv_session_photo_item" |
22 | 22 |
android:background="@color/black" |
23 |
- android:alpha="0.4" |
|
23 |
+ android:alpha="0.6" |
|
24 | 24 |
android:visibility="gone"> |
25 | 25 |
|
26 | 26 |
<ImageView |
27 | 27 |
android:id="@+id/iv_upload_retry" |
28 | 28 |
android:layout_width="40dp" |
29 | 29 |
android:layout_height="40dp" |
30 |
+ android:padding="10dp" |
|
30 | 31 |
android:layout_centerInParent="true" |
31 | 32 |
android:src="@drawable/retry"/> |
32 | 33 |
<TextView |
33 | 34 |
android:id="@+id/tv_upload_fail" |
34 | 35 |
android:layout_width="wrap_content" |
35 | 36 |
android:layout_height="wrap_content" |
36 |
- android:layout_marginTop="4dp" |
|
37 |
- android:layout_centerInParent="true" |
|
38 | 37 |
android:layout_below="@id/iv_upload_retry" |
38 |
+ android:layout_centerHorizontal="true" |
|
39 | 39 |
android:text="@string/upload_error" |
40 | 40 |
android:textSize="16sp" |
41 | 41 |
android:textColor="@color/white"/> |
@@ -23,6 +23,8 @@ |
||
23 | 23 |
<string name="upload_error">上传失败</string> |
24 | 24 |
<string name="upload_success">上传成功</string> |
25 | 25 |
|
26 |
+ <string name="add_to_upload_queue">已加入上传任务列表,尝试中...</string> |
|
27 |
+ |
|
26 | 28 |
<string name="network_disconnect">当前无网络连接</string> |
27 | 29 |
|
28 | 30 |
<string name="qr_scan_hint">将取景框对准二维码,\n即可自动扫码</string> |