Android Open Source - KangarooImageSearch Image Data Adapter






From Project

Back to project page KangarooImageSearch.

License

The source code is released under:

MIT License

If you think the Android project KangarooImageSearch 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.nickrasband.kangarooimagesearchv2;
/* ww w  .  j  a v a2s.  c  om*/
import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.loopj.android.image.SmartImageView;

/**
 * This adapter is in charge of updating individual smart image views inside of the GridView
 * holding all of the image search results.
 * @author Nik Rasband
 *
 */
public class ImageDataAdapter extends ArrayAdapter<ImageData> {
  public ImageDataAdapter(Context context, ArrayList<ImageData> images) {
    super(context, R.layout.image_data_view, images); 
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
    // Get data.
    ImageData data = getItem(position);
    
    SmartImageView view = (SmartImageView)convertView;
    
    // If the convertView is null, we need to create the view for the first time,
    // otherwise, we can reuse the existing view.
    if (view == null) {
      LayoutInflater inflater = LayoutInflater.from(getContext());
      view = (SmartImageView)inflater.inflate(R.layout.image_data_view, parent, false);
    }
    else {
      view.setImageResource(android.R.color.transparent);
    }
    
    // Update the image by setting its url.
    view.setImageUrl(data.getThumbnailUrl());
    
    return view;
  }
}




Java Source Code List

com.nickrasband.kangarooimagesearchv2.EndlessScrollListener.java
com.nickrasband.kangarooimagesearchv2.FullScreenImageActivity.java
com.nickrasband.kangarooimagesearchv2.ImageDataAdapter.java
com.nickrasband.kangarooimagesearchv2.ImageData.java
com.nickrasband.kangarooimagesearchv2.ImageSearchActivity.java
com.nickrasband.kangarooimagesearchv2.SettingsActivity.java
com.nickrasband.kangarooimagesearchv2.SettingsData.java
com.nickrasband.kangarooimagesearchv2.Utils.java