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:net.fred.feedex.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/* www . j a v a 2 s . com*/ 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_LONG).show(); } }); } } } }
From source file:com.viktorrudometkin.burramys.fragment.EntryFragment.java
@Override public void onClickFullText() { final BaseActivity activity = (BaseActivity) getActivity(); Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); final boolean alreadyMobilized = !cursor.isNull(mMobilizedHtmlPos); if (alreadyMobilized) { activity.runOnUiThread(new Runnable() { @Override//from www.j a v a 2s . c om public void run() { mPreferFullText = true; mEntryPagerAdapter.displayEntry(mCurrentPagerPos, null, true); } }); } else if (!isRefreshing()) { 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() { UiUtils.showMessage(getActivity(), R.string.network_error); } }); } } }
From source file:com.futureplatforms.kirin.extensions.databases.DatabasesBackend.java
public JSONObject coerceToJSONObject(String[] cols, Cursor cursor) { if (cursor instanceof AbstractWindowedCursor) { return mCursorCoercer.coerceToJSONObject(cols, (AbstractWindowedCursor) cursor); } else {//from w ww. j a v a 2 s . c o m JSONObject obj = new JSONObject(); for (int i = 0; i < cols.length; i++) { try { if (!cursor.isNull(i)) { obj.put(cols[i], cursor.getString(i)); } } catch (JSONException e) { Log.e(C.TAG, e.getLocalizedMessage(), e); } } return obj; } }
From source file:org.akvo.flow.ui.fragment.SurveyListFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor == null) { Log.e(TAG, "onFinished() - Loader returned no data"); return;/*from w w w .j ava2s . c o m*/ } mAdapter.clear(); if (cursor.moveToFirst()) { do { SurveyInfo s = new SurveyInfo(); s.mId = cursor.getString(SurveyQuery.SURVEY_ID); s.mName = cursor.getString(SurveyQuery.NAME); s.mVersion = String.valueOf(cursor.getFloat(SurveyQuery.VERSION)); if (!cursor.isNull(SurveyQuery.SUBMITTED)) { s.mLastSubmission = cursor.getLong(SurveyQuery.SUBMITTED); } if (mSurveyGroup.isMonitored() && isRegistrationSurvey(s.mId)) { mAdapter.insert(s, 0);// Make sure registration survey is at the top } else { mAdapter.add(s); } } while (cursor.moveToNext()); } }
From source file:ru.gkpromtech.exhibition.db.Table.java
private void fillFieldValue(int type, Field field, Object entity, Cursor cursor, int i) throws IllegalAccessException { if (cursor.isNull(i)) { field.set(entity, null);// www. j av a2 s. c o m return; } switch (type) { case INTEGER: field.set(entity, cursor.getInt(i)); break; case SHORT: field.set(entity, cursor.getShort(i)); break; case LONG: field.set(entity, cursor.getLong(i)); break; case FLOAT: field.set(entity, cursor.getFloat(i)); break; case DOUBLE: field.set(entity, cursor.getDouble(i)); break; case STRING: field.set(entity, cursor.getString(i)); break; case BYTE_ARRAY: field.set(entity, cursor.getBlob(i)); break; case DATE: field.set(entity, new Date(cursor.getLong(i))); break; case BOOLEAN: field.set(entity, cursor.getInt(i) != 0); break; } }
From source file:com.flym.dennikn.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);/* www . j a va2 s . co m*/ 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); } 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:ch.ethz.twimight.net.tds.TDSRequestMessage.java
public void createDisTweetsObject(Cursor tweets) throws JSONException { if (tweets != null && tweets.getCount() > 0) { tweets.moveToFirst();/* w ww.ja v a 2s.c o m*/ disTweetsObject = new JSONObject(); JSONArray disTweetsArray = new JSONArray(); CertificateManager cm = new CertificateManager(context.getApplicationContext()); while (!tweets.isAfterLast()) { if (!tweets.isNull(tweets.getColumnIndex(Tweets.COL_SIGNATURE))) { JSONObject row = new JSONObject(); row.put(Tweets.COL_TEXT_PLAIN, tweets.getString(tweets.getColumnIndex(Tweets.COL_TEXT_PLAIN))); row.put(Tweets.COL_USER_TID, tweets.getLong(tweets.getColumnIndex(Tweets.COL_USER_TID))); row.put(Tweets.COL_DISASTER_ID, tweets.getLong(tweets.getColumnIndex(Tweets.COL_DISASTER_ID))); row.put(Tweets.COL_SIGNATURE, tweets.getString(tweets.getColumnIndex(Tweets.COL_SIGNATURE))); SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); row.put(Tweets.COL_CREATED_AT + "_phone", simpleFormat .format(new Date(tweets.getLong(tweets.getColumnIndex(Tweets.COL_CREATED_AT))))); // add picture if available if (tweets.getString(tweets.getColumnIndex(Tweets.COL_MEDIA_URIS)) != null) { SDCardHelper sdCardHelper = new SDCardHelper(); String base64Photo = sdCardHelper.getImageAsBas64Jpeg( tweets.getString(tweets.getColumnIndex(Tweets.COL_MEDIA_URIS)), null); Log.d(TAG, base64Photo); row.put(PHOTO, base64Photo); } disTweetsArray.put(row); } tweets.moveToNext(); } tweets.close(); if (disTweetsArray.length() > 0) disTweetsObject.put("content", disTweetsArray); else disTweetsObject = null; } }
From source file:com.tune.news.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 va 2s . c o m*/ 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); } 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(); } // Finally hide the progress bar hideSwipeProgress(); } }
From source file:com.carlrice.reader.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);/* ww w . ja v a2 s . co m*/ byte[] iconBytes = entryCursor.getBlob(mFeedIconPos); Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length); UiUtils.getFaviconPalette(bitmap, mToolbarPaletteListener); 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)) { Application.context().startService(new Intent(Application.context(), 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 = Application.context().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.slp.rss_api.fragment.EntryFragment.java
@Override public void onClickFullText() { final BaseActivity activity = (BaseActivity) getActivity(); Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); final boolean alreadyMobilized = !cursor.isNull(mMobilizedHtmlPos); if (alreadyMobilized) { activity.runOnUiThread(new Runnable() { @Override/* w w w .j a va 2 s.c o m*/ public void run() { mPreferFullText = true; mEntryPagerAdapter.displayEntry(mCurrentPagerPos, null, true); } }); } else if (!isRefreshing()) { 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(); } }); } } }