cn.bmob.v3.exception.BmobException Java Examples

The following examples show how to use cn.bmob.v3.exception.BmobException. 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: UserInfoActivity.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private void showCancelBlackDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(false);
    builder.setMessage("确定要取消对方的黑名单吗?,取消后将可以接受对方发来的消息");
    builder.setPositiveButton("确定", (dialog, which) -> {
        dialog.dismiss();
        showLoadDialog("正在取消黑名单........请稍后");
        UserManager.getInstance().cancelBlack(uid, new CancelBlackCallBlackListener() {
            @Override
            public void onSuccess() {
                isBlack = false;
                black.setText("添加为黑名单");
                dismissLoadDialog();
            }

            @Override
            public void onFailed(BmobException e) {
                LogUtil.e("取消黑名单操作失败");
            }
        });
    });
    builder.setNegativeButton("取消", (dialog, which) -> dialog.cancel());
    builder.show();
}
 
Example #2
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 #3
Source File: WeatherActivity.java    From Pigeon with MIT License 6 votes vote down vote up
private void updateUserLocation(String city) {
    User mCurrentUser = BmobUser.getCurrentUser(User.class);
    if (mCurrentUser != null) {
        // 允许用户使用应用
        User user = new User();
        user.setLocation(city);
        user.update(mCurrentUser.getObjectId(), new UpdateListener() {
            @Override
            public void done(BmobException e) {
                if (e == null) {

                } else {
                    ToastUtils.showToast(WeatherActivity.this, "Error:" + e.getMessage());
                }
            }
        });
    } else {
        //缓存用户对象为空时, 可打开用户注册界面…
        ToastUtils.showToast(WeatherActivity.this, "no cache");
    }

}
 
Example #4
Source File: SkinEngine.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 保存反馈信息到服务器
 *
 * @param msg 反馈信息
 */
private void saveFeedbackMsg(String msg) {
    xp feedback = new xp();
    feedback.setContent(msg);
    feedback.save(new SaveListener<String>() {

        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {

            } else {

            }
        }
    });
}
 
Example #5
Source File: PublishActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void savePulish(String content, PhontoFiles files) {
    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    BILIBILI helps = new BILIBILI();
    helps.setUser(user);
    helps.setContent(content);
    helps.setState(0);
    helps.setLikeNum(1);
    helps.setPhontofile(files);
    helps.save(new SaveListener<String>() {
        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {
                finish();
                mProgressDialog.dismiss();
            } else {
                mProgressDialog.dismiss();
            }
        }
    });
}
 
Example #6
Source File: PublishActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void saveText(String content) {
    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    BILIBILI helps = new BILIBILI();
    helps.setUser(user);
    helps.setContent(content);
    helps.setState(0);
    helps.setLikeNum(1);
    helps.save(new SaveListener<String>() {
        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {
                finish();
                mProgressDialog.dismiss();
                //Log.i("bmob", "保存成功");
            } else {
                mProgressDialog.dismiss();
                //Log.i("bmob", "保存失败:" + e.getMessage());
            }
        }
    });
}
 
Example #7
Source File: PublishActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void xft() {

        BmobQuery<i_a> query = new BmobQuery<>();
        query.getObject("03bf357e85", new QueryListener<i_a>() {

            @Override
            public void done(i_a movie, BmobException e) {
                if (e == null) {
                    String s = movie.getContent();
                    String sr = nico.styTool.Constant.a_mi + "\n" + nico.styTool.Constant.a_miui;
                    if (s.equals(sr)) {

                    } else {
                        nico.styTool.ToastUtil.show(PublishActivity.this, "版本不一致,请更新", Toast.LENGTH_SHORT);
                        finish();
                    }
                } else {
                    finish();
                }
            }
        });
    }
 
Example #8
Source File: HelpsCommentActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 发表评论
 *
 * @param comment
 * @param myUser
 */
private void push(final String comment, final MyUser myUser) {
    Comment comment1 = new Comment();
    comment1.setUser(myUser);
    comment1.setHelps(helps);
    comment1.setComment(comment);
    comment1.save(new SaveListener<String>() {

        @Override
        public void done(String s, BmobException e) {
            if (e == null) {
                if (!myUser.getObjectId().equals(helps.getUser().getObjectId())) {
                    bmobpush(myUser, comment);
                }
                ToastUtil.show(HelpsCommentActivity.this, "评论成功", Toast.LENGTH_SHORT);
                isFirst = false;
                query();
                // Log.e(TAG, "====评论成功====");
            } else {
                ToastUtil.show(HelpsCommentActivity.this, "评论失败,请检查网络连接后重试", Toast.LENGTH_SHORT);
            }
        }
    });
}
 
