android.os.Bundle#EMPTY源码实例Demo

下面列出了android.os.Bundle#EMPTY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void testSaveState() {
    repoInfoPresenter.onCreateView(null);

    Bundle bundle = Bundle.EMPTY;
    repoInfoPresenter.onSaveInstanceState(bundle);
    repoInfoPresenter.onStop();

    repoInfoPresenter.onCreateView(bundle);

    verify(mockView, times(2)).showBranches(branchList);
    verify(mockView, times(2)).showContributors(contributorList);

    verify(model).getRepoContributors(TestConst.TEST_OWNER, TestConst.TEST_REPO);
    verify(model).getRepoBranches(TestConst.TEST_OWNER, TestConst.TEST_REPO);
}
 
源代码2 项目: android-job   文件: PlatformJobService.java
@TargetApi(Build.VERSION_CODES.O)
private Bundle getTransientBundle(JobParameters params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        return params.getTransientExtras();
    } else {
        return Bundle.EMPTY;
    }
}
 
@Test
public void dispatchOnRestoreInstanceState() {
    final Bundle bundle = Bundle.EMPTY;

    dispatcher.onRestoreInstanceState(activity, bundle);

    verify(lightCycleComponent1).onRestoreInstanceState(activity, bundle);
    verify(lightCycleComponent2).onRestoreInstanceState(activity, bundle);
}
 
@Test
public void shouldNotifyOnSaveInstanceState() {
    final Bundle bundle = Bundle.EMPTY;

    dispatcher.onSaveInstanceState(fragment, bundle);

    verify(lifeCycleComponent1).onSaveInstanceState(fragment, bundle);
    verify(lifeCycleComponent2).onSaveInstanceState(fragment, bundle);
}
 
源代码5 项目: android_9.0.0_r45   文件: DocumentsProvider.java
private static @Nullable String getSortClause(@Nullable Bundle queryArgs) {
    queryArgs = queryArgs != null ? queryArgs : Bundle.EMPTY;
    String sortClause = queryArgs.getString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER);

    if (sortClause == null && queryArgs.containsKey(ContentResolver.QUERY_ARG_SORT_COLUMNS)) {
        sortClause = ContentResolver.createSqlSortClause(queryArgs);
    }

    return sortClause;
}
 
源代码6 项目: bitmask_android   文件: EipSetupObserver.java
private void handleProviderApiEvent(Intent intent) {
    int resultCode = intent.getIntExtra(BROADCAST_RESULT_CODE, RESULT_CANCELED);
    Bundle resultData = intent.getParcelableExtra(BROADCAST_RESULT_KEY);
    if (resultData == null) {
        resultData = Bundle.EMPTY;
    }

    Provider provider;
    switch (resultCode) {
        case CORRECTLY_DOWNLOADED_EIP_SERVICE:
            Log.d(TAG, "correctly updated service json");
            provider = resultData.getParcelable(PROVIDER_KEY);
            ProviderObservable.getInstance().updateProvider(provider);
            PreferenceHelper.storeProviderInPreferences(preferences, provider);
            if (EipStatus.getInstance().isDisconnected()) {
                EipCommand.startVPN(context.getApplicationContext(), true);
            }
            break;
        case CORRECTLY_UPDATED_INVALID_VPN_CERTIFICATE:
            provider = resultData.getParcelable(PROVIDER_KEY);
            ProviderObservable.getInstance().updateProvider(provider);
            PreferenceHelper.storeProviderInPreferences(preferences, provider);
            EipCommand.startVPN(context.getApplicationContext(), true);
            break;
        default:
            break;
    }

    for (EipSetupListener listener : listeners) {
        listener.handleProviderApiEvent(intent);
    }
}
 
@Test
public void shouldNotifyOnCreate() {
    final Bundle bundle = Bundle.EMPTY;

    dispatcher.onCreate(fragment, bundle);

    verify(lifeCycleComponent1).onCreate(fragment, bundle);
    verify(lifeCycleComponent2).onCreate(fragment, bundle);
}
 
源代码8 项目: talkback   文件: FeedbackFragment.java
public FeedbackFragment(
    CharSequence text,
    @Nullable Set<Integer> earcons,
    @Nullable Set<Integer> haptics,
    @Nullable Bundle speechParams,
    @Nullable Bundle nonSpeechParams) {
  mText = new SpannableString(text);

  mEarcons = new HashSet<>();
  if (earcons != null) {
    mEarcons.addAll(earcons);
  }

  mHaptics = new HashSet<>();
  if (haptics != null) {
    mHaptics.addAll(haptics);
  }

  mSpeechParams = new Bundle(Bundle.EMPTY);
  if (speechParams != null) {
    mSpeechParams.putAll(speechParams);
  }

  mNonSpeechParams = new Bundle(Bundle.EMPTY);
  if (nonSpeechParams != null) {
    mNonSpeechParams.putAll(nonSpeechParams);
  }
}
 
