use of com.naman14.timber.lastfmapi.callbacks.UserListener in project Timber by naman14.
the class LastFmLoginDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new MaterialDialog.Builder(getActivity()).positiveText("Login").negativeText("Cancel").title("Login to LastFM").customView(R.layout.dialog_lastfm_login, false).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String username = ((EditText) dialog.findViewById(R.id.lastfm_username)).getText().toString();
String password = ((EditText) dialog.findViewById(R.id.lastfm_password)).getText().toString();
if (username.length() == 0 || password.length() == 0)
return;
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Logging in..");
progressDialog.show();
LastFmClient.getInstance(getActivity()).getUserLoginInfo(new UserLoginQuery(username, password), new UserListener() {
@Override
public void userSuccess() {
progressDialog.dismiss();
if (getTargetFragment() instanceof SettingsFragment) {
((SettingsFragment) getTargetFragment()).updateLastFM();
}
}
@Override
public void userInfoFailed() {
progressDialog.dismiss();
Toast.makeText(getTargetFragment().getActivity(), "Failed to Login", Toast.LENGTH_SHORT).show();
}
});
}
}).build();
}
Aggregations