// Path: app/src/main/java/com/williammora/openfeed/events/TwitterEvents.java
// public class TwitterEvents {
// 
//     public static class OAuthRequestTokenEvent extends Event<RequestToken> {
//         public OAuthRequestTokenEvent(RequestToken result) {
//             super(result);
//         }
//     }
// 
//     public static class OAuthAccessTokenEvent extends Event<AccessToken> {
//         public OAuthAccessTokenEvent(AccessToken result) {
//             super(result);
//         }
//     }
// 
//     public static class HomeTimelineEvent extends Event<List<Status>> {
//         public HomeTimelineEvent(List<Status> result) {
//             super(result);
//         }
//     }
// 
//     public static class SearchEvent extends Event<QueryResult> {
//         public SearchEvent(QueryResult result) {
//             super(result);
//         }
//     }
// 
//     public static class UserEvent extends Event<User> {
//         public UserEvent(User result) {
//             super(result);
//         }
//     }
// 
//     public static class RetweetedStatusEvent extends Event<Status> {
//         public RetweetedStatusEvent(Status result) {
//             super(result);
//         }
//     }
// 
//     public static class CreatedFavoriteEvent extends Event<Status> {
//         public CreatedFavoriteEvent(Status result) {
//             super(result);
//         }
//     }
// 
//     public static class DestroyedFavoriteEvent extends Event<Status> {
//         public DestroyedFavoriteEvent(Status result) {
//             super(result);
//         }
//     }
// 
//     public static class DestroyedStatusEvent extends Event<Status> {
//         public DestroyedStatusEvent(Status result) {
//             super(result);
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/williammora/openfeed/fragments/UserFragment.java
// public class UserFragment extends OpenFeedFragment {
// 
//     public static final String SAVED_USER = "SAVED_USER";
// 
//     public interface UserFragmentListener {
//         public User getUser();
// 
//         public String getUserScreenName();
//     }
// 
//     private UserFragmentListener mListener;
//     private User mUser;
//     private View mView;
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                              Bundle savedInstanceState) {
//         if (savedInstanceState != null) {
//             mUser = (User) savedInstanceState.getSerializable(SAVED_USER);
//         }
//         mView = inflater.inflate(R.layout.fragment_user, container, false);
//         if (mUser != null) {
//             updateView(mUser);
//         } else {
//             loadUser(mListener.getUserScreenName());
//         }
//         return mView;
//     }
// 
//     private void loadUser(String screenName) {
//         TwitterService.getInstance().showUser(screenName);
//     }
// 
//     public void updateView(User user) {
//         ImageView profileBanner = (ImageView) mView.findViewById(R.id.profile_banner);
//         Picasso.with(profileBanner.getContext())
//                 .load(user.getProfileBannerMobileRetinaURL())
//                 .transform(new ProfileBannerTransformation(profileBanner, user.getId()))
//                 .placeholder(R.drawable.profile_banner)
//                 .into(profileBanner);
//         ImageView profileImage = (ImageView) mView.findViewById(R.id.profile_image);
//         Picasso.with(mView.getContext())
//                 .load(user.getBiggerProfileImageURLHttps())
//                 .placeholder(R.drawable.image_loader_placeholder)
//                 .error(R.drawable.image_loader_placeholder)
//                 .into(profileImage);
//         TextView profileName = (TextView) mView.findViewById(R.id.profile_name);
//         profileName.setText(user.getName());
//         TextView profileScreenName = (TextView) mView.findViewById(R.id.profile_screen_name);
//         profileScreenName.setText(UserUtils.getFullScreenName(user));
//         mUser = user;
//     }
// 
//     @Override
//     public void onAttach(Activity activity) {
//         super.onAttach(activity);
//         if (activity instanceof UserFragmentListener) {
//             mListener = (UserFragmentListener) activity;
//             if (mUser == null) {
//                 mUser = mListener.getUser();
//             }
//         }
//     }
// 
//     @Override
//     public void onSaveInstanceState(Bundle outState) {
//         outState.putSerializable(SAVED_USER, mUser);
//         super.onSaveInstanceState(outState);
//     }
// 
//     @Subscribe
//     public void onUserEvent(TwitterEvents.UserEvent event) {
//         updateView(event.getResult());
//     }
// }


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import com.squareup.otto.Subscribe;
import com.williammora.openfeed.R;
import com.williammora.openfeed.events.TwitterEvents;
import com.williammora.openfeed.fragments.UserFragment;
import twitter4j.User;
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mUser = (User) savedInstanceState.getSerializable(SAVED_USER);
        mScreenName = savedInstanceState.getString(SAVED_SCREEN_NAME, "");
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public User getUser() {
        return mUser;
    }

    @Override
    public String getUserScreenName() {
        return mScreenName;
    }

    @Subscribe
// Path: app/src/main/java/com/williammora/openfeed/events/TwitterEvents.java
// public class TwitterEvents {
// 
//     public static class OAuthRequestTokenEvent extends Event<RequestToken> {
//         public OAuthRequestTokenEvent(RequestToken result) {
//             super(result);
//         }
//     }
// 
//     public static class OAuthAccessTokenEvent extends Event<AccessToken> {
//         public OAuthAccessTokenEvent(AccessToken result) {
//             super(result);
//         }
//     }
// 
//     public static class HomeTimelineEvent extends Event<List<Status>> {
//         public HomeTimelineEvent(List<Status> result) {
//             super(result);
//         }
//     }
// 
//     public static class SearchEvent extends Event<QueryResult> {
//         public SearchEvent(QueryResult result) {
//             super(result);
//         }
//     }
// 
//     public static class UserEvent extends Event<User> {
//         public UserEvent(User result) {
//             super(result);
//         }
//     }
// 
//     public static class RetweetedStatusEvent extends Event<Status> {
//         public RetweetedStatusEvent(Status result) {
//             super(result);
//         }
//     }
// 
//     public static class CreatedFavoriteEvent extends Event<Status> {
//         public CreatedFavoriteEvent(Status result) {
//             super(result);
//         }
//     }
// 
//     public static class DestroyedFavoriteEvent extends Event<Status> {
//         public DestroyedFavoriteEvent(Status result) {
//             super(result);
//         }
//     }
// 
//     public static class DestroyedStatusEvent extends Event<Status> {
//         public DestroyedStatusEvent(Status result) {
//             super(result);
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/williammora/openfeed/fragments/UserFragment.java
// public class UserFragment extends OpenFeedFragment {
// 
//     public static final String SAVED_USER = "SAVED_USER";
// 
//     public interface UserFragmentListener {
//         public User getUser();
// 
//         public String getUserScreenName();
//     }
// 
//     private UserFragmentListener mListener;
//     private User mUser;
//     private View mView;
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                              Bundle savedInstanceState) {
//         if (savedInstanceState != null) {
//             mUser = (User) savedInstanceState.getSerializable(SAVED_USER);
//         }
//         mView = inflater.inflate(R.layout.fragment_user, container, false);
//         if (mUser != null) {
//             updateView(mUser);
//         } else {
//             loadUser(mListener.getUserScreenName());
//         }
//         return mView;
//     }
// 
//     private void loadUser(String screenName) {
//         TwitterService.getInstance().showUser(screenName);
//     }
// 
//     public void updateView(User user) {
//         ImageView profileBanner = (ImageView) mView.findViewById(R.id.profile_banner);
//         Picasso.with(profileBanner.getContext())
//                 .load(user.getProfileBannerMobileRetinaURL())
//                 .transform(new ProfileBannerTransformation(profileBanner, user.getId()))
//                 .placeholder(R.drawable.profile_banner)
//                 .into(profileBanner);
//         ImageView profileImage = (ImageView) mView.findViewById(R.id.profile_image);
//         Picasso.with(mView.getContext())
//                 .load(user.getBiggerProfileImageURLHttps())
//                 .placeholder(R.drawable.image_loader_placeholder)
//                 .error(R.drawable.image_loader_placeholder)
//                 .into(profileImage);
//         TextView profileName = (TextView) mView.findViewById(R.id.profile_name);
//         profileName.setText(user.getName());
//         TextView profileScreenName = (TextView) mView.findViewById(R.id.profile_screen_name);
//         profileScreenName.setText(UserUtils.getFullScreenName(user));
//         mUser = user;
//     }
// 
//     @Override
//     public void onAttach(Activity activity) {
//         super.onAttach(activity);
//         if (activity instanceof UserFragmentListener) {
//             mListener = (UserFragmentListener) activity;
//             if (mUser == null) {
//                 mUser = mListener.getUser();
//             }
//         }
//     }
// 
//     @Override
//     public void onSaveInstanceState(Bundle outState) {
//         outState.putSerializable(SAVED_USER, mUser);
//         super.onSaveInstanceState(outState);
//     }
// 
//     @Subscribe
//     public void onUserEvent(TwitterEvents.UserEvent event) {
//         updateView(event.getResult());
//     }
// }


// Path: app/src/main/java/com/williammora/openfeed/activities/UserActivity.java
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import com.squareup.otto.Subscribe;
import com.williammora.openfeed.R;
import com.williammora.openfeed.events.TwitterEvents;
import com.williammora.openfeed.fragments.UserFragment;
import twitter4j.User;

    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mUser = (User) savedInstanceState.getSerializable(SAVED_USER);
        mScreenName = savedInstanceState.getString(SAVED_SCREEN_NAME, "");
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public User getUser() {
        return mUser;
    }

    @Override
    public String getUserScreenName() {
        return mScreenName;
    }

    @Subscribe
    public void onUserEvent(TwitterEvents.UserEvent event) {