Example #9
Source File: HelpsCommentActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 使用bmob进行消息推送
 *
 * @param myUser
 */
private void bmobpush(MyUser myUser, String comment) {
    String installationId = helps.getUser().getObjectId();
    BmobPushManager bmobPushManager = new BmobPushManager();
    BmobQuery<MyUserInstallation> query = new BmobQuery<MyUserInstallation>();
    query.addWhereEqualTo("uid", installationId);
    bmobPushManager.setQuery(query);
    bmobPushManager.pushMessage(myUser.getUsername() + "评论了你");

    NotifyMsg notifyMsg = new NotifyMsg();
    notifyMsg.setHelps(helps);
    notifyMsg.setUser(helps.getUser());
    notifyMsg.setAuthor(myUser);
    notifyMsg.setStatus(false);
    notifyMsg.setMessage(comment);
    notifyMsg.save(new SaveListener<String>() {
        @Override
        public void done(String s, BmobException e) {

        }
    });
}
 
Example #10
Source File: SampleAdapter.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindItemViewHolder(ItemViewHolder holder, final int headerPosition, final int itemPosition) {
    final Comment weibo = weibos.get(itemPosition);

    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    BmobQuery<Comment> query = new BmobQuery<>();
    //query.addWhereEqualTo("author", user);    // 查询当前用户的所有微博
    query.order("-updatedAt");
    query.include("author");// 希望在查询微博信息的同时也把发布人的信息查询出来,可以使用include方法
    query.setLimit(4);
    query.findObjects(new FindListener<Comment>() {

        @Override
        public void done(List<Comment> object, BmobException e) {
            if (e == null) {
                weibos = object;
                adapter.notifyDataSetChanged();
            } else {

            }
        }

    });
    //adapter = new MyAdapter(getActivity());
    holder.listView.setAdapter(adapter);
}
 
Example #11
Source File: Compat3.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 查询微博
 */
private void findWeibos() {
    BmobQuery<Post_> query = new BmobQuery<Post_>();
    query.order("-updatedAt");
    query.include("author");// 希望在查询微博信息的同时也把发布人的信息查询出来,可以使用include方法
    query.findObjects(new FindListener<Post_>() {
        @Override
        public void done(List<Post_> object, BmobException e) {
            if (e == null) {
                weibos = object;
                adapter.notifyDataSetChanged();
            } else {
                //loge(e);
            }
        }

    });

}
 
Example #12
Source File: Main4Activity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void xft() {

        BmobQuery<i_a> query = new BmobQuery<>();
        query.getObject("03bf357e85", new QueryListener<i_a>() {

            @Override
            public void done(i_a movie, BmobException e) {
                if (e == null) {
                    String s = movie.getContent();
                    String sr = nico.styTool.Constant.a_mi + "\n" + nico.styTool.Constant.a_miui;
                    if (s.equals(sr)) {

                    } else {
                        nico.styTool.ToastUtil.show(Main4Activity.this, "版本不一致,请更新", Toast.LENGTH_SHORT);
                        finish();
                    }
                } else {

                }
            }
        });
    }
 
Example #13
Source File: FeedbackPresenter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void sendFeedback(final String content, final String contact) {

    if(TextUtils.isEmpty(content)){
        ToastUtils.showShort("请至少填写反馈内容");
        return;
    }
    if(content.equals(mLastContent) && contact.equals(mLastContact)){
        ToastUtils.showShort("请不要重复提交");
        return;
    }

    Feedback feedback=getFeedback(content,contact);
    mView.showLoading();
    feedback.save(new SaveListener<String>() {
        @Override
        public void done(String s, BmobException e) {
           sendBack(e,content,contact);
        }
    });
}
 
Example #14
Source File: Main4Activity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void saveFeedbackMsg(String msg) {
    TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
    String imei = "" + telephonyManager.getDeviceId();
    //String last6chars = imei.remove(0,imei.length-6);
    int n = 4;
    final String b = imei.substring(imei.length() - n, imei.length());
    //final int count = Integer.parseInt(b) + 36;
    xp feedback = new xp();
    feedback.setContent(b + "; " + msg);
    feedback.save(new SaveListener<String>() {
        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {

            } else {
            }
        }
    });
}
 
