Java Code Examples for android.util.ArrayMap#putAll()

The following examples show how to use android.util.ArrayMap#putAll() . 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: OC_Diagnostics.java    From GLEXP-Team-onebillion with Apache License 2.0 4 votes vote down vote up
public void prepare()
{
    setStatus(STATUS_BUSY);
    //
    super.prepare();
    //
    timeoutEnabled = true;
    //
    loadFingers();
    loadEvent("master1");
    //
    masterObjects = new ArrayMap();
    masterObjects.putAll(objectDict);
    //
    OBGroup presenterControl = (OBGroup) objectDict.get("presenter");
    if (presenterControl != null)
    {
        presenterControl.hide();
    }
    //
    hideControls("background.*");
    //
    confirmAnswerButton = objectDict.get("confirm_answer");
    if (confirmAnswerButton != null)
    {
        confirmAnswerButton.hide();
    }
    //
    smallTick = (OBGroup) objectDict.get("tick");
    if (smallTick != null)
    {
        smallTick.hide();
    }
    //
    smallCross = (OBGroup) objectDict.get("cross");
    if (smallCross != null)
    {
        smallCross.hide();
    }
    //
    unitsUsedForParameter = new ArrayMap<>();
    touchables = new ArrayList<>();
    inertObjects = new ArrayList<>();
    eventUUID = OC_DiagnosticsManager.sharedManager().CurrentEvent();
    //
    if (eventUUID != null)
    {
        events = new ArrayList<>();
        events.add(eventUUID);
    }
    else
    {
        MainActivity.log("OC_Diagnostics --> WARNING: unable to find event in parameters");
    }
    try
    {
        questions = generateQuestionsForExercise(eventUUID);
    }
    catch (Exception e)
    {
        MainActivity.log("OC_Diagnostics --> ERROR: exception caught: " + e.toString());
        e.printStackTrace();
    }
}
 
Example 2
Source File: ResourcesManager.java    From VirtualAPK with Apache License 2.0 4 votes vote down vote up
/**
 * Use System Apis to update all existing resources.
 * <br/>
 * 1. Update ApplicationInfo.splitSourceDirs and LoadedApk.mSplitResDirs
 * <br/>
 * 2. Replace all keys of ResourcesManager.mResourceImpls to new ResourcesKey
 * <br/>
 * 3. Use ResourcesManager.appendLibAssetForMainAssetPath(appInfo.publicSourceDir, "${packageName}.vastub") to update all existing resources.
 * <br/>
 *
 * see android.webkit.WebViewDelegate.addWebViewAssetPath(Context)
 */
@TargetApi(Build.VERSION_CODES.N)
private static Resources createResourcesForN(Context context, String packageName, File apk) throws Exception {
    long startTime = System.currentTimeMillis();
    String newAssetPath = apk.getAbsolutePath();
    ApplicationInfo info = context.getApplicationInfo();
    String baseResDir = info.publicSourceDir;
    
    info.splitSourceDirs = append(info.splitSourceDirs, newAssetPath);
    LoadedApk loadedApk = Reflector.with(context).field("mPackageInfo").get();

    Reflector rLoadedApk = Reflector.with(loadedApk).field("mSplitResDirs");
    String[] splitResDirs = rLoadedApk.get();
    rLoadedApk.set(append(splitResDirs, newAssetPath));

    final android.app.ResourcesManager resourcesManager = android.app.ResourcesManager.getInstance();
    ArrayMap<ResourcesKey, WeakReference<ResourcesImpl>> originalMap = Reflector.with(resourcesManager).field("mResourceImpls").get();

    synchronized (resourcesManager) {
        HashMap<ResourcesKey, WeakReference<ResourcesImpl>> resolvedMap = new HashMap<>();

        if (Build.VERSION.SDK_INT >= 28
            || (Build.VERSION.SDK_INT == 27 && Build.VERSION.PREVIEW_SDK_INT != 0)) { // P Preview
            ResourcesManagerCompatForP.resolveResourcesImplMap(originalMap, resolvedMap, context, loadedApk);

        } else {
            ResourcesManagerCompatForN.resolveResourcesImplMap(originalMap, resolvedMap, baseResDir, newAssetPath);
        }

        originalMap.clear();
        originalMap.putAll(resolvedMap);
    }

    android.app.ResourcesManager.getInstance().appendLibAssetForMainAssetPath(baseResDir, packageName + ".vastub");

    Resources newResources = context.getResources();

    // lastly, sync all LoadedPlugin to newResources
    for (LoadedPlugin plugin : PluginManager.getInstance(context).getAllLoadedPlugins()) {
        plugin.updateResources(newResources);
    }

    Log.d(TAG, "createResourcesForN cost time: +" + (System.currentTimeMillis() - startTime) + "ms");
    return newResources;
}