Android Open Source - disconnected-content-explorer-android Custom Grid






From Project

Back to project page disconnected-content-explorer-android.

License

The source code is released under:

MIT License

If you think the Android project disconnected-content-explorer-android 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 mil.nga.dice.gridview;
//from   ww  w.  jav  a  2 s. co m
import java.io.File;
import java.util.List;

import mil.nga.dice.R;
import mil.nga.dice.report.Report;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomGrid extends BaseAdapter {

  private List<Report> mReports;
  private static LayoutInflater inflater = null;
  
  public CustomGrid(Activity activity, List<Report> reports) {
    this.mReports = reports;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  
  
  @Override
  public int getCount() {
    return mReports.size();
  }

  
  @Override
  public Object getItem(int position) {
    return mReports.get(position);
  }

  
  @Override
  public long getItemId(int position) {
    return position;
  }


  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view;
    
    if (convertView != null) {
       view = convertView;
    }
    else {
      view = inflater.inflate(R.layout.grid_item, null, false);
    }
    
    ImageView tileThumbnail = (ImageView) view.findViewById(R.id.tileThumbnail);
    TextView title = (TextView) view.findViewById(R.id.title);

    Report report = mReports.get(position);
    title.setText(report.getTitle());

    if (report.getThumbnail() != null) {
      File image = new File(report.getPath(), report.getThumbnail());
      if (image.exists()) {
        Bitmap bitmap = BitmapFactory.decodeFile(image.getAbsolutePath());
        tileThumbnail.setImageBitmap(bitmap);
      }
    }
    else {
      tileThumbnail.setImageBitmap(null);
    }

    return view;
  }
}




Java Source Code List

mil.nga.dice.DICE.java
mil.nga.dice.gridview.CustomGrid.java
mil.nga.dice.gridview.ReportGridActivity.java
mil.nga.dice.gridview.ReportGridFragment.java
mil.nga.dice.jackson.deserializer.Deserializer.java
mil.nga.dice.jackson.deserializer.FeatureDeserializer.java
mil.nga.dice.jackson.deserializer.GeometryDeserializer.java
mil.nga.dice.listview.CustomList.java
mil.nga.dice.listview.ReportListActivity.java
mil.nga.dice.listview.ReportListFragment.java
mil.nga.dice.listview.ReportListItem.java
mil.nga.dice.map.BackgroundTileProvider.java
mil.nga.dice.map.OfflineMapLoader.java
mil.nga.dice.map.OfflineMap.java
mil.nga.dice.map.ReportMapActivity.java
mil.nga.dice.map.ReportMapFragment.java
mil.nga.dice.report.NoteActivity.java
mil.nga.dice.report.NoteFragment.java
mil.nga.dice.report.ReportDetailActivity.java
mil.nga.dice.report.ReportDetailFragment.java
mil.nga.dice.report.ReportDropbox.java
mil.nga.dice.report.ReportManager.java
mil.nga.dice.report.ReportUnzipRunnable.java
mil.nga.dice.report.Report.java