コード例 #1
1
ファイル: MainActivity.java プロジェクト: LkxGithub/osc
        @Override
        public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equals(Constants.INTENT_ACTION_NOTICE)) {
            mNotice = (Notice) intent.getSerializableExtra("notice_bean");
            int atmeCount = mNotice.getAtmeCount(); // @我
            int msgCount = mNotice.getMsgCount(); // 留言
            int reviewCount = mNotice.getReviewCount(); // 评论
            int newFansCount = mNotice.getNewFansCount(); // 新粉丝
            int newLikeCount = mNotice.getNewLikeCount(); // 收到赞
            int activeCount = atmeCount + reviewCount + msgCount + newFansCount + newLikeCount;

            Fragment fragment = getCurrentFragment();
            if (fragment instanceof MyInformationFragment) {
              ((MyInformationFragment) fragment).setNotice();
            } else {
              if (activeCount > 0) {
                mBvNotice.setText(activeCount + "");
                mBvNotice.show();
              } else {
                mBvNotice.hide();
                mNotice = null;
              }
            }
          } else if (intent.getAction().equals(Constants.INTENT_ACTION_LOGOUT)) {
            mBvNotice.hide();
            mNotice = null;
          }
        }
コード例 #2
0
ファイル: MainActivity.java プロジェクト: LkxGithub/osc
 @Override
 public void onTabChanged(String tabId) {
   final int size = mTabHost.getTabWidget().getTabCount();
   for (int i = 0; i < size; i++) {
     View v = mTabHost.getTabWidget().getChildAt(i);
     if (i == mTabHost.getCurrentTab()) {
       v.setSelected(true);
     } else {
       v.setSelected(false);
     }
   }
   if (tabId.equals(getString(MainTab.ME.getResName()))) {
     mBvNotice.setText("");
     mBvNotice.hide();
   }
   supportInvalidateOptionsMenu();
 }
コード例 #3
0
ファイル: MainActivity.java プロジェクト: LkxGithub/osc
  private void initTabs() {
    MainTab[] tabs = MainTab.values();
    final int size = tabs.length;
    for (int i = 0; i < size; i++) {
      MainTab mainTab = tabs[i];
      TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName()));
      View indicator =
          LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_indicator, null);
      TextView title = (TextView) indicator.findViewById(R.id.tab_title);
      Drawable drawable = this.getResources().getDrawable(mainTab.getResIcon());
      title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
      if (i == 2) {
        indicator.setVisibility(View.INVISIBLE);
        mTabHost.setNoTabChangedTag(getString(mainTab.getResName()));
      }
      title.setText(getString(mainTab.getResName()));
      tab.setIndicator(indicator);
      tab.setContent(
          new TabContentFactory() {

            @Override
            public View createTabContent(String tag) {
              return new View(MainActivity.this);
            }
          });
      mTabHost.addTab(tab, mainTab.getClz(), null);

      if (mainTab.equals(MainTab.ME)) {
        View cn = indicator.findViewById(R.id.tab_mes);
        mBvNotice = new BadgeView(MainActivity.this, cn);
        mBvNotice.setBadgePosition(BadgeView.POSITION_TOP_RIGHT);
        mBvNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
        mBvNotice.setBackgroundResource(R.drawable.notification_bg);
        mBvNotice.setGravity(Gravity.CENTER);
      }
      mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this);
    }
  }