APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:CoC Maps
版本号:1.0
包名称:com.moonstudio.mapcoc

MD5 校验值:a69a8bb2781bb077ad0ba51d66c4fc0c

反编译源代码说明

FunnyLayoutActivity.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.moonstudio.mapcoc;

import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import androidx.multidex.MultiDex;
import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.FullScreenContentCallback;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.util.ArrayList;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class FunnyLayoutActivity extends MasterActivity {
    APIService mAPIService;
    private FunnyLayoutAdapter mAdapter;
    private ArrayList<FunnyLayout> mData;
    InterstitialAd mInterstitialAd;
    private ListView mListView;
    private FunnyLayout mMap;
    private ProgressBar mProgress;
    private Button mRetryButton;
    private LinearLayout mRetryLayout;
    private TextView mTitleText;
    RetrofitClient retrofitClient;

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_funny_layout);
        loadAd();
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                FunnyLayoutActivity.this.finish();
            }
        });
        this.mTitleText = (TextView) toolbar.findViewById(R.id.toolbar_title);
        this.mListView = (ListView) findViewById(R.id.list);
        this.mProgress = (ProgressBar) findViewById(R.id.progress);
        this.mRetryButton = (Button) findViewById(R.id.reload);
        this.mRetryLayout = (LinearLayout) findViewById(R.id.retryLayout);
        getSupportActionBar().setTitle("");
        this.mTitleText.setText("Funny Layouts");
        if (Build.VERSION.SDK_INT >= 21) {
            Window window = getWindow();
            window.addFlags(Integer.MIN_VALUE);
            window.setStatusBarColor(ViewCompat.MEASURED_STATE_MASK);
        }
        this.mRetryButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("CLICK", "CLICK");
                FunnyLayoutActivity.this.loadData();
            }
        });
        loadData();
    }

    public void loadAd() {
        InterstitialAd.load(this, getPopupAdsId(getString(R.string.popup_ad_unit_id)), new AdRequest.Builder().build(), new InterstitialAdLoadCallback() {
            @Override
            public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                FunnyLayoutActivity.this.mInterstitialAd = interstitialAd;
                interstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                    @Override
                    public void onAdDismissedFullScreenContent() {
                        FunnyLayoutActivity.this.mInterstitialAd = null;
                        FunnyLayoutActivity.this.viewMap(FunnyLayoutActivity.this.mMap);
                        Log.d("TAG", "The ad was dismissed.");
                    }

                    @Override
                    public void onAdFailedToShowFullScreenContent(AdError adError) {
                        FunnyLayoutActivity.this.mInterstitialAd = null;
                        Log.d("TAG", "The ad failed to show.");
                    }

                    @Override
                    public void onAdShowedFullScreenContent() {
                        Log.d("TAG", "The ad was shown.");
                    }
                });
            }

            @Override
            public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                FunnyLayoutActivity.this.mInterstitialAd = null;
                String.format("domain: %s, code: %d, message: %s", loadAdError.getDomain(), Integer.valueOf(loadAdError.getCode()), loadAdError.getMessage());
            }
        });
    }

    public void loadData() {
        if (isNetworkConnected()) {
            this.mRetryLayout.setVisibility(8);
            this.mProgress.setVisibility(0);
            new GetDataTask().execute(new Void[0]);
        } else {
            this.mRetryLayout.setVisibility(0);
            this.mProgress.setVisibility(8);
        }
    }

    private void retrofitGetData() {
        this.mAPIService = ApiUtils.getAPIService();
        this.mAPIService.getFunnyLayouts().enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                try {
                    String string = response.body().string();
                    Log.d("RETROFIT", string);
                    JsonElement parse = new JsonParser().parse(string);
                    if (parse != null) {
                        JsonArray asJsonArray = parse.getAsJsonArray();
                        FunnyLayoutActivity.this.mData = FunnyLayoutActivity.this.getMapData(asJsonArray);
                    }
                    FunnyLayoutActivity.this.mProgress.setVisibility(8);
                    FunnyLayoutActivity.this.loadUI();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                th.printStackTrace();
            }
        });
    }

    public void loadUI() {
        ArrayList<FunnyLayout> arrayList = this.mData;
        if (arrayList != null) {
            this.mAdapter = new FunnyLayoutAdapter(this, arrayList);
            this.mListView.setAdapter((ListAdapter) this.mAdapter);
        }
    }

    public class GetDataTask extends AsyncTask<Void, Void, Integer> {
        private GetDataTask() {
        }

        @Override
        public Integer doInBackground(Void... voidArr) {
            try {
                JsonArray asJsonArray = new JsonParser().parse(new Json().getData("http://coc.vnhow.vn/funny_layouts/get_funny_layouts")).getAsJsonArray();
                FunnyLayoutActivity.this.mData = FunnyLayoutActivity.this.getMapData(asJsonArray);
            } catch (Exception unused) {
            }
            return 1;
        }

        @Override
        public void onPostExecute(Integer num) {
            try {
                if (FunnyLayoutActivity.this.mData != null) {
                    FunnyLayoutActivity.this.mAdapter = new FunnyLayoutAdapter(FunnyLayoutActivity.this, FunnyLayoutActivity.this.mData);
                    FunnyLayoutActivity.this.mListView.setAdapter((ListAdapter) FunnyLayoutActivity.this.mAdapter);
                }
                FunnyLayoutActivity.this.mProgress.setVisibility(8);
                super.onPostExecute((GetDataTask) num);
            } catch (Exception unused) {
            }
        }
    }

    public ArrayList<FunnyLayout> getMapData(JsonArray jsonArray) {
        ArrayList<FunnyLayout> arrayList = new ArrayList<>();
        Gson gson = new Gson();
        if (jsonArray != null) {
            for (int i = 0; i < jsonArray.size(); i++) {
                arrayList.add((FunnyLayout) gson.fromJson(jsonArray.get(i).getAsJsonObject().getAsJsonObject("FunnyLayout").toString(), FunnyLayout.class));
            }
        }
        return arrayList;
    }

    public void viewData(FunnyLayout funnyLayout, int i) {
        this.mMap = funnyLayout;
        if (i == 0 || i == 4 || i == 7 || i == 11) {
            showInterstitial();
        } else {
            viewMap(this.mMap);
        }
    }

    public void viewMap(FunnyLayout funnyLayout) {
        Intent intent = new Intent(this, (Class<?>) FunnyLayoutMapActivity.class);
        intent.putExtra("image", funnyLayout.getImage());
        intent.putExtra("download", funnyLayout.getDownload());
        intent.putExtra("view", funnyLayout.getView());
        intent.putExtra("id", funnyLayout.getId());
        intent.putExtra("like", funnyLayout.getLike());
        intent.putExtra("layout_link", funnyLayout.getLayoutLink());
        startActivity(intent);
    }

    private void showInterstitial() {
        InterstitialAd interstitialAd = this.mInterstitialAd;
        if (interstitialAd != null) {
            interstitialAd.show(this);
        } else {
            viewMap(this.mMap);
        }
    }

    public boolean isNetworkConnected() {
        return ((ConnectivityManager) getSystemService("connectivity")).getActiveNetworkInfo() != null;
    }

    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }
}