@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // if the cursor is empty... get data from the internet if (data.getCount() > 1) { // moving cursor to first data.moveToFirst(); do { Repo repo = new Repo(); repo.setName(data.getString(COL_NAME)); repo.setOwner_name(data.getString(COL_OWNER_NAME)); repo.setOwner_url(data.getString(COL_OWNER_URL)); repo.setDescription(data.getString(COL_DESC)); repo.setRepo_url(data.getString(COL_REPO_URL)); repo.setFork(data.getInt(COL_FORK) == 0); reposArrayList.add(repo); } while (data.moveToNext()); mAdapter.notifyDataSetChanged(); } else { // show progress form showProgress(true); // get some data new GithubApiFetcher().execute("1"); } }
public Repo readMessage(JsonReader reader) throws IOException { repo = new Repo(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("name")) { repo.setName(reader.nextString()); } else if (name.equals("description")) { repo.setDescription(reader.nextString()); } else if (name.equals("owner")) { ReadOwnerMessage(reader); } else if (name.equals("html_url")) { repo.setRepo_url(reader.nextString()); } else if (name.equals("fork")) { repo.setFork(reader.nextBoolean()); } else { reader.skipValue(); } } reader.endObject(); return repo; }