// Path: app/src/main/java/com/murrayc/galaxyzoo/app/provider/Item.java
// public final class Item {
//     public static final String AUTHORITY =
//             "com.murrayc.galaxyzoo.app";
// 
//     /**
//      * The The content:// style URI for the list of all Items,
//      * or part of the URI for a single Item.
//      */
//     public static final Uri ITEMS_URI = Uri.parse("content://" +
//             AUTHORITY + "/" + ItemsContentProvider.URI_PART_ITEM);
// 
//     /**
//      * The URI for the list of all files,
//      * or part of the URI for a single file.
//      * Clients don't need to build a /file/ URI -
//      * they will get a /file/ URI from the Item.Columns.FILE_URI_COLUMN column
//      * in the result from a ITEMS_URI query.
//      */
//     public static final Uri FILE_URI = Uri.parse("content://" +
//             AUTHORITY + "/" + ItemsContentProvider.URI_PART_FILE);
//     public static final String ITEM_URI_PART = ItemsContentProvider.URI_PART_ITEM;
// 
//     public static final class Columns implements BaseColumns {
//         //The ID is BaseColumns._ID;
//         public static final String DONE = "done"; //Integer boolean (1 or 0)
//         public static final String UPLOADED = "uploaded"; //Integer boolean (1 or 0)
//         public static final String SUBJECT_ID = "subjectId";
//         public static final String ZOONIVERSE_ID = "zooniverseId";
//         public static final String GROUP_ID = "groupId";
//         public static final String LOCATION_STANDARD_URI_REMOTE = "locationStandardUriRemote";
//         public static final String LOCATION_STANDARD_URI = "locationStandardUri";
//         public static final String LOCATION_STANDARD_DOWNLOADED = "locationStandardDownloaded"; //Integer boolean (1 or 0)
//         public static final String LOCATION_THUMBNAIL_URI_REMOTE = "locationThumbnailUriRemote";
//         public static final String LOCATION_THUMBNAIL_URI = "locationThumbnailUri";
//         public static final String LOCATION_THUMBNAIL_DOWNLOADED = "locationThumbnailDownloaded"; //Integer boolean (1 or 0)
//         public static final String LOCATION_INVERTED_URI_REMOTE = "locationInvertedUriRemote";
//         public static final String LOCATION_INVERTED_URI = "locationInvertedUri";
//         public static final String LOCATION_INVERTED_DOWNLOADED = "locationInvertedDownloaded"; //Integer boolean (1 or 0)
//         public static final String FAVORITE = "favorite"; //Integer boolean (1 or 0)
//         public static final String DATETIME_DONE = "dateTimeDone"; //An ISO8601 string ("YYYY-MM-DD HH:MM:SS.SSS").
// 
//     }
// }


import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.murrayc.galaxyzoo.app.provider.Item;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
/*
 * Copyright (C) 2014 Murray Cumming
 *
 * This file is part of android-galaxyzoo.
 *
 * android-galaxyzoo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * android-galaxyzoo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with android-galaxyzoo.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.murrayc.galaxyzoo.app;



//TODO: Why doesn't this need a layout resource?

/**
 * A list fragment representing a list of Tables. This fragment
 * also supports tablet devices by allowing list items to be given an
 * 'activated' state upon selection. This helps indicate which item is
 * currently being viewed in a {@link ClassifyFragment}.
 * <p/>
 * Activities containing this fragment MUST implement the {@link ListFragment.Callbacks}
 * interface.
 */
