Android Open Source - android_twitter_client Twitter List Fragment






From Project

Back to project page android_twitter_client.

License

The source code is released under:

GNU General Public License

If you think the Android project android_twitter_client 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.github.snambi.twitterclient.fragemets;
/* w ww  .j  av a  2s.  c  o m*/
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.github.snambi.twitterclient.R;
import com.github.snambi.twitterclient.TwitterApplication;
import com.github.snambi.twitterclient.adapters.TwitterArrayAdapter;
import com.github.snambi.twitterclient.clients.TwitterRestClient;
import com.github.snambi.twitterclient.models.Tweet;

public class TwitterListFragment extends Fragment{
  
  protected TwitterRestClient client;
  protected ListView lvTweets;
  protected List<Tweet> tweets = new ArrayList<Tweet>();
  protected TwitterArrayAdapter aTweets=null;
  
  protected ImageClickListener imageListener=null;

  public TwitterListFragment( ){
  }
  
  public TwitterListFragment( TwitterRestClient client){
    this.client = client;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    client = TwitterApplication.getRestClient();
    aTweets = new TwitterArrayAdapter(getActivity(), tweets, imageListener);
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
  
    View view = inflater.inflate(R.layout.fragment_twitter_list, container, false);
    lvTweets = (ListView) view.findViewById(R.id.lvTweets);
    lvTweets.setAdapter(aTweets);
        
    return view;
  }
  
  @Override
  public void onAttach(Activity activity) {  
    super.onAttach(activity);
    if( activity instanceof ImageClickListener ){
      imageListener = (ImageClickListener) activity;
    }
  }
    
  public TwitterRestClient getClient() {
    return client;
  }
  public void setClient(TwitterRestClient client) {
    this.client = client;
  }

  // provides a way to add tweets from the activity
  public void addTweets( List<Tweet> tweets){
    aTweets.addAll(tweets);
  }
  
  public void addTweetAtPosition( Tweet tweet , int position){
    if( tweet != null && tweets !=null ){
      tweets.add(position, tweet);
      aTweets.notifyDataSetChanged();
    }
  }

  public void onImageClick(String screenName ){
    imageListener.onImageClick( screenName );
  }
  
  public interface ImageClickListener{
    public void onImageClick( String screenName );
  }
}




Java Source Code List

com.github.snambi.twitterclient.TwitterApplication.java
com.github.snambi.twitterclient.activities.ComposeActivity.java
com.github.snambi.twitterclient.activities.LoginActivity.java
com.github.snambi.twitterclient.activities.ProfileActivity.java
com.github.snambi.twitterclient.activities.TimelineActivity.java
com.github.snambi.twitterclient.adapters.TwitterArrayAdapter.java
com.github.snambi.twitterclient.clients.TwitterRestClient.java
com.github.snambi.twitterclient.db.TweetDbHelper.java
com.github.snambi.twitterclient.fragemets.HomeTimelineFragment.java
com.github.snambi.twitterclient.fragemets.MentionsTimelineFragment.java
com.github.snambi.twitterclient.fragemets.ProfileHeaderFragment.java
com.github.snambi.twitterclient.fragemets.TwitterListFragment.java
com.github.snambi.twitterclient.fragemets.UserTimelineFragment.java
com.github.snambi.twitterclient.listeners.EndlessScrollListener.java
com.github.snambi.twitterclient.listeners.FragmentTabListener.java
com.github.snambi.twitterclient.models.SampleModel.java
com.github.snambi.twitterclient.models.Tweet.java
com.github.snambi.twitterclient.models.User.java
com.github.snambi.twitterclient.utils.TwitterTimeUtils.java