Search in sources :

Example 16 with LongSparseArray

use of android.util.LongSparseArray in project WordPress-Android by wordpress-mobile.

the class CategoryNode method createCategoryTreeFromList.

public static CategoryNode createCategoryTreeFromList(List<TermModel> categories) {
    CategoryNode rootCategory = new CategoryNode(-1, -1, "");
    // First pass instantiate CategoryNode objects
    LongSparseArray<CategoryNode> categoryMap = new LongSparseArray<>();
    CategoryNode currentRootNode;
    for (TermModel category : categories) {
        long categoryId = category.getRemoteTermId();
        long parentId = category.getParentRemoteId();
        CategoryNode node = new CategoryNode(categoryId, parentId, category.getName());
        categoryMap.put(categoryId, node);
    }
    // Second pass associate nodes to form a tree
    for (int i = 0; i < categoryMap.size(); i++) {
        CategoryNode category = categoryMap.valueAt(i);
        if (category.getParentId() == 0) {
            // root node
            currentRootNode = rootCategory;
        } else {
            currentRootNode = categoryMap.get(category.getParentId(), rootCategory);
        }
        currentRootNode.children.put(category.getName(), categoryMap.get(category.getCategoryId()));
    }
    return rootCategory;
}
Also used : LongSparseArray(android.util.LongSparseArray) TermModel(org.wordpress.android.fluxc.model.TermModel)

Example 17 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by crdroidandroid.

the class KeySetUtils method getKeySetMapping.

public static LongSparseArray<ArraySet<Long>> getKeySetMapping(KeySetManagerService ksms) throws NoSuchFieldException, IllegalAccessException {
    Field ksField = ksms.getClass().getDeclaredField("mKeySetMapping");
    ksField.setAccessible(true);
    return (LongSparseArray<ArraySet<Long>>) ksField.get(ksms);
}
Also used : Field(java.lang.reflect.Field) LongSparseArray(android.util.LongSparseArray)

Example 18 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by crdroidandroid.

the class KeySetUtils method getPubKey.

public static PublicKey getPubKey(KeySetManagerService ksms, long pkId) throws NoSuchFieldException, IllegalAccessException {
    Field pkField = ksms.getClass().getDeclaredField("mPublicKeys");
    pkField.setAccessible(true);
    LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys = (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(ksms);
    KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
    if (pkh == null) {
        return null;
    } else {
        return pkh.getKey();
    }
}
Also used : Field(java.lang.reflect.Field) LongSparseArray(android.util.LongSparseArray)

Example 19 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by crdroidandroid.

the class AppWidgetServiceImpl method startListening.

@Override
public ParceledListSlice<PendingHostUpdate> startListening(IAppWidgetHost callbacks, String callingPackage, int hostId, int[] appWidgetIds) {
    final int userId = UserHandle.getCallingUserId();
    if (DEBUG) {
        Slog.i(TAG, "startListening() " + userId);
    }
    // Make sure the package runs under the caller uid.
    mSecurityPolicy.enforceCallFromPackage(callingPackage);
    synchronized (mLock) {
        ensureGroupStateLoadedLocked(userId);
        // NOTE: The lookup is enforcing security across users by making
        // sure the caller can only access hosts it owns.
        HostId id = new HostId(Binder.getCallingUid(), hostId, callingPackage);
        Host host = lookupOrAddHostLocked(id);
        host.callbacks = callbacks;
        int N = appWidgetIds.length;
        ArrayList<PendingHostUpdate> outUpdates = new ArrayList<>(N);
        LongSparseArray<PendingHostUpdate> updatesMap = new LongSparseArray<>();
        for (int i = 0; i < N; i++) {
            if (host.getPendingUpdatesForId(appWidgetIds[i], updatesMap)) {
                // We key the updates based on request id, so that the values are sorted in the
                // order they were received.
                int M = updatesMap.size();
                for (int j = 0; j < M; j++) {
                    outUpdates.add(updatesMap.valueAt(j));
                }
            }
        }
        return new ParceledListSlice<>(outUpdates);
    }
}
Also used : LongSparseArray(android.util.LongSparseArray) ArrayList(java.util.ArrayList) IAppWidgetHost(com.android.internal.appwidget.IAppWidgetHost) Point(android.graphics.Point) PendingHostUpdate(android.appwidget.PendingHostUpdate) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 20 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by AOSPA.

the class AppWidgetServiceImpl method startListening.

@Override
public ParceledListSlice<PendingHostUpdate> startListening(IAppWidgetHost callbacks, String callingPackage, int hostId, int[] appWidgetIds) {
    final int userId = UserHandle.getCallingUserId();
    if (DEBUG) {
        Slog.i(TAG, "startListening() " + userId);
    }
    // Make sure the package runs under the caller uid.
    mSecurityPolicy.enforceCallFromPackage(callingPackage);
    synchronized (mLock) {
        ensureGroupStateLoadedLocked(userId);
        // NOTE: The lookup is enforcing security across users by making
        // sure the caller can only access hosts it owns.
        HostId id = new HostId(Binder.getCallingUid(), hostId, callingPackage);
        Host host = lookupOrAddHostLocked(id);
        host.callbacks = callbacks;
        int N = appWidgetIds.length;
        ArrayList<PendingHostUpdate> outUpdates = new ArrayList<>(N);
        LongSparseArray<PendingHostUpdate> updatesMap = new LongSparseArray<>();
        for (int i = 0; i < N; i++) {
            if (host.getPendingUpdatesForId(appWidgetIds[i], updatesMap)) {
                // We key the updates based on request id, so that the values are sorted in the
                // order they were received.
                int M = updatesMap.size();
                for (int j = 0; j < M; j++) {
                    outUpdates.add(updatesMap.valueAt(j));
                }
            }
        }
        return new ParceledListSlice<>(outUpdates);
    }
}
Also used : LongSparseArray(android.util.LongSparseArray) ArrayList(java.util.ArrayList) IAppWidgetHost(com.android.internal.appwidget.IAppWidgetHost) Point(android.graphics.Point) PendingHostUpdate(android.appwidget.PendingHostUpdate) ParceledListSlice(android.content.pm.ParceledListSlice)

Aggregations

LongSparseArray (android.util.LongSparseArray)33 Field (java.lang.reflect.Field)19 Parcelable (android.os.Parcelable)7 Editable (android.text.Editable)7 View (android.view.View)7 ArrayList (java.util.ArrayList)7 PendingHostUpdate (android.appwidget.PendingHostUpdate)5 ParceledListSlice (android.content.pm.ParceledListSlice)5 Point (android.graphics.Point)5 IAppWidgetHost (com.android.internal.appwidget.IAppWidgetHost)5 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 SparseArray (android.util.SparseArray)1 Method (java.lang.reflect.Method)1 TermModel (org.wordpress.android.fluxc.model.TermModel)1