Java Code Examples for android.database.Cursor#getExtras()

The following examples show how to use android.database.Cursor#getExtras() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuggestionsAdapter.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void updateSpinnerState(Cursor cursor) {
    Bundle extras = cursor != null ? cursor.getExtras() : null;
    if (DBG) {
        Log.d(LOG_TAG, "updateSpinnerState - extra = "
            + (extras != null
                    ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
                    : null));
    }
    // Check if the Cursor indicates that the query is not complete and show the spinner
    if (extras != null
            && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
        // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
        return;
    }
    // If cursor is null or is done, stop the spinner
    // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}
 
Example 2
Source File: SuggestionsAdapter.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
private void updateSpinnerState(Cursor cursor) {
    Bundle extras = cursor != null ? cursor.getExtras() : null;
    if (DBG) {
        Log.d(LOG_TAG, "updateSpinnerState - extra = "
                + (extras != null
                ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
                : null));
    }
    // Check if the Cursor indicates that the query is not complete and show the spinner
    if (extras != null
            && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
        // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
        return;
    }
    // If cursor is null or is done, stop the spinner
    // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}
 
Example 3
Source File: SuggestionsAdapter.java    From zen4android with MIT License 6 votes vote down vote up
private void updateSpinnerState(Cursor cursor) {
    Bundle extras = cursor != null ? cursor.getExtras() : null;
    if (DBG) {
        Log.d(LOG_TAG, "updateSpinnerState - extra = "
                + (extras != null
                ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
                : null));
    }
    // Check if the Cursor indicates that the query is not complete and show the spinner
    if (extras != null
            && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
        // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
        return;
    }
    // If cursor is null or is done, stop the spinner
    // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}
 
Example 4
Source File: SuggestionsAdapter.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
private void updateSpinnerState(Cursor cursor) {
    Bundle extras = cursor != null ? cursor.getExtras() : null;
    if (DBG) {
        Log.d(LOG_TAG, "updateSpinnerState - extra = "
                + (extras != null
                ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
                : null));
    }
    // Check if the Cursor indicates that the query is not complete and show the spinner
    if (extras != null
            && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
        // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
        return;
    }
    // If cursor is null or is done, stop the spinner
    // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}
 
Example 5
Source File: SuggestionsAdapter.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
private void updateSpinnerState(Cursor cursor) {
    Bundle extras = cursor != null ? cursor.getExtras() : null;
    if (DBG) {
        Log.d(LOG_TAG, "updateSpinnerState - extra = "
                + (extras != null
                ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
                : null));
    }
    // Check if the Cursor indicates that the query is not complete and show the spinner
    if (extras != null
            && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
        // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
        return;
    }
    // If cursor is null or is done, stop the spinner
    // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}
 
Example 6
Source File: ImageClientFragment.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    Bundle extras = cursor.getExtras();
    int totalSize = extras.getInt(ContentResolver.EXTRA_SIZE);
    mAdapter.setTotalSize(totalSize);
    int beforeCount = mAdapter.getFetchedItemCount();
    while (cursor.moveToNext()) {
        String displayName = cursor.getString(cursor.getColumnIndex(
                ImageContract.Columns.DISPLAY_NAME));
        String absolutePath = cursor.getString(cursor.getColumnIndex(
                ImageContract.Columns.ABSOLUTE_PATH));

        ImageAdapter.ImageDocument imageDocument = new ImageAdapter.ImageDocument();
        imageDocument.mAbsolutePath = absolutePath;
        imageDocument.mDisplayName = displayName;
        mAdapter.add(imageDocument);
    }
    int cursorCount = cursor.getCount();
    if (cursorCount == 0) {
        return;
    }
    Activity activity = ImageClientFragment.this.getActivity();
    mAdapter.notifyItemRangeChanged(beforeCount, cursorCount);
    int offsetSnapShot = mOffset.get();
    String message = activity.getResources()
            .getString(R.string.fetched_images_out_of, offsetSnapShot + 1,
                    offsetSnapShot + cursorCount, totalSize);
    mOffset.addAndGet(cursorCount);
    Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
}
 
Example 7
Source File: FavoritesAndContactsLoader.java    From call_manage with MIT License 5 votes vote down vote up
@Override
public Cursor loadInBackground() {
    List<Cursor> cursors = new ArrayList<>();
    int favoritesCount = 0;
    try {
        if (mLoadFavorites) {
            Cursor favoritesCursor = loadFavoritesContacts();
            cursors.add(favoritesCursor);
            favoritesCount = favoritesCursor.getCount();
        }
    } catch (NullPointerException e) {
        favoritesCount = 0;
    }

    final Cursor contactsCursor = loadContacts();
    cursors.add(contactsCursor);

    final int finalFavoritesCount = favoritesCount;

    return new MergeCursor(cursors.toArray(new Cursor[0])) {
        @Override
        public Bundle getExtras() {
            // Need to get the extras from the contacts cursor.
            Bundle extras = contactsCursor == null ? new Bundle() : contactsCursor.getExtras();
            extras.putInt(FAVORITES_COUNT, finalFavoritesCount);
            return extras;
        }
    };
}
 
Example 8
Source File: ActivityManagerNativeWorker.java    From GPT with Apache License 2.0 5 votes vote down vote up
/**
 * getContentProviderHolder
 *
 * @param hostContext Context
 * @param authority   authority
 * @return ContentProviderHolder
 */
public static ContentProviderHolder getContentProviderHolder(Context hostContext, String authority) {
    ContentProviderHolder holder = null;

    String packageName = ContentProviderProxy.getProviderPackageName(hostContext, authority);
    if (packageName == null || packageName.length() == 0) {
        return null;
    }

    GPTPackageInfo pkginfo = GPTPackageManager.getInstance(hostContext).getPackageInfo(packageName);
    if (pkginfo == null) {
        return null;
    }

    // 插件是否运行在主进程
    boolean runOnHostProcess = pkginfo.isUnionProcess;

    // 中转代理provider
    String proxyAuthority = hostContext.getPackageName() + "_" + ContentProviderProxy.AUTHORITY;
    if (!runOnHostProcess) {
        proxyAuthority = hostContext.getPackageName() + "_" + ContentProviderProxy.AUTHORITY_EXT;
    }

    Uri uri = Uri.parse("content://" + proxyAuthority);
    Cursor c = null;

    String[] projection = {packageName, authority};
    c = hostContext.getContentResolver().query(uri, projection, null, null, null);

    if (c != null) {
        Bundle bundle = c.getExtras();
        holder = bundle.getParcelable("provider");

        c.close();
    }

    return holder;
}
 
Example 9
Source File: RemoteCursor.java    From CC with Apache License 2.0 5 votes vote down vote up
public static IRemoteCCService getRemoteCCService(Cursor cursor) {
    if (null == cursor) {
        return null;
    }
    Bundle bundle = cursor.getExtras();
    bundle.setClassLoader(BinderWrapper.class.getClassLoader());
    BinderWrapper binderWrapper = bundle.getParcelable(KEY_BINDER_WRAPPER);
    if (binderWrapper != null) {
        IBinder binder = binderWrapper.getBinder();
        return IRemoteCCService.Stub.asInterface(binder);
    }
    return null;
}
 
Example 10
Source File: BinderCursor.java    From springreplugin with Apache License 2.0 5 votes vote down vote up
public static final IBinder getBinder(Cursor cursor) {
    Bundle extras = cursor.getExtras();
    extras.setClassLoader(BinderCursor.class.getClassLoader());
    BinderParcelable w = (BinderParcelable) extras.getParcelable(BINDER_KEY);
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "get binder = " + w.mBinder);
    }
    return w.mBinder;
}
 
Example 11
Source File: ImageClientFragment.java    From android-ContentProviderPaging with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    Bundle extras = cursor.getExtras();
    int totalSize = extras.getInt(ContentResolver.EXTRA_TOTAL_SIZE);
    mAdapter.setTotalSize(totalSize);
    int beforeCount = mAdapter.getFetchedItemCount();
    while (cursor.moveToNext()) {
        String displayName = cursor.getString(cursor.getColumnIndex(
                ImageContract.Columns.DISPLAY_NAME));
        String absolutePath = cursor.getString(cursor.getColumnIndex(
                ImageContract.Columns.ABSOLUTE_PATH));

        ImageAdapter.ImageDocument imageDocument = new ImageAdapter.ImageDocument();
        imageDocument.mAbsolutePath = absolutePath;
        imageDocument.mDisplayName = displayName;
        mAdapter.add(imageDocument);
    }
    int cursorCount = cursor.getCount();
    if (cursorCount == 0) {
        return;
    }
    Activity activity = ImageClientFragment.this.getActivity();
    mAdapter.notifyItemRangeChanged(beforeCount, cursorCount);
    int offsetSnapShot = mOffset.get();
    String message = activity.getResources()
            .getString(R.string.fetched_images_out_of, offsetSnapShot + 1,
                    offsetSnapShot + cursorCount, totalSize);
    mOffset.addAndGet(cursorCount);
    Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
}
 
Example 12
Source File: SelectQuery.java    From wellsql with MIT License 5 votes vote down vote up
public Map<String, Object> getAsMap() {
    Cursor cursor = execute();
    try {
        Map<String, Object> result = new HashMap<>();
        Bundle bundle = cursor.getExtras();
        for (String column : bundle.keySet()) {
            result.put(column, bundle.get(column));
        }
        return result;
    } finally {
        cursor.close();
        mDb.close();
    }
}
 
Example 13
Source File: ServiceChannelCursor.java    From springreplugin with Apache License 2.0 4 votes vote down vote up
static final IBinder getBinder(Cursor cursor) {
    Bundle bundle = cursor.getExtras();
    bundle.setClassLoader(ParcelBinder.class.getClassLoader());
    ParcelBinder parcelBinder = bundle.getParcelable(SERVER_CHANNEL_BUNDLE_KEY);
    return parcelBinder.getIbinder();
}