源代码9 项目: android_9.0.0_r45   文件: AbstractCursor.java
@Override
public void setExtras(Bundle extras) {
    mExtras = (extras == null) ? Bundle.EMPTY : extras;
}
 
源代码10 项目: android_9.0.0_r45   文件: AbstractCursor.java
@Override
public Bundle respond(Bundle extras) {
    return Bundle.EMPTY;
}
 
源代码11 项目: android_9.0.0_r45   文件: ContentResolver.java
private void maybeLogQueryToEventLog(
        long durationMillis, Uri uri, String[] projection, @Nullable Bundle queryArgs) {
    if (!ENABLE_CONTENT_SAMPLE) return;
    int samplePercent = samplePercentForDuration(durationMillis);
    if (samplePercent < 100) {
        synchronized (mRandom) {
            if (mRandom.nextInt(100) >= samplePercent) {
                return;
            }
        }
    }

    // Ensure a non-null bundle.
    queryArgs = (queryArgs != null) ? queryArgs : Bundle.EMPTY;

    StringBuilder projectionBuffer = new StringBuilder(100);
    if (projection != null) {
        for (int i = 0; i < projection.length; ++i) {
            // Note: not using a comma delimiter here, as the
            // multiple arguments to EventLog.writeEvent later
            // stringify with a comma delimiter, which would make
            // parsing uglier later.
            if (i != 0) projectionBuffer.append('/');
            projectionBuffer.append(projection[i]);
        }
    }

    // ActivityThread.currentPackageName() only returns non-null if the
    // current thread is an application main thread.  This parameter tells
    // us whether an event loop is blocked, and if so, which app it is.
    String blockingPackage = AppGlobals.getInitialPackage();

    EventLog.writeEvent(
        EventLogTags.CONTENT_QUERY_SAMPLE,
        uri.toString(),
        projectionBuffer.toString(),
        queryArgs.getString(QUERY_ARG_SQL_SELECTION, ""),
        queryArgs.getString(QUERY_ARG_SQL_SORT_ORDER, ""),
        durationMillis,
        blockingPackage != null ? blockingPackage : "",
        samplePercent);
}
 
源代码12 项目: cathode   文件: AbsSimpleCursor.java
@Override public Bundle getExtras() {
  return Bundle.EMPTY;
}
 
源代码13 项目: cursor-utils   文件: CursorList.java
@Override
public Bundle respond(Bundle extras) {
    return Bundle.EMPTY;
}
 
源代码14 项目: GPT   文件: ProviderProxyCursor.java
/**
 * android 2.3 没有此函数,4.0 以后是个隐藏函数。
 */
public void setExtras(Bundle extras) {
    mExtras = (extras == null) ? Bundle.EMPTY : extras;
}
 
源代码15 项目: letv   文件: jk.java
public static Bundle e(Context context) {
    ApplicationInfo b = b(context);
    return (b == null || b.metaData == null) ? Bundle.EMPTY : b.metaData;
}
 
源代码16 项目: sqlite-android   文件: AbstractCursor.java
@Override
public void setExtras(Bundle extras) {
    mExtras = (extras == null) ? Bundle.EMPTY : extras;
}
 
源代码17 项目: sqlite-android   文件: AbstractCursor.java
@Override
public Bundle respond(Bundle extras) {
    return Bundle.EMPTY;
}
 
源代码18 项目: android_9.0.0_r45   文件: AppWidgetManager.java
/**
 * Get the extras associated with a given widget instance.
 * <p>
 * The extras can be used to embed additional information about this widget to be accessed
 * by the associated widget's AppWidgetProvider.
 *
 * @see #updateAppWidgetOptions(int, Bundle)
 *
 * @param appWidgetId The AppWidget instances for which to set the RemoteViews.
 * @return The options associated with the given widget instance.
 */
