@Override protected void initViews() { super.initViews(); // 转发时把输入框的大小稍微设置小一些 mEditText.setMinimumHeight(DeviceUtils.dp2px(this, 80)); mEditText.setHint(ResFinder.getString("umeng_comm_write_sth")); // 隐藏选择图片的图标 mGridView.setVisibility(View.GONE); // 隐藏话题,地理位置、图片和拍照的图标 findViewById(ResFinder.getId("umeng_community_loc_layout")).setVisibility(View.GONE); findViewById(ResFinder.getId("umeng_comm_loc_layout")).setVisibility(View.GONE); findViewById(ResFinder.getId("umeng_comm_topic_layout")).setVisibility(View.GONE); findViewById(ResFinder.getId("umeng_comm_take_photo_layout")).setVisibility(View.GONE); findViewById(ResFinder.getId("umeng_comm_pick_photo_layout")).setVisibility(View.GONE); // 设置转发时,图片跟文本layout可见 findViewById(ResFinder.getId("umeng_comm_forward_layout")).setVisibility(View.VISIBLE); // mBottomTabLayout = findViewById(ResFinder.getId("umeng_community_post_tab_bar")); int paddingRight = getResources().getDisplayMetrics().widthPixels - DeviceUtils.dp2px(this, 80); mBottomTabLayout.setPadding( mBottomTabLayout.getPaddingLeft(), mBottomTabLayout.getPaddingTop(), paddingRight, mBottomTabLayout.getPaddingBottom()); // 显示转发文本的TextView mFeedText = (TextView) findViewById(ResFinder.getId("umeng_comm_forward_text")); mFeedIcon = (ImageView) findViewById(ResFinder.getId("umeng_comm_forward_img")); mTopicTipView.setVisibility(View.GONE); // 转发页面不显示提示话题VIew }
/** * </br> * * @return */ private ViewGroup createPointLinearlayout() { LinearLayout pointContainerLayout = new LinearLayout(getContext()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); pointContainerLayout.setLayoutParams(params); pointContainerLayout.setOrientation(LinearLayout.HORIZONTAL); pointContainerLayout.setGravity(Gravity.CENTER); params.gravity = Gravity.CENTER; params.topMargin = DeviceUtils.dp2px(getContext(), 15); params.bottomMargin = DeviceUtils.dp2px(getContext(), 15); return pointContainerLayout; }
private boolean uploadFeedImages(List<ImageItem> imageItems) { if (!DeviceUtils.isNetworkAvailable(mContext)) { return false; } final List<String> imageUrls = getImagePathList(imageItems); if (imageUrls.size() == 0) { return true; } uploadedImageItems = mImageUploader.upload(imageUrls); // 要上传的数量与传递成功的数量是否相同,即所有图片是否全部上传成功 return imageItems.size() == uploadedImageItems.size(); }
public void postNewFeed(final FeedItem feedItem) { if (!DeviceUtils.isNetworkAvailable(mContext)) { ToastMsg.showShortMsgByResName("umeng_comm_not_network"); mActivityView.canNotPostFeed(); return; } if (isTitleTooLong(feedItem)) { ToastMsg.showShortMsgByResName("umeng_comm_title_too_long"); mActivityView.canNotPostFeed(); return; } // if ((!isTextValid(feedItem))&&(feedItem.getImages().size()==0)) { // ToastMsg.showShortMsgByResName("umeng_comm_content_short_tips"); // mActivityView.canNotPostFeed(); // return; // } CommUser loginUser = CommConfig.getConfig().loginedUser; if (!isForwardFeed && loginUser.subPermissions.contains(SubPermission.BULLETIN)) { // 当前用户有公告权限,此时需要确认是否发送为公告 String msg = ResFinder.getString("umeng_comm_bulletin_tips"); DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { executeRealPostFeed(feedItem, true); } }; DialogInterface.OnClickListener cancelListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { executeRealPostFeed(feedItem, false); } }; ConfirmDialog.showDialog(mContext, msg, confirmListener, cancelListener); } else { // 普通feed executeRealPostFeed(feedItem, false); } }
/** 初始化EditView并设置回调</br> */ private void initEditView() { mEditText = (FeedEditText) findViewById(ResFinder.getId("umeng_comm_post_msg_edittext")); mEditText.setFocusableInTouchMode(true); mEditText.requestFocus(); mEditText.setMinimumHeight(DeviceUtils.dp2px(this, 150)); mEditText.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mEditText.mCursorIndex = mEditText.getSelectionStart(); mFragmentLatout.setVisibility(View.GONE); mTopicButton.setChecked(false); } }); mEditText.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (count == 1) { String newChar = s.subSequence(start, start + count).toString(); // 转发时不显示话题 if (CHAR_WELL.equals(newChar) && !isForwardFeed) { showTopicFragment(); } else if (CHAR_AT.equals(newChar)) { showAtFriendsDialog(); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void afterTextChanged(Editable s) {} }); }
/** * 转发feed * * @param feedItem 发布的新feed * @param forwardFeedItem 被转发的feed */ public void forwardFeed(FeedItem feedItem, final FeedItem forwardFeedItem) { if (!DeviceUtils.isNetworkAvailable(mContext)) { ToastMsg.showShortMsgByResName("umeng_comm_not_network"); return; } mActivityView.startPostFeed(); feedItem.type = 0; // 转发的Feed都不能mark为公告,避免数据同步的影响 mCommunitySDK.forward( feedItem, new SimpleFetchListener<FeedItemResponse>() { @Override public void onComplete(FeedItemResponse response) { if (NetworkUtils.handleResponseComm(response)) { Log.w("", "forward error . code = " + response.errCode); return; } // 被转发的原始feed被删除 if (response.errCode == ErrorCode.ORIGIN_FEED_DELETE_ERR_CODE || response.errCode == ErrorCode.ERR_CODE_FEED_UNAVAILABLE) { ToastMsg.showShortMsgByResName("umeng_comm_origin_feed_delete"); return; } FeedItem feedItem = response.result; // 原始feed不是当前被转发的feed,也就是被转发的feed也是转发feed类型的情况 if (!feedItem.sourceFeedId.equals(feedItem.sourceFeed.id)) { // 原始feed 转发数量加1 BroadcastUtils.sendFeedUpdateBroadcast(mContext, feedItem.sourceFeed); // 被转发的feed数量加1 BroadcastUtils.sendFeedUpdateBroadcast(mContext, forwardFeedItem); } postFeedResponse(response, feedItem); } }); }
private void computeBoardHeight() { BOARD_HEIGHT = DeviceUtils.dp2px(getContext(), 140); }
@SuppressWarnings("deprecation") private void initUIComponents() { // 设置Fragment addFragment(ResFinder.getId("umeng_comm_user_info_fragment_container"), mPostedFragment); // 选中的某个tab时的文字颜色 mSelectedColor = ResFinder.getColor("umeng_comm_text_topic_light_color"); // 初始化feed、好友、粉丝、back、设置的listener findViewById(ResFinder.getId("umeng_comm_posted_layout")).setOnClickListener(this); findViewById(ResFinder.getId("umeng_comm_follow_user_layout")).setOnClickListener(this); findViewById(ResFinder.getId("umeng_comm_my_fans_layout")).setOnClickListener(this); findViewById(ResFinder.getId("umeng_comm_setting_back")).setOnClickListener(this); // 举报用户的Dialog mReportDialog = new UserReportDialog(this); mReportDialog.setTargetUid(mUser.id); Button settingButton = (Button) findViewById(ResFinder.getId("umeng_comm_save_bt")); settingButton.setBackgroundDrawable(ResFinder.getDrawable("umeng_comm_more")); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) settingButton.getLayoutParams(); params.width = DeviceUtils.dp2px(this, 20); params.height = DeviceUtils.dp2px(this, 20); params.rightMargin = DeviceUtils.dp2px(getApplicationContext(), 10); settingButton.setLayoutParams(params); settingButton.setOnClickListener( new LoginOnViewClickListener() { @Override protected void doAfterLogin(View v) { mReportDialog.show(); } }); // 如果是用户自己,则不显示设置菜单按钮【目前菜单只有举报功能,即自己不能举报自己】 if (mUser.id.equals(CommConfig.getConfig().loginedUser.id) || mUser.permisson == Permisson.SUPPER_ADMIN) { settingButton.setVisibility(View.GONE); } TextView titleTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_setting_title")); titleTextView.setText(ResFinder.getString("umeng_comm_user_center")); // mPostedTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_posted_msg_tv")); mPostedTv.setTextColor(mSelectedColor); // mPostedCountTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_posted_count_tv")); mPostedCountTv.setTextColor(mSelectedColor); mFollowedUserTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_followed_user_tv")); mFollowedUserCountTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_follow_user_count_tv")); mFansTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_my_fans_tv")); mFansCountTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_fans_count_tv")); // 昵称 mUserNameTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_name_tv")); mUserNameTv.setText(mUser.name); mHeaderImageView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_header")); ImgDisplayOption option = ImgDisplayOption.getOptionByGender(mUser.gender); mHeaderImageView.setImageUrl(mUser.iconUrl, option); // 用户性别 mGenderImageView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_gender")); // 关注按钮 mFollowToggleButton = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_follow")); mFollowToggleButton.setOnClickListener( new Listeners.LoginOnViewClickListener() { @Override protected void doAfterLogin(View v) { mFollowToggleButton.setClickable(false); // true为选中状态为已关注,此时显示文本为“取消关注”;false代表未关注,此时显示文本为“关注” if (mFollowToggleButton.isChecked()) { mPresenter.followUser(mResultListener); } else { mPresenter.cancelFollowUser(mResultListener); } } }); mAlbumTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_albums_tv")); mAlbumTextView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { jumpToActivityWithUid(AlbumActivity.class); } }); mTopicTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_topic_tv")); mTopicTextView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { jumpToActivityWithUid(FollowedTopicActivity.class); } }); // 用户自己(在未登录的情况下,点击设置跳转到登录,此时传递进来的uid是空的情况),隐藏关注按钮,显示设置按钮 // // 如果是超级管理员且已经关注,则隐藏取消关注按钮 if (isHideFollowStatus()) { mFollowToggleButton.setVisibility(View.GONE); } initCommentView(); }