public class ListFragment extends ZooFragment
        implements LoaderManager.LoaderCallbacks<Cursor> {

    // We have to hard-code the indices - we can't use getColumnIndex because the Cursor
    // (actually a SQliteDatabase cursor returned
    // from our ContentProvider) only knows about the underlying SQLite database column names,
    // not our ContentProvider's column names. That seems like a design error in the Android API.
    //TODO: Use org.apache.commons.lang.ArrayUtils.indexOf() instead?
    static final int COLUMN_INDEX_ID = 0;
    static final int COLUMN_INDEX_LOCATION_THUMBNAIL_URI = 1;
    static final int COLUMN_INDEX_LOCATION_THUMBNAIL_DOWNLOADED = 2;
    static final int COLUMN_INDEX_DONE = 3;
    static final int COLUMN_INDEX_UPLOADED = 4;
    static final int COLUMN_INDEX_FAVOURITE = 5;
    private static final int URL_LOADER = 0;

    /**
     * A dummy implementation of the {@link ListFragment.Callbacks} interface that does
     * nothing. Used only when this fragment is not attached to an activity.
     */
    private static final Callbacks sDummyCallbacks = new Callbacks() {
        @Override
        public void onItemSelected(final String itemId, final boolean done, final View sharedElementView) {
        }

        @Override
        public void navigateToNextAvailable() {
        }
    };

    /**
     * The fragment's current callback object, which is notified of list item
     * clicks.
     */
    private Callbacks mCallbacks = sDummyCallbacks;
// Path: app/src/main/java/com/murrayc/galaxyzoo/app/provider/Item.java
// public final class Item {
//     public static final String AUTHORITY =
//             "com.murrayc.galaxyzoo.app";
// 
//     /**
//      * The The content:// style URI for the list of all Items,
//      * or part of the URI for a single Item.
//      */
//     public static final Uri ITEMS_URI = Uri.parse("content://" +
//             AUTHORITY + "/" + ItemsContentProvider.URI_PART_ITEM);
// 
//     /**
//      * The URI for the list of all files,
//      * or part of the URI for a single file.
//      * Clients don't need to build a /file/ URI -
//      * they will get a /file/ URI from the Item.Columns.FILE_URI_COLUMN column
//      * in the result from a ITEMS_URI query.
//      */
//     public static final Uri FILE_URI = Uri.parse("content://" +
//             AUTHORITY + "/" + ItemsContentProvider.URI_PART_FILE);
//     public static final String ITEM_URI_PART = ItemsContentProvider.URI_PART_ITEM;
// 
//     public static final class Columns implements BaseColumns {
//         //The ID is BaseColumns._ID;
//         public static final String DONE = "done"; //Integer boolean (1 or 0)
//         public static final String UPLOADED = "uploaded"; //Integer boolean (1 or 0)
//         public static final String SUBJECT_ID = "subjectId";
//         public static final String ZOONIVERSE_ID = "zooniverseId";
//         public static final String GROUP_ID = "groupId";
//         public static final String LOCATION_STANDARD_URI_REMOTE = "locationStandardUriRemote";
//         public static final String LOCATION_STANDARD_URI = "locationStandardUri";
//         public static final String LOCATION_STANDARD_DOWNLOADED = "locationStandardDownloaded"; //Integer boolean (1 or 0)
//         public static final String LOCATION_THUMBNAIL_URI_REMOTE = "locationThumbnailUriRemote";
//         public static final String LOCATION_THUMBNAIL_URI = "locationThumbnailUri";
//         public static final String LOCATION_THUMBNAIL_DOWNLOADED = "locationThumbnailDownloaded"; //Integer boolean (1 or 0)
//         public static final String LOCATION_INVERTED_URI_REMOTE = "locationInvertedUriRemote";
//         public static final String LOCATION_INVERTED_URI = "locationInvertedUri";
//         public static final String LOCATION_INVERTED_DOWNLOADED = "locationInvertedDownloaded"; //Integer boolean (1 or 0)
//         public static final String FAVORITE = "favorite"; //Integer boolean (1 or 0)
//         public static final String DATETIME_DONE = "dateTimeDone"; //An ISO8601 string ("YYYY-MM-DD HH:MM:SS.SSS").
// 
//     }
// }


// Path: app/src/main/java/com/murrayc/galaxyzoo/app/ListFragment.java
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.murrayc.galaxyzoo.app.provider.Item;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

/*
 * Copyright (C) 2014 Murray Cumming
 *
 * This file is part of android-galaxyzoo.
 *
 * android-galaxyzoo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * android-galaxyzoo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with android-galaxyzoo.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.murrayc.galaxyzoo.app;



//TODO: Why doesn't this need a layout resource?

/**
 * A list fragment representing a list of Tables. This fragment
 * also supports tablet devices by allowing list items to be given an
 * 'activated' state upon selection. This helps indicate which item is
 * currently being viewed in a {@link ClassifyFragment}.
 * <p/>
 * Activities containing this fragment MUST implement the {@link ListFragment.Callbacks}
 * interface.
 */
public class ListFragment extends ZooFragment
        implements LoaderManager.LoaderCallbacks<Cursor> {

    // We have to hard-code the indices - we can't use getColumnIndex because the Cursor
    // (actually a SQliteDatabase cursor returned
    // from our ContentProvider) only knows about the underlying SQLite database column names,
    // not our ContentProvider's column names. That seems like a design error in the Android API.
    //TODO: Use org.apache.commons.lang.ArrayUtils.indexOf() instead?
    static final int COLUMN_INDEX_ID = 0;
    static final int COLUMN_INDEX_LOCATION_THUMBNAIL_URI = 1;
    static final int COLUMN_INDEX_LOCATION_THUMBNAIL_DOWNLOADED = 2;
    static final int COLUMN_INDEX_DONE = 3;
    static final int COLUMN_INDEX_UPLOADED = 4;
    static final int COLUMN_INDEX_FAVOURITE = 5;
    private static final int URL_LOADER = 0;

    /**
     * A dummy implementation of the {@link ListFragment.Callbacks} interface that does
     * nothing. Used only when this fragment is not attached to an activity.
     */
    private static final Callbacks sDummyCallbacks = new Callbacks() {
        @Override
        public void onItemSelected(final String itemId, final boolean done, final View sharedElementView) {
        }

        @Override
        public void navigateToNextAvailable() {
        }
    };

    /**
     * The fragment's current callback object, which is notified of list item
     * clicks.
     */
    private Callbacks mCallbacks = sDummyCallbacks;
    private final String[] mColumns = {Item.Columns._ID,