List of usage examples for android.database Cursor isAfterLast
boolean isAfterLast();
From source file:com.kaku.weac.fragment.SystemRingFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { switch (loader.getId()) { case LOADER_ID: // ?????? String ringName1;//from w w w. ja v a 2 s. c om if (RingSelectFragment.sRingName != null) { ringName1 = RingSelectFragment.sRingName; } else { SharedPreferences share = getActivity().getSharedPreferences(WeacConstants.EXTRA_WEAC_SHARE, Activity.MODE_PRIVATE); // ??????,? ringName1 = share.getString(WeacConstants.RING_NAME, getString(R.string.default_ring)); } // ??Set HashSet<String> set = new HashSet<>(); // ??List List<Map<String, String>> list = new ArrayList<>(); // Map<String, String> defaultRing = new HashMap<>(); defaultRing.put(WeacConstants.RING_NAME, getString(R.string.default_ring)); defaultRing.put(WeacConstants.RING_URL, WeacConstants.DEFAULT_RING_URL); list.add(defaultRing); set.add(getString(R.string.default_ring)); // ???? if (getString(R.string.default_ring).equals(ringName1)) { mPosition = 0; RingSelectItem.getInstance().setRingPager(0); } // Map<String, String> noRing = new HashMap<>(); noRing.put(WeacConstants.RING_NAME, getString(R.string.no_ring)); noRing.put(WeacConstants.RING_URL, WeacConstants.NO_RING_URL); list.add(noRing); set.add(getString(R.string.no_ring)); // ???? if (getString(R.string.no_ring).equals(ringName1)) { mPosition = list.size() - 1; RingSelectItem.getInstance().setRingPager(0); } if (cursor != null) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { // ?? String ringName = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME)); if (ringName != null) { // ?? if (!set.contains(ringName)) { // ??? set.add(ringName); // ?? ringName = MyUtil.removeEx(ringName); // ?? String ringUrl = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA)); Map<String, String> map = new HashMap<>(); map.put(WeacConstants.RING_NAME, ringName); map.put(WeacConstants.RING_URL, ringUrl); list.add(map); // ???? if (ringName.equals(ringName1)) { mPosition = list.size() - 1; RingSelectItem.getInstance().setRingPager(0); } } } } } mSystemRingAdapter = new RingSelectAdapter(getActivity(), list, ringName1); setListAdapter(mSystemRingAdapter); setSelection(mPosition); break; } }
From source file:org.digitalcampus.oppia.application.DbHelper.java
public void getCourseQuizResults(ArrayList<QuizStats> stats, int courseId, long userId) { String quizResultsWhereClause = QUIZATTEMPTS_C_COURSEID + " =? AND " + QUIZATTEMPTS_C_USERID + "=?"; String[] quizResultsArgs = new String[] { String.valueOf(courseId), String.valueOf(userId) }; String[] quizResultsColumns = new String[] { QUIZATTEMPTS_C_ACTIVITY_DIGEST, QUIZATTEMPTS_C_PASSED, QUIZATTEMPTS_C_MAXSCORE, QUIZATTEMPTS_C_SCORE }; //We get the attempts made by the user for this course's quizzes Cursor c = db.query(QUIZATTEMPTS_TABLE, quizResultsColumns, quizResultsWhereClause, quizResultsArgs, null, null, null);//from w w w.j a v a 2 s .co m if (c.getCount() <= 0) return; //we return the empty array if (stats == null) stats = new ArrayList<QuizStats>(); c.moveToFirst(); while (!c.isAfterLast()) { String quizDigest = c.getString(c.getColumnIndex(QUIZATTEMPTS_C_ACTIVITY_DIGEST)); int score = (int) (c.getFloat(c.getColumnIndex(QUIZATTEMPTS_C_SCORE)) * 100); int maxScore = (int) (c.getFloat(c.getColumnIndex(QUIZATTEMPTS_C_MAXSCORE)) * 100); boolean passed = c.getInt(c.getColumnIndex(QUIZATTEMPTS_C_PASSED)) > 0; boolean alreadyInserted = false; for (QuizStats quiz : stats) { if (quiz.getDigest().equals(quizDigest)) { if (quiz.getUserScore() < score) quiz.setUserScore(score); if (quiz.getMaxScore() < maxScore) quiz.setMaxScore(maxScore); quiz.setAttempted(true); quiz.setPassed(passed); Log.d(TAG, "quiz score: " + quiz.getUserScore()); Log.d(TAG, "quiz passed: " + quiz.isPassed()); alreadyInserted = true; break; } } if (!alreadyInserted) { QuizStats quiz = new QuizStats(); quiz.setAttempted(true); quiz.setDigest(quizDigest); quiz.setUserScore(score); quiz.setMaxScore(maxScore); quiz.setPassed(passed); stats.add(quiz); } c.moveToNext(); } c.close(); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static boolean isFiltered(final Context context, final String screen_name, final String source, final String text) { if (context == null) return false; final ContentResolver resolver = context.getContentResolver(); final String[] cols = new String[] { Filters.TEXT }; Cursor cur; if (screen_name != null) { cur = resolver.query(Filters.Users.CONTENT_URI, cols, null, null, null); cur.moveToFirst();/* ww w. j av a 2 s .co m*/ while (!cur.isAfterLast()) { if (screen_name.equals(cur.getString(0))) return true; cur.moveToNext(); } cur.close(); } if (source != null) { cur = resolver.query(Filters.Sources.CONTENT_URI, cols, null, null, null); cur.moveToFirst(); while (!cur.isAfterLast()) { if (HtmlEscapeHelper.unescape(source).equals(cur.getString(0))) return true; cur.moveToNext(); } cur.close(); } if (text != null) { cur = resolver.query(Filters.Users.CONTENT_URI, cols, null, null, null); cur.moveToFirst(); while (!cur.isAfterLast()) { if (text.contains(cur.getString(0))) return true; cur.moveToNext(); } cur.close(); } return false; }
From source file:com.dwdesign.tweetings.util.Utils.java
public static ArrayList<Long> getStatusIdsInDatabase(final Context context, final Uri uri, final long account_id) { final ArrayList<Long> list = new ArrayList<Long>(); if (context == null) return list; final ContentResolver resolver = context.getContentResolver(); final String where = Statuses.ACCOUNT_ID + " = " + account_id; final String[] projection = new String[] { Statuses.STATUS_ID }; final Cursor cur = resolver.query(uri, projection, where, null, null); if (cur != null) { final int idx = cur.getColumnIndexOrThrow(Statuses.STATUS_ID); cur.moveToFirst();//from w w w . j av a2 s . c o m while (!cur.isAfterLast()) { list.add(cur.getLong(idx)); cur.moveToNext(); } cur.close(); } return list; }
From source file:org.mariotaku.twidere.util.Utils.java
public static String[] getAccountScreenNames(final Context context) { String[] accounts = new String[0]; if (context == null) return accounts; final String[] cols = new String[] { Accounts.SCREEN_NAME }; final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, cols, null, null, null); if (cur != null) { final int idx = cur.getColumnIndexOrThrow(Accounts.SCREEN_NAME); cur.moveToFirst();//from w w w . j a v a2 s .co m accounts = new String[cur.getCount()]; int i = 0; while (!cur.isAfterLast()) { accounts[i] = cur.getString(idx); i++; cur.moveToNext(); } cur.close(); } return accounts; }
From source file:org.mariotaku.twidere.util.Utils.java
public static long[] getAllStatusesIds(final Context context, final Uri uri) { if (context == null) return new long[0]; final ContentResolver resolver = context.getContentResolver(); final Cursor cur = resolver.query(uri, new String[] { Statuses.STATUS_ID }, buildStatusFilterWhereClause(getTableNameByUri(uri), null), null, null); if (cur == null) return new long[0]; final long[] ids = new long[cur.getCount()]; cur.moveToFirst();//from w w w .ja v a2 s.c o m int i = 0; while (!cur.isAfterLast()) { ids[i] = cur.getLong(0); cur.moveToNext(); i++; } cur.close(); return ids; }
From source file:com.dwdesign.tweetings.util.Utils.java
public static long[] getAllStatusesIds(final Context context, final Uri uri, final boolean filter_enabled) { if (context == null) return new long[0]; final ContentResolver resolver = context.getContentResolver(); final ArrayList<Long> ids_list = new ArrayList<Long>(); final Cursor cur = resolver.query(uri, new String[] { Statuses.STATUS_ID }, filter_enabled ? buildFilterWhereClause(getTableNameForContentUri(uri), null) : null, null, null); if (cur == null) return new long[0]; cur.moveToFirst();/*from w w w .j a va 2 s. c o m*/ while (!cur.isAfterLast()) { ids_list.add(cur.getLong(0)); cur.moveToNext(); } cur.close(); return ArrayUtils.fromList(ids_list); }
From source file:org.mariotaku.twidere.util.Utils.java
public static String[] getActivatedAccountScreenNames(final Context context) { String[] accounts = new String[0]; if (context == null) return accounts; final String[] cols = new String[] { Accounts.SCREEN_NAME }; final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, cols, Accounts.IS_ACTIVATED + "=1", null, null); if (cur != null) { final int idx = cur.getColumnIndexOrThrow(Accounts.SCREEN_NAME); cur.moveToFirst();// w ww. j av a 2 s . c om accounts = new String[cur.getCount()]; int i = 0; while (!cur.isAfterLast()) { accounts[i] = cur.getString(idx); i++; cur.moveToNext(); } cur.close(); } return accounts; }
From source file:org.mariotaku.twidere.util.Utils.java
public static long[] getAccountIds(final Context context) { long[] accounts = new long[0]; if (context == null) return accounts; final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, new String[] { Accounts.ACCOUNT_ID }, null, null, null); if (cur != null) { final int idx = cur.getColumnIndexOrThrow(Accounts.ACCOUNT_ID); cur.moveToFirst();//ww w . ja va 2s . c om accounts = new long[cur.getCount()]; int i = 0; while (!cur.isAfterLast()) { accounts[i] = cur.getLong(idx); i++; cur.moveToNext(); } cur.close(); } return accounts; }
From source file:com.dwdesign.tweetings.util.Utils.java
public static String[] getAccountScreenNames(final Context context) { String[] accounts = new String[0]; if (context == null) return accounts; final String[] cols = new String[] { Accounts.USERNAME }; final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, cols, null, null, null); if (cur != null) { final int idx = cur.getColumnIndexOrThrow(Accounts.USERNAME); cur.moveToFirst();/*from w w w . ja va 2 s .c om*/ accounts = new String[cur.getCount()]; int i = 0; while (!cur.isAfterLast()) { accounts[i] = cur.getString(idx); i++; cur.moveToNext(); } cur.close(); } return accounts; }