Created
April 24, 2019 19:06
-
-
Save GursheeshSingh/81e31362e49558c441fdc147ac0f1daa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirebaseLogin implements ILoginAuthentication { | |
private OnLoginCompleted listener; | |
public FirebaseLogin(OnLoginCompleted listener){ | |
this.listener = listener; | |
} | |
@Override | |
public void login(String username, String password) { | |
//Firebase Login code here | |
if (noError){ | |
listener.onLoginSuccess(); | |
} else { | |
listener.onLoginFailed(new Exception("Failure message here")); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ILoginAuthentication { | |
void login(String username, String password); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginActivity extends AppCompatActivity implements OnLoginCompleted { | |
private ILoginAuthentication authentication = new FirebaseLogin(this); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_login); | |
} | |
@Override | |
public void onLoginSuccess() { | |
//Do something when login is successful | |
//Display a message and redirect to another activity or whatever else you want to do after successful login | |
} | |
@Override | |
public void onLoginFailed(Exception e) { | |
//When Login fails | |
//Display a message | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface OnLoginCompleted { | |
void onLoginSuccess(); | |
void onLoginFailed(Exception e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment