android.util.ArrayMap Java Examples

The following examples show how to use android.util.ArrayMap. 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 Project: android_9.0.0_r45   Author: lulululbj   File: FragmentTransition.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the epicenter for the exit transition.
 *
 * @param sharedElementTransition The shared element transition
 * @param exitTransition The transition for the outgoing fragment's views
 * @param outSharedElements Shared elements in the outgoing fragment
 * @param outIsPop Is the outgoing fragment being removed as a pop transaction?
 * @param outTransaction The transaction that caused the fragment to be removed.
 */
private static void setOutEpicenter(TransitionSet sharedElementTransition,
        Transition exitTransition, ArrayMap<String, View> outSharedElements, boolean outIsPop,
        BackStackRecord outTransaction) {
    if (outTransaction.mSharedElementSourceNames != null &&
            !outTransaction.mSharedElementSourceNames.isEmpty()) {
        final String sourceName = outIsPop
                ? outTransaction.mSharedElementTargetNames.get(0)
                : outTransaction.mSharedElementSourceNames.get(0);
        final View outEpicenterView = outSharedElements.get(sourceName);
        setEpicenter(sharedElementTransition, outEpicenterView);

        if (exitTransition != null) {
            setEpicenter(exitTransition, outEpicenterView);
        }
    }
}
 
Example #2
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
    // At least one application in the world actually passes in a null
    // name.  This happened to work because when we generated the file name
    // we would stringify it to "null.xml".  Nice.
    if (mPackageInfo.getApplicationInfo().targetSdkVersion <
            Build.VERSION_CODES.KITKAT) {
        if (name == null) {
            name = "null";
        }
    }

    File file;
    synchronized (ContextImpl.class) {
        if (mSharedPrefsPaths == null) {
            mSharedPrefsPaths = new ArrayMap<>();
        }
        file = mSharedPrefsPaths.get(name);
        if (file == null) {
            file = getSharedPreferencesPath(name);
            mSharedPrefsPaths.put(name, file);
        }
    }
    return getSharedPreferences(file, mode);
}
 
