@@ -3,9 +3,9 @@ package ai.pai.lensman.bean;  | 
            ||
| 3 | 3 | 
                 | 
            
| 4 | 4 | 
                import java.io.Serializable;  | 
            
| 5 | 5 | 
                 | 
            
| 6 | 
                -public class PhotoBean implements Serializable{
               | 
            |
| 6 | 
                +public class PhotoBean implements Serializable {
               | 
            |
| 7 | 7 | 
                 | 
            
| 8 | 
                - public long photoId;  | 
            |
| 8 | 
                + public long photoId;  | 
            |
| 9 | 9 | 
                 | 
            
| 10 | 10 | 
                public String photoPath;  | 
            
| 11 | 11 | 
                 | 
            
                @@ -35,13 +35,13 @@ public class PhotoBean implements Serializable{
               | 
            ||
| 35 | 35 | 
                 | 
            
| 36 | 36 | 
                @Override  | 
            
| 37 | 37 | 
                     public boolean equals(Object obj) {
               | 
            
| 38 | 
                -        if(obj == this){
               | 
            |
| 38 | 
                +        if (obj == this) {
               | 
            |
| 39 | 39 | 
                return true;  | 
            
| 40 | 40 | 
                }  | 
            
| 41 | 
                -        if(!(obj instanceof PhotoBean)){
               | 
            |
| 41 | 
                +        if (!(obj instanceof PhotoBean)) {
               | 
            |
| 42 | 42 | 
                return false;  | 
            
| 43 | 43 | 
                }  | 
            
| 44 | 
                - return (((PhotoBean) obj).photoId==this.photoId);  | 
            |
| 44 | 
                + return (((PhotoBean) obj).photoId == this.photoId);  | 
            |
| 45 | 45 | 
                }  | 
            
| 46 | 46 | 
                 | 
            
| 47 | 47 | 
                @Override  | 
            
                @@ -59,5 +59,6 @@ public class PhotoBean implements Serializable{
               | 
            ||
| 59 | 59 | 
                int STATUS_NO_BEGIN = 0;  | 
            
| 60 | 60 | 
                int STATUS_SUCCESS = 1;  | 
            
| 61 | 61 | 
                int STATUS_ERROR = -1;  | 
            
| 62 | 
                + int STATUS_UPLOADING = 2;  | 
            |
| 62 | 63 | 
                }  | 
            
| 63 | 64 | 
                }  | 
            
                @@ -15,7 +15,7 @@ import ai.pai.lensman.bean.PhotoBean;  | 
            ||
| 15 | 15 | 
                import ai.pai.lensman.db.DBService;  | 
            
| 16 | 16 | 
                import ai.pai.lensman.db.Preferences;  | 
            
| 17 | 17 | 
                 | 
            
| 18 | 
                -public class UploadService extends Service implements UploadTask.OnPhotoUploadListener,Handler.Callback{
               | 
            |
| 18 | 
                +public class UploadService extends Service implements UploadTask.OnPhotoUploadListener, Handler.Callback {
               | 
            |
| 19 | 19 | 
                 | 
            
| 20 | 20 | 
                private PhotoBean currentPhoto;  | 
            
| 21 | 21 | 
                private PhotoUploadListener listener;  | 
            
                @@ -37,44 +37,46 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi  | 
            ||
| 37 | 37 | 
                 | 
            
| 38 | 38 | 
                @Override  | 
            
| 39 | 39 | 
                     public int onStartCommand(Intent intent, int flags, int startId) {
               | 
            
| 40 | 
                -        if(intent!=null && intent.getSerializableExtra("photo")!=null){
               | 
            |
| 40 | 
                +        if (intent != null && intent.getSerializableExtra("photo") != null) {
               | 
            |
| 41 | 41 | 
                             PhotoBean bean = (PhotoBean) intent.getSerializableExtra("photo");
               | 
            
| 42 | 42 | 
                bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;  | 
            
| 43 | 43 | 
                DBService.getInstance().updatePhotoBean(bean);  | 
            
| 44 | 44 | 
                }  | 
            
| 45 | 
                - startUpload();  | 
            |
| 45 | 
                + startUpload();  | 
            |
| 46 | 46 | 
                return super.onStartCommand(intent, flags, startId);  | 
            
| 47 | 47 | 
                }  | 
            
| 48 | 48 | 
                 | 
            
| 49 | 
                -    private synchronized void startUpload(){
               | 
            |
| 50 | 
                -        if(!NetworkUtil.isNetworkConnected(this)){
               | 
            |
| 49 | 
                +    private synchronized void startUpload() {
               | 
            |
| 50 | 
                +        if (!NetworkUtil.isNetworkConnected(this)) {
               | 
            |
| 51 | 51 | 
                return;  | 
            
| 52 | 52 | 
                }  | 
            
| 53 | 53 | 
                         if (NetworkUtil.isMobileConnected(this) && !Preferences.getInstance().isUploadInMobile()) {
               | 
            
| 54 | 54 | 
                return;  | 
            
| 55 | 55 | 
                }  | 
            
| 56 | 
                -        if(currentPhoto!=null){
               | 
            |
| 57 | 
                - LogHelper.d(TAG,"当前有图片正在上传"+currentPhoto);  | 
            |
| 56 | 
                +        if (currentPhoto != null) {
               | 
            |
| 57 | 
                + LogHelper.d(TAG, "当前有图片正在上传" + currentPhoto);  | 
            |
| 58 | 58 | 
                return;  | 
            
| 59 | 59 | 
                }  | 
            
| 60 | 60 | 
                // LogHelper.d(TAG,"查询是否有可以上传的照片,时间="+System.currentTimeMillis());  | 
            
| 61 | 
                - currentPhoto = DBService.getInstance().getNextUploadPhoto();  | 
            |
| 62 | 
                -        if(currentPhoto==null){
               | 
            |
| 61 | 
                + currentPhoto = DBService.getInstance().getNextUploadPhoto();  | 
            |
| 62 | 
                +        if (currentPhoto == null) {
               | 
            |
| 63 | 63 | 
                handler.removeMessages(MSG_TRY_UPLOAD);  | 
            
| 64 | 
                - handler.sendEmptyMessageDelayed(MSG_TRY_UPLOAD,2000);  | 
            |
| 64 | 
                + handler.sendEmptyMessageDelayed(MSG_TRY_UPLOAD, 2000);  | 
            |
| 65 | 65 | 
                // LogHelper.d(TAG,"本地图片已全部上传");  | 
            
| 66 | 66 | 
                return;  | 
            
| 67 | 67 | 
                }  | 
            
| 68 | 
                - LogHelper.d(TAG,"即将上传的照片是"+currentPhoto);  | 
            |
| 69 | 
                - new UploadTask(currentPhoto,this).executeOnExecutor(ThreadExecutor.getInstance().getExecutor());  | 
            |
| 68 | 
                + LogHelper.d(TAG, "即将上传的照片是" + currentPhoto);  | 
            |
| 69 | 
                + currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_UPLOADING;  | 
            |
| 70 | 
                + DBService.getInstance().updatePhotoBean(currentPhoto);  | 
            |
| 71 | 
                + new UploadTask(currentPhoto, this).executeOnExecutor(ThreadExecutor.getInstance().getExecutor());  | 
            |
| 70 | 72 | 
                }  | 
            
| 71 | 73 | 
                 | 
            
| 72 | 74 | 
                @Override  | 
            
| 73 | 75 | 
                     public void onPhotoUploadSucceed(PhotoBean bean) {
               | 
            
| 74 | 
                -        if(bean.equals(currentPhoto)){
               | 
            |
| 75 | 
                - currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_SUCCESS;  | 
            |
| 76 | 
                +        if (bean.equals(currentPhoto)) {
               | 
            |
| 77 | 
                + currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_SUCCESS;  | 
            |
| 76 | 78 | 
                DBService.getInstance().updatePhotoBean(currentPhoto);  | 
            
| 77 | 
                -            if(listener!=null){
               | 
            |
| 79 | 
                +            if (listener != null) {
               | 
            |
| 78 | 80 | 
                listener.onPhotoUploaded(currentPhoto);  | 
            
| 79 | 81 | 
                }  | 
            
| 80 | 82 | 
                currentPhoto = null;  | 
            
                @@ -84,10 +86,10 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi  | 
            ||
| 84 | 86 | 
                 | 
            
| 85 | 87 | 
                @Override  | 
            
| 86 | 88 | 
                     public void onPhotoUploadFail(PhotoBean bean) {
               | 
            
| 87 | 
                -        if(bean.equals(currentPhoto)){
               | 
            |
| 88 | 
                - currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_ERROR;  | 
            |
| 89 | 
                +        if (bean.equals(currentPhoto)) {
               | 
            |
| 90 | 
                + currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_ERROR;  | 
            |
| 89 | 91 | 
                DBService.getInstance().updatePhotoBean(currentPhoto);  | 
            
| 90 | 
                -            if(listener!=null){
               | 
            |
| 92 | 
                +            if (listener != null) {
               | 
            |
| 91 | 93 | 
                listener.onPhotoUploadError(currentPhoto);  | 
            
| 92 | 94 | 
                }  | 
            
| 93 | 95 | 
                currentPhoto = null;  | 
            
                @@ -95,27 +97,28 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi  | 
            ||
| 95 | 97 | 
                startUpload();  | 
            
| 96 | 98 | 
                }  | 
            
| 97 | 99 | 
                 | 
            
| 98 | 
                -    public void setPhotoUploadListener(PhotoUploadListener listener){
               | 
            |
| 100 | 
                +    public void setPhotoUploadListener(PhotoUploadListener listener) {
               | 
            |
| 99 | 101 | 
                this.listener = listener;  | 
            
| 100 | 102 | 
                }  | 
            
| 101 | 103 | 
                 | 
            
| 102 | 104 | 
                @Override  | 
            
| 103 | 105 | 
                     public boolean handleMessage(Message message) {
               | 
            
| 104 | 
                -        if(message.what == MSG_TRY_UPLOAD){
               | 
            |
| 106 | 
                +        if (message.what == MSG_TRY_UPLOAD) {
               | 
            |
| 105 | 107 | 
                startUpload();  | 
            
| 106 | 108 | 
                return true;  | 
            
| 107 | 109 | 
                }  | 
            
| 108 | 110 | 
                return false;  | 
            
| 109 | 111 | 
                }  | 
            
| 110 | 112 | 
                 | 
            
| 111 | 
                -    public interface PhotoUploadListener{
               | 
            |
| 113 | 
                +    public interface PhotoUploadListener {
               | 
            |
| 112 | 114 | 
                void onPhotoUploaded(PhotoBean bean);  | 
            
| 115 | 
                +  | 
            |
| 113 | 116 | 
                void onPhotoUploadError(PhotoBean bean);  | 
            
| 114 | 117 | 
                }  | 
            
| 115 | 118 | 
                 | 
            
| 116 | 119 | 
                     public class MyBinder extends Binder {
               | 
            
| 117 | 120 | 
                 | 
            
| 118 | 
                -        public UploadService getService(){
               | 
            |
| 121 | 
                +        public UploadService getService() {
               | 
            |
| 119 | 122 | 
                return UploadService.this;  | 
            
| 120 | 123 | 
                }  | 
            
| 121 | 124 | 
                 | 
            
                @@ -13,16 +13,13 @@ import android.widget.Toast;  | 
            ||
| 13 | 13 | 
                import com.android.common.utils.DeviceUtils;  | 
            
| 14 | 14 | 
                import com.nostra13.universalimageloader.core.DisplayImageOptions;  | 
            
| 15 | 15 | 
                 | 
            
| 16 | 
                -import java.io.File;  | 
            |
| 17 | 16 | 
                import java.util.ArrayList;  | 
            
| 18 | 17 | 
                 | 
            
| 19 | 18 | 
                import ai.pai.lensman.App;  | 
            
| 20 | 19 | 
                import ai.pai.lensman.R;  | 
            
| 21 | 20 | 
                import ai.pai.lensman.bean.PhotoBean;  | 
            
| 22 | 
                -import ai.pai.lensman.db.DBService;  | 
            |
| 23 | 21 | 
                import ai.pai.lensman.db.Preferences;  | 
            
| 24 | 22 | 
                import ai.pai.lensman.service.UploadService;  | 
            
| 25 | 
                -import ai.pai.lensman.utils.Constants;  | 
            |
| 26 | 23 | 
                import ai.pai.lensman.utils.ImageLoaderUtils;  | 
            
| 27 | 24 | 
                import butterknife.BindView;  | 
            
| 28 | 25 | 
                import butterknife.ButterKnife;  | 
            
                @@ -32,10 +29,11 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap  | 
            ||
| 32 | 29 | 
                private int width;  | 
            
| 33 | 30 | 
                private Context context;  | 
            
| 34 | 31 | 
                private LayoutInflater mInflater;  | 
            
| 35 | 
                - private DisplayImageOptions options;  | 
            |
| 32 | 
                + private DisplayImageOptions options;  | 
            |
| 36 | 33 | 
                private ArrayList<PhotoBean> photoList;  | 
            
| 37 | 34 | 
                private int delay = 10;  | 
            
| 38 | 
                -    public PhotoRecyclerAdapter(Context context){
               | 
            |
| 35 | 
                +  | 
            |
| 36 | 
                +    public PhotoRecyclerAdapter(Context context) {
               | 
            |
| 39 | 37 | 
                this.context = context;  | 
            
| 40 | 38 | 
                width = DeviceUtils.getScreenWidth(context);  | 
            
| 41 | 39 | 
                mInflater = LayoutInflater.from(context);  | 
            
                @@ -43,108 +41,120 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap  | 
            ||
| 43 | 41 | 
                delay = Preferences.getInstance().getUploadDelay();  | 
            
| 44 | 42 | 
                }  | 
            
| 45 | 43 | 
                 | 
            
| 46 | 
                -    public PhotoBean getPhotoAt(int position){
               | 
            |
| 47 | 
                -        if(photoList==null|| photoList.size()<=position ||position<0){
               | 
            |
| 44 | 
                +    public PhotoBean getPhotoAt(int position) {
               | 
            |
| 45 | 
                +        if (photoList == null || photoList.size() <= position || position < 0) {
               | 
            |
| 48 | 46 | 
                return null;  | 
            
| 49 | 47 | 
                }  | 
            
| 50 | 48 | 
                return photoList.get(position);  | 
            
| 51 | 49 | 
                }  | 
            
| 52 | 50 | 
                 | 
            
| 53 | 
                -    public synchronized void addPhotoBean(PhotoBean item){
               | 
            |
| 54 | 
                -        if(photoList==null){
               | 
            |
| 51 | 
                +    public synchronized void addPhotoBean(PhotoBean item) {
               | 
            |
| 52 | 
                +        if (photoList == null) {
               | 
            |
| 55 | 53 | 
                photoList = new ArrayList<>();  | 
            
| 56 | 54 | 
                }  | 
            
| 57 | 
                -        if(!photoList.contains(item)){
               | 
            |
| 58 | 
                - photoList.add(0,item);  | 
            |
| 55 | 
                +        if (!photoList.contains(item)) {
               | 
            |
| 56 | 
                + photoList.add(0, item);  | 
            |
| 59 | 57 | 
                notifyItemInserted(0);  | 
            
| 60 | 
                - notifyItemRangeChanged(0,photoList.size());  | 
            |
| 58 | 
                + notifyItemRangeChanged(0, photoList.size());  | 
            |
| 61 | 59 | 
                }  | 
            
| 62 | 60 | 
                }  | 
            
| 63 | 61 | 
                 | 
            
| 64 | 
                -    public synchronized void addPreviousPhotos(ArrayList<PhotoBean> photos){
               | 
            |
| 65 | 
                -        if(photos==null||photos.size()==0){
               | 
            |
| 62 | 
                +    public synchronized void addPreviousPhotos(ArrayList<PhotoBean> photos) {
               | 
            |
| 63 | 
                +        if (photos == null || photos.size() == 0) {
               | 
            |
| 66 | 64 | 
                return;  | 
            
| 67 | 65 | 
                }  | 
            
| 68 | 
                -        if(photoList==null){
               | 
            |
| 66 | 
                +        if (photoList == null) {
               | 
            |
| 69 | 67 | 
                photoList = new ArrayList<>();  | 
            
| 70 | 68 | 
                }  | 
            
| 71 | 
                -        if(photoList.size()==0){
               | 
            |
| 69 | 
                +        if (photoList.size() == 0) {
               | 
            |
| 72 | 70 | 
                photoList.addAll(photos);  | 
            
| 73 | 71 | 
                notifyDataSetChanged();  | 
            
| 74 | 72 | 
                }  | 
            
| 75 | 73 | 
                }  | 
            
| 76 | 74 | 
                 | 
            
| 77 | 
                -    public synchronized void removePhotoAtIndex(int index){
               | 
            |
| 78 | 
                -        if(photoList==null || photoList.size()<=index){
               | 
            |
| 75 | 
                +    public synchronized void removePhotoAtIndex(int index) {
               | 
            |
| 76 | 
                +        if (photoList == null || photoList.size() <= index) {
               | 
            |
| 79 | 77 | 
                return;  | 
            
| 80 | 78 | 
                }  | 
            
| 81 | 79 | 
                photoList.remove(index);  | 
            
| 82 | 80 | 
                notifyItemRemoved(index);  | 
            
| 83 | 
                - notifyItemRangeChanged(0,photoList.size());  | 
            |
| 81 | 
                + notifyItemRangeChanged(0, photoList.size());  | 
            |
| 84 | 82 | 
                }  | 
            
| 85 | 83 | 
                 | 
            
| 86 | 84 | 
                @Override  | 
            
| 87 | 85 | 
                     public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
               | 
            
| 88 | 
                - return new MyViewHolder(mInflater.inflate(R.layout.photo_item,parent,false));  | 
            |
| 86 | 
                + return new MyViewHolder(mInflater.inflate(R.layout.photo_item, parent, false));  | 
            |
| 89 | 87 | 
                }  | 
            
| 90 | 88 | 
                 | 
            
| 91 | 89 | 
                @Override  | 
            
| 92 | 90 | 
                     public void onBindViewHolder(final MyViewHolder holder, final int position) {
               | 
            
| 93 | 
                -        if(photoList==null){
               | 
            |
| 91 | 
                +        if (photoList == null) {
               | 
            |
| 94 | 92 | 
                return;  | 
            
| 95 | 93 | 
                }  | 
            
| 96 | 94 | 
                final PhotoBean item = photoList.get(position);  | 
            
| 97 | 95 | 
                ImageLoaderUtils.displayLocalImage(item.photoPath, holder.photo, options);  | 
            
| 98 | 
                - int height = width*10/16;  | 
            |
| 99 | 
                - ViewGroup.LayoutParams lp=holder.photo.getLayoutParams();  | 
            |
| 96 | 
                + int height = width * 10 / 16;  | 
            |
| 97 | 
                + ViewGroup.LayoutParams lp = holder.photo.getLayoutParams();  | 
            |
| 100 | 98 | 
                lp.width = width;  | 
            
| 101 | 99 | 
                lp.height = height;  | 
            
| 102 | 100 | 
                holder.photo.setLayoutParams(lp);  | 
            
| 103 | 
                -        if(item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR){
               | 
            |
| 101 | 
                +        if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR) {
               | 
            |
| 104 | 102 | 
                holder.errorLayout.setVisibility(View.VISIBLE);  | 
            
| 105 | 
                -            holder.retryImg.setOnClickListener(new View.OnClickListener(){
               | 
            |
| 103 | 
                +            holder.retryImg.setOnClickListener(new View.OnClickListener() {
               | 
            |
| 106 | 104 | 
                @Override  | 
            
| 107 | 105 | 
                                 public void onClick(View view) {
               | 
            
| 108 | 106 | 
                Intent intent = new Intent(App.getAppContext(), UploadService.class);  | 
            
| 109 | 
                -                    intent.putExtra("photo",item);
               | 
            |
| 107 | 
                +                    intent.putExtra("photo", item);
               | 
            |
| 110 | 108 | 
                App.getAppContext().startService(intent);  | 
            
| 111 | 109 | 
                item.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;  | 
            
| 112 | 110 | 
                notifyItemChanged(position);  | 
            
| 113 | 
                - Toast.makeText(context,R.string.add_to_upload_queue,Toast.LENGTH_SHORT).show();  | 
            |
| 111 | 
                + Toast.makeText(context, R.string.add_to_upload_queue, Toast.LENGTH_SHORT).show();  | 
            |
| 114 | 112 | 
                }  | 
            
| 115 | 113 | 
                });  | 
            
| 116 | 
                -        }else{
               | 
            |
| 114 | 
                +        } else {
               | 
            |
| 117 | 115 | 
                holder.errorLayout.setVisibility(View.GONE);  | 
            
| 118 | 116 | 
                }  | 
            
| 119 | 
                - long timeLeft = delay-(System.currentTimeMillis()-item.captureTime)/1000;  | 
            |
| 117 | 
                + long timeLeft = delay - (System.currentTimeMillis() - item.captureTime) / 1000;  | 
            |
| 120 | 118 | 
                 | 
            
| 121 | 
                -        if(timeLeft<0|| DBService.getInstance().isPhotoUploaded(item.photoId)){
               | 
            |
| 119 | 
                +        if (timeLeft < 0) {
               | 
            |
| 122 | 120 | 
                item.canDelete = false;  | 
            
| 123 | 
                - holder.autoUploadHintText.setVisibility(View.GONE);  | 
            |
| 124 | 
                -        }else{
               | 
            |
| 121 | 
                +            if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR) {
               | 
            |
| 122 | 
                + holder.uploadStatusText.setText(context.getString(R.string.upload_error));  | 
            |
| 123 | 
                +            } else if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_SUCCESS) {
               | 
            |
| 124 | 
                + holder.uploadStatusText.setText(context.getString(R.string.upload_success));  | 
            |
| 125 | 
                +            } else if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_NO_BEGIN) {
               | 
            |
| 126 | 
                + holder.uploadStatusText.setText(context.getString(R.string.upload_in_waiting));  | 
            |
| 127 | 
                +            } else if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_UPLOADING) {
               | 
            |
| 128 | 
                + holder.uploadStatusText.setText(context.getString(R.string.upload_processing));  | 
            |
| 129 | 
                + }  | 
            |
| 130 | 
                +        } else {
               | 
            |
| 125 | 131 | 
                item.canDelete = true;  | 
            
| 126 | 
                - holder.autoUploadHintText.setVisibility(View.VISIBLE);  | 
            |
| 127 | 
                - holder.autoUploadHintText.setText(context.getString(R.string.auto_upload_after_seconds,timeLeft));  | 
            |
| 132 | 
                + holder.uploadStatusText.setText(context.getString(R.string.auto_upload_after_seconds, timeLeft));  | 
            |
| 128 | 133 | 
                }  | 
            
| 129 | 134 | 
                }  | 
            
| 130 | 135 | 
                 | 
            
| 131 | 136 | 
                @Override  | 
            
| 132 | 137 | 
                     public int getItemCount() {
               | 
            
| 133 | 
                -        if(photoList==null){
               | 
            |
| 138 | 
                +        if (photoList == null) {
               | 
            |
| 134 | 139 | 
                return 0;  | 
            
| 135 | 140 | 
                }  | 
            
| 136 | 141 | 
                return photoList.size();  | 
            
| 137 | 142 | 
                }  | 
            
| 138 | 143 | 
                 | 
            
| 139 | 
                -    class MyViewHolder extends RecyclerView.ViewHolder{
               | 
            |
| 144 | 
                +    class MyViewHolder extends RecyclerView.ViewHolder {
               | 
            |
| 145 | 
                +  | 
            |
| 146 | 
                + @BindView(R.id.iv_session_photo_item)  | 
            |
| 147 | 
                + ImageView photo;  | 
            |
| 148 | 
                + @BindView(R.id.layout_upload_fail)  | 
            |
| 149 | 
                + View errorLayout;  | 
            |
| 150 | 
                + @BindView(R.id.iv_upload_retry)  | 
            |
| 151 | 
                + ImageView retryImg;  | 
            |
| 152 | 
                + @BindView(R.id.tv_upload_status)  | 
            |
| 153 | 
                + TextView uploadStatusText;  | 
            |
| 140 | 154 | 
                 | 
            
| 141 | 
                - @BindView(R.id.iv_session_photo_item) ImageView photo;  | 
            |
| 142 | 
                - @BindView(R.id.layout_upload_fail) View errorLayout;  | 
            |
| 143 | 
                - @BindView(R.id.iv_upload_retry) ImageView retryImg;  | 
            |
| 144 | 
                - @BindView(R.id.tv_auto_upload_hint) TextView autoUploadHintText;  | 
            |
| 145 | 
                -        public MyViewHolder(View view){
               | 
            |
| 155 | 
                +        public MyViewHolder(View view) {
               | 
            |
| 146 | 156 | 
                super(view);  | 
            
| 147 | 
                - ButterKnife.bind(this,view);  | 
            |
| 157 | 
                + ButterKnife.bind(this, view);  | 
            |
| 148 | 158 | 
                }  | 
            
| 149 | 159 | 
                }  | 
            
| 150 | 160 | 
                }  | 
            
                @@ -209,7 +209,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie  | 
            ||
| 209 | 209 | 
                 | 
            
| 210 | 210 | 
                 | 
            
| 211 | 211 | 
                @Override  | 
            
| 212 | 
                -    public void refreshUploadTimeHint() {
               | 
            |
| 212 | 
                +    public void refreshRecyclerView() {
               | 
            |
| 213 | 213 | 
                         if(adapter!=null && photosRecyclerView!=null && photosRecyclerView.getVisibility()==View.VISIBLE){
               | 
            
| 214 | 214 | 
                             photosRecyclerView.post(new Runnable() {
               | 
            
| 215 | 215 | 
                @Override  | 
            
                @@ -16,7 +16,7 @@ public class SessionContract {
               | 
            ||
| 16 | 16 | 
                void showPhotoRecyclerView();  | 
            
| 17 | 17 | 
                void showEmptyView();  | 
            
| 18 | 18 | 
                void showToast(String toast);  | 
            
| 19 | 
                - void refreshUploadTimeHint();  | 
            |
| 19 | 
                + void refreshRecyclerView();  | 
            |
| 20 | 20 | 
                void addPhotos(ArrayList<PhotoBean> photoList);  | 
            
| 21 | 21 | 
                void refreshCameraStatus(String status);  | 
            
| 22 | 22 | 
                }  | 
            
                @@ -1,6 +1,10 @@  | 
            ||
| 1 | 1 | 
                package ai.pai.lensman.session;  | 
            
| 2 | 2 | 
                 | 
            
| 3 | 
                +import android.content.ComponentName;  | 
            |
| 4 | 
                +import android.content.Context;  | 
            |
| 3 | 5 | 
                import android.content.Intent;  | 
            
| 6 | 
                +import android.content.ServiceConnection;  | 
            |
| 7 | 
                +import android.os.IBinder;  | 
            |
| 4 | 8 | 
                 | 
            
| 5 | 9 | 
                import com.android.common.utils.LogHelper;  | 
            
| 6 | 10 | 
                 | 
            
                @@ -16,7 +20,7 @@ import ai.pai.lensman.db.DBService;  | 
            ||
| 16 | 20 | 
                import ai.pai.lensman.service.UploadService;  | 
            
| 17 | 21 | 
                 | 
            
| 18 | 22 | 
                 | 
            
| 19 | 
                -public class SessionPresenter implements SessionContract.Presenter, SessionInteractor.SessionListener{
               | 
            |
| 23 | 
                +public class SessionPresenter implements SessionContract.Presenter, SessionInteractor.SessionListener,UploadService.PhotoUploadListener{
               | 
            |
| 20 | 24 | 
                 | 
            
| 21 | 25 | 
                private SessionInteractor interactor;  | 
            
| 22 | 26 | 
                private ArrayList<PhotoBean> photoList;  | 
            
                @@ -25,12 +29,24 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter  | 
            ||
| 25 | 29 | 
                private boolean isWorking;  | 
            
| 26 | 30 | 
                private String groupId;  | 
            
| 27 | 31 | 
                private Timer refreshTimer;  | 
            
| 32 | 
                + private ServiceConnection uploadServiceConnection;  | 
            |
| 28 | 33 | 
                 | 
            
| 29 | 34 | 
                private static final String TAG = "SessionPresenter";  | 
            
| 30 | 35 | 
                 | 
            
| 31 | 36 | 
                     public SessionPresenter(SessionBean sessionBean, SessionContract.View view) {
               | 
            
| 32 | 37 | 
                this.sessionView = view;  | 
            
| 33 | 38 | 
                this.sessionBean = sessionBean;  | 
            
| 39 | 
                +        uploadServiceConnection = new ServiceConnection() {
               | 
            |
| 40 | 
                + @Override  | 
            |
| 41 | 
                +            public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
               | 
            |
| 42 | 
                + ((UploadService.MyBinder) iBinder).getService().setPhotoUploadListener(SessionPresenter.this);  | 
            |
| 43 | 
                + }  | 
            |
| 44 | 
                +  | 
            |
| 45 | 
                + @Override  | 
            |
| 46 | 
                +            public void onServiceDisconnected(ComponentName componentName) {
               | 
            |
| 47 | 
                +  | 
            |
| 48 | 
                + }  | 
            |
| 49 | 
                + };  | 
            |
| 34 | 50 | 
                }  | 
            
| 35 | 51 | 
                 | 
            
| 36 | 52 | 
                @Override  | 
            
                @@ -55,16 +71,22 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter  | 
            ||
| 55 | 71 | 
                         refreshTimer.schedule(new TimerTask() {
               | 
            
| 56 | 72 | 
                @Override  | 
            
| 57 | 73 | 
                             public void run() {
               | 
            
| 58 | 
                - sessionView.refreshUploadTimeHint();  | 
            |
| 74 | 
                + sessionView.refreshRecyclerView();  | 
            |
| 59 | 75 | 
                }  | 
            
| 60 | 76 | 
                },1000,1000);  | 
            
| 61 | 
                -  | 
            |
| 77 | 
                + App.getAppContext().bindService(new Intent(App.getAppContext(),UploadService.class),  | 
            |
| 78 | 
                + uploadServiceConnection, Context.BIND_AUTO_CREATE);  | 
            |
| 62 | 79 | 
                }  | 
            
| 63 | 80 | 
                 | 
            
| 64 | 81 | 
                @Override  | 
            
| 65 | 82 | 
                     public void stop() {
               | 
            
| 66 | 83 | 
                interactor.endSession();  | 
            
| 67 | 84 | 
                refreshTimer.cancel();  | 
            
| 85 | 
                +        try{
               | 
            |
| 86 | 
                + App.getAppContext().unbindService(uploadServiceConnection);  | 
            |
| 87 | 
                +        }catch (Exception e){
               | 
            |
| 88 | 
                + e.printStackTrace();  | 
            |
| 89 | 
                + }  | 
            |
| 68 | 90 | 
                isWorking = false;  | 
            
| 69 | 91 | 
                LogHelper.d(TAG,"stop");  | 
            
| 70 | 92 | 
                }  | 
            
                @@ -136,4 +158,25 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter  | 
            ||
| 136 | 158 | 
                this.groupId = groupId;  | 
            
| 137 | 159 | 
                }  | 
            
| 138 | 160 | 
                 | 
            
| 161 | 
                + @Override  | 
            |
| 162 | 
                +    public void onPhotoUploaded(PhotoBean bean) {
               | 
            |
| 163 | 
                +        for(PhotoBean photoBean : photoList){
               | 
            |
| 164 | 
                +            if(photoBean.photoId == bean.photoId){
               | 
            |
| 165 | 
                + photoBean.uploadStatus = PhotoBean.UploadStatus.STATUS_SUCCESS;  | 
            |
| 166 | 
                + sessionView.refreshRecyclerView();  | 
            |
| 167 | 
                + break;  | 
            |
| 168 | 
                + }  | 
            |
| 169 | 
                + }  | 
            |
| 170 | 
                + }  | 
            |
| 171 | 
                +  | 
            |
| 172 | 
                + @Override  | 
            |
| 173 | 
                +    public void onPhotoUploadError(PhotoBean bean) {
               | 
            |
| 174 | 
                +        for(PhotoBean photoBean : photoList){
               | 
            |
| 175 | 
                +            if(photoBean.photoId == bean.photoId){
               | 
            |
| 176 | 
                + photoBean.uploadStatus = PhotoBean.UploadStatus.STATUS_ERROR;  | 
            |
| 177 | 
                + sessionView.refreshRecyclerView();  | 
            |
| 178 | 
                + break;  | 
            |
| 179 | 
                + }  | 
            |
| 180 | 
                + }  | 
            |
| 181 | 
                + }  | 
            |
| 139 | 182 | 
                }  | 
            
                @@ -12,7 +12,7 @@  | 
            ||
| 12 | 12 | 
                android:scaleType="centerCrop"/>  | 
            
| 13 | 13 | 
                 | 
            
| 14 | 14 | 
                <TextView  | 
            
| 15 | 
                - android:id="@+id/tv_auto_upload_hint"  | 
            |
| 15 | 
                + android:id="@+id/tv_upload_status"  | 
            |
| 16 | 16 | 
                android:layout_width="match_parent"  | 
            
| 17 | 17 | 
                android:layout_height="48dp"  | 
            
| 18 | 18 | 
                android:gravity="center"  | 
            
                @@ -46,7 +46,7 @@  | 
            ||
| 46 | 46 | 
                android:layout_height="wrap_content"  | 
            
| 47 | 47 | 
                android:layout_below="@id/iv_upload_retry"  | 
            
| 48 | 48 | 
                android:layout_centerHorizontal="true"  | 
            
| 49 | 
                - android:text="@string/upload_error"  | 
            |
| 49 | 
                + android:text="@string/click_to_retry"  | 
            |
| 50 | 50 | 
                android:textSize="16sp"  | 
            
| 51 | 51 | 
                android:textColor="@color/white"/>  | 
            
| 52 | 52 | 
                 | 
            
                @@ -3,7 +3,7 @@  | 
            ||
| 3 | 3 | 
                <string name="bar_app_name">拍爱摄影师版</string>  | 
            
| 4 | 4 | 
                 | 
            
| 5 | 5 | 
                <string name="version_text">拍爱 V1.0</string>  | 
            
| 6 | 
                - <string name="copyright">Copyright © 2016 </string>  | 
            |
| 6 | 
                + <string name="copyright">Copyright © 2017 </string>  | 
            |
| 7 | 7 | 
                <string name="company_name">北京佳艺徕经贸有限责任公司</string>  | 
            
| 8 | 8 | 
                 | 
            
| 9 | 9 | 
                <string name="bt_connected">已连接</string>  | 
            
                @@ -20,12 +20,6 @@  | 
            ||
| 20 | 20 | 
                <string name="login_fail">登录失败</string>  | 
            
| 21 | 21 | 
                <string name="please_wait">请稍候</string>  | 
            
| 22 | 22 | 
                 | 
            
| 23 | 
                - <string name="upload_processing">上传中</string>  | 
            |
| 24 | 
                - <string name="upload_error">上传失败</string>  | 
            |
| 25 | 
                - <string name="upload_success">上传成功</string>  | 
            |
| 26 | 
                -  | 
            |
| 27 | 
                - <string name="add_to_upload_queue">已加入上传任务列表,尝试中...</string>  | 
            |
| 28 | 
                -  | 
            |
| 29 | 23 | 
                <string name="network_disconnect">当前无网络连接</string>  | 
            
| 30 | 24 | 
                 | 
            
| 31 | 25 | 
                <string name="qr_scan_hint">将取景框对准二维码,\n即可自动扫码</string>  | 
            
                @@ -113,10 +107,6 @@  | 
            ||
| 113 | 107 | 
                 | 
            
| 114 | 108 | 
                <string name="box_status_error">盒子状态错误,请检查</string>  | 
            
| 115 | 109 | 
                 | 
            
| 116 | 
                - <string name="auto_upload_after_seconds">距自动上传还有%d秒</string>  | 
            |
| 117 | 
                -  | 
            |
| 118 | 
                - <string name="can_not_delete">该照片已在上传队列,无法删除</string>  | 
            |
| 119 | 
                -  | 
            |
| 120 | 110 | 
                <string name="sdcard_fail">手机sd卡错误</string>  | 
            
| 121 | 111 | 
                 | 
            
| 122 | 112 | 
                <string name="upload_setting">上传延时设置</string>  | 
            
                @@ -153,4 +143,13 @@  | 
            ||
| 153 | 143 | 
                 | 
            
| 154 | 144 | 
                <string name="upload_in_mobile_network">运营商网络下自动上传</string>  | 
            
| 155 | 145 | 
                 | 
            
| 146 | 
                + <string name="can_not_delete">该照片已在上传队列,无法删除</string>  | 
            |
| 147 | 
                + <string name="auto_upload_after_seconds">距加入上传队列还有%d秒</string>  | 
            |
| 148 | 
                + <string name="upload_in_waiting">等待上传</string>  | 
            |
| 149 | 
                + <string name="upload_processing">上传中</string>  | 
            |
| 150 | 
                + <string name="upload_error">上传失败</string>  | 
            |
| 151 | 
                + <string name="upload_success">上传成功</string>  | 
            |
| 152 | 
                +  | 
            |
| 153 | 
                + <string name="click_to_retry">点击重试</string>  | 
            |
| 154 | 
                + <string name="add_to_upload_queue">已加入上传任务列表,尝试中...</string>  | 
            |
| 156 | 155 | 
                </resources>  |