diff options
-rw-r--r-- | src/com/android/photos/AlbumActivity.java | 2 | ||||
-rw-r--r-- | src/com/android/photos/AlbumFragment.java | 33 | ||||
-rw-r--r-- | src/com/android/photos/MultiSelectGridFragment.java | 15 |
3 files changed, 35 insertions, 15 deletions
diff --git a/src/com/android/photos/AlbumActivity.java b/src/com/android/photos/AlbumActivity.java index a93ab13da..c616b998b 100644 --- a/src/com/android/photos/AlbumActivity.java +++ b/src/com/android/photos/AlbumActivity.java @@ -22,7 +22,7 @@ import android.os.Bundle; public class AlbumActivity extends Activity implements MultiChoiceManager.Provider { public static final String KEY_ALBUM_URI = AlbumFragment.KEY_ALBUM_URI; - public static final String KEY_ALBUM_TITLE = "AlbumTitle"; + public static final String KEY_ALBUM_TITLE = AlbumFragment.KEY_ALBUM_TITLE; private MultiChoiceManager mMultiChoiceManager; diff --git a/src/com/android/photos/AlbumFragment.java b/src/com/android/photos/AlbumFragment.java index e7164b616..406fd2a29 100644 --- a/src/com/android/photos/AlbumFragment.java +++ b/src/com/android/photos/AlbumFragment.java @@ -27,23 +27,30 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; +import android.widget.ImageView; +import android.widget.TextView; +import com.android.gallery3d.R; import com.android.gallery3d.app.Gallery; import com.android.photos.adapters.PhotoThumbnailAdapter; import com.android.photos.data.PhotoSetLoader; import com.android.photos.shims.LoaderCompatShim; import com.android.photos.shims.MediaItemsLoader; +import com.android.photos.views.HeaderGridView; import java.util.ArrayList; public class AlbumFragment extends MultiSelectGridFragment implements LoaderCallbacks<Cursor> { protected static final String KEY_ALBUM_URI = "AlbumUri"; + protected static final String KEY_ALBUM_TITLE = "AlbumTitle"; private static final int LOADER_ALBUM = 1; private LoaderCompatShim<Cursor> mLoaderCompatShim; private PhotoThumbnailAdapter mAdapter; private String mAlbumPath; + private String mAlbumTitle; + private View mHeaderView; @Override public void onCreate(Bundle savedInstanceState) { @@ -53,15 +60,15 @@ public class AlbumFragment extends MultiSelectGridFragment implements LoaderCall Bundle args = getArguments(); if (args != null) { mAlbumPath = args.getString(KEY_ALBUM_URI, null); + mAlbumTitle = args.getString(KEY_ALBUM_TITLE, null); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View root = super.onCreateView(inflater, container, savedInstanceState); getLoaderManager().initLoader(LOADER_ALBUM, null, this); - return root; + return inflater.inflate(R.layout.album_content, container, false); } @Override @@ -71,6 +78,27 @@ public class AlbumFragment extends MultiSelectGridFragment implements LoaderCall getGridView().setColumnWidth(MediaItemsLoader.getThumbnailSize()); } + private void updateHeaderView() { + if (mHeaderView == null) { + mHeaderView = LayoutInflater.from(getActivity()) + .inflate(R.layout.album_header, getGridView(), false); + ((HeaderGridView) getGridView()).addHeaderView(mHeaderView, null, false); + + // TODO remove this when the data model stabilizes + mHeaderView.setMinimumHeight(200); + } + ImageView iv = (ImageView) mHeaderView.findViewById(R.id.album_header_image); + TextView title = (TextView) mHeaderView.findViewById(R.id.album_header_title); + TextView subtitle = (TextView) mHeaderView.findViewById(R.id.album_header_subtitle); + title.setText(mAlbumTitle); + int count = mAdapter.getCount(); + subtitle.setText(getActivity().getResources().getQuantityString( + R.plurals.number_of_photos, count, count)); + if (count > 0) { + iv.setImageDrawable(mLoaderCompatShim.drawableForItem(mAdapter.getItem(0), null)); + } + } + @Override public void onGridItemClick(GridView g, View v, int position, long id) { if (mLoaderCompatShim == null) { @@ -97,6 +125,7 @@ public class AlbumFragment extends MultiSelectGridFragment implements LoaderCall public void onLoadFinished(Loader<Cursor> loader, Cursor data) { mAdapter.swapCursor(data); + updateHeaderView(); setAdapter(mAdapter); } diff --git a/src/com/android/photos/MultiSelectGridFragment.java b/src/com/android/photos/MultiSelectGridFragment.java index 123b55df0..dda9fe443 100644 --- a/src/com/android/photos/MultiSelectGridFragment.java +++ b/src/com/android/photos/MultiSelectGridFragment.java @@ -18,8 +18,6 @@ package com.android.photos; import android.app.Activity; import android.app.Fragment; -import android.database.Cursor; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.util.SparseBooleanArray; @@ -34,14 +32,13 @@ import android.widget.TextView; import com.android.gallery3d.R; -import java.util.ArrayList; - public abstract class MultiSelectGridFragment extends Fragment implements MultiChoiceManager.Delegate, AdapterView.OnItemClickListener { final private Handler mHandler = new Handler(); final private Runnable mRequestFocus = new Runnable() { + @Override public void run() { mGrid.focusableViewAvailable(mGrid); } @@ -66,12 +63,6 @@ public abstract class MultiSelectGridFragment extends Fragment * {@link android.R.id#grid android.R.id.list} and can optionally have a * sibling text view id {@link android.R.id#empty android.R.id.empty} that * is to be shown when the grid is empty. - * <p> - * If you are overriding this method with your own custom content, consider - * including the standard layout R.layout.multigrid_content in your layout - * file, so that you continue to retain all of the standard behavior of - * MultiSelectGridFragment. In particular, this is currently the only way to - * have the built-in indeterminate progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -275,7 +266,7 @@ public abstract class MultiSelectGridFragment extends Fragment * Get the ListAdapter associated with this activity's GridView. */ public ListAdapter getAdapter() { - return mAdapter; + return mGrid.getAdapter(); } private void ensureGrid() { @@ -330,7 +321,7 @@ public abstract class MultiSelectGridFragment extends Fragment @Override public Object getItemAtPosition(int position) { - return mAdapter.getItem(position); + return getAdapter().getItem(position); } @Override |