Android Open Source - dejalist Dejalist Contract






From Project

Back to project page dejalist.

License

The source code is released under:

Apache License

If you think the Android project dejalist listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.luboganev.dejalist.data;
//  w w w  .j  av a2  s.c  o  m
import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;

public class DejalistContract {

    interface ProductColumns {
      String PRODUCT_NAME = "name";
      String PRODUCT_URI = "uri";
      String PRODUCT_INLIST = "inlist";
      String PRODUCT_CHECKED = "checked";
      String PRODUCT_CATEGORY_ID = "categoryId";
      String PRODUCT_USED_COUNT = "usedCount";
      String PRODUCT_LAST_USED = "lastUsed";
      String PRODUCT_DELETED = "deleted";
    }
    
    interface CategoryColumns {
      String CATEGORY_NAME = "name";
      String CATEGORY_COLOR = "color";
    }
    
    public static final String CONTENT_AUTHORITY = "com.luboganev.dejalist";

    public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
    
    public static final String PATH_PRODUCTS = "products";
    public static final String PATH_CATEGORIES = "categories";
    public static final String PATH_CATEGORY = "category";
    
    
    public static class Products implements BaseColumns, ProductColumns {
        public static final Uri CONTENT_URI =
                BASE_CONTENT_URI.buildUpon().appendPath(PATH_PRODUCTS).build();
        
        public static final Uri CATEGORY_CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_PRODUCTS).appendPath(PATH_CATEGORY).build();
        
      // default value for no category
      public static final long PRODUCT_CATEGORY_NONE_ID = -1L;
        
        public static final String CONTENT_TYPE =
                "vnd.android.cursor.dir/vnd.dejalist.product";
        public static final String CONTENT_ITEM_TYPE =
                "vnd.android.cursor.item/vnd.dejalist.product";
        
        /** Build {@link Uri} for requested {@link #_ID}. */
        public static Uri buildProductUri(long productId) {
          return ContentUris.withAppendedId(CONTENT_URI, productId);
        }
        
        /** Read {@link #_ID} built with {@link #buildProductUri(long)}. */
        public static long getProductId(Uri uri) {
          return Long.parseLong(uri.getPathSegments().get(1));
        }
        
        /** Build {@link Uri} for all {@link Products} with the requested {@link #PRODUCT_CATEGORY_ID}. */
        public static Uri buildCategoryProductsUri(long categoryId) {
          return ContentUris.withAppendedId(CATEGORY_CONTENT_URI, categoryId);
        }
        
        /** Read {@link #PRODUCT_CATEGORY_ID} built with {@link #buildCategoryProductsUri(long)}. */
        public static long getCategoryProductsId(Uri uri) {
          return Long.parseLong(uri.getPathSegments().get(2));
        }
        
        /** Used to fetch {@link Products} that are contained in the shopping list */
        public static final String SELECTION_NO_CATEGORY = PRODUCT_CATEGORY_ID + " == " + PRODUCT_CATEGORY_NONE_ID;
        
        /** Used to fetch {@link Products} that are contained in the shopping list */
        public static final String SELECTION_IN_LIST = PRODUCT_INLIST + " == 1";
        
        /** Used to fetch {@link Products} that are <b>NOT</b> contained in the shopping list */
        public static final String SELECTION_NOT_IN_LIST = PRODUCT_INLIST + " == 0";
        
        /** Used to fetch {@link Products} that are checked in the shopping list */
        public static final String SELECTION_CHECKED = PRODUCT_CHECKED + " == 1";
        
        /** Used to fetch {@link Products} that are <b>NOT</b> checked in the shopping list */
        public static final String SELECTION_NOT_CHECKED = PRODUCT_CHECKED + " == 0";
        
        /** Used to fetch {@link Products} that are marked as deleted */
        public static final String SELECTION_DELETED = PRODUCT_DELETED + " == 1";
        
        /** Used to fetch {@link Products} that are <b>NOT</b> marked as deleted */
        public static final String SELECTION_NOT_DELETED = PRODUCT_DELETED + " == 0";
        
      /** Used to fetch {@link Products} with a particular name */
        public static final String SELECTION_NAME = PRODUCT_NAME + " = ?";
        
        /** Builds a selection arguments for {@link #SELECTION_NAME} */
        public static final String[] buildNameSelectionArgs(String name) {
          return new String[]{name};
        }
        
        /** Used to fetch {@link Products} with a particular category id */
        public static final String SELECTION_CATEGORY_ID = PRODUCT_CATEGORY_ID + " = ?";
        
        /** Builds a selection arguments for {@link #SELECTION_CATEGORY_ID} */
        public static final String[] buildCategoryIdSelectionArgs(long categoryId) {
          return new String[]{String.valueOf(categoryId)};
        }
        
        /**
         * Builds a selection string of type WHERE _ID IN (...)
         * 
         * @param productIds
         *     The ids of the products
         * @return
         *     The selection string
         */
        public static final String buildSelectionIdIn(long[] productIds) {
          if(productIds.length <= 0) return null;
          StringBuilder selection = new StringBuilder();
          selection.append(_ID).append(" IN (" + productIds[0]);
          for (int i = 1; i < productIds.length; i++) {
            selection.append(", ").append(productIds[i]);
      }
          selection.append(")");
          return selection.toString();
        }
        