Example #3
Source Project: android_9.0.0_r45   Author: lulululbj   File: UsageStatsManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * A convenience method that queries for all stats in the given range (using the best interval
 * for that range), merges the resulting data, and keys it by package name.
 * See {@link #queryUsageStats(int, long, long)}.
 * <p> The caller must have {@link android.Manifest.permission#PACKAGE_USAGE_STATS} </p>
 *
 * @param beginTime The inclusive beginning of the range of stats to include in the results.
 * @param endTime The exclusive end of the range of stats to include in the results.
 * @return A {@link java.util.Map} keyed by package name
 */
public Map<String, UsageStats> queryAndAggregateUsageStats(long beginTime, long endTime) {
    List<UsageStats> stats = queryUsageStats(INTERVAL_BEST, beginTime, endTime);
    if (stats.isEmpty()) {
        return Collections.emptyMap();
    }

    ArrayMap<String, UsageStats> aggregatedStats = new ArrayMap<>();
    final int statCount = stats.size();
    for (int i = 0; i < statCount; i++) {
        UsageStats newStat = stats.get(i);
        UsageStats existingStat = aggregatedStats.get(newStat.getPackageName());
        if (existingStat == null) {
            aggregatedStats.put(newStat.mPackageName, newStat);
        } else {
            existingStat.add(newStat);
        }
    }
    return aggregatedStats;
}
 
Example #4
Source Project: android_9.0.0_r45   Author: lulululbj   File: AccessibilityManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Notifies the registered {@link HighTextContrastChangeListener}s.
 */
private void notifyHighTextContrastStateChanged() {
    final boolean isHighTextContrastEnabled;
    final ArrayMap<HighTextContrastChangeListener, Handler> listeners;
    synchronized (mLock) {
        if (mHighTextContrastStateChangeListeners.isEmpty()) {
            return;
        }
        isHighTextContrastEnabled = mIsHighTextContrastEnabled;
        listeners = new ArrayMap<>(mHighTextContrastStateChangeListeners);
    }

    final int numListeners = listeners.size();
    for (int i = 0; i < numListeners; i++) {
        final HighTextContrastChangeListener listener = listeners.keyAt(i);
        listeners.valueAt(i).post(() ->
                listener.onHighTextContrastStateChanged(isHighTextContrastEnabled));
    }
}
 
Example #5
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
Example #6
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: ScrollingHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static void prepareForScrollMeasureTickValue(OBControl con, float tickValue,double decay,float minSpeedX, float minSpeedY)
{
    Object data = con.propertyValue("scrolling_data");
    Map<String,Object> scrollingData;
    if(data == null)
        scrollingData = new ArrayMap<String,Object>();
    else
        scrollingData = (ArrayMap<String,Object>)data;

    scrollingData.put("last_action",SystemClock.uptimeMillis());
    scrollingData.put("last_loc",OBMisc.copyPoint(con.position()));
    scrollingData.put("speed_x",0.0f);
    scrollingData.put("speed_y",0.0f);
    scrollingData.put("min_speed_x",minSpeedX);
    scrollingData.put("min_speed_y",minSpeedY);
    scrollingData.put("decay",decay);
    scrollingData.put("tick",tickValue);
    con.setProperty("scrolling_data", scrollingData);
}
 
Example #7
Source Project: android_9.0.0_r45   Author: lulululbj   File: FingerprintGestureController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Called when gesture detection becomes active or inactive
 * @hide
 */
public void onGestureDetectionActiveChanged(boolean active) {
    final ArrayMap<FingerprintGestureCallback, Handler> handlerMap;
    synchronized (mLock) {
        handlerMap = new ArrayMap<>(mCallbackHandlerMap);
    }
    int numListeners = handlerMap.size();
    for (int i = 0; i < numListeners; i++) {
        FingerprintGestureCallback callback = handlerMap.keyAt(i);
        Handler handler = handlerMap.valueAt(i);
        if (handler != null) {
            handler.post(() -> callback.onGestureDetectionAvailabilityChanged(active));
        } else {
            callback.onGestureDetectionAvailabilityChanged(active);
        }
    }
}
 
Example #8
Source Project: android_9.0.0_r45   Author: lulululbj   File: AccessibilityManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Notifies the registered {@link AccessibilityStateChangeListener}s.
 */
private void notifyAccessibilityStateChanged() {
    final boolean isEnabled;
    final ArrayMap<AccessibilityStateChangeListener, Handler> listeners;
    synchronized (mLock) {
        if (mAccessibilityStateChangeListeners.isEmpty()) {
            return;
        }
        isEnabled = isEnabled();
        listeners = new ArrayMap<>(mAccessibilityStateChangeListeners);
    }

    final int numListeners = listeners.size();
    for (int i = 0; i < numListeners; i++) {
        final AccessibilityStateChangeListener listener = listeners.keyAt(i);
        listeners.valueAt(i).post(() ->
                listener.onAccessibilityStateChanged(isEnabled));
    }
}
 
Example #9
Source Project: android_9.0.0_r45   Author: lulululbj   File: ShortcutPackage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Build a list of shortcuts for each target activity and return as a map. The result won't
 * contain "floating" shortcuts because they don't belong on any activities.
 */
private ArrayMap<ComponentName, ArrayList<ShortcutInfo>> sortShortcutsToActivities() {
    final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> activitiesToShortcuts
            = new ArrayMap<>();
    for (int i = mShortcuts.size() - 1; i >= 0; i--) {
        final ShortcutInfo si = mShortcuts.valueAt(i);
        if (si.isFloating()) {
            continue; // Ignore floating shortcuts, which are not tied to any activities.
        }

        final ComponentName activity = si.getActivity();
        if (activity == null) {
            mShortcutUser.mService.wtf("null activity detected.");
            continue;
        }

        ArrayList<ShortcutInfo> list = activitiesToShortcuts.get(activity);
        if (list == null) {
            list = new ArrayList<>();
            activitiesToShortcuts.put(activity, list);
        }
        list.add(si);
    }
    return activitiesToShortcuts;
}
 
Example #10
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
    // At least one application in the world actually passes in a null
    // name.  This happened to work because when we generated the file name
    // we would stringify it to "null.xml".  Nice.
    if (mPackageInfo.getApplicationInfo().targetSdkVersion <
            Build.VERSION_CODES.KITKAT) {
        if (name == null) {
            name = "null";
        }
    }

    File file;
    synchronized (ContextImpl.class) {
        if (mSharedPrefsPaths == null) {
            mSharedPrefsPaths = new ArrayMap<>();
        }
        file = mSharedPrefsPaths.get(name);
        if (file == null) {
            file = getSharedPreferencesPath(name);
            mSharedPrefsPaths.put(name, file);
        }
    }
    return getSharedPreferences(file, mode);
}
 
Example #11
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: OC_2dShapes_S2f.java    License: Apache License 2.0 6 votes vote down vote up
public void prepare()
{
    setStatus(STATUS_BUSY);
    super.prepare();
    loadFingers();
    loadEvent("master2");
    this.localisations = loadLocalisations(getLocalPath("_localisations.xml"));
    textColour = OBUtils.colorFromRGBString(eventAttributes.get("colour_text"));
    dropObjs = new ArrayMap<>();
    events = Arrays.asList(eventAttributes.get("scenes").split(","));
    OBPath box = (OBPath)objectDict.get("box");

    box.setProperty("start_loc", OBMisc.copyPoint(box.position()));
    OBPath dot = (OBPath)objectDict.get("dot");
    dot.sizeToBoundingBoxInset(-applyGraphicScale(2));
    setSceneXX(currentEvent());
    box.sizeToBoundingBoxIncludingStroke();
}
 
Example #12
Source Project: android_9.0.0_r45   Author: lulululbj   File: EnterTransitionCoordinator.java    License: Apache License 2.0 6 votes vote down vote up
private ArrayMap<String, View> mapNamedElements(ArrayList<String> accepted,
        ArrayList<String> localNames) {
    ArrayMap<String, View> sharedElements = new ArrayMap<String, View>();
    ViewGroup decorView = getDecor();
    if (decorView != null) {
        decorView.findNamedViews(sharedElements);
    }
    if (accepted != null) {
        for (int i = 0; i < localNames.size(); i++) {
            String localName = localNames.get(i);
            String acceptedName = accepted.get(i);
            if (localName != null && !localName.equals(acceptedName)) {
                View view = sharedElements.get(localName);
                if (view != null) {
                    sharedElements.put(acceptedName, view);
                }
            }
        }
    }
    return sharedElements;
}
 
Example #13
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: ScrollingHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static void measureScrollSpeed(OBControl con)
{
    Object data = con.propertyValue("scrolling_data");
    if(data == null)
        return;
    Map<String,Object> scrollingData = (ArrayMap<String,Object>)data;

    long currentTime = SystemClock.uptimeMillis();
    long lastTime = (long)scrollingData.get("last_action");
    if(currentTime == lastTime)
        return;
    float lastSpeedX = (float)scrollingData.get("speed_x");
    float lastSpeedY = (float)scrollingData.get("speed_y");
    float tick = (float)scrollingData.get("tick") ;
    PointF lastLoc = (PointF)scrollingData.get("last_loc");
    PointF currentLoc = OBMisc.copyPoint(con.position());
    float ticks =  (currentTime - lastTime)*1.0f/(1000.0f*tick);
    float speedX = 0.8f * ((currentLoc.x - lastLoc.x) / ticks) + 0.2f * lastSpeedX;
    float speedY = 0.8f * ((currentLoc.y - lastLoc.y) / ticks) + 0.2f * lastSpeedY;
    scrollingData.put("speed_x",speedX);
    scrollingData.put("speed_y", speedY);
    scrollingData.put("last_loc",currentLoc);
    scrollingData.put("last_action",currentTime);
}
 
Example #14
Source Project: android_9.0.0_r45   Author: lulululbj   File: SnoozeHelper.java    License: Apache License 2.0 6 votes vote down vote up
public void dump(PrintWriter pw, NotificationManagerService.DumpFilter filter) {
    pw.println("\n  Snoozed notifications:");
    for (int userId : mSnoozedNotifications.keySet()) {
        pw.print(INDENT);
        pw.println("user: " + userId);
        ArrayMap<String, ArrayMap<String, NotificationRecord>> snoozedPkgs =
                mSnoozedNotifications.get(userId);
        for (String pkg : snoozedPkgs.keySet()) {
            pw.print(INDENT);
            pw.print(INDENT);
            pw.println("package: " + pkg);
            Set<String> snoozedKeys = snoozedPkgs.get(pkg).keySet();
            for (String key : snoozedKeys) {
                pw.print(INDENT);
                pw.print(INDENT);
                pw.print(INDENT);
                pw.println(key);
            }
        }
    }
}
 
Example #15
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ContentService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@RequiresPermission(android.Manifest.permission.CACHE_CONTENT)
public Bundle getCache(String packageName, Uri key, int userId) {
    enforceCrossUserPermission(userId, TAG);
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CACHE_CONTENT, TAG);
    mContext.getSystemService(AppOpsManager.class).checkPackage(Binder.getCallingUid(),
            packageName);

    final String providerPackageName = getProviderPackageName(key);
    final Pair<String, Uri> fullKey = Pair.create(packageName, key);

    synchronized (mCache) {
        final ArrayMap<Pair<String, Uri>, Bundle> cache = findOrCreateCacheLocked(userId,
                providerPackageName);
        return cache.get(fullKey);
    }
}
 
