cn.bmob.v3.datatype.BmobFile Java Examples

The following examples show how to use cn.bmob.v3.datatype.BmobFile. 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 File: TaskUtil.java    From Conquer with 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 #2
Source File: PersonFragment.java    From Pigeon with 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 #3
Source File: AddFaceActivity.java    From Swface with 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 File: UserProfileActivity.java    From stynico with 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 #5
Source File: AlertActivity.java    From Conquer with 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 File: EditMyInfoActivity.java    From Conquer with 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 File: UserProfileActivity.java    From styT with 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 #8
Source File: MyPhotoActivity.java    From Conquer with 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 #9
Source File: UpdateUserInfoActivity.java    From Pigeon with 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 #10
Source File: RegisterFaceActivity.java    From Swface with 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 #11
Source File: EditFamilyActivity.java    From Pigeon with 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 #12
Source File: MineFragment.java    From Aurora with 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 #13
Source File: BikeDamageReportActivity.java    From Mobike with 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 #14
Source File: UserDetailActivity.java    From Mobike with 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 #15
Source File: MyUser.java    From Mobike with Apache License 2.0 4 votes vote down vote up
public void setWeixinPic(BmobFile weixinPic) {
    this.weixinPic = weixinPic;
}
 
Example #16
Source File: MyUser.java    From Mobike with Apache License 2.0 4 votes vote down vote up
public BmobFile getPicUser() {
    return picUser;
}
 
Example #17
Source File: MyUser.java    From Mobike with Apache License 2.0 4 votes vote down vote up
public void setPicUser(BmobFile picUser) {
    this.picUser = picUser;
}
 
Example #18
Source File: BikeDamageData.java    From Mobike with Apache License 2.0 4 votes vote down vote up
public BmobFile getCarPic() {
    return carPic;
}
 
Example #19
Source File: UserInfoActivity.java    From Pigeon with MIT License 4 votes vote down vote up
private void initUserInfo(final String objectId) {
    query = new BmobQuery<>();
    query.include("family");
    query.getObject(objectId, new QueryListener<User>() {
        @Override
        public void done(User user, BmobException e) {
            if (e == null) {
                dialog.dismissDialog();

                BmobFile userPhotoFile = user.getUserPhoto();
                String nickString = user.getNick();
                int ageInt = user.getAge();
                String phoneString = user.getMobilePhoneNumber();
                String familyNameString = user.getFamily().getFamilyName();
                int typeInt = user.getType();

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

                if (!TextUtils.isEmpty(nickString)) {
                    mTvNick.setText("昵         称:" + nickString);
                }

                if (ageInt <= 0) {
                    mTvAge.setText("年         龄:" + "请更新个人信息");
                } else {
                    mTvAge.setText("年         龄:" + ageInt);
                }

                if (!TextUtils.isEmpty(phoneString)) {
                    mTvPhone.setText("手机号码:" + phoneString);
                } else {
                    mTvPhone.setText("手机号码:" + "null");
                }

                if (!TextUtils.isEmpty(familyNameString)) {
                    mTvFamily.setText("家庭信息:" + familyNameString);
                } else {
                    mTvFamily.setText("家庭信息:暂未加入家庭");
                }

                if (typeInt == 0) {
                    mTvType.setText("关         系: 子女");
                } else if (typeInt == 1) {
                    mTvType.setText("关         系: 父母");
                }


            } else {
                dialog.dismissDialog();
                ToastUtils.showToast(UserInfoActivity.this, "" + e.getMessage());
            }
        }
    });
}
 
Example #20
Source File: Family.java    From Pigeon with MIT License 4 votes vote down vote up
public BmobFile getFamilyIcon() {
    return familyIcon;
}
 
Example #21
Source File: Family.java    From Pigeon with MIT License 4 votes vote down vote up
public void setFamilyIcon(BmobFile familyIcon) {
    this.familyIcon = familyIcon;
}
 
Example #22
Source File: Tools.java    From Pigeon with MIT License 4 votes vote down vote up
public BmobFile getToolsIcon() {
    return toolsIcon;
}
 
Example #23
Source File: Tools.java    From Pigeon with MIT License 4 votes vote down vote up
public void setToolsIcon(BmobFile toolsIcon) {
    this.toolsIcon = toolsIcon;
}
 
Example #24
Source File: User.java    From Pigeon with MIT License 4 votes vote down vote up
public BmobFile getUserPhoto() {
    return userPhoto;
}
 
Example #25
Source File: User.java    From Pigeon with MIT License 4 votes vote down vote up
public void setUserPhoto(BmobFile userPhoto) {
    this.userPhoto = userPhoto;
}
 
Example #26
Source File: MyUser.java    From stynico with MIT License 4 votes vote down vote up
public void setAuvter(BmobFile auvter)
{
       this.auvter = auvter;
   }
 
Example #27
Source File: User.java    From ToDoList with Apache License 2.0 4 votes vote down vote up
public void setImg(BmobFile img) {
    this.img = img;
}
 
Example #28
Source File: PhontoFiles.java    From styT with Apache License 2.0 4 votes vote down vote up
public List<BmobFile> getPhotos() {
    return photos;
}
 
Example #29
Source File: PhontoFiles.java    From styT with Apache License 2.0 4 votes vote down vote up
public void setPhotos(List<BmobFile> photos) {
    this.photos = photos;
}
 
Example #30
Source File: LookImgAdapter.java    From styT with Apache License 2.0 4 votes vote down vote up
public LookImgAdapter(Context context, List<BmobFile> list) {
    this.mContext = context;
    this.mData = list;
    initViews();
}