Some cleaning

This commit is contained in:
stom79 2017-12-02 14:54:25 +01:00
parent 0bd711be9a
commit 2ed93d99dc
15 changed files with 45 additions and 157 deletions

View File

@ -144,10 +144,8 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
} catch (HttpsConnection.HttpsConnectionException e) {
isLoadingInstance = false;
e.printStackTrace();
} catch (Exception e) {
isLoadingInstance = false;
e.printStackTrace();
}
}
}).start();
@ -233,17 +231,11 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
i.putExtra("instance", instance);
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
});
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
}
}).start();
@ -287,9 +279,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
editor.apply();
//Update the account with the token;
new UpdateAccountInfoAsyncTask(BaseLoginActivity.this, token, instance).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
});
}catch (HttpsConnection.HttpsConnectionException e) {
@ -299,7 +289,6 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
Toast.makeText(getApplicationContext(),R.string.toast_error_login,Toast.LENGTH_LONG).show();
}
});
e.printStackTrace();
} catch (Exception e) {
runOnUiThread(new Runnable() {
public void run() {
@ -307,7 +296,6 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
Toast.makeText(getApplicationContext(),R.string.toast_error_login,Toast.LENGTH_LONG).show();
}
});
e.printStackTrace();
}
}
}).start();

View File

@ -439,7 +439,6 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}else if(requestCode == PICK_IMAGE_PROFILE && resultCode == Activity.RESULT_OK) {
if (data == null) {
@ -464,7 +463,6 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
profile_picture = "data:image/png;base64, " + Base64.encodeToString(byteArray, Base64.DEFAULT);
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}

View File

@ -180,11 +180,7 @@ public class InstanceHealthActivity extends AppCompatActivity {
}
});
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
}
}).start();
}

View File

@ -214,10 +214,8 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
} catch (HttpsConnection.HttpsConnectionException e) {
isLoadingInstance = false;
e.printStackTrace();
} catch (Exception e) {
isLoadingInstance = false;
e.printStackTrace();
}
}
}).start();

View File

@ -683,7 +683,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true);
e.printStackTrace();
}
} else {
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
@ -710,7 +709,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true);
e.printStackTrace();
}
}else if(requestCode == Helper.REQ_CODE_SPEECH_INPUT && resultCode == Activity.RESULT_OK){
if (null != data) {
@ -828,7 +826,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
@ -865,7 +862,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
}

View File

@ -131,14 +131,8 @@ public class WebviewConnectActivity extends AppCompatActivity {
editor.apply();
//Update the account with the token;
new UpdateAccountInfoAsyncTask(WebviewConnectActivity.this, token, instance).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
} catch (Exception ignored) {}
}}).start();
return true;
}

View File

