Search in sources :

Example 1 with FragmentOtpChecker

use of com.manan.dev.ec2018app.Fragments.FragmentOtpChecker in project EC2018App by Manan-YMCA.

the class RegisterActivity method checkOTP.

private void checkOTP(UserDetails userDetails) {
    checkAndRequestPermissions();
    if (ContextCompat.checkSelfPermission(RegisterActivity.this, android.Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) {
        FragmentManager fm = getFragmentManager();
        FragmentOtpChecker otpChecker = new FragmentOtpChecker();
        Bundle bundle = new Bundle();
        bundle.putString("phone", userPhone.getText().toString());
        otpChecker.setArguments(bundle);
        otpChecker.show(fm, "otpCheckerFragment");
    }
    mProgress.dismiss();
}
Also used : FragmentManager(android.app.FragmentManager) Bundle(android.os.Bundle) FragmentOtpChecker(com.manan.dev.ec2018app.Fragments.FragmentOtpChecker)

Example 2 with FragmentOtpChecker

use of com.manan.dev.ec2018app.Fragments.FragmentOtpChecker in project EC2018App by Manan-YMCA.

the class LoginActivity method getDetails.

private void getDetails(final UserDetails userDetails, final String phone) {
    String url = getResources().getString(R.string.get_user_details_api) + phone;
    RequestQueue queue = Volley.newRequestQueue(this);
    StringRequest obreq = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            try {
                JSONObject obj1 = new JSONObject(response);
                Long success = obj1.getLong("success");
                if (success == 1) {
                    checkAndRequestPermissions();
                    if (ContextCompat.checkSelfPermission(LoginActivity.this, android.Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) {
                        FragmentManager fm = getFragmentManager();
                        FragmentOtpChecker otpChecker = new FragmentOtpChecker();
                        Bundle bundle = new Bundle();
                        bundle.putString("phone", mobileNum.getText().toString());
                        otpChecker.setArguments(bundle);
                        otpChecker.show(fm, "otpCheckerFragment");
                    }
                } else {
                    pbLogin.setVisibility(View.GONE);
                    // Snackbar.make(RelativeView, "Please register yourself first!", Snackbar.LENGTH_LONG).show();
                    MDToast.makeText(LoginActivity.this, "Please register yourself first!", Toast.LENGTH_LONG, MDToast.TYPE_INFO).show();
                    Intent i = new Intent(LoginActivity.this, RegisterActivity.class).putExtra("parent", "xunbao");
                    ;
                    startActivity(i);
                    finish();
                }
            }// Try and catch are included to handle any errors due to JSON
             catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public // Handles errors that occur due to Volley
        void onErrorResponse(VolleyError error) {
        }
    });
    queue.add(obreq);
}
Also used : VolleyError(com.android.volley.VolleyError) Bundle(android.os.Bundle) StringRequest(com.android.volley.toolbox.StringRequest) FragmentOtpChecker(com.manan.dev.ec2018app.Fragments.FragmentOtpChecker) Intent(android.content.Intent) Response(com.android.volley.Response) FragmentManager(android.app.FragmentManager) JSONObject(org.json.JSONObject) RequestQueue(com.android.volley.RequestQueue)

Example 3 with FragmentOtpChecker

use of com.manan.dev.ec2018app.Fragments.FragmentOtpChecker in project EC2018App by Manan-YMCA.

the class LoginActivity method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == REQUEST_ID_MULTIPLE_PERMISSIONS) {
        FragmentManager fm = getFragmentManager();
        FragmentOtpChecker otpChecker = new FragmentOtpChecker();
        Bundle bundle = new Bundle();
        bundle.putString("phone", mobileNum.getText().toString());
        otpChecker.setArguments(bundle);
        otpChecker.show(fm, "otpCheckerFragment");
    }
}
Also used : FragmentManager(android.app.FragmentManager) Bundle(android.os.Bundle) FragmentOtpChecker(com.manan.dev.ec2018app.Fragments.FragmentOtpChecker)

Example 4 with FragmentOtpChecker

use of com.manan.dev.ec2018app.Fragments.FragmentOtpChecker in project EC2018App by Manan-YMCA.

the class RegisterActivity method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == REQUEST_ID_MULTIPLE_PERMISSIONS) {
        Bundle bundle = new Bundle();
        FragmentManager fm = getFragmentManager();
        FragmentOtpChecker otpChecker = new FragmentOtpChecker();
        bundle.putString("phone", userDetails.getmPhone());
        otpChecker.setArguments(bundle);
        otpChecker.show(fm, "otpCheckerFragment");
    }
}
Also used : FragmentManager(android.app.FragmentManager) Bundle(android.os.Bundle) FragmentOtpChecker(com.manan.dev.ec2018app.Fragments.FragmentOtpChecker)

Aggregations

FragmentManager (android.app.FragmentManager)4 Bundle (android.os.Bundle)4 FragmentOtpChecker (com.manan.dev.ec2018app.Fragments.FragmentOtpChecker)4 Intent (android.content.Intent)1 RequestQueue (com.android.volley.RequestQueue)1 Response (com.android.volley.Response)1 VolleyError (com.android.volley.VolleyError)1 StringRequest (com.android.volley.toolbox.StringRequest)1 JSONObject (org.json.JSONObject)1