Android Open Source - Test-SimpleTwitterClient User Info Fragment






From Project

Back to project page Test-SimpleTwitterClient.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project Test-SimpleTwitterClient listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.Twitter_Android.Fragments;
/*www.ja  v a 2s. c om*/
import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager;
import android.content.Loader;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.Twitter_Android.Loaders.AsyncUserInfoLoader;
import com.example.Twitter_Android.AsynkTasks.ImageDownloader;
import com.example.Twitter_Android.Logic.Constants;
import com.example.Twitter_Android.Logic.Person;
import com.example.Twitter_Android.AppActivity.MainActivity;
import com.example.Twitter_Android.Net.Connector;
import com.example.Twitter_Android.R;

public class UserInfoFragment extends Fragment implements LoaderManager.LoaderCallbacks<Person> {
  private MainActivity mainActivity;
  private static Connector connector;
  private ImageView userAvatar;
  private TextView userName;
  private TextView userInfo;
  private static ImageDownloader imageDownloader;
  private static final int USER_INFO_LOADER_ID = Constants.USER_INFO_LOADER_ID;

  public static final String ARG_ID = "USER_ID";
  public static final String TAG = "TAG_USER_INFO_FRAGMENT";
  //------------------------------------------------------------------------------------------------------------------

  public UserInfoFragment() {
    Log.i(TAG, "create new UserInfoFragment");
    if (imageDownloader == null) {
      imageDownloader = new ImageDownloader();
    }

    Bundle args = new Bundle();
    args.putLong(ARG_ID, 0);
    setArguments(args);
//    setRetainInstance(true);
  }

  public static UserInfoFragment newInstance(Connector c, long id) {
    connector = c;
    UserInfoFragment fragment = new UserInfoFragment();
    Bundle args = new Bundle();
    args.putLong(ARG_ID, id);
    fragment.setArguments(args);
    return fragment;
  }
  //------------------------------------------------------------------------------------------------------------------

  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    mainActivity = (MainActivity) activity;
  }
  //------------------------------------------------------------------------------------------------------------------

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mainActivity.getLoaderManager().initLoader(USER_INFO_LOADER_ID, getArguments(), this).forceLoad();
  }
  //------------------------------------------------------------------------------------------------------------------

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Log.i(TAG, "onCreateView");
    View v = inflater.inflate(R.layout.layout_connected_user_info_fragment, container, false);
    userAvatar = (ImageView) v.findViewById(R.id.userinfo_fragment_user_avatar);
    userName = (TextView) v.findViewById(R.id.userinfo_fragment_username_textview);
    userInfo = (TextView) v.findViewById(R.id.userinfo_fragment_user_description_textView);
    return v;
  }
  //------------------------------------------------------------------------------------------------------------------

  @Override
  public Loader<Person> onCreateLoader(int id, Bundle args) {
    return new AsyncUserInfoLoader(mainActivity, connector, args.getLong("ID_VALUE", 0));
  }

  @Override
  public void onLoadFinished(Loader<Person> loader, Person data) {
    if (loader.getId() == USER_INFO_LOADER_ID) {
      userName.setText(data.getName());
      userInfo.setText(data.getDescription());
      imageDownloader.loadBitmap(data.getProfileImage(), userAvatar);
    }
  }

  @Override
  public void onLoaderReset(Loader<Person> loader) {

  }
  //------------------------------------------------------------------------------------------------------------------

  public void loadNewInfo(Bundle args) {
    Log.i(TAG, "Loading new Info id = " + args.getLong("ID_VALUE"));
    mainActivity.getLoaderManager().restartLoader(USER_INFO_LOADER_ID, args, this).forceLoad();
  }
}




Java Source Code List

com.example.Twitter_Android.AppActivity.ConcreteUserTimelineActivity.java
com.example.Twitter_Android.AppActivity.MainActivity.java
com.example.Twitter_Android.AppActivity.MessagesActivity.java
com.example.Twitter_Android.AppActivity.SearchableActivity.java
com.example.Twitter_Android.AppActivity.SettingsActivity.java
com.example.Twitter_Android.AsynkTasks.ImageDownloader.java
com.example.Twitter_Android.AsynkTasks.TaskDeleteTweet.java
com.example.Twitter_Android.AsynkTasks.TaskFollow.java
com.example.Twitter_Android.AsynkTasks.TaskPostTweet.java
com.example.Twitter_Android.AsynkTasks.TaskReply.java
com.example.Twitter_Android.AsynkTasks.TaskRetweet.java
com.example.Twitter_Android.AsynkTasks.TaskSendMessage.java
com.example.Twitter_Android.AsynkTasks.TaskUnfollow.java
com.example.Twitter_Android.Fragments.ConcreteUserTimelineFragment.java
com.example.Twitter_Android.Fragments.ConnectedUserTimelineFragment.java
com.example.Twitter_Android.Fragments.FollowersFragment.java
com.example.Twitter_Android.Fragments.FollowingsFragment.java
com.example.Twitter_Android.Fragments.HomeTimelineFragment.java
com.example.Twitter_Android.Fragments.TimelineFragment.java
com.example.Twitter_Android.Fragments.UserInfoFragment.java
com.example.Twitter_Android.Fragments.Adapters.ConcreteUserTimelineAdapter.java
com.example.Twitter_Android.Fragments.Adapters.FollowingsListAdapter.java
com.example.Twitter_Android.Fragments.Adapters.MessagesAdapter.java
com.example.Twitter_Android.Fragments.Adapters.TimelineAdapter.java
com.example.Twitter_Android.Fragments.Adapters.TweetAdapter.java
com.example.Twitter_Android.Fragments.Dialogs.DeleteTweetDialog.java
com.example.Twitter_Android.Fragments.Dialogs.DirectMessageDialog.java
com.example.Twitter_Android.Fragments.Dialogs.ErrorDialog.java
com.example.Twitter_Android.Fragments.Dialogs.PostTweetDialog.java
com.example.Twitter_Android.Fragments.Dialogs.ReplyDialog.java
com.example.Twitter_Android.Fragments.Dialogs.RetweetDialog.java
com.example.Twitter_Android.Fragments.Dialogs.ShowImageDialog.java
com.example.Twitter_Android.Fragments.Dialogs.UserInfoDialog.java
com.example.Twitter_Android.Fragments.Preferences.SettingsFragment.java
com.example.Twitter_Android.Loaders.AsyncUserInfoLoader.java
com.example.Twitter_Android.Loaders.FollowersLoader.java
com.example.Twitter_Android.Loaders.FollowingsLoader.java
com.example.Twitter_Android.Loaders.HomeTimelineLoader.java
com.example.Twitter_Android.Loaders.MessageLoader.java
com.example.Twitter_Android.Loaders.Task_LoadSearchedTweets.java
com.example.Twitter_Android.Loaders.Task_LoadSearchedUsers.java
com.example.Twitter_Android.Loaders.TweetLoader.java
com.example.Twitter_Android.Loaders.UserTimelineLoader.java
com.example.Twitter_Android.Logic.AppDatabase.java
com.example.Twitter_Android.Logic.Constants.java
com.example.Twitter_Android.Logic.DataCache.java
com.example.Twitter_Android.Logic.FileWorker.java
com.example.Twitter_Android.Logic.Person.java
com.example.Twitter_Android.Logic.Tweet.java
com.example.Twitter_Android.Net.Connector.java
com.example.Twitter_Android.Net.Parser.java
com.mass.cmassive.CMassive.java