mobile/android/base/ActivityHandlerHelper.java

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 package org.mozilla.gecko;
     7 import org.mozilla.gecko.util.ActivityResultHandler;
     8 import org.mozilla.gecko.util.ActivityResultHandlerMap;
    10 import android.app.Activity;
    11 import android.content.Intent;
    13 public class ActivityHandlerHelper {
    14     private static final String LOGTAG = "GeckoActivityHandlerHelper";
    15     private static final ActivityResultHandlerMap mActivityResultHandlerMap = new ActivityResultHandlerMap();
    17     private static int makeRequestCode(ActivityResultHandler aHandler) {
    18         return mActivityResultHandlerMap.put(aHandler);
    19     }
    21     public static void startIntent(Intent intent, ActivityResultHandler activityResultHandler) {
    22         startIntentForActivity(GeckoAppShell.getGeckoInterface().getActivity(), intent, activityResultHandler);
    23     }
    25     public static void startIntentForActivity(Activity activity, Intent intent, ActivityResultHandler activityResultHandler) {
    26         activity.startActivityForResult(intent, mActivityResultHandlerMap.put(activityResultHandler));
    27     }
    30     public static boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
    31         ActivityResultHandler handler = mActivityResultHandlerMap.getAndRemove(requestCode);
    32         if (handler != null) {
    33             handler.onActivityResult(resultCode, data);
    34             return true;
    35         }
    36         return false;
    37     }
    38 }

mercurial