Skip to content

Commit

Permalink
fix: skip press issue in login page (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
atm1504 authored Jun 15, 2019
1 parent 640b2a9 commit 88f8666
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/com/example/saar/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class Constant {
public static final String ACHIEVEMENTS = "achievements";
public static final String IMG_URL = "img_url";

//Notification service
//Utilities
public static final String SUBSCRIBE_NOTIFICATION = "subscribe_notification";
public static final String SKIP_LOGIN = "skip_login";

}
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/saar/Login_SignUp/LoginFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class LoginFragment extends Fragment {
Button loginButton;
String email, password;
SharedPreferences.Editor sharedPreferenceEditor;
SharedPreferences preferences;
ProgressDialog progressDialog;

@Override
Expand All @@ -60,6 +61,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
skipLogin = rootView.findViewById(R.id.skip_login);
loginButton = rootView.findViewById(R.id.login_button);
sharedPreferenceEditor = PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
return rootView;
}

Expand All @@ -69,6 +71,13 @@ public void onViewCreated(final View view, @Nullable Bundle savedInstanceState)
//you can set the title for your toolbar here for different fragments different titles
getActivity().setTitle(R.string.saar_login);

if (preferences.getBoolean(Constant.SKIP_LOGIN, false)) {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
getActivity().finish();
}

verifyOTP.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -87,6 +96,8 @@ public void onClick(View v) {
skipLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sharedPreferenceEditor.putBoolean(Constant.SKIP_LOGIN, true);
sharedPreferenceEditor.apply();
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Expand Down

0 comments on commit 88f8666

Please sign in to comment.