@ -123,7 +123,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return apiResponse;
}
@ -149,7 +148,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return apiResponse;
}
@ -168,7 +166,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return account;
}
@ -188,7 +185,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return account;
}
@ -214,7 +210,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return relationship;
}
@ -248,7 +243,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setRelationships(relationships);
return apiResponse;
@ -338,7 +332,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -363,7 +356,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -385,7 +377,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return statusContext;
}
@ -439,7 +430,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -499,7 +489,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -549,7 +538,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -624,7 +612,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setAccounts(accounts);
return apiResponse;
@ -668,7 +655,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setAccounts(accounts);
return apiResponse;
@ -712,7 +698,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -821,7 +806,6 @@ public class API {
params.put("status", URLEncoder.encode(status.getContent(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
params.put("status", status.getContent());
e.printStackTrace();
}
if( status.getIn_reply_to_id() != null)
params.put("in_reply_to_id", status.getIn_reply_to_id());
@ -839,7 +823,6 @@ public class API {
params.put("spoiler_text", URLEncoder.encode(status.getSpoiler_text(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
params.put("spoiler_text", status.getSpoiler_text());
e.printStackTrace();
}
params.put("visibility", status.getVisibility());
break;
@ -856,7 +839,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
}else{
try {
@ -867,7 +849,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
}
return actionCode;
@ -886,7 +867,6 @@ public class API {
params.put("status", URLEncoder.encode(status.getContent(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
params.put("status", status.getContent());
e.printStackTrace();
}
if( status.getIn_reply_to_id() != null)
params.put("in_reply_to_id", status.getIn_reply_to_id());
@ -919,7 +899,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setStatuses(statuses);
return apiResponse;
@ -947,7 +926,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return apiResponse;
}
@ -1041,7 +1019,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setNotifications(notifications);
return apiResponse;
@ -1063,7 +1040,6 @@ public class API {
params.put("description", URLEncoder.encode(description, "UTF-8"));
} catch (UnsupportedEncodingException e) {
params.put("description", description);
e.printStackTrace();
}
try {
HttpsConnection httpsConnection = new HttpsConnection();
@ -1073,7 +1049,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return attachment;
}
@ -1096,7 +1071,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
return results;
}
@ -1127,7 +1101,6 @@ public class API {
setError(e.getStatusCode(), e);
}catch (Exception e) {
setDefaultError();
e.printStackTrace();
}
apiResponse.setAccounts(accounts);
return apiResponse;
@ -1152,7 +1125,7 @@ public class API {
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
}catch (Exception e) {
e.printStackTrace();
setDefaultError();
}
apiResponse.setEmojis(emojis);
return apiResponse;
@ -1172,7 +1145,6 @@ public class API {
results.setHashtags(parseTags(resobj.getJSONArray("hashtags")));
} catch (JSONException e) {
setDefaultError();
e.printStackTrace();
}
return results;
}
@ -1212,9 +1184,7 @@ public class API {
instanceSocial.setUsers(Long.parseLong(resobj.get("users").toString()));
instanceSocial.setStatuses(Long.parseLong(resobj.get("statuses").toString()));
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
return instanceSocial;
}
@ -1252,7 +1222,7 @@ public class API {
}
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return statuses;
}
@ -1365,9 +1335,7 @@ public class API {
try{
status.setReblog(parseStatuses(context, resobj.getJSONObject("reblog")));
}catch (Exception ignored){}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
return status;
}
@ -1386,7 +1354,7 @@ public class API {
instance.setEmail(resobj.get("email").toString());
instance.setVersion(resobj.get("version").toString());
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return instance;
}
@ -1409,7 +1377,7 @@ public class API {
i++;
}
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return emojis;
}
@ -1426,9 +1394,7 @@ public class API {
emojis.setShortcode(resobj.get("shortcode").toString());
emojis.setStatic_url(resobj.get("static_url").toString());
emojis.setUrl(resobj.get("url").toString());
}catch (Exception e){
e.printStackTrace();
}
}catch (Exception ignored){}
return emojis;
}
@ -1456,9 +1422,7 @@ public class API {
account.setAvatar_static(resobj.get("avatar_static").toString());
account.setHeader(resobj.get("header").toString());
account.setHeader_static(resobj.get("header_static").toString());
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
return account;
}
@ -1479,7 +1443,7 @@ public class API {
i++;
}
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return accounts;
}
@ -1501,7 +1465,7 @@ public class API {
relationship.setMuting(Boolean.valueOf(resobj.get("muting").toString()));
relationship.setRequested(Boolean.valueOf(resobj.get("requested").toString()));
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return relationship;
}
@ -1524,7 +1488,7 @@ public class API {
i++;
}
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return relationships;
}
@ -1541,7 +1505,7 @@ public class API {
context.setAncestors(parseStatuses(jsonObject.getJSONArray("ancestors")));
context.setDescendants(parseStatuses(jsonObject.getJSONArray("descendants")));
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return context;
}
@ -1571,9 +1535,7 @@ public class API {
attachment.setText_url(resobj.get("text_url").toString());
}catch (JSONException ignore){}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
return attachment;
}
@ -1596,9 +1558,7 @@ public class API {
notification.setStatus(parseStatuses(context, resobj.getJSONObject("status")));
}catch (Exception ignored){}
notification.setCreated_at(Helper.mstStringToDate(context, resobj.get("created_at").toString()));
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
return notification;
}
@ -1620,7 +1580,7 @@ public class API {
i++;
}
} catch (JSONException e) {
e.printStackTrace();
setDefaultError();
}
return notifications;
}

View File

