List of usage examples for android.database Cursor getInt
int getInt(int columnIndex);
From source file:com.tct.mail.providers.Attachment.java
public Attachment(Cursor cursor) { if (cursor == null) { return;/* www . j a va 2 s . c om*/ } name = cursor.getString(cursor.getColumnIndex(AttachmentColumns.NAME)); size = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.SIZE)); uri = Uri.parse(cursor.getString(cursor.getColumnIndex(AttachmentColumns.URI))); contentType = cursor.getString(cursor.getColumnIndex(AttachmentColumns.CONTENT_TYPE)); state = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.STATE)); destination = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.DESTINATION)); downloadedSize = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.DOWNLOADED_SIZE)); contentUri = parseOptionalUri(cursor.getString(cursor.getColumnIndex(AttachmentColumns.CONTENT_URI))); thumbnailUri = parseOptionalUri(cursor.getString(cursor.getColumnIndex(AttachmentColumns.THUMBNAIL_URI))); previewIntentUri = parseOptionalUri( cursor.getString(cursor.getColumnIndex(AttachmentColumns.PREVIEW_INTENT_URI))); providerData = cursor.getString(cursor.getColumnIndex(AttachmentColumns.PROVIDER_DATA)); supportsDownloadAgain = cursor .getInt(cursor.getColumnIndex(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN)) == 1; type = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.TYPE)); flags = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.FLAGS)); //TS: wenggangjin 2014-12-10 EMAIL BUGFIX_852100 MOD_S contentId = cursor.getString(cursor.getColumnIndex(AttachmentColumns.CONTENT_ID)); //TS: wenggangjin 2014-12-10 EMAIL BUGFIX_852100 MOD_E //TS: zhonghua.tuo 2015-3-3 EMAIL BUGFIX_936728 ADD_S realUri = parseOptionalUri(cursor.getString(cursor.getColumnIndex(AttachmentColumns.REAL_URI))); //TS: zhonghua.tuo 2015-3-3 EMAIL BUGFIX_936728 ADD_E // TS: Gantao 2015-09-19 EMAIL BUGFIX_570084 ADD_S isInline = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.ISINLINE)); // TS: Gantao 2015-09-19 EMAIL BUGFIX_570084 ADD_E }
From source file:net.smart_json_database.JSONDatabase.java
private void getTagsForJSONEntity(JSONEntity entity, SQLiteDatabase db) { ArrayList<String> names = new ArrayList<String>(); String sql = "SELECT * FROM " + TABLE_REL_TAG_JSON_DATA + " WHERE to_id = ?"; Cursor c = db.rawQuery(sql, new String[] { "" + entity.getUid() }); if (c.getCount() > 0) { String name = ""; c.moveToFirst();//from ww w. j a va 2 s . c o m int col_from_id = c.getColumnIndex("from_id"); do { name = invertedTags.get(new Integer(c.getInt(col_from_id))); if (name == null) { continue; } if (names.contains(name)) { continue; } names.add(name); } while (c.moveToNext()); } c.close(); if (names.size() > 0) { TagRelation relation = new TagRelation(); relation.init(names); entity.setTags(relation); } }
From source file:fr.openbike.android.database.OpenBikeDBAdapter.java
public void cleanAndInsertStations(long version, JSONArray jsonBikes) throws JSONException { if ("".equals(jsonBikes)) return;// w w w . j av a 2s . c om Cursor favorites = getFilteredStationsCursor(new String[] { BaseColumns._ID }, KEY_FAVORITE + " = 1", null); // Get count : hack for forcing cursor query favorites.getCount(); int network = jsonBikes.getJSONObject(0).getInt(Station.NETWORK); mDb.delete(STATIONS_TABLE, KEY_NETWORK + " = ?", new String[] { String.valueOf(network) }); mDb.delete(STATIONS_VIRTUAL_TABLE, KEY_NETWORK + " = ?", new String[] { String.valueOf(network) }); insertStations(jsonBikes); while (favorites.moveToNext()) { updateFavorite(favorites.getInt(0), true); } favorites.close(); mPreferences.edit().putLong(AbstractPreferencesActivity.STATIONS_VERSION, version).commit(); }
From source file:se.lu.nateko.edca.BackboneSvc.java
/** * Deactivates all layers by removing the "active" factor from * the layer mode./*from w w w .ja v a 2 s . c o m*/ */ public void deactivateLayers() { Log.d(TAG, "deactivateLayers() called."); Cursor activeLayers = getSQLhelper().fetchData(LocalSQLDBhelper.TABLE_LAYER, LocalSQLDBhelper.KEY_LAYER_COLUMNS, LocalSQLDBhelper.ALL_RECORDS, null, true); getActiveActivity().startManagingCursor(activeLayers); while (activeLayers.moveToNext()) { // As long as there's another row: if (activeLayers.getInt(2) % LocalSQLDBhelper.LAYER_MODE_ACTIVE == 0) {// If the layer is set to "active", then deactivate; getSQLhelper().updateData(LocalSQLDBhelper.TABLE_LAYER, activeLayers.getLong(0), LocalSQLDBhelper.KEY_LAYER_ID, new String[] { LocalSQLDBhelper.KEY_LAYER_USEMODE }, new String[] { String.valueOf(activeLayers.getInt(2) / LocalSQLDBhelper.LAYER_MODE_ACTIVE) }); } } }
From source file:com.phonegap.plugins.sqlitePlugin.SQLitePlugin.java
/** * Process query results.//from ww w. ja v a 2s . co m * * @param cur * Cursor into query results * @param tx_id * Transaction id */ public void processResults(Cursor cur, String query_id, String tx_id) { String result = "[]"; // If query result has rows if (cur.moveToFirst()) { JSONArray fullresult = new JSONArray(); String key = ""; int colCount = cur.getColumnCount(); // Build up JSON result object for each row do { JSONObject row = new JSONObject(); try { for (int i = 0; i < colCount; ++i) { key = cur.getColumnName(i); if (android.os.Build.VERSION.SDK_INT >= 11) { switch (cur.getType(i)) { case Cursor.FIELD_TYPE_NULL: row.put(key, null); break; case Cursor.FIELD_TYPE_INTEGER: row.put(key, cur.getInt(i)); break; case Cursor.FIELD_TYPE_FLOAT: row.put(key, cur.getFloat(i)); break; case Cursor.FIELD_TYPE_STRING: row.put(key, cur.getString(i)); break; case Cursor.FIELD_TYPE_BLOB: row.put(key, cur.getBlob(i)); break; } } else { row.put(key, cur.getString(i)); } } fullresult.put(row); } catch (JSONException e) { e.printStackTrace(); } } while (cur.moveToNext()); result = fullresult.toString(); } if (query_id.length() > 0) this.sendJavascript(" SQLitePluginTransaction.queryCompleteCallback('" + tx_id + "','" + query_id + "', " + result + ");"); }
From source file:com.ichi2.anki.tests.ContentProviderTest.java
/** * Check that querying the current model gives a valid result */// w w w . jav a 2 s . com public void testQueryCurrentModel() { final ContentResolver cr = getContext().getContentResolver(); Uri uri = Uri.withAppendedPath(FlashCardsContract.Model.CONTENT_URI, FlashCardsContract.Model.CURRENT_MODEL_ID); final Cursor modelCursor = cr.query(uri, null, null, null, null); assertNotNull(modelCursor); try { assertEquals("Check that there is exactly one result", 1, modelCursor.getCount()); assertTrue("Move to beginning of cursor", modelCursor.moveToFirst()); assertNotNull("Check non-empty field names", modelCursor.getString(modelCursor.getColumnIndex(FlashCardsContract.Model.FIELD_NAMES))); assertTrue("Check at least one template", modelCursor.getInt(modelCursor.getColumnIndex(FlashCardsContract.Model.NUM_CARDS)) > 0); } finally { modelCursor.close(); } }
From source file:com.aware.ui.ESM_UI.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // getActivity().getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); builder = new AlertDialog.Builder(getActivity()); inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); TAG = Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG) : TAG;/*from w w w. ja v a 2s. c om*/ Cursor visible_esm = getActivity().getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1"); if (visible_esm != null && visible_esm.moveToFirst()) { esm_id = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data._ID)); //Fixed: set the esm as not new anymore, to avoid displaying the same ESM twice due to changes in orientation ContentValues update_state = new ContentValues(); update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE); getActivity().getContentResolver().update(ESM_Data.CONTENT_URI, update_state, ESM_Data._ID + "=" + esm_id, null); esm_type = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.TYPE)); expires_seconds = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.EXPIRATION_THREASHOLD)); builder.setTitle(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.TITLE))); View ui = null; switch (esm_type) { case ESM.TYPE_ESM_TEXT: ui = inflater.inflate(R.layout.esm_text, null); break; case ESM.TYPE_ESM_RADIO: ui = inflater.inflate(R.layout.esm_radio, null); break; case ESM.TYPE_ESM_CHECKBOX: ui = inflater.inflate(R.layout.esm_checkbox, null); break; case ESM.TYPE_ESM_LIKERT: ui = inflater.inflate(R.layout.esm_likert, null); break; case ESM.TYPE_ESM_QUICK_ANSWERS: ui = inflater.inflate(R.layout.esm_quick, null); break; } final View layout = ui; builder.setView(layout); current_dialog = builder.create(); sContext = current_dialog.getContext(); TextView esm_instructions = (TextView) layout.findViewById(R.id.esm_instructions); esm_instructions.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.INSTRUCTIONS))); switch (esm_type) { case ESM.TYPE_ESM_TEXT: final EditText feedback = (EditText) layout.findViewById(R.id.esm_feedback); Button cancel_text = (Button) layout.findViewById(R.id.esm_cancel); cancel_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); current_dialog.cancel(); } }); Button submit_text = (Button) layout.findViewById(R.id.esm_submit); submit_text.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, feedback.getText().toString()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_RADIO: try { final RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); final JSONArray radios = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.RADIOS))); for (int i = 0; i < radios.length(); i++) { final RadioButton radioOption = new RadioButton(getActivity()); radioOption.setId(i); radioOption.setText(radios.getString(i)); radioOptions.addView(radioOption); if (radios.getString(i).equals("Other")) { radioOption.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) radioOption.setText(otherText.getText()); inputManager.hideSoftInputFromWindow(otherText.getWindowToken(), 0); editOther.dismiss(); } }); editor.addView(confirm); } }); } } Button cancel_radio = (Button) layout.findViewById(R.id.esm_cancel); cancel_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_radio = (Button) layout.findViewById(R.id.esm_submit); submit_radio.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); if (radioOptions.getCheckedRadioButtonId() != -1) { RadioButton selected = (RadioButton) radioOptions .getChildAt(radioOptions.getCheckedRadioButtonId()); rowData.put(ESM_Data.ANSWER, selected.getText().toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_CHECKBOX: try { final LinearLayout checkboxes = (LinearLayout) layout.findViewById(R.id.esm_checkboxes); final JSONArray checks = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.CHECKBOXES))); for (int i = 0; i < checks.length(); i++) { final CheckBox checked = new CheckBox(getActivity()); checked.setText(checks.getString(i)); checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (buttonView.getText().equals("Other")) { checked.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow() .setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) { inputManager.hideSoftInputFromWindow( otherText.getWindowToken(), 0); selected_options .remove(buttonView.getText().toString()); checked.setText(otherText.getText()); selected_options.add(otherText.getText().toString()); } editOther.dismiss(); } }); editor.addView(confirm); } }); } else { selected_options.add(buttonView.getText().toString()); } } else { selected_options.remove(buttonView.getText().toString()); } } }); checkboxes.addView(checked); } Button cancel_checkbox = (Button) layout.findViewById(R.id.esm_cancel); cancel_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_checkbox = (Button) layout.findViewById(R.id.esm_submit); submit_checkbox.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); if (selected_options.size() > 0) { rowData.put(ESM_Data.ANSWER, selected_options.toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_LIKERT: final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.esm_likert); ratingBar.setMax(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); ratingBar.setStepSize( (float) visible_esm.getDouble(visible_esm.getColumnIndex(ESM_Data.LIKERT_STEP))); ratingBar.setNumStars(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); TextView min_label = (TextView) layout.findViewById(R.id.esm_min); min_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MIN_LABEL))); TextView max_label = (TextView) layout.findViewById(R.id.esm_max); max_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX_LABEL))); Button cancel = (Button) layout.findViewById(R.id.esm_cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit = (Button) layout.findViewById(R.id.esm_submit); submit.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, ratingBar.getRating()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_QUICK_ANSWERS: try { final JSONArray answers = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.QUICK_ANSWERS))); final LinearLayout answersHolder = (LinearLayout) layout.findViewById(R.id.esm_answers); //If we have more than 3 possibilities, better that the UI is vertical for UX if (answers.length() > 3) { answersHolder.setOrientation(LinearLayout.VERTICAL); } for (int i = 0; i < answers.length(); i++) { final Button answer = new Button(getActivity()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); answer.setLayoutParams(params); answer.setText(answers.getString(i)); answer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); rowData.put(ESM_Data.ANSWER, (String) answer.getText()); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); answersHolder.addView(answer); } } catch (JSONException e) { e.printStackTrace(); } break; } } if (visible_esm != null && !visible_esm.isClosed()) visible_esm.close(); //Start dialog visibility threshold if (expires_seconds > 0) { expire_monitor = new ESMExpireMonitor(System.currentTimeMillis(), expires_seconds, esm_id); expire_monitor.execute(); } //Fixed: doesn't dismiss the dialog if touched outside or ghost touches current_dialog.setCanceledOnTouchOutside(false); return current_dialog; }
From source file:fr.mixit.android.io.JsonHandlerApplyMembers.java
private static boolean isItemUpdated(Uri uri, JSONObject item, ContentResolver resolver, int newMemberType) throws JSONException { final Cursor cursor = resolver.query(uri, MixItContract.Members.PROJ_DETAIL.PROJECTION, null, null, null); try {/* w w w .ja v a 2s .co m*/ if (!cursor.moveToFirst()) { return false; } String curFirstName = cursor.getString(MixItContract.Members.PROJ_DETAIL.FIRSTNAME); if (TextUtils.isEmpty(curFirstName)) { curFirstName = EMPTY; } String curLastName = cursor.getString(MixItContract.Members.PROJ_DETAIL.LASTNAME); if (TextUtils.isEmpty(curLastName)) { curLastName = EMPTY; } String curLogin = cursor.getString(MixItContract.Members.PROJ_DETAIL.LOGIN); if (TextUtils.isEmpty(curLogin)) { curLogin = EMPTY; } String curCompany = cursor.getString(MixItContract.Members.PROJ_DETAIL.COMPANY); if (TextUtils.isEmpty(curCompany)) { curCompany = EMPTY; } String curShortDesc = cursor.getString(MixItContract.Members.PROJ_DETAIL.SHORT_DESC); if (TextUtils.isEmpty(curShortDesc)) { curShortDesc = EMPTY; } String curLongDesc = cursor.getString(MixItContract.Members.PROJ_DETAIL.LONG_DESC); if (TextUtils.isEmpty(curLongDesc)) { curLongDesc = EMPTY; } String curImageUrl = cursor.getString(MixItContract.Members.PROJ_DETAIL.IMAGE_URL); if (TextUtils.isEmpty(curImageUrl)) { curImageUrl = EMPTY; } final int curNbConsults = cursor.getInt(MixItContract.Members.PROJ_DETAIL.NB_CONSULT); String curLevel = cursor.getString(MixItContract.Members.PROJ_DETAIL.LEVEL); if (TextUtils.isEmpty(curLevel)) { curLevel = EMPTY; } // final int curMemberType = cursor.getInt(MixItContract.Members.PROJ_DETAIL.TYPE); final String newFirstName = item.has(TAG_FIRSTNAME) ? item.getString(TAG_FIRSTNAME).trim() : curFirstName; final String newLastName = item.has(TAG_LASTNAME) ? item.getString(TAG_LASTNAME).trim() : curLastName; final String newLogin = item.has(TAG_LOGIN) ? item.getString(TAG_LOGIN).trim() : curLogin; final String newCompany = item.has(TAG_COMPANY) ? item.getString(TAG_COMPANY).trim() : curCompany; final String newShortDesc = item.has(TAG_SHORT_DESC) ? item.getString(TAG_SHORT_DESC).trim() : curShortDesc; final String newLongDesc = item.has(TAG_LONG_DESC) ? item.getString(TAG_LONG_DESC).trim() : curLongDesc; final String newImageUrl = item.has(TAG_LOGO) ? item.getString(TAG_LOGO).trim() : item.has(TAG_IMAGE_URL) ? item.getString(TAG_IMAGE_URL).trim() : curImageUrl; final int newNbConsults = item.has(TAG_NB_CONSULTS) ? item.getInt(TAG_NB_CONSULTS) : curNbConsults; final String newLevel = item.has(TAG_LEVEL) ? item.getString(TAG_LEVEL).trim() : curLevel; return !curFirstName.equalsIgnoreCase(newFirstName) || // !curLastName.equalsIgnoreCase(newLastName) || // !curLogin.equals(newLogin) || // !curCompany.equals(newCompany) || // !curShortDesc.equals(newShortDesc) || // !curLongDesc.equals(newLongDesc) || // !curImageUrl.equals(newImageUrl) || // curNbConsults != newNbConsults || // !curLevel.equals(newLevel) /* || // curMemberType != newMemberType && newMemberType != MixItContract.Members.TYPE_MEMBER */; } finally { if (cursor != null) { cursor.close(); } } }
From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java
private void reload() { unconfirmed = null;/*w w w . j ava2s.co m*/ queue.clear(); Cursor c = getDb().query(Pictures.TABLE, new String[] { Pictures.KEY_ID, Pictures.KEY_STATE, Pictures.KEY_FILE, Pictures.KEY_SOURCE_HINT }, Pictures.KEY_STATE + "<=?", new String[] { Integer.toString(STATE_UPLOADED) }, null, null, null); while (c.moveToNext()) { SourceHint sourceHint = null; try { String s = c.getString(3); if (s != null) sourceHint = Serialization.getJsonInstance().readValue(s, SourceHint.class); } catch (IOException e) { Log.e(THIS, "Could not read SourceHint", e); } Picture picture = new Picture(c.getInt(0), c.getString(2), c.getInt(1), sourceHint); if (picture.isUnconfirmed()) { unconfirmed = picture; if (unconfirmed != null) { Log.w(THIS, "Multiple unconfirmed Pictures, discarding: " + unconfirmed); unconfirmed.discard(); } queuedUnconfirmed = autoUpload; if (autoUpload) { queue.add(picture); } } else { queue.add(picture); } } c.close(); Log.d(THIS, "Loaded " + queue.size() + " Pictures into the queue"); if (!queue.isEmpty()) notifyUploader(); }
From source file:com.android.quicksearchbox.ShortcutRepositoryImplLog.java
/** * Returns the source ranking for sources with a minimum number of clicks. * * @param minClicks The minimum number of clicks a source must have. * @return The list of sources, ranked by total clicks. *///from w w w .ja v a 2s. c o m Map<String, Integer> getCorpusScores(int minClicks) { SQLiteDatabase db = mOpenHelper.getReadableDatabase(); final Cursor cursor = db.rawQuery(SOURCE_RANKING_SQL, new String[] { String.valueOf(minClicks) }); try { Map<String, Integer> corpora = new HashMap<String, Integer>(cursor.getCount()); while (cursor.moveToNext()) { String name = cursor.getString(SourceStats.corpus.ordinal()); int clicks = cursor.getInt(SourceStats.total_clicks.ordinal()); corpora.put(name, clicks); } return corpora; } finally { cursor.close(); } }