正在查看: Clash Legends v0.0.1 应用的 HowtoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 HowtoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.clash.legends.models.CurrentUser;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.LoadAdError;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class HowtoActivity extends AppCompatActivity {
TextView apptutorialtitle;
ImageView back;
Context context;
LinearLayout howtoLl;
LoadingDialog loadingDialog;
RequestQueue mQueue;
TextView noapptutorial;
ScrollView nohowto;
Resources resources;
WebView webView;
String videoId = "";
String description = "";
String videoUrl = "";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558448);
Context locale = LocaleHelper.setLocale(this);
this.context = locale;
this.resources = locale.getResources();
SharedPreferences sp = getSharedPreferences("SMINFO", 0);
if (TextUtils.equals(sp.getString("baner", "no"), "yes")) {
final AdView mAdView = findViewById(2131361885);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setAdListener(new AdListener() {
public void onAdLoaded() {
mAdView.setVisibility(0);
}
public void onAdFailedToLoad(LoadAdError adError) {
mAdView.setVisibility(8);
}
public void onAdOpened() {
}
public void onAdClicked() {
}
public void onAdLeftApplication() {
}
public void onAdClosed() {
}
});
}
LoadingDialog loadingDialog = new LoadingDialog(this);
this.loadingDialog = loadingDialog;
loadingDialog.show();
this.howtoLl = (LinearLayout) findViewById(2131362426);
TextView textView = (TextView) findViewById(2131361952);
this.apptutorialtitle = textView;
textView.setText(this.resources.getString(2131886170));
ImageView imageView = (ImageView) findViewById(2131361977);
this.back = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
HowtoActivity.this.m48lambda$onCreate$0$comclashlegendsuiactivitiesHowtoActivity(view);
}
});
this.noapptutorial = (TextView) findViewById(2131362831);
this.nohowto = (ScrollView) findViewById(2131362835);
RequestQueue newRequestQueue = Volley.newRequestQueue(this);
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
String url = this.resources.getString(2131886167) + "youtube_link";
JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
public final void onResponse(Object obj) {
HowtoActivity.this.m49lambda$onCreate$1$comclashlegendsuiactivitiesHowtoActivity((JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("error", volleyError.toString());
}
}) {
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
UserLocalStore userLocalStore = new UserLocalStore(HowtoActivity.this.getApplicationContext());
CurrentUser user = userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
headers.put("x-localization", LocaleHelper.getPersist(HowtoActivity.this.context));
return headers;
}
};
request.setShouldCache(false);
this.mQueue.add(request);
if (savedInstanceState != null) {
this.webView.loadData(this.videoUrl, "text/html", "utf-8");
}
}
void m48lambda$onCreate$0$comclashlegendsuiactivitiesHowtoActivity(View view) {
onBackPressed();
}
void m49lambda$onCreate$1$comclashlegendsuiactivitiesHowtoActivity(JSONObject response) {
this.loadingDialog.dismiss();
try {
JSONArray arr = response.getJSONArray("youtube_links");
JSON_PARSE_DATA_AFTER_WEBCALL(arr);
} catch (JSONException e) {
e.printStackTrace();
}
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
if (TextUtils.equals(String.valueOf(array.length()), "0")) {
this.nohowto.setVisibility(8);
this.noapptutorial.setVisibility(0);
return;
}
for (int i = 0; i < array.length(); i++) {
try {
JSONObject json = array.getJSONObject(i);
this.description = json.getString("youtube_link_title");
String url = json.getString("youtube_link");
Pattern compiledPattern = Pattern.compile("/.*(?:youtu.be\\/|v\\/|u/\\w/|embed\\/|watch\\?.*&?v=)");
Matcher matcher = compiledPattern.matcher(url);
if (matcher.find()) {
int start = matcher.end();
this.videoId = url.substring(start, start + 11);
}
View view = getLayoutInflater().inflate(2131558619, (ViewGroup) null);
WebView webView = (WebView) view.findViewById(2131363786);
this.webView = webView;
webView.setWebChromeClient(new MyCrome() {
});
Button play = (Button) view.findViewById(2131363034);
this.webView.getSettings().setJavaScriptEnabled(true);
String str = "<html><body style=\"line-height:25px;\"> <b> " + this.description + "</b><br><iframe width=\"100%\" height=\"90%\" src=\"http://www.youtube.com/embed/" + this.videoId + "\" frameborder=\"0\" allowfullscreen></iframe></body></html>";
this.videoUrl = str;
this.webView.loadData(str, "text/html", "utf-8");
play.setTag(this.videoId);
play.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
HowtoActivity.this.m47x7b308e8b(view2);
}
});
Log.d("video", this.videoId);
this.howtoLl.addView(view);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
void m47x7b308e8b(View v) {
Button b = (Button) v;
try {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("vnd.youtube://" + b.getTag()));
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText((Context) this, (CharSequence) "Youtube not installed", 0).show();
}
}
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState);
this.webView.saveState(outState);
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
this.webView.restoreState(savedInstanceState);
}
public class MyCrome extends WebChromeClient {
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private int mOriginalOrientation;
private int mOriginalSystemUiVisibility;
MyCrome() {
}
@Override
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
}
@Override
public void onHideCustomView() {
((FrameLayout) HowtoActivity.this.getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
HowtoActivity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
HowtoActivity.this.setRequestedOrientation(this.mOriginalOrientation);
this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;
}
@Override
public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback) {
if (this.mCustomView != null) {
onHideCustomView();
return;
}
this.mCustomView = paramView;
paramView.setBackgroundColor(-16777216);
this.mOriginalSystemUiVisibility = HowtoActivity.this.getWindow().getDecorView().getSystemUiVisibility();
this.mOriginalOrientation = HowtoActivity.this.getRequestedOrientation();
this.mCustomViewCallback = paramCustomViewCallback;
((FrameLayout) HowtoActivity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
HowtoActivity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
}
}
}