summaryrefslogtreecommitdiffstats
path: root/photoviewer
diff options
context:
space:
mode:
authorAndrew Sapperstein <asapperstein@google.com>2012-07-26 17:53:02 -0700
committerAndrew Sapperstein <asapperstein@google.com>2012-07-26 17:54:09 -0700
commit9ceb1b41122f649cd26234f34edc2c1cf75b2f95 (patch)
treeac4baec982e2b3e38c88025c17207c5029d800d0 /photoviewer
parentebeb8b01ee3719f86d3ad96a0f0603032efbc1dc (diff)
downloadandroid_frameworks_ex-9ceb1b41122f649cd26234f34edc2c1cf75b2f95.tar.gz
android_frameworks_ex-9ceb1b41122f649cd26234f34edc2c1cf75b2f95.tar.bz2
android_frameworks_ex-9ceb1b41122f649cd26234f34edc2c1cf75b2f95.zip
Showing a default preview photo.
If we do not have a preview and are currently waiting on a full photo, we will show a stock photo. Currently shows a grey box as we do not have assets yet. Change-Id: I155071598b20bf81b2b60bdd8ac881a64b8ee1b7
Diffstat (limited to 'photoviewer')
-rw-r--r--photoviewer/res/drawable/default_image.pngbin0 -> 504 bytes
-rw-r--r--photoviewer/res/layout/photo_fragment_view.xml7
-rw-r--r--photoviewer/src/com/android/ex/photo/PhotoViewActivity.java4
-rw-r--r--photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java20
4 files changed, 27 insertions, 4 deletions
diff --git a/photoviewer/res/drawable/default_image.png b/photoviewer/res/drawable/default_image.png
new file mode 100644
index 0000000..f6e6e60
--- /dev/null
+++ b/photoviewer/res/drawable/default_image.png
Binary files differ
diff --git a/photoviewer/res/layout/photo_fragment_view.xml b/photoviewer/res/layout/photo_fragment_view.xml
index 5839533..9430d1b 100644
--- a/photoviewer/res/layout/photo_fragment_view.xml
+++ b/photoviewer/res/layout/photo_fragment_view.xml
@@ -24,4 +24,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <ImageView
+ android:id="@+id/photo_preview_image"
+ android:layout_width="256dip"
+ android:layout_height="256dip"
+ android:layout_centerInParent="true"
+ />
+
</RelativeLayout>
diff --git a/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java b/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java
index c563c69..9c04346 100644
--- a/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java
+++ b/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java
@@ -483,4 +483,8 @@ public class PhotoViewActivity extends Activity implements
return cursor;
}
+
+ public Cursor getCursor() {
+ return (mAdapter == null) ? null : mAdapter.getCursor();
+ }
}
diff --git a/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java b/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java
index 36dd9da..b4e6cd5 100644
--- a/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java
+++ b/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java
@@ -33,6 +33,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.widget.ImageView;
import com.android.ex.photo.Intents;
import com.android.ex.photo.PhotoViewActivity;
@@ -92,6 +93,7 @@ public class PhotoViewFragment extends Fragment implements
private PhotoPagerAdapter mAdapter;
private PhotoView mPhotoView;
+ private ImageView mPhotoPreview;
private final int mPosition;
/** Whether or not the fragment should make the photo full-screen */
@@ -167,6 +169,9 @@ public class PhotoViewFragment extends Fragment implements
mPhotoView = (PhotoView) view.findViewById(R.id.photo_view);
mPhotoView.setOnClickListener(this);
mPhotoView.setFullScreen(mFullScreen, false);
+ mPhotoView.enableImageTransforms(true);
+
+ mPhotoPreview = (ImageView) view.findViewById(R.id.photo_preview_image);
// Don't call until we've setup the entire view
setViewVisibility();
@@ -244,17 +249,25 @@ public class PhotoViewFragment extends Fragment implements
bindPhoto(data);
mCallback.setViewActivated();
setViewVisibility();
+ mPhotoPreview.setVisibility(View.GONE);
break;
case LOADER_ID_THUMBNAIL:
- if (data == null || isPhotoBound()) {
+ if (isPhotoBound()) {
+ return;
+ }
+
+ if (data == null) {
+ // no preview, show default
+ mPhotoPreview.setVisibility(View.VISIBLE);
+ mPhotoPreview.setImageResource(R.drawable.default_image);
return;
}
mShowingThumbnail = true;
- bindPhoto(data);
+ mPhotoPreview.setVisibility(View.VISIBLE);
+ mPhotoPreview.setImageBitmap(data);
mCallback.setViewActivated();
setViewVisibility();
- mPhotoView.enableImageTransforms(false);
break;
default:
break;
@@ -359,7 +372,6 @@ public class PhotoViewFragment extends Fragment implements
*/
public void setFullScreen(boolean fullScreen) {
mFullScreen = fullScreen;
- mPhotoView.enableImageTransforms(true);
}
@Override