@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); client = TwitterApplication.getRestClient(); // get account info client.getUserInfo( new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { user = User.fromJSON(response); // my current user account info getSupportActionBar().setTitle("@" + user.getScreenName()); populateProfileHeader(user); } }); // get the screen name from the activity that launches this String screenName = getIntent().getStringExtra("screen_name"); // if instance is not exist, create it once for all if (savedInstanceState == null) { // create the user timeline fragment UserTimelineFragment fragmentUserTimeline = UserTimelineFragment.newInstance(screenName); // display user fragment within this activity (dynamically) FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.flContainer, fragmentUserTimeline); ft.commit(); // change the fragment } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); ivMyProfileImage = (ImageView) findViewById(R.id.ivMyProfileImage); tvMyProfileName = (TextView) findViewById(R.id.tvMyProfileName); tvMyScreenName = (TextView) findViewById(R.id.tvMyScreenName); tvFollowers = (TextView) findViewById(R.id.tvFollowers); tvFollowing = (TextView) findViewById(R.id.tvFollowing); boolean isMyProfile = getIntent().getBooleanExtra("myprofile", true); long userId = getIntent().getLongExtra("userid", 0L); client = TwitterApplication.getRestClient(); if (isMyProfile) { populateUser(); } else { populateOtherUser(userId); } fragmentTweetList = (UserTimelineFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_user_timeline); fragmentTweetList.fetchUserTimelineTweets(userId); }