List of usage examples for android.support.v4.content Loader getId
public int getId()
From source file:org.sufficientlysecure.keychain.ui.CertifyKeyActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { switch (loader.getId()) { case LOADER_ID_KEYRING: // the first key here is our master key if (data.moveToFirst()) { // TODO: put findViewById in onCreate! mPubKeyId = data.getLong(INDEX_MASTER_KEY_ID); String keyIdStr = PgpKeyHelper.convertKeyIdToHex(mPubKeyId); ((TextView) findViewById(R.id.key_id)).setText(keyIdStr); String mainUserId = data.getString(INDEX_USER_ID); ((TextView) findViewById(R.id.main_user_id)).setText(mainUserId); byte[] fingerprintBlob = data.getBlob(INDEX_FINGERPRINT); String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); ((TextView) findViewById(R.id.view_key_fingerprint)) .setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); }/*ww w.j av a 2 s .c o m*/ break; case LOADER_ID_USER_IDS: mUserIdsAdapter.swapCursor(data); break; } }
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { switch (loader.getId()) { case LOADER_ID_SHIFT: if (mHasLoadedShift) return; else/*from w ww . jav a 2s .c o m*/ mHasLoadedShift = true; break; case LOADER_ID_NAMES: mNameAdapter.swapCursor(cursor); break; } }
From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvSubkeysFragment.java
public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Avoid NullPointerExceptions, if we get an empty result set. if (data.getCount() == 0) { return;//from w w w .ja v a 2 s . co m } switch (loader.getId()) { case LOADER_ID_UNIFIED: { data.moveToFirst(); mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID); mHasSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; mFingerprint = data.getBlob(INDEX_FINGERPRINT); break; } case LOADER_ID_SUBKEYS: { // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) mSubkeysAdapter.swapCursor(data); // TODO: maybe show not before both are loaded! setContentShown(true); break; } } }
From source file:com.stockbrowser.BookmarksPageCallbacks.java
@Override public void onLoaderReset(Loader<Cursor> loader) { if (loader.getId() >= LOADER_BOOKMARKS) { BrowserBookmarksAdapter adapter = mBookmarkAdapters.get(loader.getId()); adapter.changeCursor(null);// w w w.j a v a2 s . c om } }
From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Avoid NullPointerExceptions... if (data == null || data.getCount() == 0) { return;// www . j av a 2 s . c o m } // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) switch (loader.getId()) { case LOADER_ID_UNIFIED: { if (data.moveToFirst()) { // get name, email, and comment from USER_ID OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID)); if (mainUserId.name != null) { setTitle(mainUserId.name); } else { setTitle(R.string.user_id_no_name); } byte[] fingerprint = data.getBlob(INDEX_FINGERPRINT); // get key id from MASTER_KEY_ID long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID); String formattedKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(masterKeyId); getSupportActionBar().setSubtitle(formattedKeyId); mHasSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; boolean isExpired = data.getInt(INDEX_IS_EXPIRED) != 0; boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; // Note: order is important int color; if (isRevoked || isExpired) { color = getResources().getColor(R.color.key_flag_red); } else if (mHasSecret) { color = getResources().getColor(R.color.android_green_light); } else { if (isVerified) { color = getResources().getColor(R.color.android_green_light); } else { color = getResources().getColor(R.color.key_flag_orange); } } mToolbar.setBackgroundColor(color); mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color)); mSlidingTabLayout.setBackgroundColor(color); break; } } } }
From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvancedFragment.java
public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Avoid NullPointerExceptions, if we get an empty result set. if (data.getCount() == 0) { return;// w w w .j a v a 2 s . c om } // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) switch (loader.getId()) { case LOADER_SUBKEYS: mSubkeysAdapter.swapCursor(data); break; case LOADER_CERTS: mCertsAdapter.swapCursor(data); mStickyList.setAdapter(mCertsAdapter); break; } // TODO: maybe show not before both are loaded! setContentShown(true); }
From source file:org.voidsink.anewjkuapp.fragment.CalendarFragment2.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { ArrayList<WeekViewEvent> events = mWeekViewLoader.getEvents(loader.getId()); events.clear();/* w w w .j a va 2s . c o m*/ Account mAccount = AppUtils.getAccount(getContext()); if (mAccount != null) { // fetch calendar colors final SparseIntArray mColors = new SparseIntArray(); ContentResolver cr = getContext().getContentResolver(); Cursor cursor = cr.query(CalendarContractWrapper.Calendars.CONTENT_URI(), new String[] { CalendarContractWrapper.Calendars._ID(), CalendarContractWrapper.Calendars.CALENDAR_COLOR() }, null, null, null); if (cursor != null) { while (cursor.moveToNext()) { int color = cursor.getInt(1); double lastContrast = ColorUtils.calculateContrast(color, mWeekView.getEventTextColor()); //Log.d(TAG, String.format("color=%d %d %d, contrast=%f", Color.red(color), Color.green(color), Color.blue(color), lastContrast)); while (lastContrast < 1.6) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] = Math.max(0f, hsv[2] - 0.033f); // darken color = Color.HSVToColor(hsv); lastContrast = ColorUtils.calculateContrast(color, mWeekView.getEventTextColor()); //Log.d(TAG, String.format("new color=%d %d %d, contrast=%f", Color.red(color), Color.green(color), Color.blue(color), lastContrast)); if (hsv[2] == 0) break; } mColors.put(cursor.getInt(0), color); } cursor.close(); } if (data != null) { data.moveToFirst(); data.moveToPrevious(); while (data.moveToNext()) { boolean allDay = data.getInt(CalendarUtils.COLUMN_EVENT_ALL_DAY) == 1; Calendar startTime = Calendar.getInstance(); if (allDay) { startTime.setTimeZone(TimeZone.getTimeZone("UTC")); } startTime.setTimeInMillis(data.getLong(CalendarUtils.COLUMN_EVENT_DTSTART)); Calendar endTime = Calendar.getInstance(); if (allDay) { endTime.setTimeZone(TimeZone.getTimeZone("UTC")); } endTime.setTimeInMillis(data.getLong(CalendarUtils.COLUMN_EVENT_DTEND)); if (allDay && endTime.getTimeInMillis() % DateUtils.DAY_IN_MILLIS == 0) { endTime.add(Calendar.MILLISECOND, -1); } WeekViewEvent event = new WeekViewEvent(data.getLong(CalendarUtils.COLUMN_EVENT_ID), data.getString(CalendarUtils.COLUMN_EVENT_TITLE), data.getString(CalendarUtils.COLUMN_EVENT_LOCATION), startTime, endTime, allDay); event.setColor(mColors.get(data.getInt(CalendarUtils.COLUMN_EVENT_CAL_ID))); events.add(event); } } } mWeekView.notifyDatasetChanged(); }
From source file:org.xbmc.kore.ui.TVShowEpisodeListFragment.java
/** {@inheritDoc} */ @Override/* w w w . j a va 2s .c o m*/ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { switch (cursorLoader.getId()) { case LOADER_SEASONS: adapter.setGroupCursor(cursor); setState(cursor); // To prevent the empty text from appearing on the first load, set it now emptyView.setText(getString(R.string.no_episodes_found)); break; default: // Check if the group cursor is set before setting the children cursor // Somehow, when popping the back stack, the children cursor are reloaded first... if (adapter.getCursor() != null) { int id = cursorLoader.getId(); adapter.setChildrenCursor(id, cursor); childCursorsLoading.remove(id); if (isReturning && childCursorsLoading.isEmpty()) { isReturning = false; //All previous expanded child cursors loaded. Now we can finally restore the list position seasonsEpisodesListView.setSelectionFromTop(listPosition, itemPosition); } } break; } }
From source file:org.sufficientlysecure.keychain.ui.CertifyFingerprintFragment.java
public void onLoadFinished(Loader<Cursor> loader, Cursor data) { /* TODO better error handling? May cause problems when a key is deleted, * because the notification triggers faster than the activity closes. *///w ww . j a v a 2 s . c o m // Avoid NullPointerExceptions... if (data.getCount() == 0) { return; } // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) switch (loader.getId()) { case LOADER_ID_UNIFIED: { if (data.moveToFirst()) { byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); if (mEnablePhrasesConfirm) { displayWordConfirm(fingerprintBlob); } else { displayHexConfirm(fingerprintBlob); } break; } } } setContentShown(true); }
From source file:com.syncedsynapse.kore2.ui.TVShowEpisodeListFragment.java
/** {@inheritDoc} */ @Override/* w ww. j av a 2s . c o m*/ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { LogUtils.LOGD(TAG, "onLoadFinished, Loader id: " + cursorLoader.getId() + ". Rows: " + cursor.getCount()); switch (cursorLoader.getId()) { case LOADER_SEASONS: adapter.setGroupCursor(cursor); if (cursor.getCount() == 1) { // Force collapse and expand the group, to force a reload of the episodes // cursor, otherwise if it is already expanded it won't reload (and won't // apply the filters to the episodes list) seasonsEpisodesListView.collapseGroup(0); seasonsEpisodesListView.expandGroup(0); } else if (cursor.getCount() > 0) { // Expand the first season that has unseen episodes cursor.moveToFirst(); do { int unwatched = cursor.getInt(SeasonsListQuery.EPISODE) - cursor.getInt(SeasonsListQuery.WATCHEDEPISODES); if (unwatched > 0) { LogUtils.LOGD(TAG, "Expanding group: " + cursor.getPosition()); seasonsEpisodesListView.collapseGroup(cursor.getPosition()); seasonsEpisodesListView.expandGroup(cursor.getPosition()); break; } } while (cursor.moveToNext()); } // To prevent the empty text from appearing on the first load, set it now emptyView.setText(getString(R.string.no_episodes_found)); break; default: // Check if the group cursor is set before setting the children cursor // Somehow, when poping the back stack, the children cursor are reloaded first... if (adapter.getCursor() != null) { adapter.setChildrenCursor(cursorLoader.getId(), cursor); } break; } }