當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.moveToPosition方法代碼示例

本文整理匯總了Java中android.database.Cursor.moveToPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.moveToPosition方法的具體用法?Java Cursor.moveToPosition怎麽用?Java Cursor.moveToPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.moveToPosition方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getItemAt

import android.database.Cursor; //導入方法依賴的package包/類
public RecordingItem getItemAt(int position) {
    SQLiteDatabase db = getReadableDatabase();
    String[] projection = {
            DBHelperItem._ID,
            DBHelperItem.COLUMN_NAME_RECORDING_NAME,
            DBHelperItem.COLUMN_NAME_RECORDING_FILE_PATH,
            DBHelperItem.COLUMN_NAME_RECORDING_LENGTH,
            DBHelperItem.COLUMN_NAME_TIME_ADDED,
            DBHelperItem.COLUMN_NAME_IMAGE_THUMB
    };
    Cursor c = db.query(DBHelperItem.TABLE_NAME, projection, null, null, null, null, null);
    if (c.moveToPosition(position)) {
        RecordingItem item = new RecordingItem();
        item.setId(c.getInt(c.getColumnIndex(DBHelperItem._ID)));
        item.setName(c.getString(c.getColumnIndex(DBHelperItem.COLUMN_NAME_RECORDING_NAME)));
        item.setFilePath(c.getString(c.getColumnIndex(DBHelperItem.COLUMN_NAME_RECORDING_FILE_PATH)));
        item.setLength(c.getInt(c.getColumnIndex(DBHelperItem.COLUMN_NAME_RECORDING_LENGTH)));
        item.setTime(c.getLong(c.getColumnIndex(DBHelperItem.COLUMN_NAME_TIME_ADDED)));
        byte[] bytes=c.getBlob(c.getColumnIndex(DBHelperItem.COLUMN_NAME_IMAGE_THUMB));
        item.setImageThumbnail(BitmapFactory.decodeByteArray(bytes, 0, bytes.length));
        c.close();
        return item;
    }
    return null;
}
 
開發者ID:adarshgumashta,項目名稱:Facebook-Video-Downloader,代碼行數:26,代碼來源:DBHelper.java

示例2: extractCheckedContacts

