Java Code Examples for android.util.MutableInt

The following examples show how to use android.util.MutableInt. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: input-samples   Source File: ClientViewMetadataBuilder.java    License: Apache License 2.0 6 votes vote down vote up
private void parseNode(AssistStructure.ViewNode root, List<String> allHints,
        MutableInt autofillSaveType, List<AutofillId> autofillIds,
        List<AutofillId> focusedAutofillIds) {
    String[] hints = root.getAutofillHints();
    if (hints != null) {
        for (String hint : hints) {
            FieldTypeWithHeuristics fieldTypeWithHints = mFieldTypesByAutofillHint.get(hint);
            if (fieldTypeWithHints != null && fieldTypeWithHints.fieldType != null) {
                allHints.add(hint);
                autofillSaveType.value |= fieldTypeWithHints.fieldType.getSaveInfo();
                autofillIds.add(root.getAutofillId());
            }
        }
    }
    if (root.isFocused()) {
        focusedAutofillIds.add(root.getAutofillId());
    }
}
 
Example 2
Source Project: android_9.0.0_r45   Source File: TunerSession.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean isConfigFlagSet(int flag) {
    Slog.v(TAG, "isConfigFlagSet " + ConfigFlag.toString(flag));
    synchronized (mLock) {
        checkNotClosedLocked();

        MutableInt halResult = new MutableInt(Result.UNKNOWN_ERROR);
        MutableBoolean flagState = new MutableBoolean(false);
        try {
            mHwSession.isConfigFlagSet(flag, (int result, boolean value) -> {
                halResult.value = result;
                flagState.value = value;
            });
        } catch (RemoteException ex) {
            throw new RuntimeException("Failed to check flag " + ConfigFlag.toString(flag), ex);
        }
        Convert.throwOnError("isConfigFlagSet", halResult.value);

        return flagState.value;
    }
}
 
Example 3
Source Project: android_9.0.0_r45   Source File: RadioModule.java    License: Apache License 2.0 6 votes vote down vote up
public @NonNull TunerSession openSession(@NonNull android.hardware.radio.ITunerCallback userCb)
        throws RemoteException {
    TunerCallback cb = new TunerCallback(Objects.requireNonNull(userCb));
    Mutable<ITunerSession> hwSession = new Mutable<>();
    MutableInt halResult = new MutableInt(Result.UNKNOWN_ERROR);

    synchronized (mService) {
        mService.openSession(cb, (result, session) -> {
            hwSession.value = session;
            halResult.value = result;
        });
    }

    Convert.throwOnError("openSession", halResult.value);
    Objects.requireNonNull(hwSession.value);

    return new TunerSession(this, hwSession.value, cb);
}
 
Example 4
private void parseNode(AssistStructure.ViewNode root, List<String> allHints,
        MutableInt autofillSaveType, List<AutofillId> autofillIds,
        List<AutofillId> focusedAutofillIds) {
    String[] hints = root.getAutofillHints();
    if (hints != null) {
        for (String hint : hints) {
            FieldTypeWithHeuristics fieldTypeWithHints = mFieldTypesByAutofillHint.get(hint);
            if (fieldTypeWithHints != null && fieldTypeWithHints.fieldType != null) {
                allHints.add(hint);
                autofillSaveType.value |= fieldTypeWithHints.fieldType.getSaveInfo();
                autofillIds.add(root.getAutofillId());
            }
        }
    }
    if (root.isFocused()) {
        focusedAutofillIds.add(root.getAutofillId());
    }
}
 
Example 5
Source Project: input-samples   Source File: ClientViewMetadataBuilder.java    License: Apache License 2.0 5 votes vote down vote up
public ClientViewMetadata buildClientViewMetadata() {
    List<String> allHints = new ArrayList<>();
    MutableInt saveType = new MutableInt(0);
    List<AutofillId> autofillIds = new ArrayList<>();
    StringBuilder webDomainBuilder = new StringBuilder();
    List<AutofillId> focusedAutofillIds = new ArrayList<>();
    mClientParser.parse((node) -> parseNode(node, allHints, saveType, autofillIds, focusedAutofillIds));
    mClientParser.parse((node) -> parseWebDomain(node, webDomainBuilder));
    String webDomain = webDomainBuilder.toString();
    AutofillId[] autofillIdsArray = autofillIds.toArray(new AutofillId[autofillIds.size()]);
    AutofillId[] focusedIds = focusedAutofillIds.toArray(new AutofillId[focusedAutofillIds.size()]);
    return new ClientViewMetadata(allHints, saveType.value, autofillIdsArray, focusedIds, webDomain);
}
 