Example #16
Source Project: android_9.0.0_r45   Author: lulululbj   File: AccessibilityManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void notifyServicesStateChanged() {
    final ArrayMap<AccessibilityServicesStateChangeListener, Handler> listeners;
    synchronized (mLock) {
        if (mServicesStateChangeListeners.isEmpty()) {
            return;
        }
        listeners = new ArrayMap<>(mServicesStateChangeListeners);
    }

    int numListeners = listeners.size();
    for (int i = 0; i < numListeners; i++) {
        final AccessibilityServicesStateChangeListener listener =
                mServicesStateChangeListeners.keyAt(i);
        mServicesStateChangeListeners.valueAt(i).post(() -> listener
                .onAccessibilityServicesStateChanged(AccessibilityManager.this));
    }
}
 
Example #17
Source Project: AndroidComponentPlugin   Author: androidmalin   File: ContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
    synchronized (ContextImpl.class) {
        final File source = sourceContext.getSharedPreferencesPath(name);
        final File target = getSharedPreferencesPath(name);

        final int res = moveFiles(source.getParentFile(), target.getParentFile(),
                source.getName());
        if (res > 0) {
            // We moved at least one file, so evict any in-memory caches for
            // either location
            final ArrayMap<File, SharedPreferencesImpl> cache =
                    getSharedPreferencesCacheLocked();
            cache.remove(source);
            cache.remove(target);
        }
        return res != -1;
    }
}
 
