I have found a mini Deezer player on github, but I think it's been coded in Eclipse. I however work in Android Studio.
Beeing my first Android app it must be a noob question, but I am stuck on this:
private DialogListener mDeezerDialogListener = new **DialogListener**() {
@Override
public void onComplete(Bundle values) {
// store the current authentication info
SessionStore sessionStore = new SessionStore();
sessionStore.save(mDeezerConnect, LoginActivity.this);
// Launch the Home activity
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(intent);
}
@Override
public void onDeezerError(final DeezerError deezerError) {
Toast.makeText(LoginActivity.this, R.string.deezer_error_during_login,
Toast.LENGTH_LONG).show();
}
@Override
public void onError(final DialogError dialogError) {
Toast.makeText(LoginActivity.this, R.string.deezer_error_during_login,
Toast.LENGTH_LONG).show();
}
@Override
public void onCancel() {
Toast.makeText(LoginActivity.this, R.string.login_cancelled, Toast.LENGTH_LONG).show();
}
@Override
public void onOAuthException(OAuthException oAuthException) {
Toast.makeText(LoginActivity.this, R.string.invalid_credentials, Toast.LENGTH_LONG)
.show();
}
};`
The bold function is giving me an error which reads:
Class 'Anonymous class derived from DialogListener' must either be declared abstract or implement abstract method 'onException(Exception)' in 'DialogListener'.
I have no idea what is the problem, but to add insult to injury, all is well with the first @Override, but the second, the third and the last one give me this error:
Error:(91, 17) error: method does not override or implement a method from a supertype
This is supposed to be a working code snippet, so what is the problem here, why the complaints on some of the @Overrides?
Are those two errors connected?
EDIT1:
As suggested I added another function:
@Override
public void onException(Exception exception) {
}
and the first error went away. Could it be that the original code on github was written for a previous version of SDK, that did stuff diferently?
@Override errors stayed. but as far as I can see, those are sub-exceptions of onException?
EDIT2:
This is defined in the Deezer SDK:
import com.deezer.sdk.network.connect.event.DialogListener;
I am looking at their documentation and it mentions under "Method Summary":
onCancel()
,
onComplete(Bundle values)
,
onException(Exception exception)
.
It also says:
void onException(Exception exception)
is called when an exception is thrown during the authentication process.
The following exceptions may be raised :
OAuthException
,
DeezerError
,
DialogError
.
I think I will post all additional data here.
EDIT3:
This is how I rewrote the code:
@Override
public void onException(Exception exception) {
if(exception instanceof DeezerError){
Toast.makeText(LoginActivity.this, R.string.deezer_error_during_login,
Toast.LENGTH_LONG).show();
}
else if(exception instanceof DialogError){
Toast.makeText(LoginActivity.this, R.string.deezer_error_during_login,
Toast.LENGTH_LONG).show();
}
else if(exception instanceof OAuthException){
Toast.makeText(LoginActivity.this, R.string.invalid_credentials, Toast.LENGTH_LONG)
.show();
}
else{
//not implemented?
}
}
Gives a warning: Condition 'exception instanceof OAuthException' is always 'false'
.
I will have to work on that, but this is now a different question.