List of usage examples for android.database Cursor moveToPosition
boolean moveToPosition(int position);
From source file:org.sensapp.android.sensappdroid.fragments.CompositeListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); Cursor c = adapter.getCursor(); c.moveToPosition(info.position); String name = c.getString(c.getColumnIndexOrThrow(SensAppContract.Composite.NAME)); switch (item.getItemId()) { case MENU_DELETE_ID: new DeleteCompositeTask(getActivity()).execute(name); return true; case MENU_MANAGESENSORS_ID: ManageCompositeDialogFragment.newInstance(name).show(getFragmentManager(), "ManageCompositeDialog"); return true; case MENU_UPLOAD_ID: new PostComposite(PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()), getResources(), getActivity(), name); return true; }/*ww w . ja va 2 s . co m*/ return super.onContextItemSelected(item); }
From source file:ru.caseagency.twitteraddressbook.addressbook.ContactsListFragment.java
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // Gets the Cursor object currently bound to the ListView final Cursor cursor = mAdapter.getCursor(); // Moves to the Cursor row corresponding to the ListView item that was clicked cursor.moveToPosition(position); // Creates a contact lookup Uri from contact ID and lookup_key final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY)); // Notifies the parent activity that the user selected a contact. In a two-pane layout, the // parent activity loads a ContactDetailFragment that displays the details for the selected // contact. In a single-pane layout, the parent activity starts a new activity that // displays contact details in its own Fragment. mOnContactSelectedListener.onContactSelected(uri); }
From source file:org.mozilla.gecko.home.ReadingListPanel.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mTopView = view;/* ww w . ja v a 2 s . c om*/ mList = (HomeListView) view.findViewById(R.id.list); mList.setTag(HomePager.LIST_TAG_READING_LIST); mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Cursor c = mAdapter.getCursor(); if (c == null || !c.moveToPosition(position)) { return; } String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL)); url = ReaderModeUtils.getAboutReaderForUrl(url); Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM); // This item is a TwoLinePageRow, so we allow switch-to-tab. mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB)); } }); mList.setContextMenuInfoFactory(new HomeContextMenuInfo.Factory() { @Override public HomeContextMenuInfo makeInfoForCursor(View view, int position, long id, Cursor cursor) { final HomeContextMenuInfo info = new HomeContextMenuInfo(view, position, id); info.url = cursor.getString(cursor.getColumnIndexOrThrow(ReadingListItems.URL)); info.title = cursor.getString(cursor.getColumnIndexOrThrow(ReadingListItems.TITLE)); info.readingListItemId = cursor.getInt(cursor.getColumnIndexOrThrow(ReadingListItems._ID)); info.itemType = RemoveItemType.READING_LIST; return info; } }); registerForContextMenu(mList); }
From source file:com.jsw.MngProductDatabase.Fragments.ManageProduct_Fragment.java
private void save() { Cursor cursor = ((SimpleCursorAdapter) mCategory.getAdapter()).getCursor(); cursor.moveToPosition(mCategory.getSelectedItemPosition()); int id = 0;//w ww. j a v a 2s. c om if (oldProduct != null) id = oldProduct.getID(); mCallBack.saveProduct(oldProduct, new Product(id, mName.getEditText().getText().toString(), mDescription.getEditText().getText().toString(), mTrademark.getEditText().getText().toString(), mDosage.getEditText().getText().toString(), Double.valueOf(mPrice.getEditText().getText().toString()), mStock.getEditText().getText().toString(), mUrl.getEditText().getText().toString(), 1)); }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.transformationmanager.database.LocalTransformationDBMS.java
private Transformation cursorToTransformation(Cursor cursor, int position) { if (cursor.moveToPosition(position)) { Transformation transformation = new Transformation( cursor.getLong(cursor.getColumnIndex(LocalTransformationDB.COLUMN_BUNDLE_ID)), cursor.getString(cursor.getColumnIndex(LocalTransformationDB.COLUMN_TRANSFORMATION_NAME)), cursor.getString(cursor.getColumnIndex(LocalTransformationDB.COLUMN_PRODUCED_EVENT_TYPE)), cursor.getInt(cursor.getColumnIndex(LocalTransformationDB.COLUMN_TRANSFORMATION_COSTS))); String requiredEventTypes = cursor .getString(cursor.getColumnIndex(LocalTransformationDB.COLUMN_REQUIRED_EVENT_TYPES)); String[] types = requiredEventTypes.split(";"); for (String type : types) { if (D) Log.d(TAG, "required event type: " + type); transformation.addRequiredEvent(type); }// w ww. j ava2 s . c o m return transformation; } else return null; }
From source file:android.database.DatabaseUtils.java
/** * Prints the contents of a Cursor to a PrintSteam. The position is restored * after printing./*from w ww.j a v a 2 s. c o m*/ * * @param cursor the cursor to print * @param stream the stream to print to */ public static void dumpCursor(Cursor cursor, PrintStream stream) { stream.println(">>>>> Dumping cursor " + cursor); if (cursor != null) { int startPos = cursor.getPosition(); cursor.moveToPosition(-1); while (cursor.moveToNext()) { dumpCurrentRow(cursor, stream); } cursor.moveToPosition(startPos); } stream.println("<<<<<"); }
From source file:android.database.DatabaseUtils.java
/** * Prints the contents of a Cursor to a StringBuilder. The position * is restored after printing.//from ww w. java2 s .c o m * * @param cursor the cursor to print * @param sb the StringBuilder to print to */ public static void dumpCursor(Cursor cursor, StringBuilder sb) { sb.append(">>>>> Dumping cursor " + cursor + "\n"); if (cursor != null) { int startPos = cursor.getPosition(); cursor.moveToPosition(-1); while (cursor.moveToNext()) { dumpCurrentRow(cursor, sb); } cursor.moveToPosition(startPos); } sb.append("<<<<<\n"); }
From source file:com.cw.litenote.operation.delete.DeletePages.java
void doDeletePages() { DB_folder mDbFolder = new DB_folder(MainAct.mAct, DB_folder.getFocusFolder_tableId()); mDbFolder.open();/*w w w .j ava 2s. co m*/ for (int i = 0; i < list_selPage.count; i++) { if (list_selPage.mCheckedTabs.get(i)) { int pageTableId = mDbFolder.getPageTableId(i, false); mDbFolder.dropPageTable(pageTableId, false); int pageId = mDbFolder.getPageId(i, false); // delete page row mDbFolder.deletePage(DB_folder.getFocusFolder_tableName(), pageId, false); } } mDbFolder.close(); mDbFolder.open(); // check if only one page left int pgsCnt = mDbFolder.getPagesCount(false); if (pgsCnt > 0) { int newFirstPageTblId = 0; int i = 0; Cursor mPageCursor = mDbFolder.getPageCursor(); while (i < pgsCnt) { mPageCursor.moveToPosition(i); if (mPageCursor.isFirst()) newFirstPageTblId = mDbFolder.getPageTableId(i, false); i++; } System.out.println("TabsHost / _postDeletePage / newFirstPageTblId = " + newFirstPageTblId); Pref.setPref_focusView_page_tableId(act, newFirstPageTblId); } else if (pgsCnt == 0) Pref.setPref_focusView_page_tableId(act, 0);//todo 0 OK? mDbFolder.close(); // set scroll X // int scrollX = 0; //over the last scroll X // Pref.setPref_focusView_scrollX_byFolderTableId(act, scrollX ); if (BackgroundAudioService.mMediaPlayer != null) { Audio_manager.stopAudioPlayer(); Audio_manager.mAudioPos = 0; Audio_manager.setPlayerState(Audio_manager.PLAYER_AT_STOP); } list_selPage = new List_selectPage(act, rootView, mListView); }
From source file:com.hplasplas.weather.activitys.SearchPlaceActivity.java
private void deliveryId(int CursorPosition) { Cursor cursor = mSearchView.getSuggestionsAdapter().getCursor(); if (cursor != null) { cursor.moveToPosition(CursorPosition); searchedPlaceSelected(cursor.getInt(cursor.getColumnIndex(COLUMNS_PLACE_ID))); }//from w w w . j a v a 2 s. c o m }
From source file:tom.udacity.sample.sunrise.ForecastFragment.java
private void openPreferredLocationInMap() { // Using the URI scheme for showing a location found on a map. This super-handy // intent can is detailed in the "Common Intents" page of Android's developer site: // http://developer.android.com/guide/components/intents-common.html#Maps if (null != mForecastAdapter) { Cursor c = mForecastAdapter.getCursor(); if (null != c) { c.moveToPosition(0); String posLat = c.getString(COL_COORD_LAT); String posLong = c.getString(COL_COORD_LONG); Uri geoLocation = Uri.parse("geo:" + posLat + "," + posLong); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(geoLocation); if (intent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(intent);/*w w w .ja va 2s . c o m*/ } else { Log.d(LOG_TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!"); } } } }