@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#3687C5"))); getSupportActionBar().setTitle("Profile"); user = (User) getIntent().getSerializableExtra("user"); if (user == null) { client = TwitterApplication.getRestClient(); client.getUserInfo( new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { user = User.fromJSON(response); getSupportActionBar().setTitle("@" + user.getScreenName()); populateProfileHeader(user); } }); } else { populateProfileHeader(user); screenName = user.getScreenName(); } if (savedInstanceState == null) { UserTimelineFragment userTimelineFragment = UserTimelineFragment.newInstance(screenName); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.flContainer, userTimelineFragment); ft.commit(); } }
private void populateProfileHeader(User user) { TextView tvName = (TextView) findViewById(R.id.tvName); tvName.setText(user.getName()); TextView tvTagline = (TextView) findViewById(R.id.tvTagline); tvTagline.setText(user.getTagline()); TextView tvFollowers = (TextView) findViewById(R.id.tvFollowers); tvFollowers.setText("" + user.getFollowersCount() + " Followers"); tvFollowers.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ProfileActivity.this, UserListActivity.class); intent.putExtra("screenName", screenName); intent.putExtra("list", "followers"); startActivity(intent); } }); TextView tvFollowing = (TextView) findViewById(R.id.tvFollowing); tvFollowing.setText("" + user.getFriendsCount() + " Following"); tvFollowing.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ProfileActivity.this, UserListActivity.class); intent.putExtra("screenName", screenName); intent.putExtra("list", "following"); startActivity(intent); } }); ImageView ivUserProfileImage = (ImageView) findViewById(R.id.ivUserProfileImage); Picasso.with(this).load(user.getProfileImageUrl()).into(ivUserProfileImage); }