Android Open Source - android_twitter_client Mentions Timeline 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;
/*from   w  w  w.j  a v  a  2 s  .  c o m*/
import java.util.List;

import org.json.JSONArray;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.activeandroid.util.Log;
import com.github.snambi.twitterclient.clients.TwitterRestClient.TweetsCounter;
import com.github.snambi.twitterclient.db.TweetDbHelper;
import com.github.snambi.twitterclient.listeners.EndlessScrollListener;
import com.github.snambi.twitterclient.models.Tweet;
import com.loopj.android.http.JsonHttpResponseHandler;

public class MentionsTimelineFragment extends TwitterListFragment  {
  
  TweetsCounter counter = new TweetsCounter();

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    populateTimeline();
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    // attach the endless scrollview listener to the listview
    lvTweets.setOnScrollListener( new EndlessScrollListener() {
      
      @Override
      public void onLoadMore(int page, int totalItemsCount) {
        populateTimeline();
      }
    });

    return view;
  }
  
  private void populateTimeline() {
    client.getMentionsTimeline( counter, new JsonHttpResponseHandler(){
      
      @Override
      public void onFailure(Throwable t, String s) {
        Log.d( "debug", s, t);
      }
      
      @Override
      public void onSuccess(JSONArray jsonArray) {
        Log.d("debug", jsonArray.toString() );
        
        List<Tweet> tweets = Tweet.fromJSONArray(jsonArray);
                
        // these values are used for next iteration
        counter.setSinceIdMaxIdFrom(tweets);
        TweetDbHelper.saveWhenNotPresent(tweets);
        
        //aTweets.addAll( tweets );
        addTweets(tweets);
      }
    });    
  }

}




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