示例#1
0
 private void initViewPager() {
   mTabsAdapter = new TabPageAdapter(this);
   mViewPager.setAdapter(mTabsAdapter);
   mIndicator.setViewPager(mViewPager);
   String url = String.format(Urls.USER_INFO, share.getString(UID, ""));
   new ContentAsyncTask().execute(url);
 }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.user_center_activity);
    initControl();
    // this.deleteDatabase("imdata.db");
    share = getSharedPreferences(UserLoginActivity.SharedName, Context.MODE_PRIVATE);
    if (savedInstanceState != null) {
      try {
        mUserInfoItem =
            new ObjectMapper().readValue(savedInstanceState.getString("json"), UserInfoItem.class);
      } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      loadLayout.setVisibility(View.GONE);
      mTabsAdapter = new TabPageAdapter(this);
      mViewPager.setAdapter(mTabsAdapter);
      mIndicator.setViewPager(mViewPager);
      if (mUserInfoItem == null) {
        UserLogOutFragment fragment = new UserLogOutFragment(UserCenterActivity.this, true);

        mTabsAdapter.addTab(getString(R.string.user_center_get_info_error), fragment);
        return;
      }

      mTabsAdapter.addTab(
          getString(R.string.user_center_my_Collect),
          new UserCollectFragment(UserCenterActivity.this));
      mTabsAdapter.addTab(
          getString(R.string.user_center_my_Intro), new UserIntroFragment(mUserInfoItem));
      mTabsAdapter.addTab(
          getString(R.string.user_center_exit),
          new UserLogOutFragment(UserCenterActivity.this, false));

      mTabsAdapter.notifyDataSetChanged();
      mViewPager.setCurrentItem(0);
    } else if (!NetWorkHelper.checkNetState(this)) {
      loadLayout.setVisibility(View.GONE);
      loadFaillayout.setVisibility(View.VISIBLE);
    } else {
      initViewPager();
    }
  }