public Bundle getAppWidgetOptions(int appWidgetId) {
    if (mService == null) {
        return Bundle.EMPTY;
    }
    try {
        return mService.getAppWidgetOptions(mPackageName, appWidgetId);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码19 项目: AndroidComponentPlugin   文件: ContentProvider.java
/**
 * Implement this to handle query requests where the arguments are packed into a {@link Bundle}.
 * Arguments may include traditional SQL style query arguments. When present these
 * should be handled  according to the contract established in
 * {@link #query(Uri, String[], String, String[], String, CancellationSignal).
 *
 * <p>Traditional SQL arguments can be found in the bundle using the following keys:
 * <li>{@link ContentResolver#QUERY_ARG_SQL_SELECTION}
 * <li>{@link ContentResolver#QUERY_ARG_SQL_SELECTION_ARGS}
 * <li>{@link ContentResolver#QUERY_ARG_SQL_SORT_ORDER}
 *
 * <p>This method can be called from multiple threads, as described in
 * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
 * and Threads</a>.
 *
 * <p>
 * Example client call:<p>
 * <pre>// Request 20 records starting at row index 30.
   Bundle queryArgs = new Bundle();
   queryArgs.putInt(ContentResolver.QUERY_ARG_OFFSET, 30);
   queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT, 20);

   Cursor cursor = getContentResolver().query(
            contentUri,    // Content Uri is specific to individual content providers.
            projection,    // String[] describing which columns to return.
            queryArgs,     // Query arguments.
            null);         // Cancellation signal.</pre>
 *
 * Example implementation:<p>
 * <pre>

    int recordsetSize = 0x1000;  // Actual value is implementation specific.
    queryArgs = queryArgs != null ? queryArgs : Bundle.EMPTY;  // ensure queryArgs is non-null

    int offset = queryArgs.getInt(ContentResolver.QUERY_ARG_OFFSET, 0);
    int limit = queryArgs.getInt(ContentResolver.QUERY_ARG_LIMIT, Integer.MIN_VALUE);

    MatrixCursor c = new MatrixCursor(PROJECTION, limit);

    // Calculate the number of items to include in the cursor.
    int numItems = MathUtils.constrain(recordsetSize - offset, 0, limit);

    // Build the paged result set....
    for (int i = offset; i < offset + numItems; i++) {
        // populate row from your data.
    }

    Bundle extras = new Bundle();
    c.setExtras(extras);

    // Any QUERY_ARG_* key may be included if honored.
    // In an actual implementation, include only keys that are both present in queryArgs
    // and reflected in the Cursor output. For example, if QUERY_ARG_OFFSET were included
    // in queryArgs, but was ignored because it contained an invalid value (like –273),
    // then QUERY_ARG_OFFSET should be omitted.
    extras.putStringArray(ContentResolver.EXTRA_HONORED_ARGS, new String[] {
        ContentResolver.QUERY_ARG_OFFSET,
        ContentResolver.QUERY_ARG_LIMIT
    });

    extras.putInt(ContentResolver.EXTRA_TOTAL_COUNT, recordsetSize);

    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    return cursor;</pre>
 * <p>
 * @see #query(Uri, String[], String, String[], String, CancellationSignal) for
 *     implementation details.
 *
 * @param uri The URI to query. This will be the full URI sent by the client.
 * @param projection The list of columns to put into the cursor.
 *            If {@code null} provide a default set of columns.
 * @param queryArgs A Bundle containing all additional information necessary for the query.
 *            Values in the Bundle may include SQL style arguments.
 * @param cancellationSignal A signal to cancel the operation in progress,
 *            or {@code null}.
 * @return a Cursor or {@code null}.
 */
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
        @Nullable Bundle queryArgs, @Nullable CancellationSignal cancellationSignal) {
    queryArgs = queryArgs != null ? queryArgs : Bundle.EMPTY;

    // if client doesn't supply an SQL sort order argument, attempt to build one from
    // QUERY_ARG_SORT* arguments.
    String sortClause = queryArgs.getString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER);
    if (sortClause == null && queryArgs.containsKey(ContentResolver.QUERY_ARG_SORT_COLUMNS)) {
        sortClause = ContentResolver.createSqlSortClause(queryArgs);
    }

    return query(
            uri,
            projection,
            queryArgs.getString(ContentResolver.QUERY_ARG_SQL_SELECTION),
            queryArgs.getStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS),
            sortClause,
            cancellationSignal);
}
 
源代码20 项目: talkback   文件: SwitchAccessAction.java
/**
 * @param nodeCompat The {@link SwitchAccessNodeCompat} to perform this action on
 * @param id The id used to identify this action. Should correspond to a valid {@link
 *     AccessibilityActionCompat} id.
 * @param label The human readable label used to identify this action
 */
public SwitchAccessAction(
    SwitchAccessNodeCompat nodeCompat, int id, @Nullable CharSequence label) {
  this(nodeCompat, id, label, Bundle.EMPTY);
}