コード例 #1
0
  @Override
  protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    setContentView(R.layout.umeng_comm_post_feed_layout);
    setFragmentContainerId(ResFinder.getId("umeng_comm_select_layout"));
    initViews();
    initLocationLayout();
    initPresenter();
    Bundle extraBundle = getIntent().getExtras();
    if (extraBundle == null) {
      return;
    }
    isRepost = extraBundle.getBoolean(Constants.POST_FAILED, false);
    // 设置是否是重新发送
    mPostPresenter.setRepost(isRepost);
    // 从话题详情页面进入到发送新鲜事页面
    Topic mTopic = extraBundle.getParcelable(Constants.TAG_TOPIC);
    if (mTopic != null) {
      mSelecteTopics.add(mTopic);
      if (CommConfig.getConfig().isDisplayTopicOnPostFeedPage()) { // 检查是否在编辑框添加此话题
        mEditText.insertTopics(mSelecteTopics);
      }
      startFadeOutAnimForTopicTipView();
    }
  }
コード例 #2
0
  /**
   * 根据内容创建一条转发的feed</br>
   *
   * @return 一条转发的feed
   */
  @Override
  protected FeedItem prepareFeed() {
    FeedItem newFeed = new FeedItem();

    // 被转发的项
    newFeed.sourceFeed = mForwardedFeeditem;
    newFeed.sourceFeedId = getForwardFeedId();
    String originText = mForwardedFeeditem.text;
    if (!isForwardFeed()) {
      newFeed.sourceFeed.text = "@" + mForwardedFeeditem.creator.name + ": " + originText;
      CommUser friend = mForwardedFeeditem.creator;
      newFeed.sourceFeed.atFriends.add(friend);
    }

    // 转发的内容
    newFeed.text = mEditText.getText().toString().trim();
    // 转发的位置
    newFeed.location = mLocation;
    newFeed.locationAddr = getLocationAddr();
    // 转发@的好友
    newFeed.atFriends.addAll(mSelectFriends);
    // 发表的用户
    newFeed.creator = CommConfig.getConfig().loginedUser;
    // 转发用户的类型,管理员or普通用户
    newFeed.type = newFeed.creator.permisson == Permisson.ADMIN ? 1 : 0;
    return newFeed;
  }
コード例 #3
0
 protected boolean isReportable() {
   CommUser loginedUser = CommConfig.getConfig().loginedUser;
   if (!loginedUser.id.equals(mFeedItem.creator.id)) {
     return true;
   } else {
     return false;
   }
 }
コード例 #4
0
 private boolean isCharsOverflow(String extraText) {
   int extraTextLen = 0;
   if (!TextUtils.isEmpty(extraText)) {
     extraTextLen = extraText.length();
   }
   int len = mEditText.getText().length();
   return len + extraTextLen >= CommConfig.getConfig().mFeedLen;
 }
コード例 #5
0
 @Override
 protected void report() {
   String loginedUid = CommConfig.getConfig().loginedUser.id;
   if (mFeedItem.creator.id.equals(loginedUid)) {
     ToastMsg.showShortMsgByResName("umeng_comm_do_not_spam_yourself_content");
     return;
   }
   mPresenter.showReportConfirmDialog();
 }
コード例 #6
0
 /**
  * 是否可删除该feed。可删除的条件是自己的feed、管理员有删除内容的权限</br>
  *
  * @return
  */
 protected boolean isDeleteable() {
   CommUser loginedUser = CommConfig.getConfig().loginedUser;
   boolean deleteable =
       mFeedItem != null && loginedUser.id.equals(mFeedItem.creator.id); // 自己的feed情况
   boolean hasDeletePermission =
       loginedUser.permisson == Permisson.ADMIN // 管理员删除内容权限
           && loginedUser.subPermissions.contains(SubPermission.DELETE_CONTENT);
   return deleteable || hasDeletePermission;
 }
コード例 #7
0
 private void setUserHeader() {
   if (userHeader == null) return;
   user = CommConfig.getConfig().loginedUser;
   int pos = user.iconUrl.indexOf("@");
   String userIcon = user.iconUrl;
   if (pos > 0) {
     userIcon = user.iconUrl.substring(0, pos);
   }
   userHeader.setImageURI(Uri.parse(userIcon));
 }