Example #18
Source Project: android_9.0.0_r45   Author: lulululbj   File: IntentResolver.java    License: Apache License 2.0 6 votes vote down vote up
private final void addFilter(ArrayMap<String, F[]> map, String name, F filter) {
    F[] array = map.get(name);
    if (array == null) {
        array = newArray(2);
        map.put(name,  array);
        array[0] = filter;
    } else {
        final int N = array.length;
        int i = N;
        while (i > 0 && array[i-1] == null) {
            i--;
        }
        if (i < N) {
            array[i] = filter;
        } else {
            F[] newa = newArray((N*3)/2);
            System.arraycopy(array, 0, newa, 0, N);
            newa[N] = filter;
            map.put(name, newa);
        }
    }
}
 
Example #19
Source Project: android_9.0.0_r45   Author: lulululbj   File: EnterTransitionCoordinator.java    License: Apache License 2.0 6 votes vote down vote up
private void triggerViewsReady(final ArrayMap<String, View> sharedElements) {
    if (mAreViewsReady) {
        return;
    }
    mAreViewsReady = true;
    final ViewGroup decor = getDecor();
    // Ensure the views have been laid out before capturing the views -- we need the epicenter.
    if (decor == null || (decor.isAttachedToWindow() &&
            (sharedElements.isEmpty() || !sharedElements.valueAt(0).isLayoutRequested()))) {
        viewsReady(sharedElements);
    } else {
        mViewsReadyListener = OneShotPreDrawListener.add(decor, () -> {
            mViewsReadyListener = null;
            viewsReady(sharedElements);
        });
        decor.invalidate();
    }
}
 
