Life Simulator: Game Dev v0.6版本的 MD5 值为:ecca8c682c00d3b861fbed7f58e41c8d

以下内容为反编译后的 c.java 源代码,内容仅作参考


package com.startapp.android.publish.c;

import android.R;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import com.startapp.android.publish.d.b;
import com.startapp.android.publish.i.n;
import com.startapp.android.publish.i.w;
import com.startapp.android.publish.i.x;
import com.startapp.android.publish.inappbrowser.AnimatingProgressBar;

public class c extends b implements View.OnClickListener {
    private static boolean i = false;
    protected FrameLayout c;
    private RelativeLayout d;
    private com.startapp.android.publish.inappbrowser.a e;
    private WebView f;
    private AnimatingProgressBar g;
    private String h;

    public c(String str) {
        this.h = str;
    }

    @Override
    public void a(Bundle bundle) {
        super.a(bundle);
        i = false;
        this.d = new RelativeLayout(b());
        b(this.h);
        if (bundle != null) {
            c(bundle);
        }
        b().setContentView(this.d, new RelativeLayout.LayoutParams(-2, -2));
    }

    @Override
    public void t() {
    }

    private void b(String str) {
        n.a("IABrowserMode", 3, "initUi");
        if (this.e == null) {
            this.e = new com.startapp.android.publish.inappbrowser.a(b());
            this.e.a();
            this.e.b();
            this.e.setButtonsListener(this);
        }
        this.d.addView(this.e);
        this.g = new AnimatingProgressBar(b(), null, R.attr.progressBarStyleHorizontal);
        ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape());
        shapeDrawable.getPaint().setColor(Color.parseColor("#45d200"));
        this.g.setProgressDrawable(new ClipDrawable(shapeDrawable, 3, 1));
        this.g.setBackgroundColor(-1);
        this.g.setId(2108);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, w.a(b(), 4));
        layoutParams.addRule(3, 2101);
        this.d.addView(this.g, layoutParams);
        this.c = new FrameLayout(b());
        if (this.f == null) {
            try {
                x();
                this.f.loadUrl(str);
            } catch (Exception e) {
                this.e.c();
                x.c(b(), str);
                com.startapp.android.publish.d.d.a(b(), b.a.EXCEPTION, "IABrowserMode.initUi - Webvie  failed", e.getMessage(), "");
                b().finish();
            }
        }
        this.c.addView(this.f);
        RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -1);
        layoutParams2.addRule(15);
        layoutParams2.addRule(3, 2108);
        this.d.addView(this.c, layoutParams2);
    }

    @Override
    public void r() {
    }

    @Override
    public void b(Bundle bundle) {
        this.f.saveState(bundle);
    }

    @Override
    public void c(Bundle bundle) {
        this.f.restoreState(bundle);
    }

    private void x() {
        this.f = new WebView(b());
        y();
        this.f.setWebViewClient(new a(b(), this.e, this.g));
        this.f.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int progress) {
                c.this.g.setProgress(progress);
            }

            @Override
            public void onReceivedTitle(WebView view, String title) {
                if (title != null && !title.equals("")) {
                    c.this.e.getTitleTxt().setText(title);
                }
            }
        });
    }

    private void y() {
        this.f.getSettings().setJavaScriptEnabled(true);
        this.f.getSettings().setUseWideViewPort(true);
        this.f.getSettings().setLoadWithOverviewMode(true);
        this.f.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        this.f.getSettings().setBuiltInZoomControls(true);
        if (Build.VERSION.SDK_INT >= 11) {
            this.f.getSettings().setDisplayZoomControls(false);
        }
    }

    public static class a extends WebViewClient {
        private Context a;
        private com.startapp.android.publish.inappbrowser.a b;
        private AnimatingProgressBar c;
        private int d = 0;
        private boolean e = false;

        public a(Context context, com.startapp.android.publish.inappbrowser.a aVar, AnimatingProgressBar animatingProgressBar) {
            this.a = context;
            this.c = animatingProgressBar;
            this.b = aVar;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (!c.i) {
                n.a("IABrowserMode", 3, "IABWebViewClient::onPageStarted - [" + url + "]REDIRECTED  -> " + this.d + " Can go back " + view.canGoBack());
                if (this.e) {
                    this.d = 1;
                    this.c.a();
                    this.b.a(view);
                } else {
                    this.d = Math.max(this.d, 1);
                }
                this.c.setVisibility(0);
                this.b.getUrlTxt().setText(url);
                this.b.a(view);
                super.onPageStarted(view, url, favicon);
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            n.a("IABrowserMode", 3, "IABWebViewClient::shouldOverrideUrlLoading - [" + url + "]");
            if (!c.i) {
                if (!this.e) {
                    this.e = true;
                    this.c.a();
                    this.d = 0;
                }
                this.d++;
                if ((url.startsWith("http:") || url.startsWith("https:")) && !url.startsWith("http://play.google.com") && !url.startsWith("https://play.google.com")) {
                    return false;
                }
                this.d = 1;
                this.a.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
            }
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (!c.i) {
                n.a("IABrowserMode", 3, "IABWebViewClient::onPageFinished - [" + url + "]");
                this.b.a(view);
                int i = this.d - 1;
                this.d = i;
                if (i == 0) {
                    this.e = false;
                    this.c.a();
                    if (this.c.isShown()) {
                        this.c.setVisibility(8);
                    }
                    this.b.a(view);
                }
                super.onPageFinished(view, url);
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            n.a("IABrowserMode", 3, "IABWebViewClient::onReceivedError - [" + description + "], [" + failingUrl + "]");
            this.c.a();
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case 2103:
                z();
                return;
            case 2104:
                x.c(b(), this.f.getUrl());
                z();
                return;
            case 2105:
                if (this.f.canGoBack()) {
                    this.g.a();
                    this.f.goBack();
                    return;
                }
                return;
            case 2106:
                if (this.f.canGoForward()) {
                    this.g.a();
                    this.f.goForward();
                    return;
                }
                return;
            default:
                return;
        }
    }

    @Override
    public boolean a(int i2, KeyEvent keyEvent) {
        if (keyEvent.getAction() == 0) {
            switch (i2) {
                case 4:
                    if (this.f.canGoBack()) {
                        n.a("IABrowserMode", 3, "IABWebViewClient::KEYCODE_BACK can go back");
                        this.g.a();
                        this.f.goBack();
                    } else {
                        n.a("IABrowserMode", 3, "IABWebViewClient::KEYCODE_BACK canT go back");
                        z();
                    }
                    return true;
            }
        }
        return super.a(i2, keyEvent);
    }

    private void z() {
        A();
        this.e.c();
        b().finish();
    }

    private void A() {
        i = true;
        this.f.stopLoading();
        this.f.removeAllViews();
        this.f.postInvalidate();
        com.startapp.android.publish.i.b.b(this.f);
        this.f.destroy();
        this.f = null;
    }
}