import android.database.Cursor; //導入方法依賴的package包/類
public List<Contact> extractCheckedContacts() {
    List<Contact> list = new LinkedList<>();
    Cursor cursor = getCursor();
    if (cursor != null) {
        int position = cursor.getPosition();
        cursor.moveToFirst();
        do {
            Contact contact = ((ContactSource) cursor).getContact();
            if (checkedItems.contains((int) contact.id)) {
                list.add(contact);
            }
        } while (cursor.moveToNext());
        cursor.moveToPosition(position);
    }
    return list;
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:17,代碼來源:ContactsCursorAdapter.java

示例3: refreshSelection

import android.database.Cursor; //導入方法依賴的package包/類
public void refreshSelection() {
    GridLayoutManager layoutManager = (GridLayoutManager) mRecyclerView.getLayoutManager();
    int first = layoutManager.findFirstVisibleItemPosition();
    int last = layoutManager.findLastVisibleItemPosition();
    if (first == -1 || last == -1) {
        return;
    }
    Cursor cursor = getCursor();
    for (int i = first; i <= last; i++) {
        RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(first);
        if (holder instanceof MediaViewHolder) {
            if (cursor.moveToPosition(i)) {
                setCheckStatus(Item.valueOf(cursor), ((MediaViewHolder) holder).mMediaGrid);
            }
        }
    }
}
 
開發者ID:sathishmscict,項目名稱:Matisse-Image-and-Video-Selector,代碼行數:18,代碼來源:AlbumMediaAdapter.java

示例4: searchAlarmUri

import android.database.Cursor; //導入方法依賴的package包/類
private Uri searchAlarmUri(int alarmId) {
    Context context = MBApp.getApp();

    RingtoneManager ringtoneMgr = new RingtoneManager(context);
    ringtoneMgr.setType(RingtoneManager.TYPE_ALARM);
    Cursor alarms = ringtoneMgr.getCursor();
    Log.i(TAG, "playAlarm: total alarms = " + alarms.getCount());

    alarms.moveToPosition(alarmId - 4);
    Uri alarm = ringtoneMgr.getRingtoneUri(alarms.getPosition());

    if(alarm == null) {
        Log.i(TAG, "Cannot play nth Alarm. Playing default");
        alarm = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    }

    return alarm;
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:19,代碼來源:AlertPlugin.java

示例5: onItemClick

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Cursor cursor = hostsAdapter.getCursor();
    cursor.moveToPosition(position);
    Intent outputIntent = new Intent();
    outputIntent.putExtra(Constants.HOST_BUNDLE_URL, cursor.getString(cursor.getColumnIndex(Host.COLUMN_URL)));
    outputIntent.putExtra(Constants.HOST_BUNDLE_LOGIN, cursor.getString(cursor.getColumnIndex(Host.COLUMN_LOGIN)));
    outputIntent.putExtra(Constants.HOST_BUNDLE_PASSWORD, cursor.getString(cursor.getColumnIndex(Host.COLUMN_PASSWORD)));
    setResult(RESULT_OK, outputIntent);
    finish();
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:12,代碼來源:HostActivity.java

示例6: getUIDFromRowCount

import android.database.Cursor; //導入方法依賴的package包/類
private int getUIDFromRowCount(long rowCount) {
    int UID = -1;
    int intRowCount = (int) rowCount;
    SQLiteDatabase db = mDatabaseHelper.getWritableDatabase ();
    Cursor cursor = db.query (DatabaseHelper.TABLE_NAME, null, null, null, null, null, null);
    Log.d (TAG, "getUIDFromRowCount: rowCount = "+rowCount);
    if (cursor.getCount () != 0) {
        cursor.moveToPosition (intRowCount - 1);
        UID = cursor.getInt (cursor.getColumnIndex (DatabaseHelper.KEY_ID));
    }
    cursor.close ();
    db.close ();
    return UID;
}
 
開發者ID:atulgpt,項目名稱:TimeTrix,代碼行數:15,代碼來源:DatabaseAdapter.java

示例7: putPageInfo

import android.database.Cursor; //導入方法依賴的package包/類
private static void putPageInfo(Cursor photos, WritableMap response, int limit) {
  WritableMap pageInfo = new WritableNativeMap();
  pageInfo.putBoolean("has_next_page", limit < photos.getCount());
  if (limit < photos.getCount()) {
    photos.moveToPosition(limit - 1);
    pageInfo.putString(
        "end_cursor",
        photos.getString(photos.getColumnIndex(Images.Media.DATE_TAKEN)));
  }
  response.putMap("page_info", pageInfo);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:12,代碼來源:CameraRollManager.java

示例8: onLoadAudio

import android.database.Cursor; //導入方法依賴的package包/類
private List<Folder> onLoadAudio(Cursor cursor) {
    if (cursor.getPosition() != -1) {
        cursor.moveToPosition(-1);
    }
    List<Folder> folders = new ArrayList<>();
    List<BaseFile> audioFiles = new ArrayList<>();
    while (cursor.moveToNext()) {
        //Create a File instance
        AudioFile audio = new AudioFile();
        audio.setId(cursor.getLong(cursor.getColumnIndexOrThrow(_ID)));
        audio.setName(cursor.getString(cursor.getColumnIndexOrThrow(TITLE)));
        audio.setPath(cursor.getString(cursor.getColumnIndexOrThrow(DATA)));
        audio.setSize(cursor.getLong(cursor.getColumnIndexOrThrow(SIZE)));
        audio.setDate(cursor.getLong(cursor.getColumnIndexOrThrow(DATE_ADDED)));

        audio.setDuration(cursor.getLong(cursor.getColumnIndexOrThrow(DURATION)));
        audioFiles.add(audio);
        //Create a Folder
        Folder folder = new Folder();
        folder.setName(Util.extractName(Util.extractDirectory(audio.getPath())));
        folder.setPath(Util.extractDirectory(audio.getPath()));

        if (!folders.contains(folder)) {
            folder.addFile(audio);
            folders.add(folder);
        } else {
            folders.get(folders.indexOf(folder)).addFile(audio);
        }
    }
    Folder all = new Folder();
    all.setName(mContext.getString(R.string.all));
    all.setFiles(audioFiles);
    all.setSelected(true);
    folders.add(0, all);
    return folders;
}
 
開發者ID:liuke2016,項目名稱:filepicker,代碼行數:37,代碼來源:AudioPickerModel.java

示例9: onContextItemSelected

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    String[] actions = getResources().getStringArray(R.array.list_hosts_actions);
    if (item.getTitle().equals(actions[0])) {
        AdapterView.AdapterContextMenuInfo contextMenuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        int position = contextMenuInfo.position;
        Cursor cursor = getHostsAdapter().getCursor();
        cursor.moveToPosition(position);
        removeHost(cursor.getString(cursor.getColumnIndex(Host.COLUMN_URL)));
    }
    return super.onContextItemSelected(item);
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:13,代碼來源:MainHostsFragment.java

示例10: onItemClick

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> adapterView, View view,
                        int position, long id) {
    Cursor cursor = mCursorAdapter.getCursor();
    cursor.moveToPosition(position);
    Intent intent = new Intent(getActivity(), GraphActivity.class);
    intent.putExtra(Constants.GRAPH_ID, cursor.getString(cursor.getColumnIndex(Bookmark.COLUMN_GRAPH_ID)));
    intent.putExtra(Constants.HOST_ID, cursor.getString(cursor.getColumnIndex(Bookmark.COLUMN_SERVER_ID)));
    intent.putExtra(Constants.HOST_NAME, cursor.getString(cursor.getColumnIndex(Bookmark.COLUMN_SERVER_NAME)));
    intent.putExtra(Constants.PARAM_NAME, cursor.getString(cursor.getColumnIndex(Bookmark.COLUMN_PARAM_NAME)));
    intent.putExtra(Constants.PERIOD, cursor.getString(cursor.getColumnIndex(Bookmark.COLUMN_PERIOD)));
    startActivity(intent);
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:14,代碼來源:BookmarksFragment.java

示例11: getLoadingDownloadInfo

import android.database.Cursor; //導入方法依賴的package包/類
public DownloadDBListBean getLoadingDownloadInfo() {
    DownloadDBListBean list = new DownloadDBListBean();
    boolean flag = false;
    Cursor cursor = null;
    try {
        cursor = this.context.getContentResolver().query(LetvContentProvider.URI_WORLDCUPTRACE, null, "finish<>?", new String[]{"4"}, "timestamp ASC");
        if (!PreferencesManager.getInstance().hasUpdateMulti()) {
            if (cursor != null && cursor.getCount() > 0) {
                while (cursor.moveToNext()) {
                    int episodeId = cursor.getInt(cursor.getColumnIndex("episodeid"));
                    if (!DownloadManager.getInstance(this.context).isDownloadExist(episodeId + "")) {
                        delete(episodeId);
                        flag = true;
                    }
                }
            }
            PreferencesManager.getInstance().updateMulti();
        }
        if (flag) {
            cursor = this.context.getContentResolver().query(LetvContentProvider.URI_WORLDCUPTRACE, null, "finish<>?", new String[]{"4"}, "timestamp ASC");
        } else {
            cursor.moveToPosition(-1);
        }
        while (cursor.moveToNext()) {
            list.add(createDownloadDBBean(cursor));
        }
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
        return list;
    } finally {
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
    }
    return list;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:40,代碼來源:WorldCupTraceHandler.java

示例12: onItemClick

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Cursor cursor = ((SimpleCursorAdapter) parent.getAdapter()).getCursor();

    cursor.moveToPosition(position);

    String contactName = cursor.getString(LOOKUP_KEY_INDEX);

    Uri mContactUri = ContactsContract.Contacts.getLookupUri(
            cursor.getLong(CONTACT_ID_INDEX),
            contactName
    );

    String email = getEmail(mContactUri);

    if(!email.equals(""))
        sendEmail(email, contactName);

}
 
開發者ID:micromasterandroid,項目名稱:androidbeginners-Lesson3,代碼行數:21,代碼來源:MainActivity.java

示例13: getSongs

import android.database.Cursor; //導入方法依賴的package包/類
public ArrayList<Songs> getSongs(String withWhat,String content)
{   Cursor c;
    ArrayList<Songs> s= new ArrayList<>();
    String  orderby = MediaStore.Audio.Media.TITLE;;
    boolean condition;
    String[]  col = {MediaStore.Audio.Albums._ID ,MediaStore.Audio.Media.DATA,MediaStore.Audio.Media.ALBUM,MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.COMPOSER, MediaStore.Audio.Media.DURATION};
    final String where= "is_music AND duration > 10000";

    c= context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,col ,where ,null,orderby) ;
    for(int i=0 ;i< c.getCount() ; i++)
    { Songs songs = new Songs();
        c.moveToPosition(i);
        switch(withWhat)
        {
            case "album" : if(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)).equals(content))
                               {
                                   songs.settitle(c.getString(c.getColumnIndex(MediaStore.Audio.Media.TITLE)));
                                   songs.setSonguri(Uri.parse(c.getString(c.getColumnIndex(MediaStore.Audio.Media.DATA))));
                                   songs.setartist(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ARTIST)));
                                   songs.setalbum(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)));
                                   songs.setDuration(Long.decode(c.getString(c.getColumnIndex(MediaStore.Audio.Media.DURATION))));
                                   songs.setPosition(i);
                                   songs.setAlbumart(albumartwithalbum(content));
                                   s.add(songs);
                               }
                break;

            case "artist" : if(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ARTIST)).equals(content))
            {
                songs.settitle(c.getString(c.getColumnIndex(MediaStore.Audio.Media.TITLE)));
                songs.setSonguri(Uri.parse(c.getString(c.getColumnIndex(MediaStore.Audio.Media.DATA))));
                songs.setartist(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ARTIST)));
                songs.setalbum(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)));
                songs.setDuration(Long.decode(c.getString(c.getColumnIndex(MediaStore.Audio.Media.DURATION))));
                songs.setPosition(i);
                songs.setAlbumart(albumartwithalbum(songs.getalbum()));
                s.add(songs);
            }
                break ;

            case "geners" :
                if(c.getString(c.getColumnIndex(MediaStore.Audio.Media.COMPOSER)).equals(content))
                {
                    songs.settitle(c.getString(c.getColumnIndex(MediaStore.Audio.Media.TITLE)));
                    songs.setSonguri(Uri.parse(c.getString(c.getColumnIndex(MediaStore.Audio.Media.DATA))));
                    songs.setartist(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ARTIST)));
                    songs.setalbum(c.getString(c.getColumnIndex(MediaStore.Audio.Media.ALBUM)));
                    songs.setDuration(Long.decode(c.getString(c.getColumnIndex(MediaStore.Audio.Media.DURATION))));
                    songs.setPosition(i);
                    songs.setAlbumart(albumartwithalbum(songs.getalbum()));
                    s.add(songs);
                }
                break;
            default:  return null ;
        }

    }
    for(int j=0 ;j< s.size();j++)
    {
        Log.d("positions--->",""+s.get(j).getPosition());
    }
    c.close();
    return s;
}
 
