Skip to content

Commit

Permalink
Add support for sync'ing and dynamically viewing all schema in a migr…
Browse files Browse the repository at this point in the history
…ate service.
  • Loading branch information
ldornin committed Jan 24, 2014
1 parent 87d49f6 commit a1f2df7
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import net.migrate.api.SchemaManager;
import net.migrate.api.WebData;

public class SchemasActivity extends Activity
implements LoaderManager.LoaderCallbacks<Cursor>
implements LoaderManager.LoaderCallbacks<Cursor>
{
public static final String TAG = "SCHEMAS";

Expand Down Expand Up @@ -57,7 +58,16 @@ public void onItemClick(AdapterView<?> l, View v, int p, long id) {
}
});

getLoaderManager().initLoader(MigrateBrowserApplication.SCHEMAS_LOADER_ID, null, this);
SchemaManager adminManager = new SchemaManager(this, "*", "userNotSupportedYet",
new SchemaManager.SchemaLoaderListener() {
@Override
public void onSchemaLoaded(String s, boolean b) {
}
}, true);
adminManager.initSchema();

getLoaderManager().initLoader(MigrateBrowserApplication.SCHEMAS_LOADER_ID, null,
SchemasActivity.this);
}

void showDetails(int pos) {
Expand All @@ -81,7 +91,8 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
Log.d(TAG, "Creating all schemas loader: " + WebData.Schema.ADMIN_SCHEMA_CONTENT_URI);
return new CursorLoader(
this,
WebData.Schema.ADMIN_SCHEMA_CONTENT_URI,
WebData.Schema.SCHEMA_CONTENT_URI,
// WebData.Schema.ADMIN_SCHEMA_CONTENT_URI,
PROJ,
null,
null,
Expand All @@ -92,7 +103,11 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
// getting a null pointer exception here

Log.d(TAG, "Content loaded: " + cursor.getCount());
if (cursor == null) {
Log.d(TAG, "Content loaded: null");
} else {
Log.d(TAG, "Content loaded: " + cursor.getCount());
}
listAdapter.swapCursor(cursor);
}

Expand Down

0 comments on commit a1f2df7

Please sign in to comment.