Skip to content

Instantly share code, notes, and snippets.

@GursheeshSingh
Created April 24, 2019 19:06
Show Gist options
  • Save GursheeshSingh/81e31362e49558c441fdc147ac0f1daa to your computer and use it in GitHub Desktop.
Save GursheeshSingh/81e31362e49558c441fdc147ac0f1daa to your computer and use it in GitHub Desktop.
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"));
}
}
}
public interface ILoginAuthentication {
void login(String username, String password);
}
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
}
}
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