Java Code Examples for cn.bmob.v3.listener.UploadFileListener

The following examples show how to use cn.bmob.v3.listener.UploadFileListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: styT   Source File: UserProfileActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void uploaderAvertor(String file) {
    File path = new File(file);
    //Log.e(TAG, "=====uploade_avertor___success===>" + path.getAbsolutePath());
    final BmobFile bmobFile = new BmobFile(path);
    bmobFile.uploadblock(new UploadFileListener() {
        @Override
        public void done(BmobException e) {
            if (e == null) {
                //bmobFile.getFileUrl()--返回的上传文件的完整地址
                user.setAuvter(bmobFile);
                //Log.e(TAG, "=====uploade_avertor___success===>" + bmobFile.getUrl());
                updateProfile();
            } else {
                //toast("上传文件失败:" + e.getMessage());
            }

        }

        @Override
        public void onProgress(Integer value) {
            // 返回的上传进度(百分比)
        }
    });
}
 
Example 2
Source Project: stynico   Source File: UserProfileActivity.java    License: MIT License 6 votes vote down vote up
private void uploaderAvertor(String file)
  {
      File path = new File(file);
//  Log.e(TAG, "=====uploade_avertor___success===>" + path.getAbsolutePath());
      final BmobFile bmobFile = new BmobFile(path);
      bmobFile.upload(this, new UploadFileListener() {
		@Override
		public void onSuccess()
		{
			user.setAuvter(bmobFile);
			//   Log.e(TAG, "=====uploade_avertor___success===>" + bmobFile.getUrl());
			updateProfile();
		}

		@Override
		public void onFailure(int i, String s)
		{

			// Log.e(TAG, "=====uploade_avertor___onfailure===>" + s);
		}
	});
  }
 
Example 3
Source Project: Swface   Source File: AddFaceActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void updateImageFile(File imageFile) {
	final BmobFile file = new BmobFile(imageFile);
	file.uploadblock(new UploadFileListener() {
		@Override
		public void done(BmobException e) {
			if (e == null) {
				Log.i(TAG, "file.uploadblock:success ");
				createFaceSet(file.getFileUrl());
			} else {
				Log.e(TAG, "file.uploadblock:failed ", e);
				Message message = new Message();
				message.arg1 = FinalUtil.UPDATE_PICTURE_EXCEPTION;
				myhandler.sendMessage(message);
			}
		}

		@Override
		public void onProgress(Integer value) {
			super.onProgress(value);
			Log.i(TAG, "onProgress: " + value);
		}
	});

}
 
Example 4
Source Project: Mobike   Source File: ReportViolationsActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void toQuery() {
    if (mTvCarnub.getText().toString()=="扫描二维码或者手动输入") {
        ToastUtils.show(ReportViolationsActivity.this, "请输入单车编号");
        return;
    }
    if (TextUtils.isEmpty(mEtBikeDamage.getText().toString())) {
        ToastUtils.show(ReportViolationsActivity.this, "请输入描述信息");
        return;
    }
    mDialog.show();
    mDialog.show();
    bmobFile.upload(new UploadFileListener() {
        @Override
        public void done(BmobException e) {
            if (e == null) {
                saveDatial();
            } else {
                Logger.d(e);
                ToastUtils.show(ReportViolationsActivity.this, "图片上传失败");
            }
            if (mDialog.isShowing())
                mDialog.dismiss();
        }
    });
}
 
Example 5
Source Project: Mobike   Source File: DepositRefundIssueActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void toQuery() {
    if (bmobFile == null) {
        ToastUtils.show(this, "请上传订单截图");
        return;
    }
    if (TextUtils.isEmpty(mEtOrder.getText().toString())) {
        ToastUtils.show(this, "请填写订单号");
        return;
    }
    mDialog.show();
    bmobFile.upload(new UploadFileListener() {
        @Override
        public void done(BmobException e) {
            if (e == null) {
               uploadData();
            } else {
                ToastUtils.show(DepositRefundIssueActivity.this, "上传失败");
            }
            DismissDialog();
        }
    });
}
 
Example 6
Source Project: Conquer   Source File: AlertActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 上传录音
 */
private void upLoadAudio() {
	File f = new File(recorderPath);
	if (!f.exists()) {
		T.show(context, "文件出错");
	}
	L.i("录音文件路径" + recorderPath);
	final BmobFile bf = new BmobFile(f);
	loading.setVisibility(0);
	bf.uploadblock(context, new UploadFileListener() {
		@Override
		public void onSuccess() {
			audioUrl = bf.getFileUrl(context);
			loading.setVisibility(View.GONE);
			L.e("录音上传成功:" + audioUrl);
		}

		@Override
		public void onFailure(int arg0, String arg1) {
			// loading.setVisibility(View.GONE);
			L.e("录音上传失败" + arg0 + arg1);
		}
	});
}
 
Example 7
Source Project: Conquer   Source File: EditMyInfoActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 上传图片更新网络信息
 *
 * @param f
 */
