Example usage for android.content MutableContextWrapper MutableContextWrapper

List of usage examples for android.content MutableContextWrapper MutableContextWrapper

Introduction

In this page you can find the example usage for android.content MutableContextWrapper MutableContextWrapper.

Prototype

public MutableContextWrapper(Context base) 

Source Link

Usage

From source file:Main.java

/**
 * <p>Creates the shared webView used throughout the lifetime of the TurbolinksSession.</p>
 *
 * @param applicationContext An application context.
 * @return The shared WebView./*from ww w .  ja v a2s  .  c o  m*/
 */
static WebView createWebView(Context applicationContext) {
    MutableContextWrapper contextWrapper = new MutableContextWrapper(applicationContext);
    WebView webView = new WebView(contextWrapper);
    configureWebViewDefaults(webView);
    setWebViewLayoutParams(webView);

    return webView;
}

From source file:com.github.markzhai.react.preloader.ReactPreLoader.java

/**
 * Pre-load {@link ReactRootView} to local {@link Map}, you may want to
 * load it in previous activity./*from   w  w w.  j  a  v a  2  s .  co m*/
 */
public static void init(Activity activity, ReactInfo reactInfo) {
    if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) {
        return;
    }
    ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity));
    rootView.startReactApplication(
            ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
            reactInfo.getMainComponentName(), reactInfo.getLaunchOptions());
    CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView);
}

From source file:com.appnexus.opensdk.ANNativeAdResponse.java

boolean handleClick(String clickUrl, Context context) {
    if (clickUrl == null || clickUrl.isEmpty()) {
        return false;
    }// w  w  w .j  av a2  s .c  o m
    // if install, open store
    if (clickUrl.contains("://play.google.com") || clickUrl.contains("market://")) {
        Clog.d(Clog.nativeLogTag, Clog.getString(R.string.opening_app_store));
        return openNativeIntent(clickUrl, context);
    }
    // open browser
    if (openNativeBrowser) {
        // if set to use native browser, open intent
        if (openNativeIntent(clickUrl, context)) {
            if (listener != null) {
                listener.onAdWillLeaveApplication();
            }
            return true;
        }
        return false;
    } else {
        // launch Browser Activity
        Class<?> activity_clz = AdActivity.getActivityClass();
        try {
            WebView out = new WebView(new MutableContextWrapper(context));
            WebviewUtil.setWebViewSettings(out);
            out.loadUrl(clickUrl);
            BrowserAdActivity.BROWSER_QUEUE.add(out);

            Intent intent = new Intent(context, activity_clz);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER);
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException e) {
            Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName()));
            BrowserAdActivity.BROWSER_QUEUE.remove();
        } catch (Exception e) {
            // Catches PackageManager$NameNotFoundException for webview
            Clog.e(Clog.baseLogTag, "Exception initializing the redirect webview: " + e.getMessage());
            return false;
        }

        return false;
    }
}