Back to project page Exif-Editor.
The source code is released under:
MIT License
If you think the Android project Exif-Editor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * @user https://github.com/Egatuts/*from w w w . jav a2 s . c om*/ * @repo https://github.com/Egatuts/Exif-Editor.git * @file https://github.com/Egatuts/Exif-Editor/blob/master/src/git/egatuts/android/FileUtils/EgaCursorLoader.java * @package git.egatuts.android.FileUtils * @license MIT (http://www.opensource.org/licenses/MIT) */ package git.egatuts.android.FileUtils; import android.app.Activity; import android.net.Uri; import android.provider.MediaStore; import android.support.v4.content.CursorLoader; /** * CursorLoader utils using Android's MediaStore. * @author Esa Garca * @author EgaTuts * @version 1.0.0 * @created 25/8/2014 at 16:13:32. */ public class EgaCursorLoader extends CursorLoader { /** * Image stream column. */ public static final String IMAGES_DATA = MediaStore.Images.ImageColumns.DATA; /** * Image ID column */ public static final String IMAGES_ID = MediaStore.Images.ImageColumns._ID; /** * Image creation date column. */ public static final String IMAGES_DATE_TAKEN = MediaStore.Images.ImageColumns.DATE_TAKEN; /** * Image stream data projection. */ public static final String[] PROJECTION_IMAGES_DATA = new String[] { IMAGES_DATA }; /** * Image ID projection. */ public static final String[] PROJECTION_IMAGES_ID = new String[] { IMAGES_ID }; /** * Selection date. */ public static final String SELECTION_DATE = "Date = ?"; /** * External content URI. */ public static final Uri EXTERNAL_CONTENT = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; /** * Internal content URI. */ public static final Uri INTERNAL_CONTENT = MediaStore.Images.Media.INTERNAL_CONTENT_URI; /** * Activity reference. */ private static Activity myActivity; /** * Source content reference. */ private Uri mySource; /** * Projection reference. */ private String[] myProjection; /** * Selection reference. */ private String mySelection; /** * Selection arguments reference. */ private String[] mySelectionArgs; /** * Sorting order reference. */ private String mySortOrder; /** * Instantiates a new EgaCursorLoader object setting up only the context. * @param activity The application Context (Activity). * @see CursorLoader */ public EgaCursorLoader (Activity activity) { super(activity); myActivity = activity; } /** * Instantiates a new EgaCursorLoader setting all properties up. * @param activity The application Context (Activity). * @param source The source content URI. * @param projection The projection. * @param selection The selection. * @param selectionArguments The selection arguments. * @param sortOrder The sorting order. * @see CursorLoader */ public EgaCursorLoader (Activity activity, Uri source, String[] projection, String selection, String[] selectionArguments, String sortOrder ) { super(activity, source, projection, selection, selectionArguments, sortOrder); myActivity = activity; mySource = source; myProjection = projection; mySelection = selection; mySelectionArgs = selectionArguments; mySortOrder = sortOrder; } /** * Syncs all private references with the active CursorLoader object. * @return The EgaCursorLoader object to allow chaining. */ public EgaCursorLoader syncParams () { myActivity = (Activity) this.getContext(); mySource = this.getUri(); myProjection = this.getProjection(); mySelection = this.getSelection(); mySelectionArgs = this.getSelectionArgs(); mySortOrder = this.getSortOrder(); return this; } /** * Gets a new EgaCursorLoader with different context. * @param newActivity The new Context (Activity). * @return The new EgaCursorLoader instance. */ public EgaCursorLoader context (Activity newActivity) { syncParams(); EgaCursorLoader newLoaderContext = new EgaCursorLoader(newActivity, mySource, myProjection, mySelection, mySelectionArgs, mySortOrder); myActivity = newActivity; return newLoaderContext; } /** * Gets the Context (Activity) of the actual EgaCursorLoader instance. * @param sync Flags if all private variables should be synced with the CursorLoader ones. * @return The Context (Activity). * @see #syncParams() */ public Activity context (boolean sync) { if (sync) syncParams(); return myActivity; } /** * Gets the CursorLoader Context (Activity) without syncing. * @return The Context (Activity). * @see #context(boolean) */ public Activity context () { return context(false); } /** * Sets the new source content. * @param newSource The new source content. * @return The EgaCursorLoader object to allow chaining. */ public EgaCursorLoader source (Uri newSource) { this.setUri(newSource); mySource = newSource; return this; } /** * Gets the source content. * @param sync Flags if all private variables should be synced with the CursorLoader ones. * @return The source content. * @see #syncParams() */ public Uri source (boolean sync) { if (sync) syncParams(); return mySource; } /** * Gets the source content without the syncing flag. * @return The source content. * @see #source(boolean) */ public Uri source () { return source(false); } /** * Sets the new projection. * @param newProjection The new projection. * @return Rhe EgaCursorLoader object to allow chaining. */ public EgaCursorLoader projection (String[] newProjection) { this.setProjection(newProjection); myProjection = newProjection; return this; } /** * Gets the EgaCursorLoader projection. * @param sync Flags if all private variables should be synced with the EgaCursorLoader ones. * @return The projection. * @see #syncParams() */ public String[] projection (boolean sync) { if (sync) syncParams(); return myProjection; } /** * Gets the EgaCursorLoader projection. * @return The projection. * @see #projection(boolean) */ public String[] projection () { return projection(false); } /** * Sets the selection condition. Like SQL WHERE clause. * @param newSelection The new selection. * @return The EgaCursorLoader object to allow chaining. */ public EgaCursorLoader selection (String newSelection) { this.setSelection(newSelection); mySelection = newSelection; return this; } /** * Gets the EgaCursorLoader selection. * @param sync Flags if the all private variables should be synced with the CursorLoader ones. * @return The selection condition. * @see #syncParams() */ public String selection (boolean sync) { if (sync) syncParams(); return mySelection; } /** * Gets the EgaCursorLoader selection without the syncing flag. * @return The selection condition. * @see #selection(boolean) */ public String selection () { return selection(false); } /** * Sets the selection arguments. * @param newArguments The new selection arguments. * @return The EgaCursorLoader to allow chaining. */ public EgaCursorLoader arguments (String[] newArguments) { this.setSelectionArgs(newArguments); mySelectionArgs = newArguments; return this; } /** * Gets the selection arguments. * @param sync Flags if all private variables should be synced with the CursorLoader ones. * @return The selection arguments. * @see #syncParams() */ public String[] arguments (boolean sync) { if (sync) syncParams(); return mySelectionArgs; } /** * Gets the selection arguments. * @return The selection arguments. * @see #arguments(boolean) */ public String[] arguments () { return arguments(false); } /** * Sets the sorting order. * @param newSorting The new sorting order. * @return The EgaCursorLoader to allow chaining. */ public EgaCursorLoader sort (String newSorting) { this.setSortOrder(newSorting); mySortOrder = newSorting; return this; } /** * Gets the sorting order. * @param sync Flags if all private variables should be synced with the CursorLoader ones. * @return The sorting order. * @see #syncParams() */ public String sort (boolean sync) { if (sync) syncParams(); return mySortOrder; } /** * Gets the sorting order. * @return The sorting order. * @see #sort(boolean) */ public String sort () { return sort(false); } }