List of usage examples for android.database Cursor isAfterLast
boolean isAfterLast();
From source file:com.bellman.bible.service.db.mynote.MyNoteDBAdapter.java
public List<MyNoteDto> getAllMyNotes() { Log.d(TAG, "about to getAllMyNotes"); List<MyNoteDto> allMyNotes = new ArrayList<MyNoteDto>(); Cursor c = db.query(MyNoteQuery.TABLE, MyNoteQuery.COLUMNS, null, null, null, null, null); try {//from w w w . j a v a2s . com if (c.moveToFirst()) { while (!c.isAfterLast()) { MyNoteDto mynote = getMyNoteDto(c); allMyNotes.add(mynote); c.moveToNext(); } } } finally { c.close(); } Log.d(TAG, "allMyNotes set to " + allMyNotes.size() + " item long list"); return allMyNotes; }
From source file:fr.eoit.activity.loader.BaseProductionNeedsLoader.java
public static SparseItemBeanArray getBaseProductionNeeds(Context context, long itemId, long categorieId, long numberOfItems) { final Cursor cursorItemMaterials = context.getContentResolver().query( ContentUris.withAppendedId(ItemMaterials.CONTENT_ITEM_ID_URI_BASE_PRICES, itemId), new String[] { ItemMaterials._ID, ItemMaterials.COLUMN_NAME_MATERIAL_ITEM_ID, ItemMaterials.COLUMN_NAME_DAMAGE_PER_JOB, ItemMaterials.COLUMN_NAME_QUANTITY, Item.COLUMN_NAME_NAME, Item.COLUMN_NAME_VOLUME, Item.COLUMN_NAME_CHOSEN_PRICE_ID, Blueprint.COLUMN_NAME_ML, Blueprint.COLUMN_NAME_MATERIAL_UNIT_PER_BATCH, Prices.COLUMN_NAME_BUY_PRICE, Prices.COLUMN_NAME_OWN_PRICE, Prices.COLUMN_NAME_SELL_PRICE, Prices.COLUMN_NAME_PRODUCE_PRICE, Groups.COLUMN_NAME_CATEGORIE_ID }, //null, "(" + ItemMaterials.COLUMN_NAME_ACTIVITY_ID + " = 1 OR " + ItemMaterials.COLUMN_NAME_ACTIVITY_ID + " IS NULL) AND " + Groups.COLUMN_NAME_CATEGORIE_ID + " NOT IN ( " + EOITConst.Categories.SKILL_CATEGORIE_ID + ")", null, null);//from w ww. j a v a 2s . c o m SparseItemBeanArray items = new SparseItemBeanArray(); try { if (DbUtil.hasAtLeastOneRow(cursorItemMaterials)) { while (!cursorItemMaterials.isAfterLast()) { long id = cursorItemMaterials.getInt( cursorItemMaterials.getColumnIndexOrThrow(ItemMaterials.COLUMN_NAME_MATERIAL_ITEM_ID)); int chosenPrice = cursorItemMaterials .getInt(cursorItemMaterials.getColumnIndexOrThrow(Item.COLUMN_NAME_CHOSEN_PRICE_ID)); ItemBeanWithMaterials item = ItemUtil.getItemWithPrices(cursorItemMaterials, numberOfItems, categorieId); items = ManufactureUtils.addItemToMap(items, item, numberOfItems, null); if (chosenPrice == EOITConst.PRODUCE_PRICE_ID) { item.materials = getBaseProductionNeeds(context, id, categorieId, numberOfItems); } cursorItemMaterials.moveToNext(); } } } finally { cursorItemMaterials.close(); } return items; }
From source file:com.commonsware.android.video.browse.VideosFragment.java
private void mapCursorToModels(Cursor c) { videos.clear();// www .ja v a 2s. c om int idColumn = c.getColumnIndex(MediaStore.Video.Media._ID); int uriColumn = c.getColumnIndex(MediaStore.Video.Media.DATA); int mimeTypeColumn = c.getColumnIndex(MediaStore.Video.Media.MIME_TYPE); int titleColumn = c.getColumnIndex(MediaStore.Video.Media.TITLE); for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { videos.add(new Video(c.getInt(idColumn), c.getString(uriColumn), c.getString(mimeTypeColumn), c.getString(titleColumn))); } c.close(); }
From source file:com.google.samples.apps.iosched.map.MapInfoFragment.java
private void showSessionList(String roomTitle, int roomType, Cursor sessions) { if (sessions == null || sessions.isAfterLast()) { onSessionLoadingFailed(roomTitle, roomType); return;// w w w. j a v a 2 s. com } onSessionsLoaded(roomTitle, roomType, sessions); mList.setAdapter(new SessionAdapter(getActivity(), sessions, MapUtils.hasInfoSessionListIcons(roomType), mOnClickListener)); }
From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java
private void renameCategory(String name) { if (TextUtils.isEmpty(name)) { CommonUtils.showToast(getActivity(), R.string.error_category_editor_empty_field); } else {/*from w ww .ja v a2s . c om*/ // First updates all words from the category with the new category name Cursor cursor = mWordDbAdapter.getRecordsByCategory(getName()); while (!cursor.isAfterLast()) { long id = cursor.getLong(cursor.getColumnIndex(WordEntry._ID)); String wordName = cursor.getString(cursor.getColumnIndex(WordEntry.COLUMN_NAME)); String wordTranslation = cursor.getString(cursor.getColumnIndex(WordEntry.COLUMN_TRANSLATION)); mWordDbAdapter.update(new Word(id, wordName, wordTranslation, name)); cursor.moveToNext(); } mCategoryDbAdapter.update(new Category(mSelectedItemId, name)); getLoaderManager().restartLoader(LOADER_ID, null, this); } }
From source file:com.stoyanr.feeder.activity.ItemsActivity.java
private long[] getItemIds() { Cursor cursor = adapter.getCursor(); assert (cursor != null); long[] result = new long[cursor.getCount()]; int i = 0;//from w ww .j a va 2 s . co m for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { result[i++] = ContentManager.getItemId(cursor); } return result; }
From source file:com.google.samples.apps.iosched.map.MapInfoFragment.java
private void showSessionSubtitle(String roomTitle, int roomType, Cursor sessions) { if (sessions == null || sessions.isAfterLast()) { onSessionLoadingFailed(roomTitle, roomType); return;//from w ww. j av a2s . c o m } sessions.moveToFirst(); final String title = roomTitle; final String subtitle = sessions.getString(SingleSessionLoader.Query.SESSION_ABSTRACT); setHeader(MapUtils.getRoomIcon(roomType), title, subtitle); mList.setVisibility(View.GONE); onRoomSubtitleLoaded(title, roomType, subtitle); }
From source file:fr.eoit.activity.fragment.manufacture.ProductionPlanFragment.java
@Override public void onLoadFinished(Cursor cursor) { if (DbUtil.hasAtLeastOneRow(cursor)) { while (!cursor.isAfterLast()) { int id = cursor.getInt(cursor.getColumnIndexOrThrow(Stock.COLUMN_NAME_ITEM_ID)); long quantity = cursor.getLong(cursor.getColumnIndexOrThrow(Stock.COLUMN_NAME_QUANTITY)); ItemBeanWithMaterials item = new ItemBeanWithMaterials(); item.id = id;// w ww.ja v a2 s . c om item.quantity = quantity; stockItems.include(item); cursor.moveToNext(); } } productionNeeds = ManufactureUtils.getProductionNeeds(baseProductionNeedItemMap, stockItems, currentNumberOfRuns); remainingProductionNeedsItems = new SparseItemBeanArray(productionNeeds); List<ProductionStep> steps = new ArrayList<ProductionStep>(); ProductionStep miningSteps; if (Parameters.isMiningActive) { miningSteps = getMiningStep(); if (!miningSteps.isEmpty()) steps.add(miningSteps); } ProductionStep shoppingSteps = getShoppingStep(); if (!shoppingSteps.isEmpty()) steps.add(shoppingSteps); steps.addAll(findSteps()); int index = 0; for (EnhancedMaterialListFragment fragment : stepsFragments) { if (steps.size() > index) { fragment.initialize(steps.get(index)); } else { fragment.getView().setVisibility(View.GONE); } index++; } updateProductionInfos(currentNumberOfRuns); }
From source file:net.fluidnexus.FluidNexusAndroid.services.NexusServiceThread.java
/** * Start the listeners for zeroconf services */// w ww .j a v a 2 s . co m public void doStateNone() { if (wifiManager.getWifiState() == wifiManager.WIFI_STATE_ENABLED) { Cursor c = messagesProviderHelper.publicMessages(); while (c.isAfterLast() == false) { String message_hash = c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_MESSAGE_HASH)); boolean result = checkHash(message_hash); if (!result) { try { JSONObject message = new JSONObject(); message.put("message_title", c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_TITLE))); message.put("message_content", c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_CONTENT))); message.put("message_hash", c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_MESSAGE_HASH))); message.put("message_type", c.getInt(c.getColumnIndex(MessagesProviderHelper.KEY_TYPE))); message.put("message_time", c.getFloat(c.getColumnIndex(MessagesProviderHelper.KEY_TIME))); message.put("message_received_time", c.getFloat(c.getColumnIndex(MessagesProviderHelper.KEY_RECEIVED_TIME))); message.put("message_priority", c.getInt(c.getColumnIndex(MessagesProviderHelper.KEY_PRIORITY))); String attachment_path = c .getString(c.getColumnIndex(MessagesProviderHelper.KEY_ATTACHMENT_PATH)); //String serializedMessage = message.toString(); // First, get our nonce consumer = new CommonsHttpOAuthConsumer(key, secret); consumer.setTokenWithSecret(token, token_secret); HttpPost nonce_request = new HttpPost(NEXUS_NONCE_URL); consumer.sign(nonce_request); HttpClient client = new DefaultHttpClient(); String response = client.execute(nonce_request, new BasicResponseHandler()); JSONObject object = new JSONObject(response); String nonce = object.getString("nonce"); // Then, take our nonce and key and put them in the message message.put("message_nonce", nonce); message.put("message_key", key); // Setup our multipart entity MultipartEntity entity = new MultipartEntity(); // Deal with file attachment if (!attachment_path.equals("")) { File file = new File(attachment_path); ContentBody cbFile = new FileBody(file); entity.addPart("message_attachment", cbFile); // add the original filename to the message message.put("message_attachment_original_filename", c.getString( c.getColumnIndex(MessagesProviderHelper.KEY_ATTACHMENT_ORIGINAL_FILENAME))); } String serializedMessage = message.toString(); ContentBody messageBody = new StringBody(serializedMessage); entity.addPart("message", messageBody); HttpPost message_request = new HttpPost(NEXUS_MESSAGE_URL); message_request.setEntity(entity); client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); response = client.execute(message_request, new BasicResponseHandler()); object = new JSONObject(response); boolean message_result = object.getBoolean("result"); if (message_result) { ContentValues values = new ContentValues(); values.put(MessagesProviderHelper.KEY_MESSAGE_HASH, message_hash); values.put(MessagesProviderHelper.KEY_UPLOADED, 1); int res = messagesProviderHelper .setPublic(c.getLong(c.getColumnIndex(MessagesProviderHelper.KEY_ID)), values); if (res == 0) { log.debug("Message with hash " + message_hash + " not found; this should never happen!"); } } } catch (OAuthMessageSignerException e) { log.debug("OAuthMessageSignerException: " + e); } catch (OAuthExpectationFailedException e) { log.debug("OAuthExpectationFailedException: " + e); } catch (OAuthCommunicationException e) { log.debug("OAuthCommunicationException: " + e); } catch (JSONException e) { log.debug("JSON Error: " + e); } catch (IOException e) { log.debug("IOException: " + e); } } c.moveToNext(); } c.close(); } setServiceState(STATE_SERVICE_WAIT); }
From source file:org.mariotaku.twidere.util.DataStoreUtils.java
@NonNull public static int[] getAccountColors(@NonNull final Context context, @NonNull final UserKey[] accountKeys) { final String[] cols = new String[] { Accounts.ACCOUNT_KEY, Accounts.COLOR }; final String where = Expression.inArgs(new Column(Accounts.ACCOUNT_KEY), accountKeys.length).getSQL(); final String[] whereArgs = TwidereArrayUtils.toStringArray(accountKeys); final int[] colors = new int[accountKeys.length]; final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, cols, where, whereArgs, null); if (cur == null) return colors; try {//w ww . j a v a 2s. c o m cur.moveToFirst(); while (!cur.isAfterLast()) { final int idx = ArrayUtils.indexOf(accountKeys, UserKey.valueOf(cur.getString(0))); if (idx >= 0) { colors[idx] = cur.getInt(1); } cur.moveToNext(); } return colors; } finally { cur.close(); } }