Java tutorial
/* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.udacity.lego.data; import android.content.Context; import android.net.Uri; import android.support.v4.content.CursorLoader; /** * Helper for loading a list of articles or a single article. */ public class ArticleLoader extends CursorLoader { private ArticleLoader(Context context, Uri uri) { super(context, uri, Query.PROJECTION, null, null, ItemsContract.Items.DEFAULT_SORT); } public static ArticleLoader newAllArticlesInstance(Context context) { return new ArticleLoader(context, ItemsContract.Items.buildDirUri()); } public static ArticleLoader newInstanceForItemId(Context context, long itemId) { return new ArticleLoader(context, ItemsContract.Items.buildItemUri(itemId)); } public interface Query { String[] PROJECTION = { ItemsContract.Items._ID, ItemsContract.Items.TITLE, ItemsContract.Items.PUBLISHED_DATE, ItemsContract.Items.AUTHOR, ItemsContract.Items.THUMB_URL, ItemsContract.Items.PHOTO_URL, ItemsContract.Items.ASPECT_RATIO, ItemsContract.Items.BODY, ItemsContract.Items.DARK_MUTED_COLOR, ItemsContract.Items.IS_DARK }; int _ID = 0; int TITLE = 1; int PUBLISHED_DATE = 2; int AUTHOR = 3; int THUMB_URL = 4; int PHOTO_URL = 5; int ASPECT_RATIO = 6; int BODY = 7; int DARK_MUTED_COLOR = 8; int IS_DARK = 9; } }