開發者ID:mdnafiskhan,項目名稱:Mp3Player,代碼行數:65,代碼來源:songDetailloader.java

示例14: getLoadingDownloadInfo

import android.database.Cursor; //導入方法依賴的package包/類
public DownloadDBListBean getLoadingDownloadInfo() {
    DownloadDBListBean list = new DownloadDBListBean();
    Cursor cursor = this.mContext.getContentResolver().query(LetvContentProvider.URI_DOWNLOADTRACE, null, "finish<>?", new String[]{"4"}, "timestamp ASC");
    if (cursor != null) {
        if (!PreferencesManager.getInstance().hasUpdateMulti()) {
            if (cursor != null && cursor.getCount() > 0) {
                while (cursor.moveToNext()) {
                    cursor.getInt(cursor.getColumnIndex("episodeid"));
                }
            }
            PreferencesManager.getInstance().updateMulti();
        }
        if (false) {
            cursor = this.mContext.getContentResolver().query(LetvContentProvider.URI_DOWNLOADTRACE, null, "finish<>?", new String[]{"4"}, "timestamp ASC");
        } else {
            cursor.moveToPosition(-1);
        }
        while (cursor.moveToNext()) {
            DownloadDBBean mDownloadDBBean = new DownloadDBBean();
            mDownloadDBBean.vid = cursor.getInt(cursor.getColumnIndex("episodeid"));
            mDownloadDBBean.aid = cursor.getInt(cursor.getColumnIndex(PageJumpUtil.IN_TO_ALBUM_PID));
            mDownloadDBBean.icon = cursor.getString(cursor.getColumnIndex(SettingsJsonConstants.APP_ICON_KEY));
            mDownloadDBBean.type = cursor.getInt(cursor.getColumnIndex("type"));
            mDownloadDBBean.ord = (float) cursor.getInt(cursor.getColumnIndex("ord"));
            mDownloadDBBean.cid = cursor.getInt(cursor.getColumnIndex("cid"));
            mDownloadDBBean.episodetitle = cursor.getString(cursor.getColumnIndex("episodetitle"));
            mDownloadDBBean.episodeIcon = cursor.getString(cursor.getColumnIndex("episodeicon"));
            mDownloadDBBean.albumtitle = cursor.getString(cursor.getColumnIndex(DownloadAlbumTable.COLUMN_ALBUMTITLE));
            mDownloadDBBean.totalsize = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_TOTALSIZE));
            mDownloadDBBean.finish = cursor.getInt(cursor.getColumnIndex("finish"));
            mDownloadDBBean.timestamp = cursor.getLong(cursor.getColumnIndex("timestamp"));
            mDownloadDBBean.length = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_LENGTH));
            mDownloadDBBean.isHd = cursor.getInt(cursor.getColumnIndex("isHd"));
            mDownloadDBBean.isNew = cursor.getInt(cursor.getColumnIndex(DownloadVideoTable.COLUMN_ISNEW));
            mDownloadDBBean.btime = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_BTIME));
            mDownloadDBBean.etime = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_ETIME));
            mDownloadDBBean.duration = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_DURATION));
            list.add(mDownloadDBBean);
        }
        cursor.close();
    }
    return list;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:44,代碼來源:DownloadTraceHandler.java

