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 */ onFullScreenChanged(boolean fullScreen)26 public void onFullScreenChanged(boolean fullScreen); 27 28 /** 29 * A new view has been activated and the previous view de-activated. 30 */ onViewActivated()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 */ onViewUpNext()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 */ onInterceptMoveLeft(float origX, float origY)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 */ onInterceptMoveRight(float origX, float origY)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 */ onCursorChanged(Cursor cursor)67 public void onCursorChanged(Cursor cursor); 68 } 69 addScreenListener(int position, OnScreenListener listener)70 public void addScreenListener(int position, OnScreenListener listener); 71 removeScreenListener(int position)72 public void removeScreenListener(int position); 73 addCursorListener(CursorChangedListener listener)74 public void addCursorListener(CursorChangedListener listener); 75 removeCursorListener(CursorChangedListener listener)76 public void removeCursorListener(CursorChangedListener listener); 77 setViewActivated(int position)78 public void setViewActivated(int position); 79 onNewPhotoLoaded(int position)80 public void onNewPhotoLoaded(int position); 81 onFragmentPhotoLoadComplete(PhotoViewFragment fragment, boolean success)82 public void onFragmentPhotoLoadComplete(PhotoViewFragment fragment, 83 boolean success); 84 toggleFullScreen()85 public void toggleFullScreen(); 86 isFragmentActive(Fragment fragment)87 public boolean isFragmentActive(Fragment fragment); 88 onFragmentVisible(PhotoViewFragment fragment)89 public void onFragmentVisible(PhotoViewFragment fragment); 90 isFragmentFullScreen(Fragment fragment)91 public boolean isFragmentFullScreen(Fragment fragment); 92 onCursorChanged(PhotoViewFragment fragment, Cursor cursor)93 public void onCursorChanged(PhotoViewFragment fragment, Cursor cursor); 94 onCreateBitmapLoader(int id, Bundle args, String uri)95 public Loader<BitmapResult> onCreateBitmapLoader(int id, Bundle args, String uri); 96 97 /** 98 * Returns the adapter associated with this activity. 99 */ getAdapter()100 public PhotoPagerAdapter getAdapter(); 101 } 102