正在查看: Clash Legends v0.0.1 应用的 SelectedMyContestActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 SelectedMyContestActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
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.UserLocalStore;
import com.squareup.picasso.Picasso;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class SelectedMyContestActivity extends AppCompatActivity {
private static final int MANAGE_STORAGE_PERMISSION_CODE = 2;
private static final int PICK_IMAGE = 3;
private static final int STORAGE_PERMISSION_CODE = 1;
private static final String TAG = "MyContestActivity";
ImageView acceptIv;
TextView acceptNameTv;
String acceptStatus;
String acceptedLudoKingUsername;
String acceptedMemberId;
String acceptedMemberName;
String acceptedPlayerId;
String acceptedProfileImage;
String acceptedResult;
String addedResult;
String api;
String autoId;
TextView autoTv;
ImageView back;
String base64;
LinearLayout btnll;
TextView cancelBtn;
String cancelledBy;
TextView challengCoinTv;
String challengeStatus;
TextView chatBtn;
String coin;
ImageView creatoeIv;
TextView creatorNameTv;
String dateCreated;
TextView error;
String firstName;
String gameid;
TextView hidedata;
RequestQueue jQueue;
String lastName;
LoadingDialog loadingDialog;
TextView lost;
String ludoChallengeId;
String ludoKingUsername;
TextView ludocontestrules;
TextView ludocontesttitle;
String memberId;
String playerId;
String profileImage;
ImageView reasonIv;
ImageView reasonIvtest;
ImageView refresh;
LinearLayout resultll;
String roomCode;
TextView roomCodeBtn;
TextView roomCodeTv;
CurrentUser user;
UserLocalStore userLocalStore;
TextView waitll;
String winnerId;
TextView winningCoinTv;
String winningPrice;
TextView won;
String reasonUri = "";
String reasonName = "";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558479);
ImageView imageView = (ImageView) findViewById(2131361999);
this.back = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m172x23acfaa2(view);
}
});
ImageView imageView2 = (ImageView) findViewById(2131363138);
this.refresh = imageView2;
imageView2.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m173x3462c763(view);
}
});
this.loadingDialog = new LoadingDialog(this);
UserLocalStore userLocalStore = new UserLocalStore(this);
this.userLocalStore = userLocalStore;
this.user = userLocalStore.getLoggedInUser();
this.loadingDialog.show();
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
SelectedMyContestActivity.this.m174x45189424();
}
}, 2000L);
SharedPreferences sp = getSharedPreferences("gameinfo", 0);
String gamename = sp.getString("gametitle", "");
final String packege = sp.getString("packege", "");
this.gameid = sp.getString("gameid", "");
Log.d("pac", packege);
Intent intent = getIntent();
this.ludoChallengeId = intent.getStringExtra("ludoChallengeId");
this.autoId = intent.getStringExtra("autoId");
this.memberId = intent.getStringExtra("memberId");
this.acceptedMemberId = intent.getStringExtra("acceptedMemberId");
this.ludoKingUsername = intent.getStringExtra("ludoKingUsername");
this.acceptedLudoKingUsername = intent.getStringExtra("acceptedLudoKingUsername");
this.coin = intent.getStringExtra("coin");
this.winningPrice = intent.getStringExtra("winningPrice");
this.acceptStatus = intent.getStringExtra("acceptStatus");
this.challengeStatus = intent.getStringExtra("challengeStatus");
this.cancelledBy = intent.getStringExtra("cancelledBy");
this.winnerId = intent.getStringExtra("winnerId");
this.dateCreated = intent.getStringExtra("dateCreated");
this.firstName = intent.getStringExtra("firstName");
this.lastName = intent.getStringExtra("lastName");
this.profileImage = intent.getStringExtra("profileImage");
this.acceptedMemberName = intent.getStringExtra("acceptedMemberName");
this.acceptedProfileImage = intent.getStringExtra("acceptedProfileImage");
this.addedResult = intent.getStringExtra("addedResult");
this.acceptedResult = intent.getStringExtra("acceptedResult");
this.playerId = intent.getStringExtra("playerId");
String stringExtra = intent.getStringExtra("acceptedPlayerId");
this.acceptedPlayerId = stringExtra;
Log.d(this.playerId, stringExtra);
this.ludocontesttitle = (TextView) findViewById(2131362663);
this.ludocontestrules = (TextView) findViewById(2131362662);
this.resultll = (LinearLayout) findViewById(2131363172);
this.btnll = (LinearLayout) findViewById(2131362069);
this.waitll = (TextView) findViewById(2131363775);
this.autoTv = (TextView) findViewById(2131361963);
this.creatorNameTv = (TextView) findViewById(2131362199);
this.acceptNameTv = (TextView) findViewById(2131361824);
this.creatoeIv = (ImageView) findViewById(2131362197);
this.acceptIv = (ImageView) findViewById(2131361822);
this.challengCoinTv = (TextView) findViewById(2131362118);
this.winningCoinTv = (TextView) findViewById(2131363801);
this.roomCodeTv = (TextView) findViewById(2131363716);
this.cancelBtn = (TextView) findViewById(2131362086);
this.roomCodeBtn = (TextView) findViewById(2131363715);
this.chatBtn = (TextView) findViewById(2131362119);
this.won = (TextView) findViewById(2131363820);
this.lost = (TextView) findViewById(2131362642);
this.error = (TextView) findViewById(2131362314);
this.hidedata = (TextView) findViewById(2131362417);
this.ludocontesttitle.setText(gamename + " Contest");
this.ludocontestrules.setText("⦁ If you win the match then take a screen shot of the win and upload it in the won section\n⦁If you lose the match then just update your result by clicking on the lose option.\n⦁ If your match is canceled due to any reason then click on cancel option then select the reason and update your status.\n⦁ It is necessary to upload the result after the match is over\n⦁ If a user does not upload the result within 1 hour after the end of the match, then he will have to pay a fine and the winning will credit to the winner wallet within 4 hours after uploading the result.\n⦁ If any user cheats, then record the game for your safety and contact customer suppor,t after investigation your coin will be refunded to you if other user found guilty.\n⦁ You have to play your " + gamename + " game only in " + gamename + " application.\n⦁ If you have any other qurey then customer support");
this.autoTv.setText(this.autoId);
this.creatorNameTv.setText(this.firstName + " " + this.lastName);
SharedPreferences noti = getApplicationContext().getSharedPreferences("PLAYER_ID", 0);
String fireabasetoken = noti.getString("player_id", "");
Log.d("HMMMM", fireabasetoken);
if (TextUtils.equals(this.acceptStatus, "0")) {
this.acceptNameTv.setText("Waiting");
} else {
this.acceptNameTv.setText(this.acceptedMemberName);
}
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.jQueue = newRequestQueue;
newRequestQueue.getCache().clear();
roomcodeapi();
if (!TextUtils.equals(this.profileImage, "null") && !TextUtils.equals(this.profileImage, "")) {
Picasso.get().load(this.profileImage).placeholder(2131230869).fit().into(this.creatoeIv);
}
if (!TextUtils.equals(this.acceptedProfileImage, "null") && !TextUtils.equals(this.acceptedProfileImage, "")) {
Picasso.get().load(this.acceptedProfileImage).placeholder(2131230869).fit().into(this.acceptIv);
}
this.challengCoinTv.setText("Challenged Coins- " + this.coin);
this.winningCoinTv.setText("Winning Coins- " + this.winningPrice);
if (TextUtils.equals(this.roomCode, "") || TextUtils.equals(this.roomCode, "null")) {
this.cancelBtn.setText("CANCEL");
} else {
this.cancelBtn.setText("CLICK TO GO ON APP");
}
if (TextUtils.equals(this.addedResult, "0") && TextUtils.equals(this.acceptedResult, "0")) {
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.waitll.setText("Review by team");
this.btnll.setVisibility(8);
}
this.roomCodeTv.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m175x55ce60e5(view);
}
});
this.cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m176x66842da6(packege, view);
}
});
this.roomCodeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m177x7739fa67(view);
}
});
this.chatBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m178x87efc728(view);
}
});
this.won.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m179x98a593e9(view);
}
});
this.lost.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m180xa95b60aa(view);
}
});
this.error.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m181xba112d6b(view);
}
});
}
void m172x23acfaa2(View v) {
onBackPressed();
}
void m173x3462c763(View v) {
finish();
startActivity(getIntent());
overridePendingTransition(0, 0);
}
void m174x45189424() {
this.loadingDialog.dismiss();
}
void m175x55ce60e5(View v) {
if (!TextUtils.equals(this.roomCode, "") && !TextUtils.equals(this.roomCode, "null")) {
viewroomcodeDialog();
}
}
void m176x66842da6(String packege, View v) {
String flag;
if (!TextUtils.equals(this.cancelBtn.getText().toString(), "CANCEL")) {
if (TextUtils.equals(this.cancelBtn.getText().toString(), "CLICK TO GO ON APP")) {
openApplication(this, packege);
}
} else {
if (TextUtils.equals(this.memberId, this.user.getMemberid())) {
flag = "0";
} else {
flag = "1";
}
openWarningDialog(this.ludoChallengeId, flag);
}
}
void m177x7739fa67(View v) {
if (TextUtils.equals(this.acceptStatus, "0")) {
Toast.makeText(getApplicationContext(), "Please wait for opponent", 0).show();
} else {
openRoomCodeDialog(this.ludoChallengeId);
}
}
void m178x87efc728(View v) {
String receiverImg;
String senderImg;
String receiverName;
String senderName;
String receiverPlayerId;
Log.d("acceptedMemberName", this.acceptedMemberName);
if (TextUtils.equals(this.acceptStatus, "0")) {
Toast.makeText(getApplicationContext(), "Please wait for opponent", 0).show();
return;
}
CurrentUser user = this.userLocalStore.getLoggedInUser();
Log.d(user.memberId, this.acceptedMemberId);
if (TextUtils.equals(user.getMemberid(), this.memberId)) {
senderImg = this.profileImage;
receiverImg = this.acceptedProfileImage;
receiverName = this.acceptedMemberName;
if (user.memberId.equals(this.acceptedMemberId)) {
Log.d("PLAYERID ", this.playerId);
receiverPlayerId = this.playerId;
} else {
Log.d("ACCEPTED PLAYERID ", this.acceptedPlayerId);
receiverPlayerId = this.acceptedPlayerId;
}
senderName = this.firstName + " " + this.lastName;
} else {
receiverImg = this.profileImage;
senderImg = this.acceptedProfileImage;
receiverName = this.firstName + " " + this.lastName;
senderName = this.acceptedMemberName;
if (user.memberId.equals(this.acceptedMemberId)) {
Log.d("PLAYERID1 ", this.playerId);
receiverPlayerId = this.playerId;
} else {
Log.d("ACCEPTED1 PLAYERID ", this.acceptedPlayerId);
receiverPlayerId = this.acceptedPlayerId;
}
}
Intent intent1 = new Intent(getApplicationContext(), (Class<?>) LudoChatActivity.class);
intent1.putExtra("AUTO_ID", this.autoId);
intent1.putExtra("SENDER_IMG", senderImg);
intent1.putExtra("RECEIVER_IMG", receiverImg);
intent1.putExtra("RECEIVER_NAME", receiverName);
intent1.putExtra("SENDER_NAME", senderName);
intent1.putExtra("RECEIVER_PLAYER_ID", receiverPlayerId);
startActivity(intent1);
}
void m179x98a593e9(View v) {
String flag;
if (TextUtils.equals(this.roomCode, "")) {
Toast.makeText(getApplicationContext(), "Challenge not started yet", 0).show();
return;
}
if (TextUtils.equals(this.memberId, this.user.getMemberid())) {
flag = "0";
} else {
flag = "1";
}
openWonDialog(this.ludoChallengeId, flag, "0");
}
void m180xa95b60aa(View v) {
String flag;
if (TextUtils.equals(this.roomCode, "")) {
Toast.makeText(getApplicationContext(), "Challenge not started yet", 0).show();
return;
}
if (TextUtils.equals(this.memberId, this.user.getMemberid())) {
flag = "0";
} else {
flag = "1";
}
openResultWarningDialog(this.ludoChallengeId, flag, "1");
}
void m181xba112d6b(View v) {
String flag;
if (TextUtils.equals(this.memberId, this.user.getMemberid())) {
flag = "0";
} else {
flag = "1";
}
openErrorWarningDialog(this.ludoChallengeId, flag, "2");
}
public void openApplication(Context context, String packageN) {
Intent i = context.getPackageManager().getLaunchIntentForPackage(packageN);
if (i == null) {
try {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=" + packageN));
intent.addFlags(268435456);
context.startActivity(intent);
return;
} catch (ActivityNotFoundException e) {
Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse("Uri.parse(\"http://play.google.com/store/apps/details?id=\"" + packageN));
intent2.addFlags(268435456);
context.startActivity(intent2);
return;
}
}
i.addCategory("android.intent.category.LAUNCHER");
context.startActivity(i);
}
public void openWarningDialog(final String challengeId, final String flag) {
getSharedPreferences("gameinfo", 0);
final Dialog builder = new Dialog(this);
builder.setContentView(2131558509);
CardView yes = builder.findViewById(2131363830);
CardView no = builder.findViewById(2131362825);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m190xb76dcb84(builder, challengeId, flag, view);
}
});
no.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
builder.dismiss();
}
});
builder.create();
builder.show();
}
void m190xb76dcb84(Dialog builder, String challengeId, String flag, View v) {
builder.dismiss();
cancelChallenge(challengeId, flag);
}
public void cancelChallenge(String challengeId, String flag) {
this.loadingDialog.show();
HashMap<String, String> params = new HashMap<>();
params.put("ludo_challenge_id", challengeId);
params.put("member_id", this.user.getMemberid());
params.put("canceled_by_flag", flag);
params.put("submit", "cancelChallenge");
RequestQueue mQueue = Volley.newRequestQueue(this);
mQueue.getCache().clear();
String url = getResources().getString(2131886167) + "cancel_challenge";
JsonObjectRequest mrequest = new JsonObjectRequest(url, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m171xba156d77((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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
mrequest.setShouldCache(false);
mQueue.add(mrequest);
}
void m171xba156d77(JSONObject response) {
this.loadingDialog.dismiss();
Log.d("cancel challenge", response.toString());
this.loadingDialog.dismiss();
try {
String status = response.getString("status");
TextUtils.equals(status, "true");
Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
} catch (JSONException e) {
this.loadingDialog.dismiss();
e.printStackTrace();
}
}
public void openRoomCodeDialog(final String challengeId) {
final Dialog builder = new Dialog(this);
builder.setCancelable(true);
builder.setContentView(2131558772);
final EditText et = (EditText) builder.findViewById(2131363252);
CardView addRoom = builder.findViewById(2131361888);
ImageView copyroomcode = (ImageView) builder.findViewById(2131362186);
TextView roomcodeupdate = (TextView) builder.findViewById(2131363254);
et.setText(this.roomCode);
if (this.roomCode.isEmpty()) {
copyroomcode.setVisibility(8);
} else {
copyroomcode.setVisibility(0);
roomcodeupdate.setText("UPDATE");
}
copyroomcode.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m186xa74a214e(view);
}
});
addRoom.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m187xb7ffee0f(et, builder, challengeId, view);
}
});
builder.create();
builder.show();
}
void m186xa74a214e(View v) {
ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService("clipboard");
ClipData clip = ClipData.newPlainText("Room Code", this.roomCode);
clipboard.setPrimaryClip(clip);
Toast.makeText(getApplicationContext(), "Room code copied successfully", 0).show();
}
void m187xb7ffee0f(EditText et, Dialog builder, String challengeId, View v) {
if (TextUtils.equals(et.getText().toString().trim(), "")) {
Toast.makeText(getApplicationContext(), "Please enter room code", 0).show();
} else if (et.getText().toString().trim().matches(this.roomCode)) {
Toast.makeText(getApplicationContext(), "Code already registered, Please enter diffrent code", 0).show();
} else {
builder.dismiss();
addRoomCode(challengeId, et.getText().toString().trim());
}
}
public void addRoomCode(String challengeId, final String rc) {
SharedPreferences sp = getSharedPreferences("gameinfo", 0);
sp.getString("gametitle", "");
this.loadingDialog.show();
HashMap<String, String> params = new HashMap<>();
params.put("ludo_challenge_id", challengeId);
params.put("room_code", rc);
params.put("submit", "updateRoom");
RequestQueue mQueue = Volley.newRequestQueue(this);
mQueue.getCache().clear();
String url = getResources().getString(2131886167) + "update_challenge_room";
JsonObjectRequest mrequest = new JsonObjectRequest(url, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m170xe32ce8db(rc, (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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
mrequest.setShouldCache(false);
mQueue.add(mrequest);
}
void m170xe32ce8db(String rc, JSONObject response) {
this.loadingDialog.dismiss();
Log.d("update room code ", response.toString());
this.loadingDialog.dismiss();
try {
String status = response.getString("status");
if (TextUtils.equals(status, "true")) {
this.roomCode = rc;
this.cancelBtn.setText("CLICK TO GO ON APP");
this.roomCodeTv.setText("Room Code\nView");
this.roomCodeBtn.setVisibility(0);
openSuccessRoomCodeUpdateDialog();
}
Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
} catch (JSONException e) {
this.loadingDialog.dismiss();
e.printStackTrace();
}
}
public void openSuccessRoomCodeUpdateDialog() {
SharedPreferences sp = getSharedPreferences("gameinfo", 0);
String gamename = sp.getString("gametitle", "");
final Dialog builder = new Dialog(this);
builder.setContentView(2131558787);
CardView ok = builder.findViewById(2131362880);
TextView room_code_updated_meassge = (TextView) builder.findViewById(2131363249);
room_code_updated_meassge.setText("1. Now go on your " + gamename + " application\n2. Use chat option to chat with your teammate\n3. If you face any problem then use error option");
ok.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
builder.dismiss();
}
});
builder.create();
builder.show();
}
public void openResultWarningDialog(final String challengeId, final String flag, final String resultStaus) {
SharedPreferences sp = getSharedPreferences("gameinfo", 0);
String gamename = sp.getString("gametitle", "");
final Dialog builder = new Dialog(this);
builder.setContentView(2131558666);
CardView yes = builder.findViewById(2131363830);
CardView no = builder.findViewById(2131362825);
TextView make_sure_to_upload_the_correct_result = (TextView) builder.findViewById(2131362680);
make_sure_to_upload_the_correct_result.setText("Make sure to upload the correct result of " + gamename);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m185x41b2510a(builder, challengeId, flag, resultStaus, view);
}
});
no.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
builder.dismiss();
}
});
builder.create();
builder.show();
}
void m185x41b2510a(Dialog builder, String challengeId, String flag, String resultStaus, View v) {
builder.dismiss();
updateLostResult(challengeId, flag, resultStaus);
}
public void updateLostResult(String challengeId, String flag, String resultStaus) {
this.loadingDialog.show();
HashMap<String, String> params = new HashMap<>();
params.put("ludo_challenge_id", challengeId);
params.put("member_id", this.user.getMemberid());
params.put("result_uploded_by_flag", flag);
params.put("result_status", resultStaus);
params.put("submit", "uploadResult");
RequestQueue mQueue = Volley.newRequestQueue(this);
mQueue.getCache().clear();
String url = getResources().getString(2131886167) + "challenge_result_upload";
JsonObjectRequest mrequest = new JsonObjectRequest(url, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m197x7a05f8da((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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
mrequest.setShouldCache(false);
mQueue.add(mrequest);
}
void m197x7a05f8da(JSONObject response) {
this.loadingDialog.dismiss();
Log.d("upload lost result", response.toString());
this.loadingDialog.dismiss();
try {
String status = response.getString("status");
if (TextUtils.equals(status, "true")) {
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
}
Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
} catch (JSONException e) {
this.loadingDialog.dismiss();
e.printStackTrace();
}
}
public void openErrorWarningDialog(final String challengeId, final String flag, final String resultStaus) {
final Dialog builder = new Dialog(this);
builder.setContentView(2131558593);
CardView yes = builder.findViewById(2131363831);
CardView no = builder.findViewById(2131362826);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m184xc8a1d0e0(builder, challengeId, flag, resultStaus, view);
}
});
no.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
builder.dismiss();
}
});
builder.create();
builder.show();
}
void m184xc8a1d0e0(Dialog builder, String challengeId, String flag, String resultStaus, View v) {
builder.dismiss();
openErrorDialog(challengeId, flag, resultStaus);
}
public void openErrorDialog(final String challengeId, final String flag, final String resultStaus) {
final Dialog builder = new Dialog(this);
builder.setContentView(2131558592);
builder.setCancelable(true);
CardView submit = builder.findViewById(2131363407);
RadioGroup rg = (RadioGroup) builder.findViewById(2131362315);
RadioButton er1 = (RadioButton) builder.findViewById(2131362310);
final RadioButton other = (RadioButton) builder.findViewById(2131362947);
final EditText dp = (EditText) builder.findViewById(2131362252);
final String[] problem = {"Teammate upload wrong result."};
er1.setChecked(true);
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public final void onCheckedChanged(RadioGroup radioGroup, int i) {
SelectedMyContestActivity.lambda$openErrorDialog$25(problem, dp, radioGroup, i);
}
});
CardView chooseReason = builder.findViewById(2131362132);
this.reasonIv = (ImageView) builder.findViewById(2131362134);
this.reasonIvtest = (ImageView) builder.findViewById(2131362135);
chooseReason.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m182x369e673d(view);
}
});
submit.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m183x475433fe(other, dp, problem, builder, challengeId, flag, resultStaus, view);
}
});
builder.create();
builder.show();
}
static void lambda$openErrorDialog$25(String[] problem, EditText dp, RadioGroup group, int checkedId) {
switch (checkedId) {
case 2131362310:
problem[0] = "Teammate upload wrong result.";
dp.setVisibility(8);
break;
case 2131362311:
problem[0] = "Game not start by the teammate.";
dp.setVisibility(8);
break;
case 2131362947:
dp.setVisibility(0);
break;
default:
dp.setVisibility(8);
break;
}
}
void m182x369e673d(View v) {
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
getFileChooserIntent();
return;
}
if (Build.VERSION.SDK_INT >= 30) {
if (Environment.isExternalStorageManager()) {
getFileChooserIntent();
return;
} else {
requestManageStoragePermission();
return;
}
}
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
getFileChooserIntent();
} else {
requestStoragePermission();
}
}
void m183x475433fe(RadioButton other, EditText dp, String[] problem, Dialog builder, String challengeId, String flag, String resultStaus, View v) {
if (other.isChecked()) {
if (TextUtils.equals(dp.getText().toString().trim(), "")) {
dp.setError("Please describe your problem");
return;
}
problem[0] = dp.getText().toString().trim();
}
builder.dismiss();
try {
updateErrorResult(challengeId, flag, resultStaus, problem[0]);
} catch (IOException e) {
e.printStackTrace();
}
}
public void updateErrorResult(String challengeId, String flag, String resultStaus, String problem) throws IOException {
this.loadingDialog.show();
if (TextUtils.equals(this.reasonName, "") && TextUtils.equals(this.reasonUri, "")) {
HashMap<String, String> params = new HashMap<>();
params.put("ludo_challenge_id", challengeId);
params.put("member_id", this.user.getMemberid());
params.put("result_uploded_by_flag", flag);
params.put("result_status", resultStaus);
params.put("reason", problem);
params.put("submit", "uploadResult");
Log.d("error upload", new JSONObject(params).toString());
RequestQueue mQueue = Volley.newRequestQueue(this);
mQueue.getCache().clear();
String url = getResources().getString(2131886167) + "challenge_result_upload";
JsonObjectRequest mrequest = new JsonObjectRequest(url, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m195x52e38649((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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
mrequest.setShouldCache(false);
mQueue.add(mrequest);
return;
}
Log.d("abc", this.base64);
HashMap<String, String> params2 = new HashMap<>();
params2.put("ludo_challenge_id", challengeId);
params2.put("member_id", this.user.getMemberid());
params2.put("result_uploded_by_flag", flag);
params2.put("result_status", resultStaus);
params2.put("reason", problem);
params2.put("submit", "uploadResult");
params2.put("result_image", this.base64);
RequestQueue mQueue2 = Volley.newRequestQueue(this);
mQueue2.getCache().clear();
String URL = getResources().getString(2131886167) + "challenge_result_upload";
Log.d("error with img", new JSONObject(params2).toString());
JsonObjectRequest mrequest2 = new JsonObjectRequest(URL, new JSONObject(params2), new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m196xd338eba0((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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
mrequest2.setShouldCache(false);
mQueue2.add(mrequest2);
}
void m195x52e38649(JSONObject response) {
this.loadingDialog.dismiss();
Log.d("upload lost result", response.toString());
this.loadingDialog.dismiss();
try {
String status = response.getString("status");
if (TextUtils.equals(status, "true")) {
openSuccessErrorDialog();
}
Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
} catch (JSONException e) {
this.loadingDialog.dismiss();
e.printStackTrace();
}
}
void m196xd338eba0(JSONObject response) {
this.loadingDialog.dismiss();
Log.d("upload lost result", response.toString());
this.loadingDialog.dismiss();
try {
Log.d("upload error result", response.toString());
this.loadingDialog.dismiss();
String status = response.getString("status");
if (TextUtils.equals(status, "true")) {
openSuccessErrorDialog();
}
Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
} catch (JSONException e) {
Log.d("exception", "-----");
e.printStackTrace();
}
}
public void openSuccessErrorDialog() {
final Dialog builder = new Dialog(this);
builder.setContentView(2131558786);
CardView ok = builder.findViewById(2131362879);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m188xdad5ba8d(builder, view);
}
});
builder.create();
builder.show();
}
void m188xdad5ba8d(Dialog builder, View v) {
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
builder.dismiss();
}
public void openWonDialog(final String challengeId, final String flag, final String resultStaus) {
final Dialog builder = new Dialog(this);
builder.setContentView(2131558815);
builder.setCancelable(true);
CardView submit = builder.findViewById(2131363409);
CardView chooseReason = builder.findViewById(2131362131);
this.reasonIv = (ImageView) builder.findViewById(2131362133);
chooseReason.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m191x6c79eccb(view);
}
});
submit.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m192x7d2fb98c(builder, challengeId, flag, resultStaus, view);
}
});
builder.create();
builder.show();
}
void m191x6c79eccb(View v) {
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
getFileChooserIntent();
return;
}
if (Build.VERSION.SDK_INT >= 30) {
if (Environment.isExternalStorageManager()) {
getFileChooserIntent();
return;
} else {
requestManageStoragePermission();
return;
}
}
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
getFileChooserIntent();
} else {
requestStoragePermission();
}
}
void m192x7d2fb98c(Dialog builder, String challengeId, String flag, String resultStaus, View v) {
if (TextUtils.equals(this.reasonUri, "") && TextUtils.equals(this.reasonName, "")) {
Toast.makeText((Context) this, (CharSequence) "Please select reason", 0).show();
return;
}
builder.dismiss();
try {
updateWonResult(challengeId, flag, resultStaus);
} catch (IOException e) {
e.printStackTrace();
}
}
private void requestManageStoragePermission() {
Log.d(TAG, "Requesting MANAGE_EXTERNAL_STORAGE permission");
Intent intent = new Intent("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION");
intent.setData(Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, MANAGE_STORAGE_PERMISSION_CODE);
}
private void requestStoragePermission() {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.WRITE_EXTERNAL_STORAGE")) {
Log.d(TAG, "Showing permission rationale");
new AlertDialog.Builder(this).setTitle("Permission needed").setMessage("This permission is needed because of access storage.").setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
SelectedMyContestActivity.this.m193xcc0a800c(dialogInterface, i);
}
}).setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
SelectedMyContestActivity.lambda$requestStoragePermission$36(dialogInterface, i);
}
}).create().show();
} else {
Log.d(TAG, "Requesting WRITE_EXTERNAL_STORAGE permission without rationale");
ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, STORAGE_PERMISSION_CODE);
}
}
void m193xcc0a800c(DialogInterface dialog, int which) {
Log.d(TAG, "Requesting WRITE_EXTERNAL_STORAGE permission");
ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, STORAGE_PERMISSION_CODE);
}
static void lambda$requestStoragePermission$36(DialogInterface dialog, int which) {
Log.d(TAG, "Permission request cancelled");
dialog.dismiss();
}
private void getFileChooserIntent() {
Log.d(TAG, "getFileChooserIntent called");
Intent intent = new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, PICK_IMAGE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == MANAGE_STORAGE_PERMISSION_CODE) {
if (Build.VERSION.SDK_INT >= 30 && Environment.isExternalStorageManager()) {
getFileChooserIntent();
} else {
Log.d(TAG, "Manage storage permission denied");
}
}
if (requestCode == PICK_IMAGE && resultCode == -1 && data != null) {
Uri mImageUri = data.getData();
if (mImageUri == null) {
Toast.makeText((Context) this, (CharSequence) "You haven't picked Image", STORAGE_PERMISSION_CODE).show();
return;
}
Log.v("LOG_TAG", "Selected Image: " + mImageUri);
File myFile = new File(mImageUri.toString());
String displayName = " ";
if (mImageUri.toString().startsWith("content://")) {
Cursor cursor = getContentResolver().query(mImageUri, null, null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
displayName = cursor.getString(cursor.getColumnIndex("_display_name"));
}
} catch (Throwable th) {
if (cursor != null) {
try {
cursor.close();
} catch (Throwable th2) {
th.addSuppressed(th2);
}
}
throw th;
}
}
if (cursor != null) {
cursor.close();
}
} else if (mImageUri.toString().startsWith("file://")) {
displayName = myFile.getName();
}
this.reasonName = displayName;
this.reasonUri = String.valueOf(mImageUri);
this.reasonIv.setVisibility(0);
try {
this.reasonIv.setImageBitmap(MediaStore.Images.Media.getBitmap(getContentResolver(), mImageUri));
} catch (Exception e) {
Log.e(TAG, "Error setting image", e);
}
BitmapDrawable drawable = (BitmapDrawable) this.reasonIv.getDrawable();
Bitmap bitmap = drawable.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, stream);
byte[] byte_arr = stream.toByteArray();
Log.d("After compress size", String.valueOf((byte_arr.length / 1024.0f) / 1024.0f));
String encodedImage = Base64.encodeToString(byte_arr, 0);
this.base64 = "data:image/jpeg;base64," + encodedImage;
return;
}
Toast.makeText((Context) this, (CharSequence) "You haven't picked Image", STORAGE_PERMISSION_CODE).show();
}
public void roomcodeapi() {
String url = getResources().getString(2131886167) + "my_challenge_list/" + this.gameid;
JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m194x63ff5a51((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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
request.setShouldCache(false);
this.jQueue.add(request);
}
void m194x63ff5a51(JSONObject response) {
Log.d("mylist----", response.toString());
this.loadingDialog.dismiss();
try {
JSONArray arr = response.getJSONArray("challenge_list");
JSON_PARSE_DATA_AFTER_WEBCALL(arr);
} catch (JSONException e) {
e.printStackTrace();
}
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
for (int i = 0; i < array.length(); i += STORAGE_PERMISSION_CODE) {
try {
JSONObject json = array.getJSONObject(i);
if (TextUtils.equals(json.getString("ludo_challenge_id"), this.ludoChallengeId)) {
this.roomCode = json.getString("room_code");
if (TextUtils.equals(this.memberId, this.user.getMemberid())) {
this.roomCodeBtn.setVisibility(0);
this.refresh.setVisibility(8);
if (!TextUtils.equals(this.roomCode, "") && !TextUtils.equals(this.roomCode, "null")) {
this.roomCodeTv.setText("Room Code\nView");
this.roomCodeBtn.setVisibility(0);
if (!TextUtils.equals(this.addedResult, "0") || TextUtils.equals(this.addedResult, "1") || TextUtils.equals(this.addedResult, "2")) {
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
}
}
this.roomCodeTv.setText("Update Room Code To Proceed");
if (!TextUtils.equals(this.addedResult, "0")) {
}
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
} else {
if (!TextUtils.equals(this.roomCode, "") && !TextUtils.equals(this.roomCode, "null")) {
Log.d("create", "22");
this.roomCodeTv.setText("Room Code\nView");
this.refresh.setVisibility(0);
this.roomCodeBtn.setVisibility(8);
if (!TextUtils.equals(this.acceptedResult, "0") || TextUtils.equals(this.acceptedResult, "1") || TextUtils.equals(this.acceptedResult, "2")) {
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
}
}
Log.d("create", "11");
this.refresh.setVisibility(8);
this.roomCodeTv.setText("Wait For Code");
this.roomCodeBtn.setVisibility(8);
if (!TextUtils.equals(this.acceptedResult, "0")) {
}
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
}
Log.d("ROOOMCODEDATAAAA", json.getString("room_code") + " == " + this.hidedata.getText().toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
public void updateWonResult(String challengeId, String flag, String resultStaus) throws IOException {
this.loadingDialog.show();
HashMap<String, String> params = new HashMap<>();
params.put("ludo_challenge_id", challengeId);
params.put("member_id", this.user.getMemberid());
params.put("result_uploded_by_flag", flag);
params.put("result_status", resultStaus);
params.put("submit", "uploadResult");
params.put("result_image", this.base64);
Log.d("RESPONCE DATA", String.valueOf(params));
RequestQueue mQueue = Volley.newRequestQueue(this);
mQueue.getCache().clear();
String URL = getResources().getString(2131886167) + "challenge_result_upload";
JsonObjectRequest mrequest = new JsonObjectRequest(URL, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
SelectedMyContestActivity.this.m198xa793429b((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 = SelectedMyContestActivity.this.userLocalStore.getLoggedInUser();
String credentials = user.getUsername() + ":" + user.getPassword();
String str = "Basic " + Base64.encodeToString(credentials.getBytes(), SelectedMyContestActivity.MANAGE_STORAGE_PERMISSION_CODE);
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
return headers;
}
};
mrequest.setShouldCache(false);
mQueue.add(mrequest);
}
void m198xa793429b(JSONObject response) {
this.loadingDialog.dismiss();
this.loadingDialog.dismiss();
try {
Log.d("upload won result", response.toString());
this.loadingDialog.dismiss();
String status = response.getString("status");
Log.d("uploadstatus", status);
if (TextUtils.equals(status, "true")) {
openSuccessWonDialog();
}
Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
} catch (JSONException e) {
}
}
public byte[] getBytes(Uri imageUri) throws IOException {
InputStream iStream = getContentResolver().openInputStream(imageUri);
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (true) {
int len = iStream.read(buffer);
if (len != -1) {
byteBuffer.write(buffer, 0, len);
} else {
return byteBuffer.toByteArray();
}
}
}
public void onBackPressed() {
Intent intent = new Intent(getApplicationContext(), (Class<?>) LudoActivity.class);
intent.putExtra("N", "1");
startActivity(intent);
finish();
}
public void openSuccessWonDialog() {
final Dialog builder = new Dialog(this);
builder.setContentView(2131558788);
CardView ok = builder.findViewById(2131362881);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m189x140912dd(builder, view);
}
});
builder.create();
builder.show();
}
void m189x140912dd(Dialog builder, View v) {
this.resultll.setVisibility(8);
this.waitll.setVisibility(0);
this.btnll.setVisibility(8);
builder.dismiss();
}
public void viewroomcodeDialog() {
Dialog builder = new Dialog(this);
builder.setContentView(2131558813);
TextView roomcode_view = (TextView) builder.findViewById(2131363716);
TextView roomcode_copy = (TextView) builder.findViewById(2131362187);
roomcode_view.setText(this.roomCode);
roomcode_copy.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SelectedMyContestActivity.this.m199x490b36ee(view);
}
});
builder.create();
builder.show();
}
void m199x490b36ee(View v) {
if (!TextUtils.equals(this.roomCode, "") && !TextUtils.equals(this.roomCode, "null")) {
ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService("clipboard");
ClipData clip = ClipData.newPlainText("Room Code", this.roomCode);
clipboard.setPrimaryClip(clip);
Toast.makeText(getApplicationContext(), "Room code copied successfully", 0).show();
}
}
}