当前位置: 首页>>代码示例>>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;未经允许,请勿转载。