导航菜单

页面标题

页面副标题

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

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

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


package com.clash.legends.ui.fragments;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;
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.models.BanerData;
import com.clash.legends.models.CurrentUser;
import com.clash.legends.ui.activities.AboutusActivity;
import com.clash.legends.ui.activities.AnnouncementActivity;
import com.clash.legends.ui.activities.CustomerSupportActivity;
import com.clash.legends.ui.activities.HowtoActivity;
import com.clash.legends.ui.activities.LeaderboardActivity;
import com.clash.legends.ui.activities.LotteryActivity;
import com.clash.legends.ui.activities.MyProfileActivity;
import com.clash.legends.ui.activities.MyReferralsActivity;
import com.clash.legends.ui.activities.MyRewardedActivity;
import com.clash.legends.ui.activities.MyStatisticsActivity;
import com.clash.legends.ui.activities.MyWalletActivity;
import com.clash.legends.ui.activities.ProductActivity;
import com.clash.legends.ui.activities.ReferandEarnActivity;
import com.clash.legends.ui.activities.SelectedGameActivity;
import com.clash.legends.ui.activities.TermsandConditionActivity;
import com.clash.legends.ui.activities.TopPlayerActivity;
import com.clash.legends.ui.activities.WatchAndEarnActivity;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.squareup.picasso.Picasso;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class EarnFragment extends Fragment {
    TextView balInEarn;
    CardView balance;
    LinearLayout banerll;
    Context context;
    RequestQueue dQueue;
    TextView earntitle;
    LoadingDialog loadingDialog;
    RequestQueue mQueue;
    LinearLayout refll;
    TextView reftv;
    Resources resources;
    String shareBody = "";
    SharedPreferences sp;
    CurrentUser user;
    UserLocalStore userLocalStore;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(2131558589, container, false);
        Context locale = LocaleHelper.setLocale(getContext());
        this.context = locale;
        this.resources = locale.getResources();
        this.loadingDialog = new LoadingDialog(getActivity());
        SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("tabinfo", 0);
        this.sp = sharedPreferences;
        String selectedtab = sharedPreferences.getString("selectedtab", "");
        if (TextUtils.equals(selectedtab, "0")) {
            this.loadingDialog.show();
        }
        this.earntitle = (TextView) view.findViewById(2131362268);
        this.banerll = (LinearLayout) view.findViewById(2131362015);
        ImageView share = (ImageView) view.findViewById(2131363325);
        this.balInEarn = (TextView) view.findViewById(2131362010);
        this.reftv = (TextView) view.findViewById(2131363139);
        this.refll = (LinearLayout) view.findViewById(2131363136);
        this.earntitle.setText(this.resources.getString(2131886421));
        UserLocalStore userLocalStore = new UserLocalStore(requireContext());
        this.userLocalStore = userLocalStore;
        this.user = userLocalStore.getLoggedInUser();
        RequestQueue newRequestQueue = Volley.newRequestQueue(requireContext());
        this.dQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String durl = this.resources.getString(2131886167) + "dashboard/" + this.user.getMemberid();
        JsonObjectRequest drequest = new JsonObjectRequest(durl, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                EarnFragment.this.m1xd5d0ad5d((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<>();
                CurrentUser user = EarnFragment.this.userLocalStore.getLoggedInUser();
                String token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(EarnFragment.this.context));
                return headers;
            }
        };
        drequest.setShouldCache(false);
        this.dQueue.add(drequest);
        share.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                EarnFragment.this.m2xb12325f(view2);
            }
        });
        CardView findViewById = view.findViewById(2131362006);
        this.balance = findViewById;
        findViewById.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                EarnFragment.this.m3xa5b2f4e0(view2);
            }
        });
        viewBaner();
        return view;
    }

    void m1xd5d0ad5d(JSONObject response) {
        String win;
        String joinm;
        String totalMoney;
        try {
            JSONObject obj = new JSONObject(response.getString("web_config"));
            TextUtils.equals(obj.getString("active_referral"), "1");
            this.shareBody = obj.getString("share_description");
            JSONObject memobj = new JSONObject(response.getString("member"));
            String winMoney = memobj.getString("wallet_balance");
            String joinMoney = memobj.getString("join_money");
            if (TextUtils.equals(winMoney, "null")) {
                winMoney = "0";
            }
            if (TextUtils.equals(joinMoney, "null")) {
                joinMoney = "0";
            }
            if (isDouble(winMoney)) {
                win = String.format("%.2f", Double.valueOf(Double.parseDouble(winMoney)));
            } else {
                win = String.valueOf(Integer.parseInt(winMoney));
            }
            if (isDouble(joinMoney)) {
                joinm = String.format("%.2f", Double.valueOf(Double.parseDouble(joinMoney)));
            } else {
                joinm = String.valueOf(Integer.parseInt(joinMoney));
            }
            if (win.startsWith("0")) {
                if (isDouble(joinm)) {
                    totalMoney = String.valueOf(Double.parseDouble(joinm));
                } else {
                    totalMoney = String.valueOf(Integer.parseInt(joinm));
                }
            } else if (joinm.startsWith("-")) {
                if (isDouble(win)) {
                    totalMoney = String.valueOf(Double.parseDouble(win));
                } else {
                    totalMoney = String.valueOf(Integer.parseInt(win));
                }
            } else if (isDouble(win) && isDouble(joinm)) {
                totalMoney = String.valueOf(Double.parseDouble(win) + Double.parseDouble(joinm));
            } else {
                totalMoney = String.valueOf(Integer.parseInt(win) + Integer.parseInt(joinm));
            }
            if (isDouble(totalMoney)) {
                totalMoney = String.format("%.2f", Double.valueOf(Double.parseDouble(totalMoney)));
            }
            this.balInEarn.setText(totalMoney);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        this.loadingDialog.dismiss();
    }

    void m2xb12325f(View view12) {
        Intent sharingIntent = new Intent("android.intent.action.SEND");
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra("android.intent.extra.TEXT", this.shareBody + " Referral Code : " + this.user.getUsername());
        startActivity(Intent.createChooser(sharingIntent, "Share using"));
    }

    void m3xa5b2f4e0(View view1) {
        Intent intent = new Intent(getContext(), (Class<?>) MyWalletActivity.class);
        intent.putExtra("FROM", "EARN");
        startActivity(intent);
    }

    public void viewBaner() {
        RequestQueue newRequestQueue = Volley.newRequestQueue(getContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String url = this.resources.getString(2131886167) + "banner";
        final UserLocalStore userLocalStore = new UserLocalStore(getContext());
        JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                EarnFragment.this.m4lambda$viewBaner$4$comclashlegendsuifragmentsEarnFragment((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<>();
                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(EarnFragment.this.context));
                return headers;
            }
        };
        request.setShouldCache(false);
        this.mQueue.add(request);
    }

    void m4lambda$viewBaner$4$comclashlegendsuifragmentsEarnFragment(JSONObject response) {
        try {
            JSONArray arr = response.getJSONArray("banner");
            JSON_PARSE_DATA_AFTER_WEBCALL(arr);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        this.loadingDialog.dismiss();
    }

    boolean isDouble(String str) {
        try {
            Double.parseDouble(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
        for (int i = 0; i < array.length(); i++) {
            try {
                JSONObject json = array.getJSONObject(i);
                final BanerData data = new BanerData(json.getString("banner_id"), json.getString("banner_title"), json.getString("banner_image"), json.getString("banner_link_type"), json.getString("banner_link"), json.getString("link_id"), json.getString("game_name"));
                View view = getLayoutInflater().inflate(2131558501, (ViewGroup) null);
                CardView banercard = view.findViewById(2131362013);
                ImageView baneriv = (ImageView) view.findViewById(2131362014);
                if (TextUtils.equals(data.getLink(), "Refer and Earn")) {
                    Picasso.get().load(Uri.parse(data.getImage())).placeholder(2131231388).fit().into(baneriv);
                } else if (TextUtils.equals(data.getLink(), "Luckey Draw")) {
                    Picasso.get().load(Uri.parse(data.getImage())).placeholder(2131231128).fit().into(baneriv);
                } else if (TextUtils.equals(data.getLink(), "Watch and Earn")) {
                    Picasso.get().load(Uri.parse(data.getImage())).placeholder(2131231438).fit().into(baneriv);
                } else if (TextUtils.equals(data.getLink(), "Buy Product")) {
                    Picasso.get().load(Uri.parse(data.getImage())).placeholder(2131230889).fit().into(baneriv);
                } else {
                    Picasso.get().load(Uri.parse(data.getImage())).placeholder(2131231003).fit().into(baneriv);
                }
                banercard.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view2) {
                        EarnFragment.this.m0x565fd526(data, view2);
                    }
                });
                this.banerll.addView(view);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    void m0x565fd526(BanerData data, View v) {
        if (TextUtils.equals(data.getLinkType(), "app")) {
            if (TextUtils.equals(data.getLink(), "Refer and Earn")) {
                Intent intent = new Intent((Context) getActivity(), (Class<?>) ReferandEarnActivity.class);
                startActivity(intent);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Luckey Draw")) {
                Intent intent2 = new Intent((Context) getActivity(), (Class<?>) LotteryActivity.class);
                startActivity(intent2);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Watch and Earn")) {
                Intent intent3 = new Intent((Context) getActivity(), (Class<?>) WatchAndEarnActivity.class);
                startActivity(intent3);
                return;
            }
            if (TextUtils.equals(data.getLink(), "My Profile")) {
                Intent intent4 = new Intent((Context) getActivity(), (Class<?>) MyProfileActivity.class);
                startActivity(intent4);
                return;
            }
            if (TextUtils.equals(data.getLink(), "My Wallet")) {
                Intent intent5 = new Intent((Context) getActivity(), (Class<?>) MyWalletActivity.class);
                startActivity(intent5);
                return;
            }
            if (TextUtils.equals(data.getLink(), "My Matches")) {
                Intent intent6 = new Intent((Context) getActivity(), (Class<?>) SelectedGameActivity.class);
                SharedPreferences sp = getActivity().getSharedPreferences("gameinfo", 0);
                SharedPreferences.Editor editor = sp.edit();
                editor.putString("gametitle", "My Matches");
                editor.putString("gameid", "not");
                editor.apply();
                startActivity(intent6);
                return;
            }
            if (TextUtils.equals(data.getLink(), "My Statics")) {
                Intent intent7 = new Intent((Context) getActivity(), (Class<?>) MyStatisticsActivity.class);
                startActivity(intent7);
                return;
            }
            if (TextUtils.equals(data.getLink(), "My Referral")) {
                Intent intent8 = new Intent((Context) getActivity(), (Class<?>) MyReferralsActivity.class);
                startActivity(intent8);
                return;
            }
            if (TextUtils.equals(data.getLink(), "My Rewards")) {
                Intent intent9 = new Intent((Context) getActivity(), (Class<?>) MyRewardedActivity.class);
                startActivity(intent9);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Announcement")) {
                Intent intent10 = new Intent((Context) getActivity(), (Class<?>) AnnouncementActivity.class);
                startActivity(intent10);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Top Players")) {
                Intent intent11 = new Intent((Context) getActivity(), (Class<?>) TopPlayerActivity.class);
                startActivity(intent11);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Leaderboard")) {
                Intent intent12 = new Intent((Context) getActivity(), (Class<?>) LeaderboardActivity.class);
                startActivity(intent12);
                return;
            }
            if (TextUtils.equals(data.getLink(), "App Tutorials")) {
                Intent intent13 = new Intent((Context) getActivity(), (Class<?>) HowtoActivity.class);
                startActivity(intent13);
                return;
            }
            if (TextUtils.equals(data.getLink(), "About us")) {
                Intent intent14 = new Intent((Context) getActivity(), (Class<?>) AboutusActivity.class);
                startActivity(intent14);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Customer Support")) {
                Intent intent15 = new Intent((Context) getActivity(), (Class<?>) CustomerSupportActivity.class);
                startActivity(intent15);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Terms and Condition")) {
                Intent intent16 = new Intent((Context) getActivity(), (Class<?>) TermsandConditionActivity.class);
                startActivity(intent16);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Game")) {
                Intent intent17 = new Intent((Context) getActivity(), (Class<?>) SelectedGameActivity.class);
                SharedPreferences sp2 = requireActivity().getSharedPreferences("gameinfo", 0);
                SharedPreferences.Editor editor2 = sp2.edit();
                editor2.putString("gametitle", data.getLinkname());
                editor2.putString("gameid", data.getLinkId());
                editor2.apply();
                startActivity(intent17);
                return;
            }
            if (TextUtils.equals(data.getLink(), "Buy Product")) {
                Intent intent18 = new Intent((Context) getActivity(), (Class<?>) ProductActivity.class);
                startActivity(intent18);
                return;
            }
            return;
        }
        Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(data.getLink()));
        startActivity(browserIntent);
    }
}