@ -256,7 +256,6 @@ public class HttpsConnection {
error.setError(context.getString(R.string.toast_error));
if(httpsURLConnection != null)
httpsURLConnection.disconnect();
e.printStackTrace();
}
}
@ -292,11 +291,8 @@ public class HttpsConnection {
if (ous != null)
ous.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {}
byte[] pixels = ous.toByteArray();
int lengthSent = pixels.length;
@ -391,7 +387,6 @@ public class HttpsConnection {
listener.onRetrieveAttachment(attachment, null);
}});
}catch (Exception e) {
e.printStackTrace();
((TootActivity)context).runOnUiThread(new Runnable() {
public void run() {
listener.onUpdateProgress(101);
@ -585,11 +580,10 @@ public class HttpsConnection {
}
}
public int getActionCode() {
int getActionCode() {
try {
return httpsURLConnection.getResponseCode();
} catch (IOException e) {
e.printStackTrace();
return -1;
}
}

View File

@ -609,9 +609,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
b.putString("fileMention", fname);
b.putString("tootMention", (status.getReblog() != null)?status.getReblog().getAccount().getAcct():status.getAccount().getAcct());
b.putString("urlMention", (status.getReblog() != null)?status.getReblog().getUrl():status.getUrl());

View File

@ -1101,9 +1101,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
b.putString("fileMention", fname);
b.putString("tootMention", (status.getReblog() != null)?status.getReblog().getAccount().getAcct():status.getAccount().getAcct());
b.putString("urlMention", (status.getReblog() != null)?status.getReblog().getUrl():status.getUrl());

View File

@ -358,9 +358,7 @@ public class Helper {
emoji.put(str[0],unicode);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException ignored) {}
}
/***
@ -378,7 +376,6 @@ public class Helper {
InetAddress ipAddr = InetAddress.getByName(instance);
return !ipAddr.toString().equals("");
} catch (Exception e) {
e.printStackTrace();
return false;
}
} else {
@ -751,9 +748,7 @@ public class Helper {
Toast.makeText(context, R.string.toast_saved,Toast.LENGTH_LONG).show();
}
});
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
}
@ -1191,16 +1186,11 @@ public class Helper {
if( emojis != null && emojis.size() > 0 ) {
final int[] i = {0};
for (final Emojis emoji : emojis) {
Glide.with(context)
.asBitmap()
.load(emoji.getUrl())
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
return false;
@ -1479,9 +1469,7 @@ public class Helper {
}
return hexString.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
} catch (NoSuchAlgorithmException ignored) {}
return "";
}

View File

@ -211,17 +211,14 @@ public class LiveNotificationService extends IntentService {
try {
JSONObject eventJson = new JSONObject(event);
onRetrieveStreaming(eventStreaming, account, eventJson);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
}
}else {
httpsURLConnection.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
} catch (Exception ignored) {
}finally {
if (reader != null) {
try {
@ -240,7 +237,9 @@ public class LiveNotificationService extends IntentService {
SystemClock.sleep(5000);
Intent streamingIntent = new Intent(this, LiveNotificationService.class);
streamingIntent.putExtra("userId", account.getId());
startService(streamingIntent);
try {
startService(streamingIntent);
}catch (Exception ignored){}
}
}
}
@ -383,9 +382,7 @@ public class LiveNotificationService extends IntentService {
}else if( event == Helper.EventStreaming.DELETE){
try {
dataId = response.getString("id");
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
if( account != null)
b.putString("userIdService",account.getId());

View File

@ -132,19 +132,14 @@ public class StreamingFederatedTimelineService extends IntentService {
try {
JSONObject eventJson = new JSONObject(event);
onRetrieveStreaming(accountStream, eventJson);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
} catch (Exception e) {
e.printStackTrace();
} catch (Exception ignored) {
}finally {
if(reader != null){
try{
reader.close();
}catch (IOException e){
e.printStackTrace();
}
}catch (IOException ignored){}
}
if( sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + accountStream.getId(), true)) {
SystemClock.sleep(1000);

View File

@ -131,19 +131,14 @@ public class StreamingLocalTimelineService extends IntentService {
try {
JSONObject eventJson = new JSONObject(event);
onRetrieveStreaming(accountStream, eventJson);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
} catch (Exception e) {
e.printStackTrace();
} catch (Exception ignored) {
}finally {
if(reader != null){
try{
reader.close();
}catch (IOException e){
e.printStackTrace();
}
}catch (IOException ignored){}
}
if( sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + accountStream.getId(), true)) {
SystemClock.sleep(1000);

View File

@ -152,20 +152,15 @@ public class StreamingService extends IntentService {
try {
JSONObject eventJson = new JSONObject(event);
onRetrieveStreaming(eventStreaming, accountStream, eventJson);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
}
} catch (Exception e) {
e.printStackTrace();
} catch (Exception ignored) {
}finally {
if(reader != null){
try{
reader.close();
}catch (IOException e){
e.printStackTrace();
}
}catch (IOException ignored){}
}
SystemClock.sleep(1000);
sendBroadcast(new Intent("RestartStreamingService"));
@ -195,9 +190,7 @@ public class StreamingService extends IntentService {
try {
//noinspection UnusedAssignment
dataId = response.getString("id");
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException ignored) {}
}
if( account != null)
b.putString("userIdService",account.getId());