Example 6
Source Project: android_9.0.0_r45   Source File: RadioModule.java    License: Apache License 2.0 5 votes vote down vote up
public android.hardware.radio.ICloseHandle addAnnouncementListener(@NonNull int[] enabledTypes,
        @NonNull android.hardware.radio.IAnnouncementListener listener) throws RemoteException {
    ArrayList<Byte> enabledList = new ArrayList<>();
    for (int type : enabledTypes) {
        enabledList.add((byte)type);
    }

    MutableInt halResult = new MutableInt(Result.UNKNOWN_ERROR);
    Mutable<ICloseHandle> hwCloseHandle = new Mutable<>();
    IAnnouncementListener hwListener = new IAnnouncementListener.Stub() {
        public void onListUpdated(ArrayList<Announcement> hwAnnouncements)
                throws RemoteException {
            listener.onListUpdated(hwAnnouncements.stream().
                map(a -> Convert.announcementFromHal(a)).collect(Collectors.toList()));
        }
    };

    synchronized (mService) {
        mService.registerAnnouncementListener(enabledList, hwListener, (result, closeHnd) -> {
            halResult.value = result;
            hwCloseHandle.value = closeHnd;
        });
    }
    Convert.throwOnError("addAnnouncementListener", halResult.value);

    return new android.hardware.radio.ICloseHandle.Stub() {
        public void close() {
            try {
                hwCloseHandle.value.close();
            } catch (RemoteException ex) {
                Slog.e(TAG, "Failed closing announcement listener", ex);
            }
        }
    };
}
 
Example 7
Source Project: LaunchEnr   Source File: BgDataModel.java    License: GNU General Public License v3.0 5 votes vote down vote up
synchronized void removeItem(Context context, Iterable<? extends ItemInfo> items) {
    for (ItemInfo item : items) {
        switch (item.itemType) {
            case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
                folders.remove(item.id);

                workspaceItems.remove(item);
                break;
            case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: {
                // Decrement pinned shortcut count
                ShortcutKey pinnedShortcut = ShortcutKey.fromItemInfo(item);
                MutableInt count = pinnedShortcutCounts.get(pinnedShortcut);
                if ((count == null || --count.value == 0)
                        && !InstallShortcutReceiver.getPendingShortcuts(context)
                            .contains(pinnedShortcut)) {
                    DeepShortcutManager.getInstance(context).unpinShortcut(pinnedShortcut);
                }
                // Fall through.
            }
            case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
            case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
                workspaceItems.remove(item);
                break;
            case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
            case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
                appWidgets.remove(item);
                break;
        }
        itemsIdMap.remove(item.id);
    }
}
 
Example 8
public ClientViewMetadata buildClientViewMetadata() {
    List<String> allHints = new ArrayList<>();
    MutableInt saveType = new MutableInt(0);
    List<AutofillId> autofillIds = new ArrayList<>();
    StringBuilder webDomainBuilder = new StringBuilder();
    List<AutofillId> focusedAutofillIds = new ArrayList<>();
    mClientParser.parse((node) -> parseNode(node, allHints, saveType, autofillIds, focusedAutofillIds));
    mClientParser.parse((node) -> parseWebDomain(node, webDomainBuilder));
    String webDomain = webDomainBuilder.toString();
    AutofillId[] autofillIdsArray = autofillIds.toArray(new AutofillId[autofillIds.size()]);
    AutofillId[] focusedIds = focusedAutofillIds.toArray(new AutofillId[focusedAutofillIds.size()]);
    return new ClientViewMetadata(allHints, saveType.value, autofillIdsArray, focusedIds, webDomain);
}