Untitled

mail@pastecode.io avatar
unknown
java
a year ago
4.1 kB
2
Indexable
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.Toast;

public class Main26Activity extends Activity {
private WebView view6;

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main26);



    String url6 = "https://www.youtube.com/watch?v=MPK43O87atA";
    view6=(WebView)findViewById(R.id.webView6);
    view6.getSettings().setJavaScriptEnabled(true);
    view6.setWebViewClient(new WebViewClient());
    view6.setWebViewClient(new Browser());
    view6.setWebChromeClient(new MyWebClient());
    if (savedInstanceState != null)
    {
        view6.restoreState(savedInstanceState);
    }
    else
    {
        view6.loadUrl(url6);
    }

    Context context = getApplicationContext();
    CharSequence text = "please wait while episodes are loaded";
    int duration = Toast.LENGTH_LONG;

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
}
public void onPause()
{
    view6.onPause();
    super.onPause();
}
class Browser
        extends WebViewClient
{
    Browser() {}

    public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString)
    {
        paramWebView.loadUrl(paramString);
        return true;
    }
}

public class MyWebClient
        extends WebChromeClient
{
    private View mCustomView;
    private WebChromeClient.CustomViewCallback mCustomViewCallback;
    protected FrameLayout mFullscreenContainer;
    private int mOriginalOrientation;
    private int mOriginalSystemUiVisibility;

    public MyWebClient() {}

    public Bitmap getDefaultVideoPoster()
    {
        if (Main26Activity.this == null) {
            return null;
        }
        return BitmapFactory.decodeResource(Main26Activity.this.getApplicationContext().getResources(), 2130837573);
    }

    public void onHideCustomView()
    {
        ((FrameLayout)Main26Activity.this.getWindow().getDecorView()).removeView(this.mCustomView);
        this.mCustomView = null;
        Main26Activity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
        Main26Activity.this.setRequestedOrientation(this.mOriginalOrientation);
        this.mCustomViewCallback.onCustomViewHidden();
        this.mCustomViewCallback = null;
    }

    public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
    {
        if (this.mCustomView != null)
        {
            onHideCustomView();
            return;
        }
        this.mCustomView = paramView;
        this.mOriginalSystemUiVisibility = Main26Activity.this.getWindow().getDecorView().getSystemUiVisibility();
        this.mOriginalOrientation = Main26Activity.this.getRequestedOrientation();
        this.mCustomViewCallback = paramCustomViewCallback;
        ((FrameLayout)Main26Activity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
        Main26Activity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
    }
}
@Override
protected void onSaveInstanceState(Bundle outState )
{
    super.onSaveInstanceState(outState);
    view6.saveState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
    super.onRestoreInstanceState(savedInstanceState);
    view6.restoreState(savedInstanceState);
}
public void onBackPressed() {
    if (view6.canGoBack()) {
        view6.goBack();
    } else {
        super.onBackPressed();
    }
}