正在查看: Clash Legends v0.0.1 应用的 SelectedLanguageActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 SelectedLanguageActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import androidx.appcompat.app.AppCompatActivity;
import com.android.volley.AuthFailureError;
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.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class SelectedLanguageActivity extends AppCompatActivity {
Button buttoncontinue;
Context context;
RadioGroup langRg;
LoadingDialog loadingDialog;
RequestQueue mQueue;
Resources resources;
JSONArray langArray = new JSONArray();
String selectedLangKey = "";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558477);
Context locale = LocaleHelper.setLocale(this);
this.context = locale;
this.resources = locale.getResources();
LoadingDialog loadingDialog = new LoadingDialog(this);
this.loadingDialog = loadingDialog;
loadingDialog.show();
getLanguage();
this.buttoncontinue = (Button) findViewById(2131362068);
RadioGroup radioGroup = (RadioGroup) findViewById(2131362566);
this.langRg = radioGroup;
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public final void onCheckedChanged(RadioGroup radioGroup2, int i) {
SelectedLanguageActivity.this.m166x96078b7c(radioGroup2, i);
}
});
this.buttoncontinue.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedLanguageActivity.this.m167x22f4a29b(view);
}
});
}
void m166x96078b7c(RadioGroup group, int checkedId) {
try {
this.selectedLangKey = this.langArray.getJSONObject(checkedId).keys().next();
} catch (JSONException e) {
e.printStackTrace();
}
}
void m167x22f4a29b(View view) {
LocaleHelper.persist(this, this.selectedLangKey);
startActivity(new Intent(getApplicationContext(), (Class<?>) IndroductionActivity.class));
}
void getLanguage() {
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
String url = this.resources.getString(2131886167) + "all_language";
new UserLocalStore(getApplicationContext());
JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
public final void onResponse(Object obj) {
SelectedLanguageActivity.this.m165x83f916a1((JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("**VolleyError", "error" + volleyError.getMessage());
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("x-localization", LocaleHelper.getPersist(SelectedLanguageActivity.this.context));
return headers;
}
};
request.setShouldCache(false);
this.mQueue.add(request);
}
void m165x83f916a1(JSONObject response) {
try {
Log.d("language", String.valueOf(response));
JSONObject lang = response.getJSONObject("supported_language");
Iterator x = lang.keys();
int id = 0;
while (x.hasNext()) {
String key = x.next();
if (id == 0) {
this.selectedLangKey = key;
}
JSONObject obj = new JSONObject();
obj.put(key, lang.get(key));
this.langArray.put(obj);
RadioButton rdbtn = new RadioButton(this);
if (TextUtils.equals(this.selectedLangKey, key)) {
rdbtn.setChecked(true);
}
rdbtn.setId(id);
String langText = lang.get(key).toString();
rdbtn.setText(langText.substring(0, 1).toUpperCase() + langText.substring(1));
rdbtn.setBackgroundDrawable(this.resources.getDrawable(2131230873));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
params.setMargins(0, 20, 0, 20);
rdbtn.setLayoutParams(params);
rdbtn.setPadding(50, 50, 50, 50);
this.langRg.addView(rdbtn);
id++;
}
Log.d("lang", this.langArray.toString());
JSONObject rtl = response.getJSONObject("rtl_supported_language");
Iterator y = rtl.keys();
JSONArray rtlArray = new JSONArray();
while (y.hasNext()) {
String key2 = y.next();
JSONObject obj2 = new JSONObject();
obj2.put(key2, rtl.get(key2));
rtlArray.put(obj2);
}
Log.d("rtl", rtlArray.toString());
} catch (JSONException e) {
e.printStackTrace();
}
this.loadingDialog.dismiss();
}
}