@Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   ListView listView = (ListView) getRefreshView();
   position -= listView.getHeaderViewsCount();
   if (position >= 0 && position < getAdapterCount())
     BizFragment.getBizFragment(this).replyComment(null, getAdapterItems().get(position));
 }
示例#2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (drawerToggle != null && drawerToggle.onOptionsItemSelected(item)) return true;

    if (android.R.id.home == item.getItemId()) {
      if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) mDrawerLayout.closeDrawers();
      else mDrawerLayout.openDrawer(GravityCompat.START);

      return true;
    }

    // 关于
    //        if (item.getItemId() == R.id.about)
    //            AboutWebFragment.launchAbout(this);
    // 意见反馈
    //        else if (item.getItemId() == R.id.feedback)
    //            PublishActivity.publishFeedback(this);
    // 退出
    if (item.getItemId() == R.id.exitapp) {
      finish();

      MobclickAgent.onEvent(this, "exitapp");
    }
    // 新微博
    else if (item.getItemId() == R.id.publish) PublishActivity.publishStatus(this, null);
    // 开始离线
    else if (item.getItemId() == R.id.toggle_offline) {
      OfflineUtils.toggleOffline(this);

      MobclickAgent.onEvent(this, "toggle_offline");
    }
    // 停止离线
    else if (item.getItemId() == R.id.stop_offline) {
      OfflineService.stopOffline();

      MobclickAgent.onEvent(this, "stop_offline");
    }
    // 通知设置
    else if (item.getItemId() == R.id.notification_settings)
      NotificationSettingsFragment.launch(this);
    // 搜索
    else if (item.getItemId() == R.id.search) {
      new IAction(
          MainActivity.this,
          new WebLoginAction(MainActivity.this, BizFragment.createBizFragment(this))) {

        @Override
        public void doAction() {
          SearchFragment.launch(MainActivity.this, "");

          MobclickAgent.onEvent(MainActivity.this, "toggle_search");
        }
      }.run();
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // @Ta
    if (item.getItemId() == R.id.mention) {
      BizFragment.getBizFragment(this).mentionUser(getActivity(), mUser);
    }
    // 关注
    else if (item.getItemId() == R.id.create) {
      BizFragment.getBizFragment(this).createFriendship(mUser, this);
    }
    // 取消关注
    else if (item.getItemId() == R.id.destory) {
      BizFragment.getBizFragment(this).destoryFriendship(mUser, this);
    }
    // 移除粉丝
    else if (item.getItemId() == R.id.followDestory) {
      BizFragment.getBizFragment(this).destoryFollower(mUser, this);
    }

    return super.onOptionsItemSelected(item);
  }