Example #15
Source File: CommentListActivity_.java    From styT with Apache License 2.0 6 votes vote down vote up
private void findComments() {
    BmobQuery<Comment_> query = new BmobQuery<Comment_>();
    // pointer类型
    query.addWhereEqualTo("post", new BmobPointer(weibo));
    query.include("user,post.author");
    query.findObjects(new FindListener<Comment_>() {

        @Override
        public void done(List<Comment_> object, BmobException e) {
            if (e == null) {
                comments = object;
                adapter.notifyDataSetChanged();
                et_content.setText("");
            } else {
                //loge(e);
            }
        }

    });

}
 
Example #16
Source File: ManagerApplication.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Bmob.initialize(this, "06cefecaee1c01cac71cb2f7de18dc9c");
    BmobInstallationManager.getInstance().initialize(new InstallationListener<BmobInstallation>() {
        @Override
        public void done(BmobInstallation bmobInstallation, BmobException e) {
            if (e == null) {
                CommonLogger.e("初始化成功");
            }else {
                CommonLogger.e("初始化失败"+e.toString());
            }
        }
    });
    BmobPush.startWork(this);
}
 
Example #17
Source File: NewFriendAdapter.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
protected void convert(BaseWrappedViewHolder holder, ChatMessageEntity data, boolean isSwipeItem) {
        UserManager.getInstance().findUserById(data.getBelongId(), new FindListener<User>() {
                @Override
                public void done(List<User> list, BmobException e) {
                        if (list != null && list.size() > 0) {
                                holder.setImageUrl(R.id.iv_new_friend_item_avatar, list.get(0).getAvatar())
                                        .setText(R.id.tv_new_friend_item_name, list.get(0).getName());
                        }
                }
        });
        if (data.getReadStatus()==ConstantUtil.READ_STATUS_READED) {
                holder.setVisible(R.id.tv_new_friend_item_agree, true);
                holder.setVisible(R.id.btn_new_friend_item_agree, false);
        } else if (data.getReadStatus()==ConstantUtil.READ_STATUS_READED) {
                holder.setVisible(R.id.btn_new_friend_item_agree, false);
                holder.setVisible(R.id.tv_new_friend_item_agree, true);
        }
        holder.setOnItemChildClickListener(R.id.btn_new_friend_item_agree);
}
 
Example #18
Source File: ChatNotificationManager.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private void realSendGroupMessageNotification(String name, GroupChatMessage groupChatMessage, Context context) {
    UserManager.getInstance().findUserById(groupChatMessage.getBelongId(), new FindListener<User>() {
        @Override
        public void done(List<User> list, BmobException e) {
            if (list != null && list.size() > 0) {
                if (groupChatMessage.getContentType().equals(ConstantUtil.TAG_MSG_TYPE_IMAGE)) {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":[图片]", HomeActivity.class);
                } else if (groupChatMessage.getContentType().equals(ConstantUtil.TAG_MSG_TYPE_LOCATION)) {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":[位置]", HomeActivity.class);
                } else if (groupChatMessage.getContentType().equals(ConstantUtil.TAG_MSG_TYPE_VOICE)) {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":[语音]", HomeActivity.class);
                } else {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":" + FaceTextUtil.toSpannableString(context, groupChatMessage.getContent()), HomeActivity.class);
                }
            }
        }
    });
}
 
Example #19
Source File: MsgManager.java    From TestChat with Apache License 2.0 6 votes vote down vote up
/**
 * 推送消息
 *
 * @param installId 对方用户设备ID
 * @param message   可推送的消息  JSONObject
 * @param listener  回调
 */
private void sendJsonMessage(String installId, final JSONObject message, final OnSendPushMessageListener listener) {
        sendJsonMessage(installId, message, new PushListener() {
                        @Override
                        public void onSuccess() {
                                LogUtil.e("推送消息成功");
                                listener.onSuccess();
                        }

                        @Override
                        public void onFailure(int i, String s) {
                                LogUtil.e("推送消息失败" + s + i);
                                listener.onFailed(new BmobException(s));
                        }
                }
        );
}
 
