Java Code Examples for android.os.Bundle#EMPTY

The following examples show how to use android.os.Bundle#EMPTY . 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: RepoInfoPresenterTest.java    From android-step-by-step with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: EipSetupObserver.java    From bitmask_android with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example 3
Source File: FeedbackFragment.java    From talkback with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 4
Source File: SupportFragmentLightCycleDispatcherTest.java    From lightcycle with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotifyOnCreate() {
    final Bundle bundle = Bundle.EMPTY;

    dispatcher.onCreate(fragment, bundle);

    verify(lifeCycleComponent1).onCreate(fragment, bundle);
    verify(lifeCycleComponent2).onCreate(fragment, bundle);
}
 
Example 5
Source File: PlatformJobService.java    From android-job with Apache License 2.0 5 votes vote down vote up
@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;
    }
}
 
Example 6
Source File: DocumentsProvider.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: FragmentLightCycleDispatcherTest.java    From lightcycle with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotifyOnSaveInstanceState() {
    final Bundle bundle = Bundle.EMPTY;

    dispatcher.onSaveInstanceState(fragment, bundle);

    verify(lifeCycleComponent1).onSaveInstanceState(fragment, bundle);
    verify(lifeCycleComponent2).onSaveInstanceState(fragment, bundle);
}
 
Example 8
Source File: ActivityLightCycleDispatcherTest.java    From lightcycle with Apache License 2.0 5 votes vote down vote up
@Test
public void dispatchOnRestoreInstanceState() {
    final Bundle bundle = Bundle.EMPTY;

    dispatcher.onRestoreInstanceState(activity, bundle);

    verify(lightCycleComponent1).onRestoreInstanceState(activity, bundle);
    verify(lightCycleComponent2).onRestoreInstanceState(activity, bundle);
}
 
Example 9
Source File: ContentResolver.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 10
Source File: AbsSimpleCursor.java    From cathode with Apache License 2.0 4 votes vote down vote up
@Override public Bundle getExtras() {
  return Bundle.EMPTY;
}
 
Example 11
Source File: AbstractCursor.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public Bundle respond(Bundle extras) {
    return Bundle.EMPTY;
}
 
Example 12
Source File: CursorList.java    From cursor-utils with MIT License 4 votes vote down vote up
@Override
public Bundle respond(Bundle extras) {
    return Bundle.EMPTY;
}
 
Example 13
Source File: ProviderProxyCursor.java    From GPT with Apache License 2.0 4 votes vote down vote up
/**
 * android 2.3 没有此函数,4.0 以后是个隐藏函数。
 */
public void setExtras(Bundle extras) {
    mExtras = (extras == null) ? Bundle.EMPTY : extras;
}
 
Example 14
Source File: jk.java    From letv with Apache License 2.0 4 votes vote down vote up
public static Bundle e(Context context) {
    ApplicationInfo b = b(context);
    return (b == null || b.metaData == null) ? Bundle.EMPTY : b.metaData;
}
 
Example 15
Source File: AbstractCursor.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void setExtras(Bundle extras) {
    mExtras = (extras == null) ? Bundle.EMPTY : extras;
}
 
Example 16
Source File: AbstractCursor.java    From sqlite-android with Apache License 2.0 4 votes vote down vote up
@Override
public void setExtras(Bundle extras) {
    mExtras = (extras == null) ? Bundle.EMPTY : extras;
}
 
Example 17
Source File: AbstractCursor.java    From sqlite-android with Apache License 2.0 4 votes vote down vote up
@Override
public Bundle respond(Bundle extras) {
    return Bundle.EMPTY;
}
 
Example 18
Source File: AppWidgetManager.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * 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();
    }
}
 
Example 19
Source File: SwitchAccessAction.java    From talkback with Apache License 2.0 2 votes vote down vote up
/**
 * @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);
}
 
Example 20
Source File: ContentProvider.java    From AndroidComponentPlugin with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}