예제 #1
0
  @Subscribe
  public void onUserRetrieved(UserRetrievedEvent event) {
    CWUser u = event.getUser();

    if (event.isTaskOver()) UserFragment.this.setRefresh(false);

    if (event.getError() != null) {
      Toast.makeText(getSherlockActivity(), event.getError().getMessage(), Toast.LENGTH_LONG)
          .show();
      return;
    } else if (u == null) return;

    if (UserFragment.this.username == null) {
      UserFragment.this.username = u.getUsername();
      SharedPreferences prefs =
          PreferenceManager.getDefaultSharedPreferences(getSherlockActivity());
      prefs.edit().putString(Constants.PREF_USERNAME, u.getUsername()).commit();
    }

    UserFragment.this.u = u;
    refreshNavigationListAdapter();

    if (pagerAdapter == null || viewPager.getAdapter() == null) {
      viewPager.setAdapter(pagerAdapter = new PagerUserAdapter(getFragmentManager(), u));
      pageIndicator.setViewPager(viewPager);
      pageIndicator.setOnPageChangeListener(UserFragment.this);
      pageIndicator.setBackgroundColor(getResources().getColor(R.color.coderwall_blue));
      pageIndicator.setFooterColor(Color.WHITE);
      pageIndicator.setFooterIndicatorStyle(IndicatorStyle.Triangle);
      pageIndicator.setFooterLineHeight(0);
    } else pagerAdapter.refreshUser(u);
  }
  private void decoreIndicator() {
    float density = getResources().getDisplayMetrics().density;

    indicator.setBackgroundColor(Color.WHITE);
    indicator.setFooterColor(Color.BLACK);
    indicator.setFooterLineHeight(1 * density);
    indicator.setFooterIndicatorHeight(1 * density);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
    indicator.setTextColor(0xAA000000);
    indicator.setSelectedColor(0xFF000000);
    indicator.setSelectedBold(true);
  }