Example #20
Source Project: android_9.0.0_r45   Author: lulululbj   File: Parcel.java    License: Apache License 2.0 6 votes vote down vote up
void readArrayMapSafelyInternal(ArrayMap outVal, int N,
    ClassLoader loader) {
    if (DEBUG_ARRAY_MAP) {
        RuntimeException here =  new RuntimeException("here");
        here.fillInStackTrace();
        Log.d(TAG, "Reading safely " + N + " ArrayMap entries", here);
    }
    while (N > 0) {
        String key = readString();
        if (DEBUG_ARRAY_MAP) Log.d(TAG, "  Read safe #" + (N-1) + ": key=0x"
                + (key != null ? key.hashCode() : 0) + " " + key);
        Object value = readValue(loader);
        outVal.put(key, value);
        N--;
    }
}
 
Example #21
Source Project: android_9.0.0_r45   Author: lulululbj   File: FileUpdater.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Write values to files. (Note the actual writes happen ASAP but asynchronously.)
 */
public void writeFiles(ArrayMap<String, String> fileValues) {
    synchronized (mLock) {
        for (int i = fileValues.size() - 1; i >= 0; i--) {
            final String file = fileValues.keyAt(i);
            final String value = fileValues.valueAt(i);

            if (DEBUG) {
                Slog.d(TAG, "Scheduling write: '" + value + "' to '" + file + "'");
            }

            mPendingWrites.put(file, value);

        }
        mRetries = 0;

        mHandler.removeCallbacks(mHandleWriteOnHandlerRunnable);
        mHandler.post(mHandleWriteOnHandlerRunnable);
    }
}
 
Example #22
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: OC_Pws.java    License: Apache License 2.0 6 votes vote down vote up
public void prepare()
{
    setStatus(STATUS_BUSY);
    super.prepare();
    loadFingers();
    loadEvent("master");
    showDemo = OBUtils.getBooleanValue(parameters.get("demo"));
    eventColours = new ArrayMap<>();
    eventColours = OBMisc.loadEventColours(this);
    componentDict = OBUtils.LoadWordComponentsXML(true);
    loadEvent(eventName());
    eventColours.putAll(OBMisc.loadEventColours(this));
    wordBag = new OC_WordBag((OBGroup)objectDict.get("word_bag"),this);
    setSceneXX(currentEvent());

    animateWobble = false;
    boxTouchMode = true;
    currentMode = MODE_BAG;
}
 
