/*
* Generated by Robotoworks Mechanoid
*/
package com.robotoworks.example.ghissues.db;
import android.content.Context;
import android.content.UriMatcher;
import android.net.Uri;
import java.util.Set;
import com.robotoworks.mechanoid.db.MechanoidContentProvider;
import com.robotoworks.mechanoid.db.MechanoidSQLiteOpenHelper;
import com.robotoworks.mechanoid.db.DefaultContentProviderActions;
import com.robotoworks.mechanoid.db.ContentProviderActions;
import com.robotoworks.example.ghissues.db.AbstractGithubDBOpenHelper.Sources;
import com.robotoworks.example.ghissues.db.IssuesRecord;
public abstract class AbstractGithubDBContentProvider extends MechanoidContentProvider {
public static final int ISSUES = 0;
public static final int ISSUES_ID = 1;
public static final int NUM_URI_MATCHERS = 2;
@Override
protected UriMatcher createUriMatcher() {
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = GithubDBContract.CONTENT_AUTHORITY;
matcher.addURI(authority, "issues", ISSUES);
matcher.addURI(authority, "issues/#", ISSUES_ID);
// User Actions
return matcher;
}
@Override
protected String[] createContentTypes() {
String[] contentTypes = new String[NUM_URI_MATCHERS];
contentTypes[ISSUES] = GithubDBContract.Issues.CONTENT_TYPE;
contentTypes[ISSUES_ID] = GithubDBContract.Issues.ITEM_CONTENT_TYPE;
return contentTypes;
}
@Override
protected MechanoidSQLiteOpenHelper createOpenHelper(Context context) {
return new GithubDBOpenHelper(context);
}
@Override
protected Set<Uri> getRelatedUris(Uri uri) {
return GithubDBContract.REFERENCING_VIEWS.get(uri);
}
@Override
protected ContentProviderActions createActions(int id) {
switch(id) {
case ISSUES:
return createIssuesActions();
case ISSUES_ID:
return createIssuesByIdActions();
default:
throw new UnsupportedOperationException("Unknown id: " + id);
}
}
protected ContentProviderActions createIssuesByIdActions() {
return new DefaultContentProviderActions(Sources.ISSUES, true, IssuesRecord.getFactory());
}
protected ContentProviderActions createIssuesActions() {
return new DefaultContentProviderActions(Sources.ISSUES, false, IssuesRecord.getFactory());
}
}