Example #20
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
public void updateCommentReadStatus(List<CommentNotifyBean> result) {
    for (CommentNotifyBean bean :
            result) {
        bean.setReadStatus(ConstantUtil.READ_STATUS_READED);
    }
    List<BmobObject> bmobObjectList = new ArrayList<>(result);
    new BmobBatch().updateBatch(bmobObjectList).doBatch(new QueryListListener<BatchResult>() {
        @Override
        public void done(List<BatchResult> list, BmobException e) {
            if (e == null) {
                CommonLogger.e("批量更新评论已读成功");
            } else {
                CommonLogger.e("批量更新评论已读失败" + e.toString());
            }
        }
    });
}
 
Example #21
Source File: HistoryModel.java    From Aurora with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<List<VideoDaoEntity>> getListFromNet(int start, String userid) {
    return Observable.create((ObservableOnSubscribe<List<VideoDaoEntity>>) emitter -> {

        BmobQuery<VideoDaoEntity> query = new BmobQuery<VideoDaoEntity>();
        query.addWhereEqualTo("userId", userid);
        query.setLimit(10);
        query.order("-updatedAt");
        query.setSkip(start);
        query.findObjects(new FindListener<VideoDaoEntity>() {
            @Override
            public void done(List<VideoDaoEntity> list, BmobException e) {
                List<VideoDaoEntity> infolist = new ArrayList<VideoDaoEntity>();
                if (!StringUtils.isEmpty(list)) {
                    for (VideoDaoEntity entity1 : list) {
                        entity1.setVideo(mGson.fromJson(entity1.getBody(), VideoListInfo.Video.VideoData.class));
                        infolist.add(entity1);
                    }
                }
                emitter.onNext(infolist);
            }
        });
    });
}
 
Example #22
Source File: BikeDamageReportActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void saveDatial() {
    mData.setMyUser(mMyUser);
    mData.setCarNub(mTvCarnub.getText().toString());
    mData.setDesc(mEtBikeDamage.getText().toString());
    mData.setCarPic(bmobFile);
    mData.setType(mAdapter.getType());
    mData.save(new SaveListener<String>() {
        @Override
        public void done(String s, BmobException e) {
            if (e == null) {
                ToastUtils.show(BikeDamageReportActivity.this, "提交成功");
                finish();
            } else {

                Logger.d(e);
                ToastUtils.show(BikeDamageReportActivity.this, "提交失败");
            }
            mBtQuery.setClickable(true);
            if (mDialog.isShowing())
                mDialog.dismiss();
        }
    });
}
 
Example #23
Source File: MsgManager.java    From TestChat with Apache License 2.0 6 votes vote down vote up
/**
         * 发送文件消息
         *
         * @param isPerson         是否是单聊
         * @param uid              目标ID
         * @param localFilePath    图片的本地路径  或者是语音的本地路径&长度  或者是地址内容:格式为:  显示图片的本地路径&纬度&经度&地址
         * @param sendFileListener 回调
         */
        private void sendFileMessage(boolean isPerson, final String uid, final String localFilePath, Integer messageType, final SendFileListener sendFileListener) {
//                明天这里开始
                BaseMessage message = createFileMessage(isPerson, uid, localFilePath, messageType);
                String localPath = null;
                if (messageType.equals(Constant.TAG_MSG_TYPE_IMAGE)) {
                        localPath = localFilePath;
                } else if (messageType.equals(Constant.TAG_MSG_TYPE_VOICE)) {
                        localPath = localFilePath.split("&")[0];
                } else if (messageType.equals(Constant.TAG_MSG_TYPE_LOCATION)) {
                        localPath = localFilePath.split(",")[0];
                }
                message.setSendStatus(Constant.SEND_STATUS_START);
                sendFileListener.onStart(message);
                if (!CommonUtils.isNetWorkAvailable(CustomApplication.getInstance())) {
//                        如果没有网络
                        message.setSendStatus(Constant.SEND_STATUS_FAILED);
                        saveAndUploadSendMessage(false, message);
                        sendFileListener.onFailed(new BmobException("没有网络,请检查网络配置"));
                        return;
                }
                realSendFileMessage(false, message, localPath, sendFileListener);
        }
 
