private void updateCursor(final long trackId) { MusicInfo info = mPlaylistInfo.get(trackId); if (mPlaylistInfo.get(trackId) != null) { MatrixCursor cursor = new MatrixCursor(PROJECTION); cursor.addRow(new Object[]{info.songId, info.artist, info.albumName, info.musicName , info.data, info.albumData, info.albumId, info.artistId}); cursor.moveToFirst(); mCursor = cursor; cursor.close(); } }
@Override public void close() { super.close(); if (mLoadingTask != null && mLoadingTask.getStatus() != Status.FINISHED) { if(BuildConfig.DEBUG) Log.d(TAG, "Cursor is closed. Cancel the loading task " + mLoadingTask); // Interrupting the task is not a good choice as it's waiting for the Samba client thread // returning the result. Interrupting the task only frees the task from waiting for the // result, rather than freeing the Samba client thread doing the hard work. mLoadingTask.cancel(false); } } }
public Cursor query(@NonNull Uri paramUri, String[] paramArrayOfString1, String paramString1, String[] paramArrayOfString2, String paramString2) { MatrixCursor cursor = new MatrixCursor(new String[]{"string"}); try { if (getContext() == null) return cursor; final String path = paramUri.getPath().substring(1); final String[] items = getContext().getAssets().list(path); for (String s : items) { cursor.newRow().add(s); cursor.moveToNext(); } cursor.moveToFirst(); } catch (Exception e) { cursor.close(); throw new RuntimeException(e); } return cursor; }
public Cursor query(@NonNull Uri paramUri, String[] paramArrayOfString1, String paramString1, String[] paramArrayOfString2, String paramString2) { MatrixCursor cursor = new MatrixCursor(new String[]{"string"}); try { if (getContext() == null) return cursor; final String path = paramUri.getPath().substring(1); final String[] items = getContext().getAssets().list(path); for (String s : items) { cursor.newRow().add(s); cursor.moveToNext(); } cursor.moveToFirst(); } catch (Exception e) { cursor.close(); throw new RuntimeException(e); } return cursor; }
public Cursor query(@NonNull Uri paramUri, String[] paramArrayOfString1, String paramString1, String[] paramArrayOfString2, String paramString2) { MatrixCursor cursor = new MatrixCursor(new String[]{"string"}); try { if (getContext() == null) return cursor; final String path = paramUri.getPath().substring(1); final String[] items = getContext().getAssets().list(path); for (String s : items) { cursor.newRow().add(s); cursor.moveToNext(); } cursor.moveToFirst(); } catch (Exception e) { cursor.close(); throw new RuntimeException(e); } return cursor; }
mMatrixCursor.close();
private Cursor addEmptyItem(Cursor cursor) { MatrixCursor matrixCursor = null; try { matrixCursor = new MatrixCursor(new String[] { Database.SHADERS_ID, Database.SHADERS_THUMB, Database.SHADERS_NAME, Database.SHADERS_MODIFIED }); matrixCursor.addRow(new Object[] { 0, null, getString(R.string.no_shader_selected), null }); return new MergeCursor(new Cursor[] { matrixCursor, cursor }); } finally { if (matrixCursor != null) { matrixCursor.close(); } } } }