示例#4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ui_main);

    CacheClearFragment.clearCompress();

    BizFragment bizFragment = BizFragment.createBizFragment(this);
    bizFragment.createFabAnimator(fabBtn);
    fabBtn.setOnLongClickListener(
        new View.OnLongClickListener() {

          @Override
          public boolean onLongClick(View v) {
            // 触发一次刷新
            ((AsToolbar) getToolbar()).performDoublcClick();
            appBarLayout.setExpanded(true);

            return true;
          }
        });
    bizFragment.getFabAnimator().setDuration(200);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    setupDrawer(savedInstanceState);
    setupMenu(savedInstanceState);
    setupFab(savedInstanceState);
    setupAppBarLayout(savedInstanceState);

    if (savedInstanceState != null) {
      toolbarTitle = savedInstanceState.getString("toolbarTitle");
      if (!TextUtils.isEmpty(toolbarTitle)) getSupportActionBar().setTitle(toolbarTitle);
    }

    mInstance = this;

    OtherItemFragment.checkPhotoPermission(this, true);
  }
    @Override
    protected void onSuccess(StatusComments result) {
      super.onSuccess(result);

      if (result == null) return;

      if (AppContext.getUnreadCount() != null && AppContext.getUnreadCount().getMention_cmt() > 0) {
        requestDataDelay(1000);

        // f**k sina
        AppContext.getUnreadCount().setMention_cmt(0);

        BizFragment.getBizFragment(MentionCommentsFragment.this)
            .remindSetCount(RemindType.mention_cmt);
      }
    }
  private void setProfileView() {
    ImageView imgPhoto = (ImageView) viewProfile.findViewById(R.id.imgPhoto);
    BitmapLoader.getInstance()
        .display(
            this, AisenUtil.getUserPhoto(mUser), imgPhoto, ImageConfigUtils.getLargePhotoConfig());

    TextView txtName = (TextView) viewProfile.findViewById(R.id.txtName);
    txtName.setText(mUser.getName());
    // f**k 2014-09-04 当名字过长大于6个字时,截取部分文字
    int maxLength = AisenUtil.getStrLength("当名字过长大于个");
    if (AisenUtil.getStrLength(mUser.getName()) > maxLength) {
      StringBuffer sb = new StringBuffer();
      int index = 0;
      while (AisenUtil.getStrLength(sb.toString()) < maxLength) {
        if (index >= mUser.getName().length()) break;

        sb.append(mUser.getName().charAt(index));
        index++;
      }
      sb.append("...");
      txtName.setText(sb.toString());
    }

    // 性别
    ImageView imgGender = (ImageView) viewProfile.findViewById(R.id.imgGender);
    imgGender.setVisibility(View.VISIBLE);
    if ("m".equals(mUser.getGender())) imgGender.setImageResource(R.drawable.list_male);
    else if ("f".equals(mUser.getGender())) imgGender.setImageResource(R.drawable.list_female);
    else imgGender.setVisibility(View.GONE);

    // 认证
    ImageView imgVerified = (ImageView) viewProfile.findViewById(R.id.imgVerified);
    AisenUtil.setImageVerified(imgVerified, mUser);

    // 简介
    TextView txtDesc = (TextView) viewProfile.findViewById(R.id.txtDesc);
    if (!TextUtils.isEmpty(mUser.getDescription()))
      txtDesc.setText(String.format(getString(R.string.profile_des_hint), mUser.getDescription()));
    else
      txtDesc.setText(
          String.format(
              String.format(
                  getString(R.string.profile_des_hint), getString(R.string.profile_des_none))));

    // 认证原因
    TextView txtVerifiedReason = (TextView) viewProfile.findViewById(R.id.txtVerifiedReason);
    txtVerifiedReason.setVisibility(
        !TextUtils.isEmpty(mUser.getVerified_reason()) ? View.VISIBLE : View.GONE);
    txtVerifiedReason.setText(
        String.format(getString(R.string.profile_ver_reason), mUser.getVerified_reason() + ""));

    // 备注
    TextView txtRemark = (TextView) viewProfile.findViewById(R.id.txtRemark);
    txtRemark.setVisibility(
        mFriendship == null || !mFriendship.getSource().getFollowing() ? View.GONE : View.VISIBLE);
    if (mFriendship != null) {
      try {
        BizFragment.getBizFragment(this).modifyUserMark(txtRemark, mUser, this);
      } catch (Exception e) {
      }
      if (!TextUtils.isEmpty(mUser.getRemark()))
        txtRemark.setText(String.format(getString(R.string.profile_remark), mUser.getRemark()));
      else txtRemark.setText(R.string.profile_remark_none);
    }

    // 分组
    TextView txtGroups = (TextView) viewProfile.findViewById(R.id.txtGroups);
    txtGroups.setVisibility(mGroupMemberListed == null ? View.GONE : View.VISIBLE);
    txtGroups.setOnClickListener(this);
    if (mGroupMemberListed != null) {
      if (mGroupMemberListed.getLists().size() == 0) {
        txtGroups.setText(R.string.profile_group_none);
      } else {
        StringBuffer sb = new StringBuffer();
        for (GroupListed groupListed : mGroupMemberListed.getLists())
          sb.append(groupListed.getName()).append(" ");

        txtGroups.setText(
            String.format(getString(R.string.profile_group_hint), sb.toString().trim()));
      }
    }

    // 所在地
    TextView txtLocation = (TextView) viewProfile.findViewById(R.id.txtLocation);
    txtLocation.setText(mUser.getLocation());

    // 微博数
    TextView txtStatusCount = (TextView) viewProfile.findViewById(R.id.txtStatusCount);
    txtStatusCount.setText(AisenUtil.getCounter(mUser.getStatuses_count()));

    // 关注数
    viewProfile.findViewById(R.id.btnFriendCounter).setOnClickListener(this);
    TextView txtFriendCount = (TextView) viewProfile.findViewById(R.id.txtFriendCount);
    txtFriendCount.setText(AisenUtil.getCounter(mUser.getFriends_count()));

    // 粉丝数
    viewProfile.findViewById(R.id.btnFollowerCounter).setOnClickListener(this);
    TextView txtFollowerCount = (TextView) viewProfile.findViewById(R.id.txtFollowerCount);
    txtFollowerCount.setText(AisenUtil.getCounter(mUser.getFollowers_count()));
  }
