导航菜单

页面标题

页面副标题

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

正在查看: Clash Legends v0.0.1 应用的 HomeActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.clash.legends.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import com.clash.legends.ui.adapters.SectionsPagerAdapter;
import com.clash.legends.utils.LocaleHelper;
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 com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.android.material.tabs.TabLayout;
import java.util.Objects;

public class HomeActivity extends AppCompatActivity {
    Context context;
    Resources resources;
    SharedPreferences sp;
    ImageView tabImageView1;
    ImageView tabImageView2;
    ImageView tabImageView3;
    TextView tabImagetext;
    TabLayout tabs;
    TextView tabtextview1;
    TextView tabtextview2;
    TextView tabtextview3;
    View view1;
    View view2;
    View view3;
    Boolean doubleBackToExitPressedOnce = false;
    int n = 1;
    private final int[] tabIcons = {2131231392, 2131230867, 2131230855};

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558447);
        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")) {
            MobileAds.initialize(this, new OnInitializationCompleteListener() {
                public final void onInitializationComplete(InitializationStatus initializationStatus) {
                    HomeActivity.lambda$onCreate$0(initializationStatus);
                }
            });
            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() {
                }
            });
        }
        SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        ViewPager viewPager = findViewById(2131363751);
        SharedPreferences preferences1 = getSharedPreferences("gameinfo", 0);
        SharedPreferences.Editor editor1 = preferences1.edit();
        editor1.clear();
        editor1.apply();
        viewPager.setAdapter(sectionsPagerAdapter);
        TabLayout findViewById = findViewById(2131363437);
        this.tabs = findViewById;
        findViewById.setupWithViewPager(viewPager);
        this.tabs.setSelectedTabIndicatorHeight(0);
        setupTabIcons();
        try {
            Intent intent = getIntent();
            String N = intent.getStringExtra("N");
            this.n = Integer.parseInt(N);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        viewPager.setCurrentItem(this.n);
        viewPager.setOffscreenPageLimit(3);
        if (((TabLayout.Tab) Objects.requireNonNull(this.tabs.getTabAt(0))).isSelected()) {
            TextView tv = (TextView) ((View) Objects.requireNonNull(((TabLayout.Tab) Objects.requireNonNull(this.tabs.getTabAt(0))).getCustomView())).findViewById(2131363438);
            tv.setTextColor(getResources().getColor(2131100434));
            TextView tviv = (TextView) ((View) Objects.requireNonNull(((TabLayout.Tab) Objects.requireNonNull(this.tabs.getTabAt(0))).getCustomView())).findViewById(2131363435);
            tviv.setTextColor(getResources().getColor(2131100434));
        }
    }

    static void lambda$onCreate$0(InitializationStatus initializationStatus) {
    }

    private void setupTabIcons() {
        View inflate = getLayoutInflater().inflate(2131558570, (ViewGroup) null);
        this.view1 = inflate;
        this.tabImageView1 = (ImageView) inflate.findViewById(2131363434);
        this.tabtextview1 = (TextView) this.view1.findViewById(2131363438);
        this.tabImagetext = (TextView) this.view1.findViewById(2131363435);
        this.tabtextview1.setText(this.resources.getString(2131886421));
        this.tabImageView1.setImageDrawable(getDrawable(this.tabIcons[0]));
        this.tabImageView1.setPadding(5, 5, 5, 5);
        View inflate2 = getLayoutInflater().inflate(2131558570, (ViewGroup) null);
        this.view2 = inflate2;
        this.tabImageView2 = (ImageView) inflate2.findViewById(2131363434);
        TextView textView = (TextView) this.view2.findViewById(2131363438);
        this.tabtextview2 = textView;
        textView.setText(this.resources.getString(2131886888));
        this.tabImageView2.setImageDrawable(getDrawable(this.tabIcons[1]));
        View inflate3 = getLayoutInflater().inflate(2131558570, (ViewGroup) null);
        this.view3 = inflate3;
        this.tabImageView3 = (ImageView) inflate3.findViewById(2131363434);
        TextView textView2 = (TextView) this.view3.findViewById(2131363438);
        this.tabtextview3 = textView2;
        textView2.setText(this.resources.getString(2131886145));
        this.tabImageView3.setImageDrawable(getDrawable(this.tabIcons[2]));
        ((TabLayout.Tab) Objects.requireNonNull(this.tabs.getTabAt(0))).setCustomView(this.view1);
        ((TabLayout.Tab) Objects.requireNonNull(this.tabs.getTabAt(1))).setCustomView(this.view2);
        ((TabLayout.Tab) Objects.requireNonNull(this.tabs.getTabAt(2))).setCustomView(this.view3);
        this.tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            public void onTabSelected(TabLayout.Tab tab) {
                TextView tv = (TextView) ((View) Objects.requireNonNull(tab.getCustomView())).findViewById(2131363438);
                tv.setTextColor(HomeActivity.this.getResources().getColor(2131100434));
                ImageView iv = (ImageView) tab.getCustomView().findViewById(2131363434);
                if (tab.getPosition() != 0) {
                    iv.getDrawable().setColorFilter(HomeActivity.this.getResources().getColor(2131100434), PorterDuff.Mode.SRC_IN);
                }
                if (tab.getPosition() == 0) {
                    TextView ivtv = (TextView) tab.getCustomView().findViewById(2131363435);
                    ivtv.setTextColor(HomeActivity.this.getResources().getColor(2131100434));
                }
                HomeActivity homeActivity = HomeActivity.this;
                homeActivity.sp = homeActivity.getSharedPreferences("tabinfo", 0);
                SharedPreferences.Editor editor = HomeActivity.this.sp.edit();
                editor.putString("selectedtab", String.valueOf(tab.getPosition()));
                editor.apply();
            }

            public void onTabUnselected(TabLayout.Tab tab) {
                TextView tv = (TextView) ((View) Objects.requireNonNull(tab.getCustomView())).findViewById(2131363438);
                tv.setTextColor(-7829368);
                ImageView iv = (ImageView) tab.getCustomView().findViewById(2131363434);
                if (tab.getPosition() != 0) {
                    iv.getDrawable().setColorFilter(Color.parseColor("#dddddd"), PorterDuff.Mode.SRC_IN);
                }
                if (tab.getPosition() == 0) {
                    TextView ivtv = (TextView) tab.getCustomView().findViewById(2131363435);
                    ivtv.setTextColor(-7829368);
                }
            }

            public void onTabReselected(TabLayout.Tab tab) {
                TextView tv = (TextView) ((View) Objects.requireNonNull(tab.getCustomView())).findViewById(2131363438);
                tv.setTextColor(HomeActivity.this.getResources().getColor(2131100434));
                ImageView iv = (ImageView) tab.getCustomView().findViewById(2131363434);
                if (tab.getPosition() != 0) {
                    iv.getDrawable().setColorFilter(HomeActivity.this.getResources().getColor(2131100434), PorterDuff.Mode.SRC_IN);
                }
                if (tab.getPosition() == 0) {
                    TextView ivtv = (TextView) tab.getCustomView().findViewById(2131363435);
                    ivtv.setTextColor(HomeActivity.this.getResources().getColor(2131100434));
                }
            }
        });
    }

    public void onBackPressed() {
        if (this.doubleBackToExitPressedOnce.booleanValue()) {
            finishAffinity();
            super.onBackPressed();
        } else {
            this.doubleBackToExitPressedOnce = true;
            Toast.makeText((Context) this, (CharSequence) this.resources.getString(2131886919), 0).show();
            new Handler().postDelayed(new Runnable() {
                @Override
                public final void run() {
                    HomeActivity.this.m46xf92a2340();
                }
            }, 1500L);
        }
    }

    void m46xf92a2340() {
        this.doubleBackToExitPressedOnce = false;
    }
}