FileDocCategorySizeDatePackage
PhotoPagerAdapter.javaAPI DocAndroid 5.1 API4476Thu Mar 12 22:22:52 GMT 2015com.android.ex.photo.adapters

PhotoPagerAdapter

public class PhotoPagerAdapter extends BaseCursorPagerAdapter
Pager adapter for the photo view

Fields Summary
protected android.support.v4.util.SimpleArrayMap
mColumnIndices
protected final float
mMaxScale
protected boolean
mDisplayThumbsFullScreen
Constructors Summary
public PhotoPagerAdapter(android.content.Context context, android.support.v4.app.FragmentManager fm, android.database.Cursor c, float maxScale, boolean thumbsFullScreen)


     
                 
                
        super(context, fm, c);
        mMaxScale = maxScale;
        mDisplayThumbsFullScreen = thumbsFullScreen;
    
Methods Summary
protected com.android.ex.photo.fragments.PhotoViewFragmentcreatePhotoViewFragment(android.content.Intent intent, int position, boolean onlyShowSpinner)

        return PhotoViewFragment.newInstance(intent, position, onlyShowSpinner);
    
public java.lang.StringgetContentType(android.database.Cursor cursor)

        return getString(cursor, PhotoViewColumns.CONTENT_TYPE);
    
public android.support.v4.app.FragmentgetItem(android.content.Context context, android.database.Cursor cursor, int position)

        final String photoUri = getPhotoUri(cursor);
        final String thumbnailUri = getThumbnailUri(cursor);
        boolean loading = shouldShowLoadingIndicator(cursor);
        boolean onlyShowSpinner = false;
        if(photoUri == null && loading) {
            onlyShowSpinner = true;
        }

        // create new PhotoViewFragment
        final PhotoViewIntentBuilder builder =
                Intents.newPhotoViewFragmentIntentBuilder(mContext, getPhotoViewFragmentClass());
        builder
            .setResolvedPhotoUri(photoUri)
            .setThumbnailUri(thumbnailUri)
            .setDisplayThumbsFullScreen(mDisplayThumbsFullScreen)
            .setMaxInitialScale(mMaxScale);

        return createPhotoViewFragment(builder.build(), position, onlyShowSpinner);
    
public java.lang.StringgetPhotoUri(android.database.Cursor cursor)

        return getString(cursor, PhotoViewColumns.CONTENT_URI);
    
protected java.lang.ClassgetPhotoViewFragmentClass()

        return PhotoViewFragment.class;
    
private java.lang.StringgetString(android.database.Cursor cursor, java.lang.String column)

        if (mColumnIndices.containsKey(column)) {
            return cursor.getString(mColumnIndices.get(column));
        } else {
            return null;
        }
    
public java.lang.StringgetThumbnailUri(android.database.Cursor cursor)

        return getString(cursor, PhotoViewColumns.THUMBNAIL_URI);
    
public booleanshouldShowLoadingIndicator(android.database.Cursor cursor)

        String value = getString(cursor, PhotoViewColumns.LOADING_INDICATOR);
        if (value == null) {
            return false;
        } else {
            return Boolean.valueOf(value);
        }
    
public android.database.CursorswapCursor(android.database.Cursor newCursor)

        mColumnIndices.clear();

        if (newCursor != null) {
            for(String column : PhotoQuery.PROJECTION) {
                mColumnIndices.put(column, newCursor.getColumnIndexOrThrow(column));
            }

            for(String column : PhotoQuery.OPTIONAL_COLUMNS) {
                int index = newCursor.getColumnIndex(column);
                if (index != -1) {
                    mColumnIndices.put(column, index);
                }
            }
        }

        return super.swapCursor(newCursor);