类android.util.MutableInt源码实例Demo

下面列出了怎么用android.util.MutableInt的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: input-samples   文件: ClientViewMetadataBuilder.java
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());
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: TunerSession.java
@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;
    }
}
 
源代码3 项目: android_9.0.0_r45   文件: RadioModule.java
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);
}
 
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());
    }
}
 
源代码5 项目: input-samples   文件: ClientViewMetadataBuilder.java
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);
}
 
源代码6 项目: android_9.0.0_r45   文件: RadioModule.java
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);
            }
        }
    };
}
 
源代码7 项目: LaunchEnr   文件: BgDataModel.java
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);
    }
}
 
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);
}
 
 类所在包