        public static final String ORDER_NAME_ASC = PRODUCT_NAME;
        public static final String ORDER_LAST_USED_DESC = PRODUCT_LAST_USED +" DESC";
        public static final String ORDER_USEDCOUNT_DESC = PRODUCT_USED_COUNT +" DESC";
        
        public static final String ORDER_CATEGORY = PRODUCT_CATEGORY_ID;
        public static final String ORDER_CHECKED = PRODUCT_CHECKED;
    }
    
    public static class Categories implements BaseColumns, CategoryColumns {
      public static final Uri CONTENT_URI =
          BASE_CONTENT_URI.buildUpon().appendPath(PATH_CATEGORIES).build();
      
      public static final String CONTENT_TYPE =
          "vnd.android.cursor.dir/vnd.dejalist.category";
      public static final String CONTENT_ITEM_TYPE =
          "vnd.android.cursor.item/vnd.dejalist.category";
      
      /** Build {@link Uri} for requested {@link #_ID}. */
      public static Uri buildCategoryUri(long categoryId) {
        return ContentUris.withAppendedId(CONTENT_URI, categoryId);
      }
      
      /** Read {@link #_ID} from {@link Categories} {@link Uri}. */
      public static long getCategoryId(Uri uri) {
        return Long.parseLong(uri.getPathSegments().get(1));
      }
      
      /** Used to fetch {@link Categories} with a particular name */
        public static final String SELECTION_NAME = CATEGORY_NAME + " = ?";
        
        /** Builds a selection arguments for {@link #SELECTION_NAME} */
        public static final String[] buildNameSelectionArgs(String name) {
          return new String[]{name};
        }
        
        /** Used to fetch {@link Categories} with a particular color */
        public static final String SELECTION_COLOR = CATEGORY_COLOR + " = ?";
        
        /** Builds a selection arguments for {@link #SELECTION_COLOR} */
        public static final String[] buildColorSelectionArgs(int color) {
          return new String[]{String.valueOf(color)};
        }
    }
    
//    private static final String DO_NOT_SYNC = "do_not_sync";
//    
//    public static Uri addDoNotSyncAdapterParameter(Uri uri) {
//        return uri.buildUpon().appendQueryParameter(
//            DO_NOT_SYNC, "true").build();
//    }
//
//    public static boolean hasDoNotSyncAdapterParameter(Uri uri) {
//        return TextUtils.equals("true",
//                uri.getQueryParameter(DO_NOT_SYNC));
//    }
}




Java Source Code List

com.larswerkman.colorpicker.ColorPicker.java
com.larswerkman.colorpicker.OpacityBar.java
com.larswerkman.colorpicker.SVBar.java
com.larswerkman.colorpicker.SaturationBar.java
com.larswerkman.colorpicker.ValueBar.java
com.luboganev.dejalist.Utils.java
com.luboganev.dejalist.crop.CropActivity.java
com.luboganev.dejalist.crop.CropDialogSave.java
com.luboganev.dejalist.crop.CropHighlightView.java
com.luboganev.dejalist.crop.CropUtils.java
com.luboganev.dejalist.crop.CropView.java
com.luboganev.dejalist.crop.ImageViewTouchBase.java
com.luboganev.dejalist.crop.RotateBitmap.java
com.luboganev.dejalist.data.BackupIntentService.java
com.luboganev.dejalist.data.CacheManager.java
com.luboganev.dejalist.data.DejalistContract.java
com.luboganev.dejalist.data.DejalistDatabase.java
com.luboganev.dejalist.data.DejalistProvider.java
com.luboganev.dejalist.data.ProductImageFileHelper.java
com.luboganev.dejalist.data.SelectionBuilder.java
com.luboganev.dejalist.data.entities.Category.java
com.luboganev.dejalist.data.entities.Product.java
com.luboganev.dejalist.ui.AboutActivity.java
com.luboganev.dejalist.ui.CategoriesListCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.CategoriesListCursorAdapter.java
com.luboganev.dejalist.ui.CategoryDialogFragment$$ViewInjector.java
com.luboganev.dejalist.ui.CategoryDialogFragment.java
com.luboganev.dejalist.ui.CheckableRelativeLayout.java
com.luboganev.dejalist.ui.ChecklistActionTaker.java
com.luboganev.dejalist.ui.ChecklistController.java
com.luboganev.dejalist.ui.ChecklistCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.ChecklistCursorAdapter.java
com.luboganev.dejalist.ui.ChecklistFragment$$ViewInjector.java
com.luboganev.dejalist.ui.ChecklistFragment.java
com.luboganev.dejalist.ui.ConfirmBackResDialogFragment.java
com.luboganev.dejalist.ui.MainActivity$$ViewInjector.java
com.luboganev.dejalist.ui.MainActivity.java
com.luboganev.dejalist.ui.NavigationCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.NavigationCursorAdapter.java
com.luboganev.dejalist.ui.ProductActivity$$ViewInjector.java
com.luboganev.dejalist.ui.ProductActivity.java
com.luboganev.dejalist.ui.ProductsGalleryActionTaker.java
com.luboganev.dejalist.ui.ProductsGalleryController.java
com.luboganev.dejalist.ui.ProductsGalleryCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.ProductsGalleryCursorAdapter.java
com.luboganev.dejalist.ui.ProductsGalleryFragment$$ViewInjector.java
com.luboganev.dejalist.ui.ProductsGalleryFragment.java
com.luboganev.dejalist.ui.SetProductsCategoryDialogFragment.java
com.luboganev.dejalist.ui.UndoBarController.java