Android Open Source - lastUpdates Tweets List Adapter






From Project

Back to project page lastUpdates.

License

The source code is released under:

GNU General Public License

If you think the Android project lastUpdates 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.focusings.focusingsworld.TwitterParser;
/* w ww.j  av a2s .  c o m*/
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;

import com.focusings.focusingsworld.ImageAndTextList.AsyncImageLoader;
import com.focusings.focusingsworld.ImageAndTextList.AsyncImageLoader.ImageCallback;
import com.focusings.focusingsworld.R;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class TweetsListAdapter extends ArrayAdapter<TweetInfo>{

  private AsyncImageLoader asyncImageLoader;
  
  
    public TweetsListAdapter(Activity activity, List<TweetInfo> imageAndTexts) {
        super(activity, 0, imageAndTexts);
        asyncImageLoader = new AsyncImageLoader();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Activity activity = (Activity) getContext();
        LayoutInflater inflater = activity.getLayoutInflater();

        // Inflate the views from XML
        View rowView = inflater.inflate(R.layout.tweet_row, null);
        TweetInfo tweet = getItem(position);

        // Load the image and set it on the ImageView
        final ImageView userImageView = (ImageView) rowView.findViewById(R.id.userImage);
        Drawable cachedImage = asyncImageLoader.loadDrawable(tweet.getUserImage(), new ImageCallback() {
            public void imageLoaded(Drawable imageDrawable, String imageUrl) {
              userImageView.setImageDrawable(imageDrawable);
            }
        });
        userImageView.setImageDrawable(cachedImage);
        
        TextView userNameView = (TextView) rowView.findViewById(R.id.userName);
        userNameView.setText(tweet.getUserName());
        
        TextView userTwitterAccountView = (TextView) rowView.findViewById(R.id.userTwitterAccount);
        userTwitterAccountView.setText(tweet.getUserTwitterAccount());
        
        TextView tweetContentView = (TextView) rowView.findViewById(R.id.tweetContent);
        tweetContentView.setText(tweet.getTweetContent());
        
        return rowView;
    }

    public static Drawable loadImageFromUrl(String url) {
        InputStream inputStream;
        try {
            inputStream = new URL(url).openStream();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return Drawable.createFromStream(inputStream, "src");
    }
  
}




Java Source Code List

com.focusings.focusingsworld.MainActivity.java
com.focusings.focusingsworld.VideoInfo.java
com.focusings.focusingsworld.ImageAndTextList.AsyncImageLoader.java
com.focusings.focusingsworld.ImageAndTextList.ImageAndTextListAdapter.java
com.focusings.focusingsworld.ImageAndTextList.ImageAndText.java
com.focusings.focusingsworld.ImageAndTextList.ShareVideoOnItemClickListener.java
com.focusings.focusingsworld.ImageAndTextList.ViewCache.java
com.focusings.focusingsworld.ImageAndTextList.ViewVideoOnItemClickListener.java
com.focusings.focusingsworld.TwitterParser.AsyncTwitterParser.java
com.focusings.focusingsworld.TwitterParser.TweetInfo.java
com.focusings.focusingsworld.TwitterParser.TweetsListAdapter.java
com.focusings.focusingsworld.TwitterParser.TwitterUtils.java
com.focusings.focusingsworld.YoutubeParser.AsyncYoutubeParser.java
com.focusings.focusingsworld.notificationManagement.AsyncNotificationResponse.java
com.focusings.focusingsworld.notificationManagement.CheckNewUpdatesServiceReceiver.java
com.focusings.focusingsworld.notificationManagement.CheckNewUpdatesService.java
com.focusings.focusingsworld.notificationManagement.Update.java
com.focusings.focusingsworld.pullToRefreshLibrary.PullToRefreshListView.java
com.focusings.focusingsworld.pullToRefreshLibrary.PullToRefreshTwitterOnRefreshListener.java
com.focusings.focusingsworld.pullToRefreshLibrary.PullToRefreshYoutubeOnRefreshListener.java
com.focusings.focusingsworld.shop.GoToStaffWebsiteOnClickListener.java