导航菜单

页面标题

页面副标题

Clash Legends v0.0.1 - ChooseLanguageActivity.java 源代码

正在查看: Clash Legends v0.0.1 应用的 ChooseLanguageActivity.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.ImageView;
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 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 ChooseLanguageActivity 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(2131558441);
        Context locale = LocaleHelper.setLocale(this);
        this.context = locale;
        this.resources = locale.getResources();
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        this.selectedLangKey = LocaleHelper.getPersist(this);
        getLanguage();
        ImageView back = (ImageView) findViewById(2131361988);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChooseLanguageActivity.this.m13xa6d5d78(view);
            }
        });
        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) {
                ChooseLanguageActivity.this.m14xba3b057(radioGroup2, i);
            }
        });
        this.buttoncontinue.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChooseLanguageActivity.this.m15xcda0336(view);
            }
        });
    }

    void m13xa6d5d78(View v) {
        onBackPressed();
    }

    void m14xba3b057(RadioGroup group, int checkedId) {
        try {
            this.selectedLangKey = this.langArray.getJSONObject(checkedId).keys().next();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    void m15xcda0336(View view) {
        LocaleHelper.persist(this, this.selectedLangKey);
        startActivity(new Intent(getApplicationContext(), (Class<?>) HomeActivity.class));
    }

    void getLanguage() {
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String url = this.resources.getString(2131886167) + "all_language";
        JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                ChooseLanguageActivity.this.m12xd657c0bc((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(ChooseLanguageActivity.this.context));
                return headers;
            }
        };
        request.setShouldCache(false);
        this.mQueue.add(request);
    }

    void m12xd657c0bc(JSONObject response) {
        try {
            Log.d("language", String.valueOf(response));
            JSONObject lang = response.getJSONObject("supported_language");
            Iterator<String> x = lang.keys();
            int id = 0;
            while (x.hasNext()) {
                String key = x.next();
                JSONObject obj = new JSONObject();
                obj.put(key, lang.get(key));
                this.langArray.put(obj);
                RadioButton rdbtn = new RadioButton(this);
                Log.d(this.selectedLangKey, key);
                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(getResources().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<String> 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();
    }
}