Update error messages and remove the unknown error text

This commit is contained in:
NorbiPeti
2024-05-13 00:08:18 +02:00
parent c7b8cc72fc
commit 629e65edba
2 changed files with 20 additions and 9 deletions

View File

@@ -32,23 +32,35 @@ public class MastodonErrorResponse extends ErrorResponse{
this.messageResource=R.string.connection_timed_out;
}else if(exception instanceof JsonSyntaxException || exception instanceof JsonIOException || httpStatus>=500){
this.messageResource=R.string.server_error;
}else if(httpStatus == 404){
}else if(httpStatus==404){
this.messageResource=R.string.not_found;
}else{
this.messageResource=R.string.unknown_error;
this.messageResource=0;
}
}
@Override
public void bindErrorView(View view){
TextView text=view.findViewById(R.id.error_text);
text.setText(view.getContext().getString(messageResource, error));
String message;
if(messageResource>0){
message=view.getContext().getString(messageResource, error);
}else{
message=error;
}
text.setText(message);
}
@Override
public void showToast(Context context){
if(context==null)
return;
Toast.makeText(context, context.getString(messageResource, error), Toast.LENGTH_SHORT).show();
String message;
if(messageResource>0){
message=context.getString(messageResource, error);
}else{
message=error;
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
}