导航菜单

页面标题

页面副标题

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

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

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


package com.clash.legends.ui.activities;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.DatePicker;
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.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.clash.legends.models.CurrentUser;
import com.clash.legends.ui.activities.MyProfileActivity;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.clash.legends.utils.VolleyMultipartRequest;
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.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.textfield.TextInputLayout;
import com.google.firebase.FirebaseException;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthOptions;
import com.google.firebase.auth.PhoneAuthProvider;
import com.mukesh.OnOtpCompletionListener;
import com.mukesh.OtpView;
import com.squareup.picasso.Picasso;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class MyProfileActivity extends AppCompatActivity {
    ImageView back;
    Dialog builder;
    Context context;
    TextView countrycodespinner;
    Dialog dialog;
    TextView editprofiletitle;
    RadioButton female;
    TextView gendertitle;
    ImageView iv;
    LoadingDialog loadingDialog;
    FirebaseAuth mAuth;
    PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallback;
    RequestQueue mQueue;
    RadioButton male;
    TextView mobileview;
    TextView myprofiletitle;
    EditText newPassword;
    TextInputLayout newPasswordt;
    EditText oldPassword;
    TextInputLayout oldPasswordt;
    OtpView otpView;
    RequestQueue pQueue;
    EditText profileDateOfBirth;
    TextInputLayout profileDateOfBirtht;
    EditText profileEmail;
    TextInputLayout profileEmailt;
    EditText profileFirstName;
    TextInputLayout profileFirstNamet;
    RadioGroup profileGender;
    EditText profileLastName;
    TextInputLayout profileLastNamet;
    EditText profileMobileNumber;
    TextInputLayout profileMobileNumbert;
    Button profileReset;
    Button profileSave;
    EditText profileUserName;
    TextInputLayout profileUserNamet;
    RequestQueue rQueue;
    TextView resend;
    TextView resetpasswordtitleid;
    Resources resources;
    EditText retypeNewPassword;
    TextInputLayout retypeNewPasswordt;
    List<String> spinnerArray;
    List<String> spinnerArrayCountryCode;
    RequestQueue uQueue;
    CurrentUser user;
    UserLocalStore userLocalStore;
    TextView verify;
    String countryCode = "";
    String imgUrl = "";
    String imgName = "";

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558459);
        SharedPreferences spb = getSharedPreferences("SMINFO", 0);
        if (TextUtils.equals(spb.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.myprofiletitle = (TextView) findViewById(2131362776);
        this.editprofiletitle = (TextView) findViewById(2131362280);
        TextView textView = (TextView) findViewById(2131362389);
        this.gendertitle = textView;
        textView.setText(this.resources.getText(2131886463));
        this.myprofiletitle.setText(this.resources.getString(2131886609));
        this.editprofiletitle.setText(this.resources.getString(2131886424));
        Dialog dialog = new Dialog(this);
        this.builder = dialog;
        dialog.setContentView(2131558689);
        this.mobileview = (TextView) this.builder.findViewById(2131362732);
        this.otpView = this.builder.findViewById(2131362962);
        this.resend = (TextView) this.builder.findViewById(2131363162);
        this.mAuth = FirebaseAuth.getInstance();
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        ImageView imageView = (ImageView) findViewById(2131361970);
        this.back = imageView;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m109xb21ad992(view);
            }
        });
        this.profileFirstNamet = findViewById(2131363061);
        this.profileLastNamet = findViewById(2131363064);
        this.profileUserNamet = findViewById(2131363070);
        this.profileEmailt = findViewById(2131363059);
        this.profileMobileNumbert = findViewById(2131363066);
        this.profileDateOfBirtht = findViewById(2131363057);
        this.oldPasswordt = findViewById(2131362883);
        this.newPasswordt = findViewById(2131362811);
        this.retypeNewPasswordt = findViewById(2131363184);
        this.verify = (TextView) findViewById(2131363736);
        this.profileFirstName = (EditText) findViewById(2131363060);
        this.profileLastName = (EditText) findViewById(2131363063);
        this.profileUserName = (EditText) findViewById(2131363069);
        this.profileEmail = (EditText) findViewById(2131363058);
        this.profileMobileNumber = (EditText) findViewById(2131363065);
        this.profileDateOfBirth = (EditText) findViewById(2131363056);
        this.profileGender = (RadioGroup) findViewById(2131363062);
        this.male = (RadioButton) findViewById(2131362681);
        this.female = (RadioButton) findViewById(2131362343);
        this.profileSave = (Button) findViewById(2131363068);
        this.resetpasswordtitleid = (TextView) findViewById(2131363168);
        this.oldPassword = (EditText) findViewById(2131362882);
        this.newPassword = (EditText) findViewById(2131362810);
        this.retypeNewPassword = (EditText) findViewById(2131363183);
        this.profileReset = (Button) findViewById(2131363067);
        this.countrycodespinner = (TextView) findViewById(2131362191);
        this.iv = (ImageView) findViewById(2131362467);
        this.resetpasswordtitleid.setText(this.resources.getString(2131886956));
        this.profileReset.setText(this.resources.getString(2131886955));
        this.profileSave.setText(this.resources.getString(2131887053));
        this.profileFirstNamet.setHint(this.resources.getString(2131886457));
        this.profileLastNamet.setHint(this.resources.getString(2131886506));
        this.profileUserNamet.setHint(this.resources.getString(2131887059));
        this.profileEmailt.setHint(this.resources.getString(2131886427));
        this.profileMobileNumbert.setHint(this.resources.getString(2131886567));
        this.profileDateOfBirtht.setHint(this.resources.getString(2131886409));
        this.oldPasswordt.setHint(this.resources.getString(2131886651));
        this.newPasswordt.setHint(this.resources.getString(2131886621));
        this.countrycodespinner.setText(this.resources.getString(2131886347));
        this.spinnerArray = new ArrayList();
        this.spinnerArrayCountryCode = new ArrayList();
        this.countrycodespinner.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m116x7cbc32d5(view);
            }
        });
        UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        this.userLocalStore = userLocalStore;
        CurrentUser loggedInUser = userLocalStore.getLoggedInUser();
        this.user = loggedInUser;
        if (TextUtils.equals(loggedInUser.getPhone().trim(), "")) {
            this.verify.setVisibility(8);
        }
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String url = this.resources.getString(2131886167) + "all_country";
        JsonObjectRequest request = new JsonObjectRequest(0, url, null, new AnonymousClass2(), 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 = MyProfileActivity.this.userLocalStore.getLoggedInUser();
                String credentials = user.getUsername() + ":" + user.getPassword();
                String auth = "Basic " + Base64.encodeToString(credentials.getBytes(), 2);
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", auth);
                headers.put("x-localization", LocaleHelper.getPersist(MyProfileActivity.this.context));
                return headers;
            }
        };
        request.setShouldCache(false);
        this.mQueue.add(request);
        this.dialog = new Dialog(this);
        this.profileDateOfBirth.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m119x8ae8a9d9(view);
            }
        });
        this.profileMobileNumber.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                SharedPreferences sp = MyProfileActivity.this.getSharedPreferences("SMINFO", 0);
                if (!TextUtils.equals(sp.getString("otp", "no"), "no")) {
                    if (TextUtils.equals(MyProfileActivity.this.user.getPhone().trim(), "") && TextUtils.equals(MyProfileActivity.this.user.getPhone().trim(), charSequence)) {
                        MyProfileActivity.this.verify.setVisibility(8);
                    } else {
                        MyProfileActivity.this.verify.setVisibility(0);
                    }
                    if (TextUtils.equals(MyProfileActivity.this.user.getPhone(), charSequence)) {
                        MyProfileActivity.this.verify.setText(MyProfileActivity.this.getResources().getString(2131887062));
                        MyProfileActivity.this.verify.setEnabled(false);
                    } else {
                        MyProfileActivity.this.verify.setText(MyProfileActivity.this.getResources().getString(2131887063));
                        MyProfileActivity.this.verify.setEnabled(true);
                    }
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {
            }
        });
        this.mCallback = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
            public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
                MyProfileActivity.this.loadingDialog.dismiss();
                MyProfileActivity.this.builder.dismiss();
                MyProfileActivity myProfileActivity = MyProfileActivity.this;
                myProfileActivity.updateMobile(myProfileActivity.profileMobileNumber.getText().toString(), MyProfileActivity.this.countryCode);
            }

            public void onVerificationFailed(FirebaseException e) {
                e.printStackTrace();
                Log.d("failed", e.getMessage());
                MyProfileActivity.this.loadingDialog.dismiss();
                Toast.makeText((Context) MyProfileActivity.this, (CharSequence) "Something went wrong, Please try again", 0).show();
            }

            public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                super.onCodeSent(s, forceResendingToken);
                Log.d("codesent", s);
                Toast.makeText(MyProfileActivity.this.getApplicationContext(), MyProfileActivity.this.resources.getString(2131886663), 0).show();
                MyProfileActivity.this.openotpdialog(s);
            }
        };
        SharedPreferences sp = getSharedPreferences("SMINFO", 0);
        if (TextUtils.equals(sp.getString("otp", "no"), "no")) {
            this.verify.setVisibility(8);
        } else {
            this.verify.setVisibility(0);
        }
        this.verify.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m120xce73c79a(view);
            }
        });
        this.iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m121x11fee55b(view);
            }
        });
        this.profileSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m113x7f61949d(view);
            }
        });
        this.profileReset.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m115x4a02ede0(view);
            }
        });
    }

    void m109xb21ad992(View view) {
        onBackPressed();
    }

    void m116x7cbc32d5(View v) {
        final Dialog builder = new Dialog(this);
        builder.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        builder.setCancelable(false);
        WindowManager.LayoutParams wlmp = builder.getWindow().getAttributes();
        builder.getWindow().setAttributes(wlmp);
        builder.setContentView(2131558785);
        ImageView cancel = (ImageView) builder.findViewById(2131363369);
        LinearLayout ll = (LinearLayout) builder.findViewById(2131363371);
        for (int i = 0; i < this.spinnerArray.size(); i++) {
            LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(-1, -2);
            View view = getLayoutInflater().inflate(2131558784, (ViewGroup) null);
            view.setLayoutParams(lparams);
            TextView tv = (TextView) view.findViewById(2131363558);
            tv.setText(this.spinnerArrayCountryCode.get(i) + " (" + this.spinnerArray.get(i) + ")");
            final int finalI = i;
            tv.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view2) {
                    MyProfileActivity.this.m110xf5a5f753(finalI, builder, view2);
                }
            });
            ll.addView(view);
        }
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                builder.dismiss();
            }
        });
        builder.create();
        builder.show();
    }

    void m110xf5a5f753(int finalI, Dialog builder, View v12) {
        this.countrycodespinner.setText(this.spinnerArrayCountryCode.get(finalI));
        this.countryCode = this.spinnerArrayCountryCode.get(finalI);
        builder.dismiss();
    }

    class AnonymousClass2 implements Response.Listener<JSONObject> {
        AnonymousClass2() {
        }

        public void onResponse(JSONObject response) {
            try {
                JSONArray arr = response.getJSONArray("all_country");
                TextUtils.equals(response.getString("all_country"), "[]");
                MyProfileActivity.this.JSON_PARSE_DATA_AFTER_WEBCALL(arr);
                MyProfileActivity myProfileActivity = MyProfileActivity.this;
                myProfileActivity.pQueue = Volley.newRequestQueue(myProfileActivity.getApplicationContext());
                MyProfileActivity.this.pQueue.getCache().clear();
                String url = MyProfileActivity.this.resources.getString(2131886167) + "my_profile/" + MyProfileActivity.this.user.getMemberid();
                JsonObjectRequest prequest = new JsonObjectRequest(url, null, new Response.Listener() {
                    public final void onResponse(Object obj) {
                        MyProfileActivity.AnonymousClass2.this.m127x53946025((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() throws AuthFailureError {
                        Map<String, String> headers = new HashMap<>();
                        CurrentUser user = MyProfileActivity.this.userLocalStore.getLoggedInUser();
                        String token = "Bearer " + user.getToken();
                        headers.put("Content-Type", "application/json");
                        headers.put("Authorization", token);
                        headers.put("x-localization", LocaleHelper.getPersist(MyProfileActivity.this.context));
                        return headers;
                    }
                };
                prequest.setShouldCache(false);
                MyProfileActivity.this.pQueue.add(prequest);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            MyProfileActivity.this.loadingDialog.dismiss();
        }

        void m127x53946025(JSONObject response1) {
            MyProfileActivity.this.loadingDialog.dismiss();
            Log.d("profile", response1.toString());
            try {
                JSONObject obj = new JSONObject(response1.getString("my_profile"));
                MyProfileActivity.this.profileFirstName.setText(obj.getString("first_name"));
                MyProfileActivity.this.profileLastName.setText(obj.getString("last_name"));
                if (TextUtils.equals(obj.getString("first_name"), "null")) {
                    MyProfileActivity.this.profileFirstName.setText("");
                }
                if (TextUtils.equals(obj.getString("last_name"), "null")) {
                    MyProfileActivity.this.profileLastName.setText("");
                }
                MyProfileActivity.this.profileUserName.setText(obj.getString("user_name"));
                MyProfileActivity.this.profileEmail.setText(obj.getString("email_id"));
                MyProfileActivity.this.profileMobileNumber.setText(obj.getString("mobile_no"));
                MyProfileActivity.this.profileDateOfBirth.setText(obj.getString("dob"));
                if (TextUtils.equals(obj.getString("dob"), "null")) {
                    MyProfileActivity.this.profileDateOfBirth.setText("");
                }
                if (obj.getString("gender").matches("0")) {
                    MyProfileActivity.this.male.setChecked(true);
                    MyProfileActivity.this.female.setChecked(false);
                } else if (obj.getString("gender").matches("1")) {
                    MyProfileActivity.this.female.setChecked(true);
                    MyProfileActivity.this.male.setChecked(false);
                } else {
                    MyProfileActivity.this.male.setChecked(false);
                    MyProfileActivity.this.female.setChecked(false);
                }
                MyProfileActivity.this.countryCode = obj.getString("country_code");
                MyProfileActivity.this.countrycodespinner.setText(MyProfileActivity.this.countryCode);
                if (!TextUtils.equals(obj.getString("profile_image"), "null") && !TextUtils.equals(obj.getString("profile_image"), "")) {
                    Picasso.get().load(obj.getString("profile_image")).placeholder(2131230869).fit().into(MyProfileActivity.this.iv);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    void m119x8ae8a9d9(View view) {
        this.dialog.setContentView(2131558588);
        final DatePicker datePicker = (DatePicker) this.dialog.findViewById(2131362219);
        Button dob_set = (Button) this.dialog.findViewById(2131362249);
        Button dob_cancel = (Button) this.dialog.findViewById(2131362248);
        dob_set.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                MyProfileActivity.this.m117x3d26e57(datePicker, view2);
            }
        });
        dob_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                MyProfileActivity.this.m118x475d8c18(view2);
            }
        });
        this.dialog.show();
    }

    void m117x3d26e57(DatePicker datePicker, View view1) {
        this.dialog.dismiss();
        String selecteddate = datePicker.getDayOfMonth() + "/" + (datePicker.getMonth() + 1) + "/" + datePicker.getYear();
        this.profileDateOfBirth.setText(selecteddate);
    }

    void m118x475d8c18(View view12) {
        this.dialog.dismiss();
    }

    void m120xce73c79a(View view) {
        if (TextUtils.equals(this.user.getMemberid(), "21") && TextUtils.equals(this.user.getUsername(), "demouser")) {
            Toast.makeText((Context) this, (CharSequence) "You can't update demo profile", 0).show();
            return;
        }
        SharedPreferences sp12 = getSharedPreferences("SMINFO", 0);
        if (!TextUtils.equals(sp12.getString("otp", "no"), "no")) {
            if (this.profileMobileNumber.getText().toString().trim().length() < 7 || this.profileMobileNumber.getText().toString().trim().length() > 15) {
                this.profileMobileNumber.setError(getResources().getString(2131887095));
            } else {
                checkMobile(this.profileMobileNumber.getText().toString().trim());
            }
        }
    }

    void m121x11fee55b(View v) {
        if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
            getFileChooserIntent();
        } else {
            requestStoragePermission();
        }
    }

    void m113x7f61949d(View view) {
        String gender;
        if (TextUtils.equals(this.user.getMemberid(), "21") && TextUtils.equals(this.user.getUsername(), "demouser")) {
            Toast.makeText((Context) this, (CharSequence) "You can't update demo profile", 0).show();
            return;
        }
        final String firstname = this.profileFirstName.getText().toString();
        final String lastname = this.profileLastName.getText().toString();
        final String username = this.profileUserName.getText().toString();
        if (username.contains(" ")) {
            this.profileUserName.setError(this.resources.getString(2131886637));
            return;
        }
        final String email = this.profileEmail.getText().toString();
        final String mobilenumber = this.profileMobileNumber.getText().toString();
        if (mobilenumber.length() >= 7 && mobilenumber.length() <= 15) {
            SharedPreferences sp1 = getSharedPreferences("SMINFO", 0);
            if (!TextUtils.equals(sp1.getString("otp", "no"), "no") && TextUtils.equals(this.verify.getText().toString(), getResources().getString(2131887063))) {
                Toast.makeText(getApplicationContext(), getResources().getString(2131886916), 0).show();
                return;
            }
            final String dateofbirth = this.profileDateOfBirth.getText().toString();
            switch (this.profileGender.getCheckedRadioButtonId()) {
                case 2131362343:
                    gender = "1";
                    break;
                case 2131362681:
                    gender = "0";
                    break;
                default:
                    gender = "-1";
                    break;
            }
            this.loadingDialog.show();
            RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
            this.uQueue = newRequestQueue;
            newRequestQueue.getCache().clear();
            String uurl = this.resources.getString(2131886167) + "update_myprofile";
            if (!TextUtils.equals(this.imgName, "") || !TextUtils.equals(this.imgUrl, "")) {
                final String gender2 = gender;
                VolleyMultipartRequest volleyMultipartRequest = new VolleyMultipartRequest(1, uurl, new Response.Listener() {
                    public final void onResponse(Object obj) {
                        MyProfileActivity.this.m112xf84b591b(username, email, mobilenumber, firstname, lastname, (NetworkResponse) obj);
                    }
                }, new Response.ErrorListener() {
                    public final void onErrorResponse(VolleyError volleyError) {
                        Log.d("error", volleyError.toString() + volleyError.networkResponse.data);
                    }
                }) {
                    protected Map<String, String> getParams() {
                        Map params = new HashMap();
                        params.put("member_id", MyProfileActivity.this.user.getMemberid());
                        params.put("first_name", firstname);
                        params.put("last_name", lastname);
                        params.put("user_name", username);
                        params.put("mobile_no", mobilenumber);
                        params.put("email_id", email);
                        params.put("dob", dateofbirth);
                        params.put("gender", gender2);
                        params.put("submit", "save");
                        params.put("member_pass", MyProfileActivity.this.user.getPassword());
                        params.put("country_code", MyProfileActivity.this.countryCode);
                        Log.d("PARAMS", params.toString());
                        return params;
                    }

                    public Map<String, String> getHeaders() {
                        Map headers = new HashMap();
                        CurrentUser user = MyProfileActivity.this.userLocalStore.getLoggedInUser();
                        String token = "Bearer " + user.getToken();
                        headers.put("Authorization", token);
                        return headers;
                    }

                    protected Map<String, VolleyMultipartRequest.DataPart> getByteData() {
                        Map params = new HashMap();
                        try {
                            Log.d("img name", MyProfileActivity.this.imgName);
                            String str = MyProfileActivity.this.imgName;
                            MyProfileActivity myProfileActivity = MyProfileActivity.this;
                            params.put("profile_image", new VolleyMultipartRequest.DataPart(this, str, myProfileActivity.getBytes(Uri.parse(myProfileActivity.imgUrl))));
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        return params;
                    }
                };
                Volley.newRequestQueue(this).add(volleyMultipartRequest);
                return;
            }
            RequestQueue newRequestQueue2 = Volley.newRequestQueue(getApplicationContext());
            this.uQueue = newRequestQueue2;
            newRequestQueue2.getCache().clear();
            HashMap<String, String> params = new HashMap<>();
            params.put("member_id", this.user.getMemberid());
            params.put("first_name", firstname);
            params.put("last_name", lastname);
            params.put("user_name", username);
            params.put("mobile_no", mobilenumber);
            params.put("email_id", email);
            params.put("dob", dateofbirth);
            params.put("gender", gender);
            params.put("submit", "save");
            params.put("member_pass", this.user.getPassword());
            params.put("country_code", this.countryCode);
            Log.d("save", new JSONObject(params).toString());
            JsonObjectRequest urequest = new JsonObjectRequest(uurl, new JSONObject(params), new Response.Listener() {
                public final void onResponse(Object obj) {
                    MyProfileActivity.this.m111x71351d99(username, email, mobilenumber, firstname, lastname, (JSONObject) obj);
                }
            }, new Response.ErrorListener() {
                public final void onErrorResponse(VolleyError volleyError) {
                    Log.e("**VolleyError", "error" + volleyError.getMessage());
                }
            }) {
                public Map<String, String> getHeaders() {
                    Map headers = new HashMap();
                    CurrentUser user = MyProfileActivity.this.userLocalStore.getLoggedInUser();
                    String credentials = user.getMemberid() + ":" + 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);
                    return headers;
                }
            };
            urequest.setShouldCache(false);
            this.uQueue.add(urequest);
            return;
        }
        this.profileMobileNumber.setError(this.resources.getString(2131887095));
    }

    void m111x71351d99(String username, String email, String mobilenumber, String firstname, String lastname, JSONObject response) {
        this.loadingDialog.dismiss();
        try {
            if (response.getString("status").matches("true")) {
                Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
                UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
                this.userLocalStore = userLocalStore;
                CurrentUser user = userLocalStore.getLoggedInUser();
                CurrentUser cUser = new CurrentUser(user.getMemberid(), username, user.getPassword(), email, mobilenumber, user.getToken(), firstname, lastname);
                UserLocalStore userLocalStore2 = new UserLocalStore(getApplicationContext());
                userLocalStore2.storeUserData(cUser);
            } else {
                Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    void m112xf84b591b(String username, String email, String mobilenumber, String firstname, String lastname, NetworkResponse nResponse) {
        this.loadingDialog.dismiss();
        try {
            Log.d("update profile", new String(nResponse.data));
            JSONObject response = new JSONObject(new String(nResponse.data));
            if (response.getString("status").matches("true")) {
                Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
                UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
                this.userLocalStore = userLocalStore;
                CurrentUser user = userLocalStore.getLoggedInUser();
                CurrentUser cUser = new CurrentUser(user.getMemberid(), username, user.getPassword(), email, mobilenumber, user.getToken(), firstname, lastname);
                UserLocalStore userLocalStore2 = new UserLocalStore(getApplicationContext());
                userLocalStore2.storeUserData(cUser);
                Intent intent1 = new Intent();
                intent1.setAction("reloadprofile");
                sendBroadcast(intent1);
            } else {
                Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    void m115x4a02ede0(View view) {
        if (TextUtils.equals(this.user.getMemberid(), "21") && TextUtils.equals(this.user.getUsername(), "demouser")) {
            Toast.makeText((Context) this, (CharSequence) "You can't update demo profile", 0).show();
            return;
        }
        String old_pass = this.oldPassword.getText().toString();
        String new_pass = this.newPassword.getText().toString().trim();
        final String retype_new_pass = this.newPassword.getText().toString().trim();
        if (TextUtils.isEmpty(old_pass)) {
            this.oldPassword.setError(this.resources.getString(2131886437));
            return;
        }
        if (TextUtils.isEmpty(new_pass)) {
            this.newPassword.setError(this.resources.getString(2131886435));
            return;
        }
        if (TextUtils.isEmpty(retype_new_pass)) {
            this.retypeNewPassword.setError(this.resources.getString(2131886964));
            return;
        }
        if (!TextUtils.equals(new_pass, retype_new_pass)) {
            this.retypeNewPassword.setError(this.resources.getString(2131886667));
            return;
        }
        this.loadingDialog.show();
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.rQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String rurl = this.resources.getString(2131886167) + "update_myprofile";
        HashMap<String, String> params = new HashMap<>();
        params.put("oldpass", old_pass);
        params.put("newpass", new_pass);
        params.put("confpass", retype_new_pass);
        params.put("submit", "reset");
        params.put("member_id", this.user.getMemberid());
        JsonObjectRequest rrequest = new JsonObjectRequest(rurl, new JSONObject(params), new Response.Listener() {
            public final void onResponse(Object obj) {
                MyProfileActivity.this.m114xc2ecb25e(retype_new_pass, (JSONObject) obj);
            }
        }, new Response.ErrorListener() {
            public final void onErrorResponse(VolleyError volleyError) {
                Log.e("**VolleyError", "error" + volleyError.getMessage());
            }
        }) {
            public Map<String, String> getHeaders() {
                Map headers = new HashMap();
                CurrentUser user = MyProfileActivity.this.userLocalStore.getLoggedInUser();
                String token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(MyProfileActivity.this.context));
                return headers;
            }
        };
        rrequest.setShouldCache(false);
        this.rQueue.add(rrequest);
    }

    void m114xc2ecb25e(String retype_new_pass, JSONObject response) {
        this.loadingDialog.dismiss();
        try {
            if (response.getString("status").matches("true")) {
                Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
                UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
                this.userLocalStore = userLocalStore;
                CurrentUser user = userLocalStore.getLoggedInUser();
                CurrentUser cUser = new CurrentUser(user.getMemberid(), user.getUsername(), retype_new_pass, user.getEmail(), user.getPhone(), user.getToken(), user.getFirstName(), user.getLastName());
                UserLocalStore userLocalStore2 = new UserLocalStore(getApplicationContext());
                userLocalStore2.storeUserData(cUser);
            } else {
                Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
            }
            this.oldPassword.setText("");
            this.newPassword.setText("");
            this.retypeNewPassword.setText("");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    private void requestStoragePermission() {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.WRITE_EXTERNAL_STORAGE")) {
            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) {
                    MyProfileActivity.this.m124x91118d81(dialogInterface, i);
                }
            }).setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            }).create().show();
        } else {
            ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
        }
    }

    void m124x91118d81(DialogInterface dialog, int which) {
        ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 1) {
            if (grantResults.length > 0 && grantResults[0] == 0) {
                getFileChooserIntent();
            } else {
                Toast.makeText((Context) this, (CharSequence) "Storage Permission DENIED", 0).show();
            }
        }
    }

    private void getFileChooserIntent() {
        String[] mimeTypes = {"image/*"};
        Intent intent = new Intent("android.intent.action.GET_CONTENT");
        intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
        intent.addCategory("android.intent.category.OPENABLE");
        intent.setType(mimeTypes.length == 1 ? mimeTypes[0] : "*/*");
        if (mimeTypes.length > 0) {
            intent.putExtra("android.intent.extra.MIME_TYPES", mimeTypes);
        }
        startActivityForResult(intent, 23);
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        try {
            if (resultCode == -1 && data != null) {
                Uri mImageUri = data.getData();
                Cursor cursor1 = getContentResolver().query(mImageUri, null, null, null, null);
                if (cursor1 != null && cursor1.moveToFirst()) {
                    int sizeIndex = cursor1.getColumnIndex("_size");
                    long size = cursor1.getLong(sizeIndex);
                    int sizedata = (int) (size / 1000);
                    if (sizedata > 2000) {
                        Toast.makeText(getApplicationContext(), "Please choose an image that is smaller than 2MB.", 0).show();
                        return;
                    }
                }
                File myFile = new File(mImageUri.toString());
                String displayName = " ";
                if (mImageUri.toString().startsWith("content://")) {
                    Cursor cursor = null;
                    try {
                        cursor = getContentResolver().query(mImageUri, null, null, null, null);
                        if (cursor != null && cursor.moveToFirst()) {
                            displayName = cursor.getString(cursor.getColumnIndex("_display_name"));
                        }
                        cursor.close();
                    } catch (Throwable th) {
                        cursor.close();
                        throw th;
                    }
                } else if (mImageUri.toString().startsWith("file://")) {
                    displayName = myFile.getName();
                }
                this.imgName = displayName;
                this.imgUrl = String.valueOf(mImageUri);
                this.iv.setImageBitmap(MediaStore.Images.Media.getBitmap(getContentResolver(), mImageUri));
            } else {
                Toast.makeText((Context) this, (CharSequence) "You haven't picked Image", 1).show();
            }
        } catch (Exception e) {
            Toast.makeText((Context) this, (CharSequence) "Something went wrong", 1).show();
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    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 JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
        for (int i = 0; i < array.length(); i++) {
            try {
                JSONObject json = array.getJSONObject(i);
                this.spinnerArray.add(json.getString("country_name"));
                this.spinnerArrayCountryCode.add(json.getString("p_code"));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    public void checkMobile(final String mobilenumber) {
        this.loadingDialog.show();
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String URL = this.resources.getString(2131886167) + "checkMobileNumber";
        HashMap<String, String> params = new HashMap<>();
        params.put("mobile_no", mobilenumber);
        Log.d(URL, new JSONObject(params).toString());
        JsonObjectRequest request_json = new JsonObjectRequest(1, URL, new JSONObject(params), new Response.Listener() {
            public final void onResponse(Object obj) {
                MyProfileActivity.this.m108xb818c8a3(mobilenumber, (JSONObject) obj);
            }
        }, new Response.ErrorListener() {
            public final void onErrorResponse(VolleyError volleyError) {
                MyProfileActivity.lambda$checkMobile$21(volleyError);
            }
        }) {
            public Map<String, String> getHeaders() {
                Map<String, String> headers = new HashMap<>();
                headers.put("x-localization", LocaleHelper.getPersist(MyProfileActivity.this.context));
                return headers;
            }
        };
        request_json.setShouldCache(false);
        this.mQueue.add(request_json);
    }

    void m108xb818c8a3(String mobilenumber, JSONObject response) {
        try {
            String status = response.getString("status");
            if (TextUtils.equals(status, "true")) {
                PhoneAuthOptions options = PhoneAuthOptions.newBuilder(this.mAuth).setPhoneNumber(this.countryCode + mobilenumber).setTimeout(60L, TimeUnit.SECONDS).setActivity(this).setCallbacks(this.mCallback).build();
                PhoneAuthProvider.verifyPhoneNumber(options);
            } else {
                this.loadingDialog.dismiss();
                Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    static void lambda$checkMobile$21(VolleyError error) {
        VolleyLog.e("Error: ", new Object[]{error.getMessage()});
        NetworkResponse response = error.networkResponse;
        if (response != null && response.data != null) {
            String errorString = new String(response.data);
            Log.d("erorostring ", errorString);
        }
    }

    public void openotpdialog(final String fotp) {
        new CountDownTimer(60000L, 1000L) {
            @Override
            public void onTick(long millisUntilFinished) {
                MyProfileActivity.this.resend.setText(String.valueOf(millisUntilFinished / 1000));
            }

            @Override
            public void onFinish() {
                MyProfileActivity.this.resend.setText(MyProfileActivity.this.resources.getString(2131886954));
                MyProfileActivity.this.resend.setClickable(true);
                MyProfileActivity.this.resend.setEnabled(true);
            }
        }.start();
        this.mobileview.setText(this.resources.getString(2131887076) + this.countryCode + this.profileMobileNumber.getText().toString().trim());
        this.resend.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyProfileActivity.this.m122x4ad114e6(view);
            }
        });
        this.otpView.setShowSoftInputOnFocus(true);
        this.otpView.setOtpCompletionListener(new OnOtpCompletionListener() {
            public final void onOtpCompleted(String str) {
                MyProfileActivity.this.m123x8e5c32a7(fotp, str);
            }
        });
        this.builder.show();
    }

    void m122x4ad114e6(View view) {
        this.builder.dismiss();
        this.loadingDialog.show();
        checkMobile(this.profileMobileNumber.getText().toString().trim());
    }

    void m123x8e5c32a7(String fotp, String otp) {
        this.loadingDialog.show();
        PhoneAuthCredential credential = PhoneAuthProvider.getCredential(fotp, otp);
        signInWithPhoneAuthCredential(credential);
    }

    private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
        this.mAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener() {
            public final void onComplete(Task task) {
                MyProfileActivity.this.m125x6dab18ac(task);
            }
        });
    }

    void m125x6dab18ac(Task task) {
        if (task.isSuccessful()) {
            this.builder.dismiss();
            updateMobile(this.profileMobileNumber.getText().toString(), this.countryCode);
            return;
        }
        Toast.makeText(getApplicationContext(), this.resources.getString(2131886449), 0).show();
        if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
            Toast.makeText(getApplicationContext(), this.resources.getString(2131887096), 0).show();
            this.otpView.setText("");
            this.loadingDialog.dismiss();
        }
    }

    public void updateMobile(final String mobile, String code) {
        this.loadingDialog.show();
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String URL = this.resources.getString(2131886167) + "update_mobile_no";
        HashMap<String, String> params = new HashMap<>();
        params.put("member_id", this.user.getMemberid());
        params.put("mobile_no", mobile);
        params.put("country_code", code);
        params.put("country_id", "");
        Log.d(URL, new JSONObject(params).toString());
        JsonObjectRequest request_json = new JsonObjectRequest(URL, new JSONObject(params), new Response.Listener() {
            public final void onResponse(Object obj) {
                MyProfileActivity.this.m126x5beaa2d(mobile, (JSONObject) obj);
            }
        }, new Response.ErrorListener() {
            public final void onErrorResponse(VolleyError volleyError) {
                VolleyLog.e("Error: ", new Object[]{volleyError.getMessage()});
            }
        }) {
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<>();
                headers.put("x-localization", LocaleHelper.getPersist(MyProfileActivity.this.context));
                return headers;
            }
        };
        request_json.setShouldCache(false);
        this.mQueue.add(request_json);
    }

    void m126x5beaa2d(String mobile, JSONObject response) {
        Log.d("update mobile response", response.toString());
        this.loadingDialog.dismiss();
        try {
            String status = response.getString("status");
            if (TextUtils.equals(status, "true")) {
                if (response.getString("status").matches("true")) {
                    Toast.makeText(getApplicationContext(), getResources().getString(2131886569), 0).show();
                    this.verify.setEnabled(false);
                    this.verify.setText(getResources().getString(2131887062));
                    UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
                    this.userLocalStore = userLocalStore;
                    CurrentUser user = userLocalStore.getLoggedInUser();
                    CurrentUser cUser = new CurrentUser(user.getMemberid(), user.getUsername(), user.getPassword(), user.getEmail(), mobile, user.getToken(), user.getFirstName(), user.getLastName());
                    UserLocalStore userLocalStore2 = new UserLocalStore(getApplicationContext());
                    userLocalStore2.storeUserData(cUser);
                } else {
                    Toast.makeText((Context) this, (CharSequence) response.getString("message"), 0).show();
                }
            }
        } catch (JSONException e) {
            this.loadingDialog.dismiss();
            e.printStackTrace();
        }
    }
}