正在查看: Clash Legends v0.0.1 应用的 WatchAndEarnActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 WatchAndEarnActivity.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.net.ParseException;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.util.Base64;
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 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.ui.activities.WatchAndEarnActivity;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.google.android.gms.ads.AdError;
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.rewarded.RewardItem;
import com.google.android.gms.ads.rewarded.RewardedAd;
import com.google.android.gms.ads.rewarded.RewardedAdCallback;
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public class WatchAndEarnActivity extends AppCompatActivity {
RewardedAdCallback adCallback;
RewardedAdLoadCallback adLoadCallback;
TextView completetasktitle;
Context context;
LoadingDialog loadingDialog;
RequestQueue mQueue;
Resources resources;
private RewardedAd rewardedAd;
CurrentUser user;
UserLocalStore userLocalStore;
TextView watchandearntitle;
TextView watchcount;
TextView watchdesc;
TextView watchnote;
Button watchnow;
int total = 0;
int current = 0;
Boolean rewarded = false;
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(2131623941, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 2131362575:
Intent intent = new Intent(getApplicationContext(), (Class<?>) LeaderboardActivity.class);
intent.putExtra("FROM", "WATCHNEARN");
startActivity(intent);
return true;
case 2131362784:
Intent intent2 = new Intent(getApplicationContext(), (Class<?>) MyRewardedActivity.class);
intent2.putExtra("FROM", "WATCHNEARN");
startActivity(intent2);
return true;
case 2131363453:
Intent intent3 = new Intent(getApplicationContext(), (Class<?>) TermsandConditionActivity.class);
intent3.putExtra("FROM", "WATCHNEARN");
startActivity(intent3);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558491);
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() {
}
});
}
Context locale = LocaleHelper.setLocale(this);
this.context = locale;
this.resources = locale.getResources();
this.watchandearntitle = (TextView) findViewById(2131363778);
this.completetasktitle = (TextView) findViewById(2131362173);
this.watchandearntitle.setText(this.resources.getString(2131887074));
this.completetasktitle.setText(this.resources.getString(2131886390));
LoadingDialog loadingDialog = new LoadingDialog(this);
this.loadingDialog = loadingDialog;
loadingDialog.show();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
UserLocalStore userLocalStore = new UserLocalStore(this);
this.userLocalStore = userLocalStore;
this.user = userLocalStore.getLoggedInUser();
this.watchdesc = (TextView) findViewById(2131363780);
this.watchnote = (TextView) findViewById(2131363782);
this.watchcount = (TextView) findViewById(2131363779);
Button button = (Button) findViewById(2131363783);
this.watchnow = button;
button.setText(this.resources.getString(2131886917));
this.watchnow.setEnabled(false);
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
String surl = this.resources.getString(2131886167) + "watch_earn/" + this.user.getMemberid();
final UserLocalStore userLocalStore2 = new UserLocalStore(getApplicationContext());
JsonObjectRequest srequest = new JsonObjectRequest(0, surl, null, new Response.Listener() {
public final void onResponse(Object obj) {
WatchAndEarnActivity.this.m222x25f906e9((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 = userLocalStore2.getLoggedInUser();
String credentials = user.getUsername() + ":" + user.getPassword();
String str = "Basic " + Base64.encodeToString(credentials.getBytes(), 2);
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
headers.put("x-localization", LocaleHelper.getPersist(WatchAndEarnActivity.this.context));
return headers;
}
};
srequest.setShouldCache(false);
this.mQueue.add(srequest);
this.adLoadCallback = new RewardedAdLoadCallback() {
public void onRewardedAdLoaded() {
WatchAndEarnActivity.this.watchnow.setText(WatchAndEarnActivity.this.resources.getString(2131887075));
WatchAndEarnActivity.this.watchnow.setEnabled(true);
}
public void onRewardedAdFailedToLoad(LoadAdError adError) {
Log.d("add error", adError.toString());
WatchAndEarnActivity watchAndEarnActivity = WatchAndEarnActivity.this;
watchAndEarnActivity.watchnow = (Button) watchAndEarnActivity.findViewById(2131363783);
WatchAndEarnActivity.this.watchnow.setText(WatchAndEarnActivity.this.resources.getString(2131887050));
WatchAndEarnActivity.this.watchnow.setEnabled(false);
}
};
this.adCallback = new AnonymousClass4();
this.watchnow.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WatchAndEarnActivity.this.m223x5a300427(view);
}
});
}
void m222x25f906e9(JSONObject response) {
this.loadingDialog.dismiss();
try {
Log.d("watch 1", response.toString());
JSONObject obj = response.getJSONObject("watch_earn");
this.current = Integer.parseInt(obj.getString("total_watch_ads"));
this.total = Integer.parseInt(obj.getString("watch_ads_per_day"));
this.watchdesc.setText(obj.getString("watch_earn_description"));
this.watchnote.setText(obj.getString("watch_earn_note"));
this.watchcount.setText(String.valueOf(this.current) + "/" + String.valueOf(this.total));
if (this.current < this.total) {
RewardedAd rewardedAd = new RewardedAd(this, this.resources.getString(2131886158));
this.rewardedAd = rewardedAd;
rewardedAd.loadAd(new AdRequest.Builder().build(), this.adLoadCallback);
} else {
this.watchnow.setEnabled(false);
this.watchnow.setText(this.resources.getString(2131887022));
countdown();
}
} catch (JSONException e) {
e.printStackTrace();
}
this.loadingDialog.dismiss();
}
class AnonymousClass4 extends RewardedAdCallback {
AnonymousClass4() {
}
public void onRewardedAdOpened() {
}
public void onRewardedAdClosed() {
if (WatchAndEarnActivity.this.rewarded.booleanValue()) {
WatchAndEarnActivity.this.rewarded = false;
WatchAndEarnActivity.this.current++;
WatchAndEarnActivity.this.watchcount.setText(String.valueOf(WatchAndEarnActivity.this.current) + "/" + String.valueOf(WatchAndEarnActivity.this.total));
if (WatchAndEarnActivity.this.current < WatchAndEarnActivity.this.total) {
WatchAndEarnActivity.this.watchnow.setEnabled(false);
WatchAndEarnActivity.this.watchnow.setText(WatchAndEarnActivity.this.resources.getString(2131886917));
WatchAndEarnActivity watchAndEarnActivity = WatchAndEarnActivity.this;
?? r4 = WatchAndEarnActivity.this;
watchAndEarnActivity.rewardedAd = new RewardedAd((Context) r4, r4.resources.getString(2131886158));
WatchAndEarnActivity.this.rewardedAd.loadAd(new AdRequest.Builder().build(), WatchAndEarnActivity.this.adLoadCallback);
} else {
WatchAndEarnActivity.this.watchnow.setEnabled(false);
WatchAndEarnActivity.this.watchnow.setText(WatchAndEarnActivity.this.resources.getString(2131887022));
WatchAndEarnActivity.this.countdown();
}
WatchAndEarnActivity.this.loadingDialog.show();
WatchAndEarnActivity watchAndEarnActivity2 = WatchAndEarnActivity.this;
watchAndEarnActivity2.mQueue = Volley.newRequestQueue(watchAndEarnActivity2.getApplicationContext());
WatchAndEarnActivity.this.mQueue.getCache().clear();
String surl = WatchAndEarnActivity.this.resources.getString(2131886167) + "watch_earn2/" + WatchAndEarnActivity.this.user.getMemberid();
final UserLocalStore userLocalStore = new UserLocalStore(WatchAndEarnActivity.this.getApplicationContext());
JsonObjectRequest srequest = new JsonObjectRequest(0, surl, null, new Response.Listener() {
public final void onResponse(Object obj) {
WatchAndEarnActivity.AnonymousClass4.this.m224x96a516b8((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(WatchAndEarnActivity.this.context));
return headers;
}
};
srequest.setShouldCache(false);
WatchAndEarnActivity.this.mQueue.add(srequest);
return;
}
if (WatchAndEarnActivity.this.current < WatchAndEarnActivity.this.total) {
WatchAndEarnActivity.this.watchnow.setEnabled(false);
WatchAndEarnActivity.this.watchnow.setText(WatchAndEarnActivity.this.resources.getString(2131886917));
WatchAndEarnActivity watchAndEarnActivity3 = WatchAndEarnActivity.this;
?? r3 = WatchAndEarnActivity.this;
watchAndEarnActivity3.rewardedAd = new RewardedAd((Context) r3, r3.resources.getString(2131886158));
WatchAndEarnActivity.this.rewardedAd.loadAd(new AdRequest.Builder().build(), WatchAndEarnActivity.this.adLoadCallback);
}
}
void m224x96a516b8(JSONObject response) {
WatchAndEarnActivity.this.loadingDialog.dismiss();
}
public void onUserEarnedReward(RewardItem reward) {
Log.d("ads", "rewarded");
WatchAndEarnActivity.this.rewarded = true;
}
public void onRewardedAdFailedToShow(AdError adError) {
Log.d("ads", "failed to load");
}
}
void m223x5a300427(View view) {
this.rewardedAd.show(this, this.adCallback);
}
public void countdown() {
Date today = new Date();
SimpleDateFormat format = new SimpleDateFormat("dd/mm/yyyy hh:mm:ss a");
String dateToStr = format.format(today);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/mm/yyyy hh:mm:ss a");
try {
Calendar c = Calendar.getInstance();
c.add(5, 1);
int year = c.get(1);
int month = c.get(2);
int day = c.get(5);
Date date2 = simpleDateFormat.parse(day + "/" + month + "/" + year + " 12:00:00 am");
Date date1 = simpleDateFormat.parse(dateToStr);
long diff = DateDifference(date1, date2);
new CountDownTimer(diff - 1000, 1000L) {
@Override
public void onTick(long millisUntilFinished) {
long minutesInMilli = 1000 * 60;
long hoursInMilli = 60 * minutesInMilli;
long daysInMilli = 24 * hoursInMilli;
long elapsedDays = millisUntilFinished / daysInMilli;
long millisUntilFinished2 = millisUntilFinished % daysInMilli;
long elapsedHours = millisUntilFinished2 / hoursInMilli;
long millisUntilFinished3 = millisUntilFinished2 % hoursInMilli;
long elapsedMinutes = millisUntilFinished3 / minutesInMilli;
long elapsedSeconds = (millisUntilFinished3 % minutesInMilli) / 1000;
if (elapsedDays == 0 && elapsedHours == 0 && elapsedMinutes == 0 && elapsedSeconds == 0) {
WatchAndEarnActivity.this.finish();
WatchAndEarnActivity.this.overridePendingTransition(0, 0);
WatchAndEarnActivity watchAndEarnActivity = WatchAndEarnActivity.this;
watchAndEarnActivity.startActivity(watchAndEarnActivity.getIntent());
WatchAndEarnActivity.this.overridePendingTransition(0, 0);
}
WatchAndEarnActivity.this.watchcount.setText(String.valueOf(elapsedHours) + ":" + String.valueOf(elapsedMinutes) + ":" + String.valueOf(elapsedSeconds));
}
@Override
public void onFinish() {
}
}.start();
} catch (ParseException | java.text.ParseException e) {
e.printStackTrace();
}
}
public long DateDifference(Date startDate, Date endDate) {
long different = endDate.getTime() - startDate.getTime();
long minutesInMilli = 1000 * 60;
long hoursInMilli = 60 * minutesInMilli;
long j = 24 * hoursInMilli;
return different;
}
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);
}
}