导航菜单

页面标题

页面副标题

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

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

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


package com.clash.legends.ui.activities;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
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.models.CurrentUser;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
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 java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class ReferandEarnActivity extends AppCompatActivity {
    Context context;
    LoadingDialog loadingDialog;
    RequestQueue mQueue;
    TextView promo;
    TextView referDetail;
    Button referNow;
    TextView referandearntitle;
    Resources resources;
    String shareBody = "";
    SharedPreferences sp;
    CurrentUser user;
    UserLocalStore userLocalStore;
    TextView yourreferalcodetitle;

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(2131623940, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case 2131362572:
                Intent intent = new Intent(getApplicationContext(), (Class<?>) LeaderboardActivity.class);
                intent.putExtra("FROM", "REFERNEARN");
                startActivity(intent);
                return true;
            case 2131362777:
                Intent intent2 = new Intent(getApplicationContext(), (Class<?>) MyReferralsActivity.class);
                intent2.putExtra("FROM", "REFERNEARN");
                startActivity(intent2);
                return true;
            case 2131363452:
                Intent intent3 = new Intent(getApplicationContext(), (Class<?>) TermsandConditionActivity.class);
                intent3.putExtra("FROM", "REFERNEARN");
                startActivity(intent3);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558474);
        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")) {
            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() {
                }
            });
        }
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        SharedPreferences sp2 = getSharedPreferences("fragmentinfo", 0);
        SharedPreferences.Editor editor = sp2.edit();
        editor.putString("fraginfo", "0");
        editor.apply();
        UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        this.userLocalStore = userLocalStore;
        this.user = userLocalStore.getLoggedInUser();
        this.yourreferalcodetitle = (TextView) findViewById(2131363832);
        this.referandearntitle = (TextView) findViewById(2131363132);
        this.yourreferalcodetitle.setText(this.resources.getString(2131887108));
        this.referandearntitle.setText(this.resources.getString(2131886947));
        this.referDetail = (TextView) findViewById(2131363133);
        Button button = (Button) findViewById(2131363134);
        this.referNow = button;
        button.setText(this.resources.getString(2131886948));
        TextView textView = (TextView) findViewById(2131363077);
        this.promo = textView;
        textView.setText(this.user.getUsername());
        this.promo.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ReferandEarnActivity.this.m154xc2f2af38(view);
            }
        });
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String url = this.resources.getString(2131886167) + "dashboard/" + this.user.getMemberid();
        JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                ReferandEarnActivity.this.m155xdd0e2dd7((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 = ReferandEarnActivity.this.userLocalStore.getLoggedInUser();
                String token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(ReferandEarnActivity.this.context));
                return headers;
            }
        };
        request.setShouldCache(false);
        this.mQueue.add(request);
        this.referNow.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ReferandEarnActivity.this.m156x11452b15(view);
            }
        });
    }

    void m154xc2f2af38(View v) {
        ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService("clipboard");
        ClipData clip = ClipData.newPlainText(this.resources.getString(2131886925), this.user.getUsername());
        clipboard.setPrimaryClip(clip);
        Toast.makeText(getApplicationContext(), this.resources.getString(2131886926), 0).show();
    }

    void m155xdd0e2dd7(JSONObject response) {
        try {
            JSONObject obj = new JSONObject(response.getString("web_config"));
            this.referDetail.setText(obj.getString("referandearn_description"));
            this.shareBody = obj.getString("share_description");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        this.loadingDialog.dismiss();
    }

    void m156x11452b15(View v) {
        Intent sharingIntent = new Intent("android.intent.action.SEND");
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra("android.intent.extra.TEXT", this.shareBody + this.resources.getString(2131886949) + " : " + this.user.getUsername());
        startActivity(Intent.createChooser(sharingIntent, this.resources.getString(2131886994)));
    }

    public boolean onSupportNavigateUp() {
        Intent intent = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
        intent.putExtra("N", "0");
        startActivity(intent);
        return true;
    }

    public void onBackPressed() {
        super.onBackPressed();
        Intent intent = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
        intent.putExtra("N", "0");
        startActivity(intent);
    }
}