Example #23
Source Project: AndroidHttpCapture   Author: JZ-Darkal   File: ProxyUtils.java    License: MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean setProxyLollipop(final Context context, String host, int port) {
    System.setProperty("http.proxyHost", host);
    System.setProperty("http.proxyPort", port + "");
    System.setProperty("https.proxyHost", host);
    System.setProperty("https.proxyPort", port + "");
    try {
        Context appContext = context.getApplicationContext();
        Class applictionClass = Class.forName("android.app.Application");
        Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk");
        mLoadedApkField.setAccessible(true);
        Object mloadedApk = mLoadedApkField.get(appContext);
        Class loadedApkClass = Class.forName("android.app.LoadedApk");
        Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers");
        mReceiversField.setAccessible(true);
        ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk);
        for (Object receiverMap : receivers.values()) {
            for (Object receiver : ((ArrayMap) receiverMap).keySet()) {
                Class clazz = receiver.getClass();
                if (clazz.getName().contains("ProxyChangeListener")) {
                    Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
                    Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
                    onReceiveMethod.invoke(receiver, appContext, intent);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
 
Example #24
Source Project: android_9.0.0_r45   Author: lulululbj   File: FragmentTransition.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * The main entry point for Fragment Transitions, this starts the transitions
 * set on the leaving Fragment's {@link Fragment#getExitTransition()}, the
 * entering Fragment's {@link Fragment#getEnterTransition()} and
 * {@link Fragment#getSharedElementEnterTransition()}. When popping,
 * the leaving Fragment's {@link Fragment#getReturnTransition()} and
 * {@link Fragment#getSharedElementReturnTransition()} and the entering
 * {@link Fragment#getReenterTransition()} will be run.
 * <p>
 * With reordered Fragment Transitions, all Views have been added to the
 * View hierarchy prior to calling this method. The incoming Fragment's Views
 * will be INVISIBLE. With ordered Fragment Transitions, this method
 * is called before any change has been made to the hierarchy. That means
 * that the added Fragments have not created their Views yet and the hierarchy
 * is unknown.
 *
 * @param fragmentManager The executing FragmentManagerImpl
 * @param records The list of transactions being executed.
 * @param isRecordPop For each transaction, whether it is a pop transaction or not.
 * @param startIndex The first index into records and isRecordPop to execute as
 *                   part of this transition.
 * @param endIndex One past the last index into records and isRecordPop to execute
 *                 as part of this transition.
 * @param isReordered true if this is a reordered transaction, meaning that the
 *                    Views of incoming fragments have been added. false if the
 *                    transaction has yet to be run and Views haven't been created.
 */
static void startTransitions(FragmentManagerImpl fragmentManager,
        ArrayList<BackStackRecord> records, ArrayList<Boolean> isRecordPop,
        int startIndex, int endIndex, boolean isReordered) {
    if (fragmentManager.mCurState < Fragment.CREATED) {
        return;
    }
    SparseArray<FragmentContainerTransition> transitioningFragments =
            new SparseArray<>();
    for (int i = startIndex; i < endIndex; i++) {
        final BackStackRecord record = records.get(i);
        final boolean isPop = isRecordPop.get(i);
        if (isPop) {
            calculatePopFragments(record, transitioningFragments, isReordered);
        } else {
            calculateFragments(record, transitioningFragments, isReordered);
        }
    }

    if (transitioningFragments.size() != 0) {
        final View nonExistentView = new View(fragmentManager.mHost.getContext());
        final int numContainers = transitioningFragments.size();
        for (int i = 0; i < numContainers; i++) {
            int containerId = transitioningFragments.keyAt(i);
            ArrayMap<String, String> nameOverrides = calculateNameOverrides(containerId,
                    records, isRecordPop, startIndex, endIndex);

            FragmentContainerTransition containerTransition = transitioningFragments.valueAt(i);

            if (isReordered) {
                configureTransitionsReordered(fragmentManager, containerId,
                        containerTransition, nonExistentView, nameOverrides);
            } else {
                configureTransitionsOrdered(fragmentManager, containerId,
                        containerTransition, nonExistentView, nameOverrides);
            }
        }
    }
}
 
Example #25
Source Project: input-samples   Author: android   File: DebugService.java    License: Apache License 2.0 5 votes vote down vote up
static FillResponse createResponse(@NonNull Context context,
        @NonNull ArrayMap<String, AutofillId> fields, int numDatasets,
        boolean authenticateDatasets) {
    String packageName = context.getPackageName();
    FillResponse.Builder response = new FillResponse.Builder();
    // 1.Add the dynamic datasets
    for (int i = 1; i <= numDatasets; i++) {
        Dataset unlockedDataset = newUnlockedDataset(fields, packageName, i);
        if (authenticateDatasets) {
            Dataset.Builder lockedDataset = new Dataset.Builder();
            for (Entry<String, AutofillId> field : fields.entrySet()) {
                String hint = field.getKey();
                AutofillId id = field.getValue();
                String value = i + "-" + hint;
                IntentSender authentication =
                        SimpleAuthActivity.newIntentSenderForDataset(context, unlockedDataset);
                RemoteViews presentation = newDatasetPresentation(packageName,
                        "Tap to auth " + value);
                lockedDataset.setValue(id, null, presentation)
                        .setAuthentication(authentication);
            }
            response.addDataset(lockedDataset.build());
        } else {
            response.addDataset(unlockedDataset);
        }
    }

    // 2.Add save info
    Collection<AutofillId> ids = fields.values();
    AutofillId[] requiredIds = new AutofillId[ids.size()];
    ids.toArray(requiredIds);
    response.setSaveInfo(
            // We're simple, so we're generic
            new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, requiredIds).build());

    // 3.Profit!
    return response.build();
}
 
Example #26
Source Project: android_9.0.0_r45   Author: lulululbj   File: NotificationListenerService.java    License: Apache License 2.0 5 votes vote down vote up
private void buildShowBadgeLocked() {
    Bundle showBadge = mRankingUpdate.getShowBadge();
    mShowBadge = new ArrayMap<>(showBadge.size());
    for (String key : showBadge.keySet()) {
        mShowBadge.put(key, showBadge.getBoolean(key));
    }
}
 
Example #27
Source Project: android_9.0.0_r45   Author: lulululbj   File: ContentService.java    License: Apache License 2.0 5 votes vote down vote up
@GuardedBy("mCache")
private ArrayMap<Pair<String, Uri>, Bundle> findOrCreateCacheLocked(int userId,
        String providerPackageName) {
    ArrayMap<String, ArrayMap<Pair<String, Uri>, Bundle>> userCache = mCache.get(userId);
    if (userCache == null) {
        userCache = new ArrayMap<>();
        mCache.put(userId, userCache);
    }
    ArrayMap<Pair<String, Uri>, Bundle> packageCache = userCache.get(providerPackageName);
    if (packageCache == null) {
        packageCache = new ArrayMap<>();
        userCache.put(providerPackageName, packageCache);
    }
    return packageCache;
}
 
Example #28
Source Project: android_9.0.0_r45   Author: lulululbj   File: PrintManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Listen for changes to the installed and enabled print services.
 *
 * @param listener the listener to add
 * @param handler the handler the listener is called back on
 *
 * @see android.print.PrintManager#getPrintServices
 *
 * @hide
 */
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRINT_SERVICES)
public void addPrintServicesChangeListener(@NonNull PrintServicesChangeListener listener,
        @Nullable Handler handler) {
    Preconditions.checkNotNull(listener);

    if (handler == null) {
        handler = mHandler;
    }

    if (mService == null) {
        Log.w(LOG_TAG, "Feature android.software.print not available");
        return;
    }
    if (mPrintServicesChangeListeners == null) {
        mPrintServicesChangeListeners = new ArrayMap<>();
    }
    PrintServicesChangeListenerWrapper wrappedListener =
            new PrintServicesChangeListenerWrapper(listener, handler);
    try {
        mService.addPrintServicesChangeListener(wrappedListener, mUserId);
        mPrintServicesChangeListeners.put(listener, wrappedListener);
    } catch (RemoteException re) {
        throw re.rethrowFromSystemServer();
    }
}
 
Example #29
Source Project: android_9.0.0_r45   Author: lulululbj   File: HealthStats.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create an ArrayMap<String,T extends Parcelable> from the given Parcel using
 * the given Parcelable.Creator.
 */
private static <T extends Parcelable> ArrayMap<String,T> createParcelableMap(Parcel in,
        Parcelable.Creator<T> creator) {
    final int count = in.readInt();
    final ArrayMap<String,T> result = new ArrayMap<String,T>(count);
    for (int i=0; i<count; i++) {
        result.put(in.readString(), creator.createFromParcel(in));
    }
    return result;
}
 
Example #30
Source Project: android_9.0.0_r45   Author: lulululbj   File: Parcel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @hide For testing only.
 */
public void readArrayMap(ArrayMap outVal, ClassLoader loader) {
    final int N = readInt();
    if (N < 0) {
        return;
    }
    readArrayMapInternal(outVal, N, loader);
}