Back to project page AndroidPlaces.
The source code is released under:
Apache License
If you think the Android project AndroidPlaces listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2014 Pretty Easy LLC/* w ww. j a v a2 s . c o m*/ * Author: Brian Lee */ package com.tigerpenguin.demo.places; import android.app.Activity; import android.app.ListFragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import com.tigerpenguin.places.model.Photo; import java.util.List; public class PlaceThumbnailsFragment extends ListFragment { private PlaceThumbnailAdapter thumbnailAdapter; private ThumbnailClickListener thumbnailClickListener; public interface ThumbnailClickListener { public void onThumbnailClicked(Photo photo); } @Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof ThumbnailClickListener) { thumbnailClickListener = (ThumbnailClickListener) activity; } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.place_thumbnails, container, false); thumbnailAdapter = new PlaceThumbnailAdapter(getActivity()); setListAdapter(thumbnailAdapter); return root; } @Override public void onDetach() { super.onDetach(); thumbnailClickListener = null; } public void addPhotos(List<Photo> photos) { if (photos != null) { thumbnailAdapter.addAll(photos); } } @Override public void onListItemClick(ListView listView, View view, int position, long id) { Photo selectedPhoto = thumbnailAdapter.getItem(position); if (thumbnailClickListener != null) { thumbnailClickListener.onThumbnailClicked(selectedPhoto); } } }