Android Open Source - lastUpdates Image And Text 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.ImageAndTextList;
//ww  w.ja va2 s .  com
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;

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.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class ImageAndTextListAdapter extends ArrayAdapter<ImageAndText>{

  private AsyncImageLoader asyncImageLoader;
  
  
    public ImageAndTextListAdapter(Activity activity, List<ImageAndText> 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.image_and_text_row, null);
        ImageAndText imageAndText = getItem(position);

        // Load the image and set it on the ImageView
        final ImageView imageView = (ImageView) rowView.findViewById(R.id.image);
        Drawable cachedImage = asyncImageLoader.loadDrawable(imageAndText.getImageUrl(), new ImageCallback() {
            public void imageLoaded(Drawable imageDrawable, String imageUrl) {
                imageView.setImageDrawable(imageDrawable);
            }
        });
        imageView.setImageDrawable(cachedImage);

        // Set the text on the TextView
        TextView textView = (TextView) rowView.findViewById(R.id.text);
        textView.setText(imageAndText.getText());
        
        //When clicking View button, go to watch Youtube video
        Button viewButton = (Button) rowView.findViewById(R.id.viewButton);
        ViewVideoOnItemClickListener v1= new ViewVideoOnItemClickListener(imageAndText.getUrl());
        viewButton.setOnClickListener(v1);
        //When clicking on the image of the video, also go to watch Youtube video
        imageView.setOnClickListener(v1);
        
        //When clicking View button, go to watch Youtube video
        Button shareButton = (Button) rowView.findViewById(R.id.shareButton);
        ShareVideoOnItemClickListener s1= new ShareVideoOnItemClickListener(imageAndText.getUrl(),imageAndText.getText());
        shareButton.setOnClickListener(s1);
        
        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