コード例 #8
0
 public void setFeedItem(FeedItem feedItem) {
   mFeedItem = feedItem;
   mPresenter.setFeedItem(feedItem);
   // 自己不能举报自己.[注意:考虑来自于推送的情况]
   if (mFeedItem.creator != null
       && CommConfig.getConfig().loginedUser.id.equals(mFeedItem.creator.id)) {
     mReportView.setVisibility(View.GONE);
   } else {
     mReportView.setVisibility(View.VISIBLE);
   }
   changeBackground();
   updateFavoriteBtnState();
 }
コード例 #9
0
 private boolean isHideFollowStatus() {
   if (TextUtils.isEmpty(mUser.id)) {
     return true;
   }
   CommUser loginUser = CommConfig.getConfig().loginedUser;
   if (mUser.id.equals(loginUser.id)) { // 如果是用户自己,则不显示关注/取消关注
     return true;
   }
   // 如果是超级管理员且已经被关注,则显示关注/取消关注
   if (mUser.permisson == Permisson.SUPPER_ADMIN && mUser.isFollowed) {
     return true;
   }
   return false;
 }
コード例 #10
0
  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);
    }
  }
コード例 #11
0
  /** 初始化相关View */
  protected void initViews() {
    // 发送和回退按钮
    findViewById(ResFinder.getId("umeng_comm_post_ok_btn")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_post_back_btn")).setOnClickListener(this);

    mLocProgressBar =
        (ProgressBar) findViewById(ResFinder.getId("umeng_comm_post_loc_progressbar"));

    mLocIcon = (ImageView) findViewById(ResFinder.getId("umeng_comm_post_loc_icon"));
    mLocIcon.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            initLocationLayout();
          }
        });
    mLocationTv = (TextView) findViewById(ResFinder.getId("umeng_comm_location_text"));
    mLocationLayout = findViewById(ResFinder.getId("umeng_community_loc_layout"));

    initEditView();
    // 以下四个按钮分别是选择话题、添加图片、选择位置、@好友
    findViewById(ResFinder.getId("umeng_comm_take_photo_btn")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_select_location_btn")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_at_friend_btn")).setOnClickListener(this);

    mPhotoButton = (ImageButton) findViewById(ResFinder.getId("umeng_comm_add_image_btn"));
    mPhotoButton.setOnClickListener(this);
    mTopicButton = (ToggleButton) findViewById(ResFinder.getId("umeng_comm_pick_topic_btn"));
    mTopicButton.setOnClickListener(this);

    mFragmentLatout = (FrameLayout) findViewById(ResFinder.getId("umeng_comm_select_layout"));
    mGridView = (GridView) findViewById(ResFinder.getId("umeng_comm_prev_images_gv"));
    initSelectedImageAdapter();
    mTopicTipView = (TopicTipView) findViewById(ResFinder.getId("umeng_comm_topic_tip"));
    if (CommConfig.getConfig().loginedUser.gender == Gender.FEMALE) { // 根据性别做不同的提示
      mTopicTipView.setText(ResFinder.getString("umeng_comm_topic_tip_female"));
    }
    if (!isForwardFeed) {
      startAnimationForTopicTipView();
    }
  }
コード例 #12
0
  /** 准备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;
  }
コード例 #13
0
  @Override
  protected void initViewClickListeners() {
    super.initViewClickListeners();
    if (mFeedItem == null || CommConfig.getConfig().loginedUser.id.equals(mFeedItem.creator.id)) {
      mReportView.setVisibility(View.GONE);
    }

    mCopyView.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            copyToClipboard();
            dismiss();
          }
        });

    //        mDeleteView.setOnClickListener(new View.OnClickListener() {
    //
    //            @Override
    //            public void onClick(View v) {
    //                dismiss();
    //                mPresenter.showDeleteConfirmDialog();
    //            }
    //        });
    //        mSaveView.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                dismiss();
    //                mPresenter.favoritesFeed();
    //            }
    //        });

    mDeleteView.setOnClickListener(
        new Listeners.LoginOnViewClickListener() {
          @Override
          protected void onStart(View v) {
            dismiss();
          }

          @Override
          protected void doAfterLogin(View v) {
            dismiss();
            mPresenter.showDeleteConfirmDialog();
          }
        });
    mSaveView.setOnClickListener(
        new Listeners.LoginOnViewClickListener() {
          @Override
          protected void onStart(View v) {
            dismiss();
          }

          @Override
          public void doAfterLogin(View v) {
            dismiss();
            if (mFeedItem.isCollected) {
              mPresenter.cancelFavoritesFeed();
            } else {
              mPresenter.favoritesFeed();
            }
          }
        });

    changeBackground();
  }
コード例 #14
0
  @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();
  }