示例#7
0
  /**
   * 选择了侧边栏,切换侧边栏菜单
   *
   * @param item
   * @return
   */
  @Override
  public void onMenuClicked(MenuFragment.NavMenuItem item, boolean closeDrawer) {
    invalidateOptionsMenu();

    ABaseFragment fragment = null;

    // 切换ContentFragment,或者跳转到新的界面
    switch (item.id) {
        // 首页
      case MenuFragment.MENU_MAIN:
        fabGroupsFragment.triggerLastPosition();
        break;
        // 通知
      case MenuFragment.MENU_NOTIFICATION:
        fragment = NotificationPagerFragment.newInstance(newIntentNotificationIndex);

        newIntentNotificationIndex = -1;
        break;
        // 提及
      case MenuFragment.MENU_MENTION:
        fragment = MentionPagerFragment.newInstance();
        break;
        // 评论
      case MenuFragment.MENU_CMT:
        fragment = CommentPagerFragment.newInstance();
        break;
        // 私信
      case MenuFragment.MENU_MD:
        new IAction(
            MainActivity.this,
            new WebLoginAction(MainActivity.this, BizFragment.createBizFragment(this))) {

          @Override
          public void doAction() {
            WeiboClientActivity.launchDM(MainActivity.this);
          }
        }.run();

        MobclickAgent.onEvent(MainActivity.this, "md");
        break;
        // 热门微博
      case MenuFragment.MENU_HOT_STATUS:
        WeiboClientActivity.launchHotStatuses(this);

        MobclickAgent.onEvent(MainActivity.this, "hot_status");
        break;
        // 草稿箱
      case MenuFragment.MENU_DRAT:
        fragment = DraftFragment.newInstance();
        break;
        // 设置
      case MenuFragment.MENU_SETTINGS:
        SettingsPagerFragment.launch(this);
        break;
        // 轻松一刻
      case MenuFragment.MENU_JOKE:
        fragment = JokesPagerFragment.newInstance();

        MobclickAgent.onEvent(this, "menu_joke");
        break;
        // 精美壁纸
      case MenuFragment.MENU_WALLPAPER:
        fragment = WallpaperFragment.newInstance();

        MobclickAgent.onEvent(this, "menu_wallpaper");
        break;
    }

    if (fragment != null) {
      setFragemnt(fragment, getString(item.toolbarRes));
    }

    // 隐藏Fab按钮
    if (item.id == 1) {
      fabBtn.setVisibility(View.VISIBLE);

      // 显示Fab
      BizFragment.createBizFragment(this).getFabAnimator().show();
    } else {
      fabBtn.setVisibility(View.GONE);
    }

    // 关闭侧边栏
    if (closeDrawer) {
      mHandler.postDelayed(
          new Runnable() {

            @Override
            public void run() {
              closeDrawer();
            }
          },
          300);
    }
  }