1 package com.android.ex.photo; 2 3 import android.database.Cursor; 4 import android.os.Bundle; 5 import android.support.v4.app.Fragment; 6 import android.support.v4.content.Loader; 7 8 import com.android.ex.photo.adapters.PhotoPagerAdapter; 9 import com.android.ex.photo.fragments.PhotoViewFragment; 10 import com.android.ex.photo.loaders.PhotoBitmapLoaderInterface.BitmapResult; 11 12 public interface PhotoViewCallbacks { 13 14 public static final int BITMAP_LOADER_AVATAR = 1; 15 public static final int BITMAP_LOADER_THUMBNAIL = 2; 16 public static final int BITMAP_LOADER_PHOTO = 3; 17 18 /** 19 * Listener to be invoked for screen events. 20 */ 21 public static interface OnScreenListener { 22 23 /** 24 * The full screen state has changed. 25 */ 26 public void onFullScreenChanged(boolean fullScreen); 27 28 /** 29 * A new view has been activated and the previous view de-activated. 30 */ 31 public void onViewActivated(); 32 33 /** 34 * This view is a candidate for being the next view. 35 * 36 * This will be called when the view is focused completely on the view immediately before 37 * or after this one, so that this view can reset itself if nessecary. 38 */ 39 public void onViewUpNext(); 40 41 /** 42 * Called when a right-to-left touch move intercept is about to occur. 43 * 44 * @param origX the raw x coordinate of the initial touch 45 * @param origY the raw y coordinate of the initial touch 46 * @return {@code true} if the touch should be intercepted. 47 */ 48 public boolean onInterceptMoveLeft(float origX, float origY); 49 50 /** 51 * Called when a left-to-right touch move intercept is about to occur. 52 * 53 * @param origX the raw x coordinate of the initial touch 54 * @param origY the raw y coordinate of the initial touch 55 * @return {@code true} if the touch should be intercepted. 56 */ 57 public boolean onInterceptMoveRight(float origX, float origY); 58 } 59 60 public static interface CursorChangedListener { 61 /** 62 * Called when the cursor that contains the photo list data 63 * is updated. Note that there is no guarantee that the cursor 64 * will be at the proper position. 65 * @param cursor the cursor containing the photo list data 66 */ 67 public void onCursorChanged(Cursor cursor); 68 } 69 70 public void addScreenListener(int position, OnScreenListener listener); 71 72 public void removeScreenListener(int position); 73 74 public void addCursorListener(CursorChangedListener listener); 75 76 public void removeCursorListener(CursorChangedListener listener); 77 78 public void setViewActivated(int position); 79 80 public void onNewPhotoLoaded(int position); 81 82 public void onFragmentPhotoLoadComplete(PhotoViewFragment fragment, 83 boolean success); 84 85 public void toggleFullScreen(); 86 87 public boolean isFragmentActive(Fragment fragment); 88 89 public void onFragmentVisible(PhotoViewFragment fragment); 90 91 public boolean isFragmentFullScreen(Fragment fragment); 92 93 public void onCursorChanged(PhotoViewFragment fragment, Cursor cursor); 94 95 public Loader<BitmapResult> onCreateBitmapLoader(int id, Bundle args, String uri); 96 97 /** 98 * Returns the adapter associated with this activity. 99 */ 100 public PhotoPagerAdapter getAdapter(); 101 } 102