Example #24
Source File: PhoneLoginPresenter.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
public void getVerifyCode(String phone) {
    BmobSMS.requestSMSCode(phone, "login", new QueryListener<Integer>() {
        @Override
        public void done(Integer smsId, BmobException ex) {
            BaseBean baseBean = new BaseBean();
            baseBean.setType(ConstantUtil.BASE_TYPE_SEND_VERIFY_CODE);
            if (ex == null) {//验证码发送成功
                baseBean.setCode(200);
                baseBean.setData(smsId);
                CommonLogger.e("smile", "短信id:" + smsId);
            } else {
                baseBean.setCode(0);
                baseBean.setDesc(ex.getMessage());
            }
            iView.updateData(baseBean);
        }
    });

}
 
Example #25
Source File: MyCouponsActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void requesData() {
    mDialog.show();
    if (mQuery == null) {
        mQuery = new BmobQuery<>("MyCouponsData");
        mQuery.setLimit(10);
        mQuery.addWhereEqualTo("mMyUser", MyApplication.getInstance().getUser().getObjectId());
        mQuery.order("-updatedAt");
    }
    mQuery.findObjects(new FindListener<MyCouponsData>() {
        @Override
        public void done(List<MyCouponsData> list, BmobException e) {
            if (e == null) {
                mData = list;
                showCoupons();
            } else {
                ToastUtils.show(MyCouponsActivity.this, "暂时没有优惠信息");
                Logger.d(e);
            }
            dismissMyDialog();
        }
    });
}
 
Example #26
Source File: WallPaperActivity.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private void initActionBar() {
    ToolBarOption toolBarOption = new ToolBarOption();
    toolBarOption.setRightText("完成");
    toolBarOption.setTitle("选择背景图片");
    toolBarOption.setAvatar(UserManager.getInstance().getCurrentUser().getAvatar());
    toolBarOption.setNeedNavigation(true);
    toolBarOption.setRightListener(v -> {
        if (selectedImage != null && !selectedImage.equals(UserManager.getInstance().getCurrentUser()
                .getTitleWallPaper())) {
            UserManager.getInstance().updateUserInfo(from, selectedImage, new UpdateListener() {
                @Override
                public void done(BmobException e) {
                    if (e == null) {
                        RxBusManager.getInstance().post(UserManager.getInstance().cover(UserManager.getInstance().getCurrentUser()));
                    } else {
                        LogUtil.e("上传背景图片到服务器上失败" + e.toString());
                    }
                    finish();
                }
            });
        }

    });
    setToolBar(toolBarOption);
}
 
Example #27
Source File: GroupInfoPresenter.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
public void exitGroup(String groupId,String uid) {
    iView.showLoading("正在退群中 。。。。。。。。。");
    MsgManager.getInstance().exitGroup(groupId,uid,new UpdateListener() {
        @Override
        public void done(BmobException e) {
            iView.hideLoading();
            if (e == null) {
                ToastUtils.showShortToast("退群成功");
                RxBusManager
                        .getInstance()
                        .post(new GroupTableEvent(groupId,GroupTableEvent.TYPE_GROUP_NUMBER
                        ,GroupTableEvent.ACTION_DELETE,uid));
                iView.updateData(groupId);
            }else {
                ToastUtils.showShortToast("退群失败");
            }
        }
    });
    iView.showLoading("正在退群中..........");

}
 
Example #28
Source File: DepositRefundIssueActivity.java    From Mobike with 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 #29
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public void getAllDefaultTitleWallPaperFromServer(final FindListener<String> findListener) {
    BmobQuery bmobQuery = new BmobQuery("sys_data");
    bmobQuery.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);
    bmobQuery.findObjectsByTable(new QueryListener<JSONArray>() {
        @Override
        public void done(JSONArray jsonArray, BmobException e) {
            if (e == null) {
                List<String> avatarList = null;
                if (jsonArray != null && jsonArray.length() > 0) {
                    LogUtil.e(jsonArray.toString());
                    avatarList = new ArrayList<>();
                    for (int i = 0; i < jsonArray.length(); i++) {
                        try {


                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            JSONObject avatarJson = jsonObject.getJSONObject("twallpaper");
                            String avatar = avatarJson.getString("url");
                            if (avatar != null) {
                                avatarList.add(avatar);
                            }
                        } catch (JSONException item) {
                            item.printStackTrace();
                        }
                    }
                }
                if (avatarList == null) {
                    LogUtil.e("服务器上面没有背景数据");
                }
                findListener.done(avatarList, null);
            } else {
                findListener.done(null, e);
            }
        }

    });
}
 
Example #30
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;
		}
	});

}