Java Code Examples for cn.bmob.v3.datatype.BmobFile

The following examples show how to use cn.bmob.v3.datatype.BmobFile. 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: Pigeon   Source File: PersonFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void initData() {
    mCurrentUser = BmobUser.getCurrentUser(User.class);
    BmobFile userPhotoFile = mCurrentUser.getUserPhoto();
    String nick = mCurrentUser.getNick();
    String objectId = mCurrentUser.getObjectId();


    if (!TextUtils.isEmpty(nick)) {
        mTvName.setText(nick);
    }

    if (!TextUtils.isEmpty(objectId)) {
        mTvID.setText("飞鸽号:" + objectId);
    }

    if (userPhotoFile == null) {
        mCivUserPhoto.setImageResource(R.drawable.ic_default);
    } else {
        Picasso.with(getContext()).load(userPhotoFile.getFileUrl()).into(mCivUserPhoto);
    }

}
 
Example 5
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 6
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 7
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 8
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 9
Source Project: Aurora   Source File: MineFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Subscriber(tag = EventBusTags.SET_USER_INFO)
public void setUserInfo(User user) {
    mTvName.setText(User.getCurrentUser().getUsername());
    if (user.getIcon() != null){
        BmobFile file = user.getIcon();
        appComponent.imageLoader().loadImage(getActivity(), ImageConfigImpl
                .builder()
                .url(file.getFileUrl())
                .imageView(mCivFace)
                .dontAnimate(true)
                .placeholder(R.drawable.ic_noface)
                .errorPic(R.drawable.ic_noface)
                .build());
    }
}
 
Example 10
Source Project: Mobike   Source File: BikeDamageReportActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void uploadImage(int requestCode, int resultCode, Intent data) {
    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);
            Glide.with(BikeDamageReportActivity.this).load(imageItem.path).into(mIvPick);
           // if (bmobFile == null)
            bmobFile = new BmobFile(new File(imageItem.path));
            bmobFile.setUrl(imageItem.path);
        } else {
            Toast.makeText(this, "没有数据", Toast.LENGTH_SHORT).show();
        }
    }
}
 
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: Pigeon   Source File: UpdateUserInfoActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void initData() {

    mCurrentUser = BmobUser.getCurrentUser(User.class);

    if (!TextUtils.isEmpty(mCurrentUser.getNick())) {
        mEdtNick.setText(mCurrentUser.getNick());
    }

    if (mCurrentUser.getAge() == 0) {
        mEdtAge.setText("");
    } else {
        mEdtAge.setText(String.valueOf(mCurrentUser.getAge()));
    }
    mEdtPhone.setText(mCurrentUser.getMobilePhoneNumber());

    typeInt = mCurrentUser.getType();

    if (typeInt == 0) {
        //子女
        mRRChild.setChecked(true);
        mRRParent.setChecked(false);
    } else if (typeInt == 1) {
        //父母
        mRRChild.setChecked(false);
        mRRParent.setChecked(true);
    }

    BmobFile userPhotoFile = mCurrentUser.getUserPhoto();
    if (userPhotoFile != null) {
        Picasso.with(UpdateUserInfoActivity.this).load(userPhotoFile.getFileUrl()).into(mCivPhoto);
    } else {
        mCivPhoto.setImageResource(R.drawable.ic_default);
    }

}
 
Example 13
Source Project: Pigeon   Source File: EditFamilyActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void initData() {
    dialog.showDialog();
    mCurrentUser = BmobUser.getCurrentUser(User.class);
    familyQuery = new BmobQuery<>();
    familyQuery.getObject(mCurrentUser.getFamily().getObjectId(), new QueryListener<Family>() {
        @Override
        public void done(Family family, BmobException e) {
            if (e == null) {
                familyName = family.getFamilyName();
                if (!TextUtils.isEmpty(familyName)) {
                    mEdtFamilyName.setText(familyName);

                    BmobFile familyIconFile = family.getFamilyIcon();

                    if (familyIconFile!=null) {
                        Picasso.with(EditFamilyActivity.this).load(familyIconFile.getFileUrl()).into(mFamilyPhoto);
                    }else {
                        mFamilyPhoto.setImageResource(R.drawable.ic_default);
                    }

                    dialog.dismissDialog();

                } else {
                    dialog.dismissDialog();
                }
            } else {
                dialog.dismissDialog();
                ToastUtils.showToast(EditFamilyActivity.this, "GetFamilyInfo : " + e.getMessage());
            }
        }
    });

}
 
Example 14
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);
}
 
Example 15
Source Project: ToDoList   Source File: User.java    License: Apache License 2.0 4 votes vote down vote up
public BmobFile getImg() {
    return img;
}
 
Example 16
Source Project: ToDoList   Source File: User.java    License: Apache License 2.0 4 votes vote down vote up
public void setImg(BmobFile img) {
    this.img = img;
}
 
Example 17
Source Project: styT   Source File: PhontoFiles.java    License: Apache License 2.0 4 votes vote down vote up
public List<BmobFile> getPhotos() {
    return photos;
}
 
Example 18
Source Project: styT   Source File: PhontoFiles.java    License: Apache License 2.0 4 votes vote down vote up
public void setPhotos(List<BmobFile> photos) {
    this.photos = photos;
}
 
Example 19
Source Project: styT   Source File: LookImgAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public LookImgAdapter(Context context, List<BmobFile> list) {
    this.mContext = context;
    this.mData = list;
    initViews();
}
 
Example 20
Source Project: styT   Source File: GridViewHelpsAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public GridViewHelpsAdapter(Context context, List<BmobFile> list) {
    this.mContext = context;
    this.mDatas = list;
    inflater = LayoutInflater.from(context);
}
 
Example 21
Source Project: styT   Source File: MyUser.java    License: Apache License 2.0 4 votes vote down vote up
public BmobFile getAuvter() {
    return auvter;
}
 
Example 22
Source Project: styT   Source File: MyUser.java    License: Apache License 2.0 4 votes vote down vote up
public void setAuvter(BmobFile auvter) {
    this.auvter = auvter;
}
 
Example 23
Source Project: stynico   Source File: MyUser.java    License: MIT License 4 votes vote down vote up
public BmobFile getAuvter()
{
       return auvter;
   }
 
Example 24
Source Project: stynico   Source File: MyUser.java    License: MIT License 4 votes vote down vote up
public void setAuvter(BmobFile auvter)
{
       this.auvter = auvter;
   }
 
Example 25
Source Project: Aurora   Source File: User.java    License: Apache License 2.0 4 votes vote down vote up
public BmobFile getIcon() {
    return icon;
}
 
Example 26
Source Project: Aurora   Source File: User.java    License: Apache License 2.0 4 votes vote down vote up
public void setIcon(BmobFile icon) {
    this.icon = icon;
}
 
Example 27
Source Project: Mobike   Source File: DepositRefundData.java    License: Apache License 2.0 4 votes vote down vote up
public BmobFile getOrderPic() {
    return orderPic;
}
 
Example 28
Source Project: Mobike   Source File: DepositRefundData.java    License: Apache License 2.0 4 votes vote down vote up
public void setOrderPic(BmobFile orderPic) {
    this.orderPic = orderPic;
}
 
Example 29
Source Project: Mobike   Source File: BikeDamageData.java    License: Apache License 2.0 4 votes vote down vote up
public BmobFile getCarPic() {
    return carPic;
}
 
Example 30
Source Project: Mobike   Source File: BikeDamageData.java    License: Apache License 2.0 4 votes vote down vote up
public void setCarPic(BmobFile carPic) {
    this.carPic = carPic;
}