private void uploadPic(File f) {
    loader.displayImage("file://" + f.getAbsolutePath(), iv_photo, option_pic);
    final BmobFile bf = new BmobFile(f);
    bf.uploadblock(context, new UploadFileListener() {
        @Override
        public void onSuccess() {
            currentUser.setAvatar(bf.getFileUrl(getApplicationContext()));
            loader.displayImage(bf.getFileUrl(getApplicationContext()), iv_photo, option_pic);
        }

        @Override
        public void onFailure(int arg0, String arg1) {
            T.show(context, "上传失败");
        }
    });
}
 
Example 8
Source Project: Conquer   Source File: TaskUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 上传一个文件
 *
 * @param context
 * @param f
 * @param upLoadListener
 */
public static void upLoadFile(final Context context, File f, final UpLoadListener upLoadListener) {
    final BmobFile bf = new BmobFile(f);
    bf.uploadblock(context, new UploadFileListener() {
        @Override
        public void onSuccess() {
            L.d("上传文件成功" + bf.getFileUrl(context));
            upLoadListener.onSuccess(bf.getFileUrl(context));
        }

        @Override
        public void onFailure(int arg0, String arg1) {
            L.d("上传文件失败" + arg0 + arg1);
            upLoadListener.onFailure(arg0, arg1);
        }
    });
}
 
Example 9
Source Project: Swface   Source File: RegisterFaceActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void updateImageFile(File imageFile, final UserHasSigned userHasSigned, final DatabaseAdapter db) {
	final BmobFile file = new BmobFile(imageFile);
	file.uploadblock(new UploadFileListener() {
		@Override
		public void done(BmobException e) {
			if (e == null) {
				Log.i(TAG, "file.uploadblock:success ");
				userHasSigned.setFace_url1(file.getFileUrl());
				Log.i(TAG, "file.uploadblock:if ");
				dialog.setMessage("上传图片成功!");
				dialog.show();
				new Thread(new Runnable() {
					@Override
					public void run() {
						BmobDataHelper bmobDataHelper = new BmobDataHelper(RegisterFaceActivity.this, myhandler);
						bmobDataHelper.addUserHasSign(userHasSigned);
					}
				}).start();
			} else {
				Log.e(TAG, "file.uploadblock:failed ", e);
				Message message = new Message();
				message.arg1 = FinalUtil.DETECT_FAILED_IO_EXCEPTION;
				myhandler.sendMessage(message);
			}
		}

		@Override
		public void onProgress(Integer value) {
			super.onProgress(value);
			Log.i(TAG, "onProgress: " + value);
			fileUploadProgress = value;
		}
	});

}
 
Example 10
Source Project: Mobike   Source File: BikeDamageReportActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void toQuery() {
    mBtQuery.setClickable(false);
    if (mTvCarnub.getText().toString()=="扫描二维码或者手动输入") {
        ToastUtils.show(BikeDamageReportActivity.this, "请输入单车编号");
        return;
    }
    if (TextUtils.isEmpty(mEtBikeDamage.getText().toString())) {
        ToastUtils.show(BikeDamageReportActivity.this, "请输入描述信息");
        return;
    }
    mDialog.show();
    bmobFile.upload(new UploadFileListener() {
        @Override
        public void done(BmobException e) {
            if (e == null) {
               saveDatial();
            } else {
                Logger.d(e);
                mBtQuery.setClickable(true);
                ToastUtils.show(BikeDamageReportActivity.this, "图片上传失败");
            }
            if (mDialog.isShowing())
                mDialog.dismiss();

        }
    });
}
 
Example 11
Source Project: Mobike   Source File: UserDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void uploadImage(int requestCode, int resultCode, Intent data) {
    Log.d("uploadImage", "uploadImage: " + requestCode);
    if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
        if (data != null && requestCode == REQS_IMAGE_PICKER) {
            ArrayList<ImageItem> images = null;
            images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
            ImageItem imageItem = images.get(0);
            final BmobFile bmobFile = new BmobFile(new File(imageItem.path));
            bmobFile.upload(new UploadFileListener() {
                @Override
                public void done(BmobException e) {
                    if (e == null) {
                        MyUser NMyUser = new MyUser();
                        NMyUser.setPicUser(bmobFile);
                        mMyUser.setPicUser(bmobFile);
                        MyApplication.getInstance().upDataUser(mMyUser, NMyUser);
                        Glide.with(UserDetailActivity.this).load(bmobFile.getUrl()).into(mTvHead.getRigtImageView());
                    } else {
                        ToastUtils.show(UserDetailActivity.this, "上传失败");
                    }
                }
            });

        } else {
            Toast.makeText(this, "没有数据", Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 12
Source Project: Conquer   Source File: MyPhotoActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    L.d(requestCode + "," + resultCode + "," + data);
    if (resultCode == RESULT_OK) {
        List<String> images = data.getStringArrayListExtra(AlbumActivity.INTENT_SELECTED_PICTURE);
        if (images == null || images.size() <= 0) {
            return;
        }
        File f = new File(images.get(0));
        L.e("照片路径:" + f.getAbsolutePath());
        if (f.exists()) {
            final BmobFile bf = new BmobFile(f);
            bf.uploadblock(context, new UploadFileListener() {
                @Override
                public void onSuccess() {
                    list.add(bf.getFileUrl(getApplicationContext()));
                    adapter.notifyDataSetChanged();
                    updateAlbum();
                }
                @Override
                public void onFailure(int arg0, String arg1) {
                    T.show(context, "上传失败");
                }
            });
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}