From: Bobby Georgescu Date: Fri, 29 Mar 2013 22:58:42 +0000 (-0700) Subject: Preliminary Album grid header in new gallery X-Git-Tag: android-x86-6.0-r3~68^2~28^2~213^2~19^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2~428^2~2^2~201^2~116^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=559535174c8c70f12a342fe46f00647c31080383;p=android-x86%2Fpackages-apps-Camera2.git Preliminary Album grid header in new gallery Change-Id: I90942de920795aedc5475f23cc3ede459949cc16 --- diff --git a/res/drawable/white_text_bg_gradient.xml b/res/drawable/white_text_bg_gradient.xml new file mode 100644 index 000000000..c355ce52f --- /dev/null +++ b/res/drawable/white_text_bg_gradient.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/res/layout/album_content.xml b/res/layout/album_content.xml new file mode 100644 index 000000000..97509fd3e --- /dev/null +++ b/res/layout/album_content.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/album_header.xml b/res/layout/album_header.xml new file mode 100644 index 000000000..76c9a457f --- /dev/null +++ b/res/layout/album_header.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/multigrid_content.xml b/res/layout/multigrid_content.xml index 82f6519d5..b1cb145a2 100644 --- a/res/layout/multigrid_content.xml +++ b/res/layout/multigrid_content.xml @@ -1,19 +1,17 @@ - { 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 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 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. - *

- * 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