/** 清除状态</br> */ @Override public void clearState() { mEditText.setText(""); mEditText.mAtMap.clear(); mEditText.mTopicMap.clear(); mImageSelectedAdapter.getDataSource().clear(); mTopicButton.setChecked(false); // mPhotoButton.setChecked(false); }
private void onPickedImages(int requestCode, Intent data) { if (requestCode == Constants.PICK_IMAGE_REQ_CODE) { // selected image if (data != null && data.getExtras() != null) { mImageSelectedAdapter.getDataSource().clear(); // 获取选中的图片 List<String> selectedList = ImagePickerManager.getInstance().getCurrentSDK().parsePickedImageList(data); updateImageList(selectedList); } } }
@Override public void restoreFeedItem(FeedItem feedItem) { mEditText.setText(feedItem.text); mLocationTv.setText(feedItem.locationAddr); mImageSelectedAdapter.getDataSource().clear(); int count = feedItem.imageUrls.size(); for (int i = 0; i < count; i++) { // 图片 mImageSelectedAdapter.getDataSource().add(feedItem.imageUrls.get(i).originImageUrl); } // 图片 if (mImageSelectedAdapter.getDataSource().size() < 9) { mImageSelectedAdapter.getDataSource().add(0, Constants.ADD_IMAGE_PATH_SAMPLE); } mImageSelectedAdapter.notifyDataSetChanged(); // 好友 mSelectFriends.addAll(feedItem.atFriends); // 话题 mSelecteTopics.addAll(feedItem.topics); FeedViewRender.parseTopicsAndFriends(mEditText, feedItem); // 设置光标位置 mEditText.setSelection(mEditText.getText().length()); }
/** 准备feed数据</br> */ protected FeedItem prepareFeed() { FeedItem mNewFeed = new FeedItem(); mNewFeed.text = mEditText.getText().toString().trim(); mNewFeed.locationAddr = getLocationAddr(); mNewFeed.location = mLocation; // 移除添加图标 mImageSelectedAdapter.getDataSource().remove(Constants.ADD_IMAGE_PATH_SAMPLE); for (String url : mImageSelectedAdapter.getDataSource()) { // 图片地址 mNewFeed.imageUrls.add(new ImageItem("", "", url)); } // 话题 mNewFeed.topics.addAll(mSelecteTopics); // @好友 mNewFeed.atFriends.addAll(mSelectFriends); // 发表的用户 mNewFeed.creator = CommConfig.getConfig().loginedUser; mNewFeed.type = mNewFeed.creator.permisson == Permisson.ADMIN ? 1 : 0; Log.d(TAG, " @@@ my new Feed = " + mNewFeed); return mNewFeed; }
/** * Add the picture to the photo gallery. Must be called on all camera images or they will * disappear once taken. */ protected void onTakedPhoto(int requestCode) { if (requestCode != TakePhotoPresenter.REQUEST_IMAGE_CAPTURE) { return; } String imgUri = mTakePhotoPresenter.updateImageToMediaLibrary(); List<String> selectedList = mImageSelectedAdapter.getDataSource(); // 更新媒体库 selectedList.remove(Constants.ADD_IMAGE_PATH_SAMPLE); if (selectedList.size() < 9) { selectedList.add(imgUri); appendAddImageIfLessThanNine(selectedList); } else { ToastMsg.showShortMsgByResName("umeng_comm_image_overflow"); } mImageSelectedAdapter.notifyDataSetChanged(); }
/** * 已选择图片显示的Adapter * * @param listener 删除某张图片的回调 */ private void initSelectedImageAdapter() { mImageSelectedAdapter = new ImageSelectedAdapter(PostFeedActivity.this); mImageSelectedAdapter.getDataSource().add(0, Constants.ADD_IMAGE_PATH_SAMPLE); // 设置选择item时得背景为透明 mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); mGridView.setAdapter(mImageSelectedAdapter); mGridView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String clickImageUrl = mImageSelectedAdapter.getItem(position); boolean isAddImage = Constants.ADD_IMAGE_PATH_SAMPLE.equals(clickImageUrl); if (isAddImage) { // 如果触发的是添加图片事件,则显示选择图片的Fragment pickImages(); } } }); }
private void pickImages() { ImagePickerManager.getInstance() .getCurrentSDK() .jumpToPickImagesPage(this, (ArrayList<String>) mImageSelectedAdapter.getDataSource()); }