示例15: SortingCursorWrapper

import android.database.Cursor; //導入方法依賴的package包/類
public SortingCursorWrapper(Cursor cursor, int sortOrder) {
    mCursor = cursor;

    final int count = cursor.getCount();
    mPosition = new int[count];
    switch (sortOrder) {
        case SORT_ORDER_DISPLAY_NAME:
            mValueString = new String[count];
            mValueLong = null;
            break;
        case SORT_ORDER_LAST_MODIFIED:
        case SORT_ORDER_SIZE:
            mValueString = null;
            mValueLong = new long[count];
            break;
        default:
            throw new IllegalArgumentException();
    }

    cursor.moveToPosition(-1);
    for (int i = 0; i < count; i++) {
        cursor.moveToNext();
        mPosition[i] = i;

        switch (sortOrder) {
            case SORT_ORDER_DISPLAY_NAME:
                final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
                final String displayName = getCursorString(
                        cursor, Document.COLUMN_DISPLAY_NAME);
                if (Utils.isDir(mimeType)) {
                    mValueString[i] = DocumentInfo.DIR_PREFIX + displayName;
                } else {
                    mValueString[i] = displayName;
                }
                break;
            case SORT_ORDER_LAST_MODIFIED:
                mValueLong[i] = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
                break;
            case SORT_ORDER_SIZE:
                mValueLong[i] = getCursorLong(cursor, Document.COLUMN_SIZE);
                break;
        }
    }

    switch (sortOrder) {
        case SORT_ORDER_DISPLAY_NAME:
            synchronized (SortingCursorWrapper.class) {

                binarySort(mPosition, mValueString);
            }
            break;
        case SORT_ORDER_LAST_MODIFIED:
        case SORT_ORDER_SIZE:
            binarySort(mPosition, mValueLong);
            break;
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:58,代碼來源:SortingCursorWrapper.java


注:本文中的android.database.Cursor.moveToPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。