List of usage examples for android.database Cursor isNull
boolean isNull(int columnIndex);
true
if the value in the indicated column is null. From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java
/** * Cursor to timer.// ww w . ja va 2 s . c o m * * @param c the c * @return the timer * @author RayBa * @date 07.04.2013 */ private Timer cursorToTimer(Cursor c) { String name = mCHannel.getName(); long channelID = mCHannel.getId(); String epgTitle = !c.isNull(c.getColumnIndex(EpgTbl.TITLE)) ? c.getString(c.getColumnIndex(EpgTbl.TITLE)) : name; long epgStart = c.getLong(c.getColumnIndex(EpgTbl.START)); long epgEnd = c.getLong(c.getColumnIndex(EpgTbl.END)); DVBViewerPreferences prefs = new DVBViewerPreferences(getSherlockActivity()); int epgBefore = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_BEFORE, 5); int epgAfter = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_AFTER, 5); Date start = epgStart > 0 ? new Date(epgStart) : new Date(); Date end = epgEnd > 0 ? new Date(epgEnd) : new Date(); Log.i(ChannelList.class.getSimpleName(), start.toString()); Log.i(ChannelList.class.getSimpleName(), start.toString()); Log.i(ChannelList.class.getSimpleName(), start.toString()); start = DateUtils.addMinutes(start, 0 - epgBefore); end = DateUtils.addMinutes(end, epgAfter); Timer timer = new Timer(); timer.setTitle(epgTitle); timer.setChannelId(channelID); timer.setChannelName(name); timer.setStart(start); timer.setEnd(end); timer.setTimerAction(prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_DEF_AFTER_RECORD, 0)); return timer; }
From source file:com.carlrice.reader.fragment.EntryFragment.java
@Override public void onClickFullText() { final BaseActivity activity = (BaseActivity) getActivity(); if (!isRefreshing()) { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); final boolean alreadyMobilized = !cursor.isNull(mMobilizedHtmlPos); if (alreadyMobilized) { activity.runOnUiThread(new Runnable() { @Override/*from www .ja v a 2 s. c o m*/ public void run() { mPreferFullText = true; mEntryPagerAdapter.displayEntry(mCurrentPagerPos, null, true); } }); } else { ConnectivityManager connectivityManager = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); // since we have acquired the networkInfo, we use it for basic checks if (networkInfo != null && networkInfo.getState() == NetworkInfo.State.CONNECTED) { FetcherService.addEntriesToMobilize(new long[] { mEntriesIds[mCurrentPagerPos] }); activity.startService(new Intent(activity, FetcherService.class) .setAction(FetcherService.ACTION_MOBILIZE_FEEDS)); activity.runOnUiThread(new Runnable() { @Override public void run() { showSwipeProgress(); } }); } else { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, R.string.network_error, Toast.LENGTH_SHORT).show(); } }); } } } }
From source file:saphion.batterycaster.providers.Alarm.java
public Alarm(Cursor c) { id = c.getLong(ID_INDEX);//ww w . ja v a 2 s .c o m enabled = c.getInt(ENABLED_INDEX) == 1; battery = c.getInt(BATTERY_INDEX); charge = c.getInt(CHARGE_INDEX); daysOfWeek = new DaysOfWeek(c.getInt(DAYS_OF_WEEK_INDEX)); vibrate = c.getInt(VIBRATE_INDEX) == 1; label = c.getString(LABEL_INDEX); deleteAfterUse = c.getInt(DELETE_AFTER_USE_INDEX) == 1; if (c.isNull(RINGTONE_INDEX)) { // Should we be saving this with the current ringtone or leave it // null // so it changes when user changes default ringtone? alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); } else { alert = Uri.parse(c.getString(RINGTONE_INDEX)); } }
From source file:nl.privacybarometer.privacyvandaag.fragment.EntryFragment.java
private void refreshUI(Cursor entryCursor) { if (entryCursor != null) { String feedTitle = entryCursor.isNull(mFeedNamePos) ? entryCursor.getString(mFeedUrlPos) : entryCursor.getString(mFeedNamePos); BaseActivity activity = (BaseActivity) getActivity(); activity.setTitle(feedTitle);/*from w w w.j a v a 2 s. co m*/ // ModPrivacyVandaag: Get icon from resource drawable instead of retrieved favicon blob in database int mIconResourceId = entryCursor.getInt(mIconIdPos); if (mIconResourceId > 0) { Drawable mDrawable = ContextCompat.getDrawable(MainApplication.getContext(), mIconResourceId); Bitmap bitmap = ((BitmapDrawable) mDrawable).getBitmap(); if (bitmap != null) { BitmapDrawable mIcon; mIcon = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, 36, 36, true)); activity.getSupportActionBar().setIcon(mIcon); } } else { activity.getSupportActionBar().setIcon(null); } /* Following code no longer needed byte[] iconBytes = entryCursor.getBlob(mFeedIconPos); Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24); if (bitmap != null) { activity.getSupportActionBar().setIcon(new BitmapDrawable(getResources(), bitmap)); } else { activity.getSupportActionBar().setIcon(null); } */ // End ModPrivacyVandaag mFavorite = entryCursor.getInt(mIsFavoritePos) == 1; activity.invalidateOptionsMenu(); // Listen the mobilizing task if (FetcherService.hasMobilizationTask(mEntriesIds[mCurrentPagerPos])) { showSwipeProgress(); // If the service is not started, start it here to avoid an infinite loading if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) { MainApplication.getContext() .startService(new Intent(MainApplication.getContext(), FetcherService.class) .setAction(FetcherService.ACTION_MOBILIZE_FEEDS)); } } else { hideSwipeProgress(); } // Mark the article as read if (entryCursor.getInt(mIsReadPos) != 1) { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread(new Runnable() { @Override public void run() { ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, FeedData.getReadContentValues(), null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }).start(); } } }
From source file:com.silentcircle.contacts.list.ScContactEntryListAdapter.java
/** * Loads the photo for the quick contact view and assigns the contact uri. * @param photoIdColumn Index of the photo id column * @param photoUriColumn Index of the photo uri column. Optional: Can be -1 * @param contactIdColumn Index of the contact id column */// w w w . ja v a2 s.c o m protected void bindQuickContact(final ContactListItemView view, int partitionIndex, Cursor cursor, int photoIdColumn, int photoUriColumn, int contactIdColumn) { long photoId = 0; if (!cursor.isNull(photoIdColumn)) { photoId = cursor.getLong(photoIdColumn); } ScQuickContactBadge quickContact = view.getQuickContact(); quickContact.assignContactUri(getContactUri(partitionIndex, cursor, contactIdColumn)); if (photoId != 0 || photoUriColumn == -1) { getPhotoLoader().loadThumbnail(quickContact, photoId, mDarkTheme); } else { final String photoUriString = cursor.getString(photoUriColumn); final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString); getPhotoLoader().loadPhoto(quickContact, photoUri, -1, mDarkTheme); } }
From source file:org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { super.onLoadFinished(loader, data); if (loader.getId() == LOADER_ID) { mIndexHasCertify = data.getColumnIndex(KeychainContract.KeyRings.HAS_CERTIFY); // If:/* www .java 2 s. c om*/ // - no key has been pre-selected (e.g. by SageSlinger) // - there are actually keys (not just "none" entry) // Then: // - select key that is capable of certifying, but only if there is only one key capable of it if (mPreSelectedKeyId == Constants.key.none && mAdapter.getCount() > 1) { // preselect if key can certify int selection = -1; while (data.moveToNext()) { if (!data.isNull(mIndexHasCertify)) { if (selection == -1) { selection = data.getPosition() + 1; mIsSingle = true; } else { // if selection is already set, we have more than one certify key! // get back to "none"! mIsSingle = false; selection = 0; } } } setSelection(selection); } } }
From source file:com.android.contacts.list.ContactEntryListAdapter.java
protected void bindQuickContact(final ContactListItemView view, int partitionIndex, Cursor cursor, int photoIdColumn, int contactIdColumn, int lookUpKeyColumn) { long photoId = 0; if (!cursor.isNull(photoIdColumn)) { photoId = cursor.getLong(photoIdColumn); }/* w w w . ja v a 2 s . co m*/ //Begin by gangzhou.qi at 2012-7-11 ?10:53:05 accountType = null; accountSet = null; accountIconDraw = null; accountQuerySelectionArgs = new String[] { cursor.getString(0) }; Cursor accountCur = null; accountCur = mContentResolver.query(ContactsContract.RawContacts.CONTENT_URI, null, accountQuerySelection, accountQuerySelectionArgs, null); if (accountCur != null && accountCur.getCount() > 0) { try { accountCur.moveToFirst(); accountType = accountCur .getString(accountCur.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE)); accountSet = accountCur.getString(accountCur.getColumnIndex(ContactsContract.RawContacts.DATA_SET)); } catch (Exception e) { e.printStackTrace(); } finally { accountCur.close(); } } if (accountType != null) { accountIconDraw = AccountTypeManager.getInstance(mContext) .getAccountType(AccountTypeWithDataSet.get(accountType, accountSet)).getDisplayIcon(mContext); } Log.d(TAG, "accountIconDraw:" + accountIconDraw); QuickContactBadgeWithAccount quickContact = view.getQuickContact(); //if(accountIconDraw != null){ quickContact.setAccountDrawable(accountIconDraw); //} //Ended by gangzhou.qi at 2012-7-11 ?10:53:05 quickContact.assignContactUri(getContactUri(partitionIndex, cursor, contactIdColumn, lookUpKeyColumn)); getPhotoLoader().loadPhoto(quickContact, photoId, false, mDarkTheme); }
From source file:org.benetech.secureapp.activities.FormGroupActivity.java
private void insertNewRow() { final Uri contentUri = FormsProviderAPI.FormsColumns.CONTENT_URI; Cursor cursor = Collect.getInstance().getContentResolver().query(contentUri, null, null, null, null); cursor.moveToFirst();//from w w w. jav a 2 s. com String jrformid = cursor.getString(cursor.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)); String jrversion = cursor.getString(cursor.getColumnIndex(FormsProviderAPI.FormsColumns.JR_VERSION)); String submissionUri = null; if (!cursor.isNull(cursor.getColumnIndex(FormsProviderAPI.FormsColumns.SUBMISSION_URI))) { submissionUri = cursor.getString(cursor.getColumnIndex(FormsProviderAPI.FormsColumns.SUBMISSION_URI)); } String path = getInstancePath(); ContentValues values = new ContentValues(); values.put(InstanceProviderAPI.InstanceColumns.DISPLAY_NAME, mFormTitle.getText().toString()); values.put(InstanceProviderAPI.InstanceColumns.INSTANCE_FILE_PATH, path); values.put(InstanceProviderAPI.InstanceColumns.JR_FORM_ID, jrformid); values.put(InstanceProviderAPI.InstanceColumns.JR_VERSION, jrversion); values.put(InstanceProviderAPI.InstanceColumns.SUBMISSION_URI, submissionUri); getContentResolver().insert(InstanceProviderAPI.InstanceColumns.CONTENT_URI, values); cursor.close(); saveNewForm(contentUri); }
From source file:org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.java
private void loadUserIds(ArrayList<IdentityInfo> identities) { Cursor cursor = contentResolver.query(UserPackets.buildUserIdsUri(masterKeyId), USER_PACKETS_PROJECTION, USER_IDS_WHERE, null, null); if (cursor == null) { Log.e(Constants.TAG, "Error loading key items!"); return;//from w w w.ja v a 2s .c om } try { while (cursor.moveToNext()) { int rank = cursor.getInt(INDEX_RANK); int verified = cursor.getInt(INDEX_VERIFIED); boolean isPrimary = cursor.getInt(INDEX_IS_PRIMARY) != 0; if (!cursor.isNull(INDEX_NAME) || !cursor.isNull(INDEX_EMAIL)) { String name = cursor.getString(INDEX_NAME); String email = cursor.getString(INDEX_EMAIL); String comment = cursor.getString(INDEX_COMMENT); IdentityInfo identityInfo = UserIdInfo.create(rank, verified, isPrimary, name, email, comment); identities.add(identityInfo); } } } finally { cursor.close(); } }
From source file:net.news.inrss.fragment.EntriesListFragment.java
/** * Schedules all entries which are not mobilized yet, for download. * Then invokes download by calling FetcherService. */// w w w. ja va 2 s. c om private void downloadUnmobilitedEntries() { Cursor cursor = mEntriesCursorAdapter.getCursor(); if (cursor != null && !cursor.isClosed()) { int mobilizedPos = cursor.getColumnIndex(EntryColumns.MOBILIZED_HTML); long[] entries = new long[cursor.getCount()]; int i = 0; if (cursor.moveToFirst()) { do { if (cursor.isNull(mobilizedPos)) { entries[i++] = cursor.getLong(0); //not mobilized, yet // entries[i++] = (Long.valueOf(cursor.getPosition())); } } while (cursor.moveToNext()); } if (i > 0) { entries = Arrays.copyOf(entries, i); FetcherService.addEntriesToMobilize(entries); getActivity().startService(new Intent(getActivity(), FetcherService.class) .setAction(FetcherService.ACTION_MOBILIZE_FEEDS)); } } }