some fixes

This commit is contained in:
Thomas 2021-02-22 17:06:38 +01:00
parent 18e4250a66
commit 973ca53393
7 changed files with 149 additions and 95 deletions

View File

@ -311,7 +311,8 @@ public abstract class BaseMainActivity extends BaseActivity
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
try { try {
new RetrievePeertubeInformationAsyncTask(BaseMainActivity.this); new RetrievePeertubeInformationAsyncTask(BaseMainActivity.this);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} }
@ -441,26 +442,26 @@ public abstract class BaseMainActivity extends BaseActivity
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_home, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_home, R.attr.iconColorMenu);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconSub = pTabsub.getCustomView().findViewById(R.id.tab_icon); ImageView iconSub = pTabsub.getCustomView().findViewById(R.id.tab_icon);
iconSub.setImageResource(R.drawable.ic_subscriptions); iconSub.setImageResource(R.drawable.ic_subscriptions);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconOver = pTabOver.getCustomView().findViewById(R.id.tab_icon); ImageView iconOver = pTabOver.getCustomView().findViewById(R.id.tab_icon);
iconOver.setImageResource(R.drawable.ic_overview); iconOver.setImageResource(R.drawable.ic_overview);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconTrend = pTabTrend.getCustomView().findViewById(R.id.tab_icon); ImageView iconTrend = pTabTrend.getCustomView().findViewById(R.id.tab_icon);
iconTrend.setImageResource(R.drawable.ic_trending_up); iconTrend.setImageResource(R.drawable.ic_trending_up);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconAdded = pTabAdded.getCustomView().findViewById(R.id.tab_icon); ImageView iconAdded = pTabAdded.getCustomView().findViewById(R.id.tab_icon);
iconAdded.setImageResource(R.drawable.ic_recently_added); iconAdded.setImageResource(R.drawable.ic_recently_added);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconLocal = pTabLocal.getCustomView().findViewById(R.id.tab_icon); ImageView iconLocal = pTabLocal.getCustomView().findViewById(R.id.tab_icon);
iconLocal.setImageResource(R.drawable.ic_home); iconLocal.setImageResource(R.drawable.ic_home);
@ -542,18 +543,18 @@ public abstract class BaseMainActivity extends BaseActivity
//pfTabDiscover.setCustomView(R.layout.tab_badge); //pfTabDiscover.setCustomView(R.layout.tab_badge);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconHome = pfTabHome.getCustomView().findViewById(R.id.tab_icon); ImageView iconHome = pfTabHome.getCustomView().findViewById(R.id.tab_icon);
iconHome.setImageResource(R.drawable.ic_home); iconHome.setImageResource(R.drawable.ic_home);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconLocal = pfTabLocal.getCustomView().findViewById(R.id.tab_icon); ImageView iconLocal = pfTabLocal.getCustomView().findViewById(R.id.tab_icon);
iconLocal.setImageResource(R.drawable.ic_people); iconLocal.setImageResource(R.drawable.ic_people);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconNotif = pfTabNotification.getCustomView().findViewById(R.id.tab_icon); ImageView iconNotif = pfTabNotification.getCustomView().findViewById(R.id.tab_icon);
iconNotif.setImageResource(R.drawable.ic_notifications); iconNotif.setImageResource(R.drawable.ic_notifications);
@ -561,7 +562,7 @@ public abstract class BaseMainActivity extends BaseActivity
ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon); ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon);
iconDiscover.setImageResource(R.drawable.ic_people);*/ iconDiscover.setImageResource(R.drawable.ic_people);*/
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
ImageView iconStories = pfStories.getCustomView().findViewById(R.id.tab_icon); ImageView iconStories = pfStories.getCustomView().findViewById(R.id.tab_icon);
iconStories.setImageResource(R.drawable.ic_story); iconStories.setImageResource(R.drawable.ic_story);
@ -1262,7 +1263,8 @@ public abstract class BaseMainActivity extends BaseActivity
try { try {
Handler handler = new Handler(); Handler handler = new Handler();
handler.postDelayed(dialogBuilderOptin::show, 1000); handler.postDelayed(dialogBuilderOptin::show, 1000);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} else { } else {
@ -1312,9 +1314,11 @@ public abstract class BaseMainActivity extends BaseActivity
dialogBuilderOptin.show(); dialogBuilderOptin.show();
} }
}, 1000); }, 1000);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} catch (IOException ignored) { } catch (IOException e) {
e.printStackTrace();
} }
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.SET_POPUP_RELEASE_NOTES, versionCode); editor.putInt(Helper.SET_POPUP_RELEASE_NOTES, versionCode);
@ -1705,7 +1709,8 @@ public abstract class BaseMainActivity extends BaseActivity
} }
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(contextReference.get(), db).removeAll(); new TimelineCacheDAO(contextReference.get(), db).removeAll();
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
}); });
} }

View File

@ -159,7 +159,8 @@ public class InstanceProfileActivity extends BaseActivity {
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
}); });
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
}).start(); }).start();
} }

View File

@ -359,7 +359,8 @@ public class LoginActivity extends BaseActivity {
login_instance.showDropDown(); login_instance.showDropDown();
oldSearch = s.toString().trim(); oldSearch = s.toString().trim();
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
}); });
@ -454,8 +455,10 @@ public class LoginActivity extends BaseActivity {
try { try {
URL url = new URL(instanceFromField); URL url = new URL(instanceFromField);
host = url.getHost(); host = url.getHost();
} catch (MalformedURLException ignored) { } catch (MalformedURLException e) {
e.printStackTrace();
} }
try { try {
instance = URLEncoder.encode(host, "utf-8"); instance = URLEncoder.encode(host, "utf-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -571,7 +574,8 @@ public class LoginActivity extends BaseActivity {
} }
try { try {
instance = URLEncoder.encode(host, "utf-8"); instance = URLEncoder.encode(host, "utf-8");
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
String username = login_uid.getText().toString().trim().toLowerCase(); String username = login_uid.getText().toString().trim().toLowerCase();
String password = login_passwd.getText().toString(); String password = login_passwd.getText().toString();
@ -744,18 +748,10 @@ public class LoginActivity extends BaseActivity {
} }
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addCategory(Intent.CATEGORY_OPENABLE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { intent.setType("*/*");
intent.setType("*/*"); String[] mimetypes = {"*/*"};
String[] mimetypes = {"*/*"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); startActivityForResult(intent, PICK_IMPORT);
startActivityForResult(intent, PICK_IMPORT);
} else {
intent.setType("*/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_import));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
startActivityForResult(chooserIntent, PICK_IMPORT);
}
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -60,7 +60,7 @@ public class RetrieveNotificationsAsyncTask {
protected void doInBackground() { protected void doInBackground() {
new Thread(() -> { new Thread(() -> {
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) { if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
API api; API api;
if (account == null) { if (account == null) {
api = new API(this.contextReference.get()); api = new API(this.contextReference.get());
@ -73,7 +73,10 @@ public class RetrieveNotificationsAsyncTask {
api = new API(this.contextReference.get(), account.getInstance(), account.getToken()); api = new API(this.contextReference.get(), account.getInstance(), account.getToken());
apiResponse = api.getNotificationsSince(type, max_id, display); apiResponse = api.getNotificationsSince(type, max_id, display);
} }
} else { Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> listener.onRetrieveNotifications(apiResponse, account, refreshData);
mainHandler.post(myRunnable);
} else if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
GNUAPI gnuapi; GNUAPI gnuapi;
if (account == null) { if (account == null) {
gnuapi = new GNUAPI(this.contextReference.get()); gnuapi = new GNUAPI(this.contextReference.get());
@ -86,10 +89,11 @@ public class RetrieveNotificationsAsyncTask {
gnuapi = new GNUAPI(this.contextReference.get(), account.getInstance(), account.getToken()); gnuapi = new GNUAPI(this.contextReference.get(), account.getInstance(), account.getToken());
apiResponse = gnuapi.getNotificationsSince(type, max_id); apiResponse = gnuapi.getNotificationsSince(type, max_id);
} }
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> listener.onRetrieveNotifications(apiResponse, account, refreshData);
mainHandler.post(myRunnable);
} }
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> listener.onRetrieveNotifications(apiResponse, account, refreshData);
mainHandler.post(myRunnable);
}).start(); }).start();
} }
} }

View File

@ -807,7 +807,8 @@ public class API {
if (resobj.has("pleroma") && resobj.getJSONObject("pleroma").has("emoji_reactions")) { if (resobj.has("pleroma") && resobj.getJSONObject("pleroma").has("emoji_reactions")) {
try { try {
reactions = parseReaction(resobj.getJSONObject("pleroma").getJSONArray("emoji_reactions")); reactions = parseReaction(resobj.getJSONObject("pleroma").getJSONArray("emoji_reactions"));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} }
status.setReactions(reactions); status.setReactions(reactions);
@ -881,7 +882,8 @@ public class API {
Emojis emojis = parseEmojis(emojisObj); Emojis emojis = parseEmojis(emojisObj);
emojiList.add(emojis); emojiList.add(emojis);
} }
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} }
status.setEmojis(emojiList); status.setEmojis(emojiList);
@ -938,7 +940,8 @@ public class API {
if (recursive) { if (recursive) {
status.setReblog(parseStatuses(context, resobj.getJSONObject("reblog"), false)); status.setReblog(parseStatuses(context, resobj.getJSONObject("reblog"), false));
} }
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
if (resobj.has("poll") && !resobj.isNull("poll")) { if (resobj.has("poll") && !resobj.isNull("poll")) {
@ -976,7 +979,8 @@ public class API {
status.setVisibility("public"); status.setVisibility("public");
} }
status.setContent(context, resobj.getString("text")); status.setContent(context, resobj.getString("text"));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
return status; return status;
} }
@ -1089,7 +1093,8 @@ public class API {
resobj.getJSONObject("renoteId"); resobj.getJSONObject("renoteId");
if (!resobj.getJSONObject("renoteId").toString().equals("null")) if (!resobj.getJSONObject("renoteId").toString().equals("null"))
status.setReblog(parseStatuses(context, resobj.getJSONObject("renote"))); status.setReblog(parseStatuses(context, resobj.getJSONObject("renote")));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
status.setMentions(mentions); status.setMentions(mentions);
@ -1131,7 +1136,8 @@ public class API {
status.setApplication(application); status.setApplication(application);
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1156,7 +1162,8 @@ public class API {
} catch (Exception e) { } catch (Exception e) {
emojis.setVisible_in_picker(true); emojis.setVisible_in_picker(true);
} }
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
return emojis; return emojis;
} }
@ -1173,7 +1180,8 @@ public class API {
emojis.setShortcode(resobj.getString("name")); emojis.setShortcode(resobj.getString("name"));
emojis.setStatic_url(resobj.getString("url")); emojis.setStatic_url(resobj.getString("url"));
emojis.setUrl(resobj.getString("url")); emojis.setUrl(resobj.getString("url"));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
return emojis; return emojis;
} }
@ -1189,7 +1197,8 @@ public class API {
try { try {
list.setId(resobj.getString("id")); list.setId(resobj.getString("id"));
list.setTitle(resobj.getString("title")); list.setTitle(resobj.getString("title"));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
return list; return list;
} }
@ -1234,7 +1243,8 @@ public class API {
} else } else
account.setAvatar(null); account.setAvatar(null);
account.setAvatar_static(resobj.getString("avatar")); account.setAvatar_static(resobj.getString("avatar"));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1429,7 +1439,8 @@ public class API {
account.setAcct(resobj.getString("value")); account.setAcct(resobj.getString("value"));
account.setUrl(resobj.getString("url")); account.setUrl(resobj.getString("url"));
account.setStatuses_count(resobj.getJSONObject("entity").getInt("post_count")); account.setStatuses_count(resobj.getJSONObject("entity").getInt("post_count"));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
return account; return account;
} }
@ -1480,12 +1491,13 @@ public class API {
} catch (Exception e) { } catch (Exception e) {
account.setBot(false); account.setBot(false);
} }
account.setMoved_to_account(null);
try { try {
if (recursive) { if (recursive && resobj.has("moved")) {
account.setMoved_to_account(parseAccountResponse(resobj.getJSONObject("moved"), false)); account.setMoved_to_account(parseAccountResponse(resobj.getJSONObject("moved"), false));
} }
} catch (Exception ignored) { } catch (Exception e) {
account.setMoved_to_account(null); e.printStackTrace();
} }
account.setUrl(resobj.getString("url")); account.setUrl(resobj.getString("url"));
account.setAvatar(resobj.getString("avatar")); account.setAvatar(resobj.getString("avatar"));
@ -1503,7 +1515,8 @@ public class API {
try { try {
account.setModerator(resobj.getJSONObject("pleroma").getBoolean("is_moderator")); account.setModerator(resobj.getJSONObject("pleroma").getBoolean("is_moderator"));
account.setAdmin(resobj.getJSONObject("pleroma").getBoolean("is_admin")); account.setAdmin(resobj.getJSONObject("pleroma").getBoolean("is_admin"));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
account.setModerator(false); account.setModerator(false);
account.setAdmin(false); account.setAdmin(false);
} }
@ -1645,7 +1658,8 @@ public class API {
attachments.add(attachment); attachments.add(attachment);
i++; i++;
} }
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
return attachments; return attachments;
} }
@ -1730,7 +1744,8 @@ public class API {
if (attachment.getOrientation() != null && attachment.getOrientation().toLowerCase().compareTo("null") == 0) { if (attachment.getOrientation() != null && attachment.getOrientation().toLowerCase().compareTo("null") == 0) {
attachment.setOrientation(null); attachment.setOrientation(null);
} }
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
return attachment; return attachment;
} }
@ -1753,12 +1768,12 @@ public class API {
if (resobj.has("status")) { if (resobj.has("status")) {
try { try {
notification.setStatus(parseStatuses(context, resobj.getJSONObject("status"), false)); notification.setStatus(parseStatuses(context, resobj.getJSONObject("status"), false));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} }
notification.setCreated_at(Helper.mstStringToDate(resobj.getString("created_at"))); notification.setCreated_at(Helper.mstStringToDate(resobj.getString("created_at")));
} catch (JSONException ignored) { } catch (JSONException | ParseException e) {
} catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
return notification; return notification;
@ -1995,7 +2010,8 @@ public class API {
} else { } else {
try { try {
id = URLEncoder.encode(id, "UTF-8"); id = URLEncoder.encode(id, "UTF-8");
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
params = new HashMap<>(); params = new HashMap<>();
params.put("query", id); params.put("query", id);
@ -3899,7 +3915,8 @@ public class API {
newStatus.setArt_attachment(attachment); newStatus.setArt_attachment(attachment);
apiResponseReply.getStatuses().add(newStatus); apiResponseReply.getStatuses().add(newStatus);
} }
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} }
} }
@ -3978,7 +3995,8 @@ public class API {
for (String a : any) { for (String a : any) {
try { try {
a = URLEncoder.encode(a, "UTF-8"); a = URLEncoder.encode(a, "UTF-8");
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
parameters.append("any[]=").append(a).append("&"); parameters.append("any[]=").append(a).append("&");
} }
@ -3990,7 +4008,8 @@ public class API {
for (String a : all) { for (String a : all) {
try { try {
a = URLEncoder.encode(a, "UTF-8"); a = URLEncoder.encode(a, "UTF-8");
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
parameters.append("all[]=").append(a).append("&"); parameters.append("all[]=").append(a).append("&");
} }
@ -4002,7 +4021,8 @@ public class API {
for (String a : none) { for (String a : none) {
try { try {
a = URLEncoder.encode(a, "UTF-8"); a = URLEncoder.encode(a, "UTF-8");
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
parameters.append("none[]=").append(a).append("&"); parameters.append("none[]=").append(a).append("&");
} }
@ -4019,7 +4039,8 @@ public class API {
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
try { try {
query = URLEncoder.encode(query, "UTF-8"); query = URLEncoder.encode(query, "UTF-8");
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
String response; String response;
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) { if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
@ -4668,7 +4689,8 @@ public class API {
try { try {
Status status1 = parseStatuses(context, new JSONObject(resp)); Status status1 = parseStatuses(context, new JSONObject(resp));
b.putParcelable("status", status1); b.putParcelable("status", status1);
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
Intent intentBC = new Intent(Helper.RECEIVE_ACTION); Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
intentBC.putExtras(b); intentBC.putExtras(b);
@ -5830,7 +5852,8 @@ public class API {
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
try { try {
list.add(jsonArray.getJSONObject(i).getString("acct")); list.add(jsonArray.getJSONObject(i).getString("acct"));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
} }
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -5880,7 +5903,8 @@ public class API {
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
try { try {
list_tmp.add(jsonArray.getString(i)); list_tmp.add(jsonArray.getString(i));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
} }
return list_tmp; return list_tmp;
@ -5906,7 +5930,8 @@ public class API {
} else { } else {
list_tmp.add(jsonArray.getString(i)); list_tmp.add(jsonArray.getString(i));
} }
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
} }
return list_tmp; return list_tmp;
@ -6014,7 +6039,8 @@ public class API {
} }
} }
trend.setTrendsHistory(historyList); trend.setTrendsHistory(historyList);
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
return trend; return trend;
} }
@ -6057,7 +6083,8 @@ public class API {
conversation.setUnread(resobj.getBoolean("unread")); conversation.setUnread(resobj.getBoolean("unread"));
conversation.setAccounts(parseAccountResponse(resobj.getJSONArray("accounts"))); conversation.setAccounts(parseAccountResponse(resobj.getJSONArray("accounts")));
conversation.setLast_status(parseStatuses(context, resobj.getJSONObject("last_status"))); conversation.setLast_status(parseStatuses(context, resobj.getJSONObject("last_status")));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
return conversation; return conversation;
} }
@ -6271,7 +6298,8 @@ public class API {
filter.setContext(finalContext); filter.setContext(finalContext);
} }
return filter; return filter;
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
return null; return null;
} }

View File

@ -206,7 +206,8 @@ public class PeertubeAPI {
peertubeAccounFollowingNotification.setName(following.get("name").toString()); peertubeAccounFollowingNotification.setName(following.get("name").toString());
try { try {
peertubeAccounFollowingNotification.setId(following.get("id").toString()); peertubeAccounFollowingNotification.setId(following.get("id").toString());
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
if (following.has("avatar")) { if (following.has("avatar")) {
peertubeAccounFollowingNotification.setAvatar(following.getJSONObject("avatar").get("path").toString()); peertubeAccounFollowingNotification.setAvatar(following.getJSONObject("avatar").get("path").toString());
@ -251,16 +252,20 @@ public class PeertubeAPI {
peertube.setAccount(parseAccountResponsePeertube(resobj.getJSONObject("account"))); peertube.setAccount(parseAccountResponsePeertube(resobj.getJSONObject("account")));
try { try {
peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel"))); peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel")));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
peertube.setView(Integer.parseInt(resobj.get("views").toString())); peertube.setView(Integer.parseInt(resobj.get("views").toString()));
peertube.setLike(Integer.parseInt(resobj.get("likes").toString())); peertube.setLike(Integer.parseInt(resobj.get("likes").toString()));
peertube.setDislike(Integer.parseInt(resobj.get("dislikes").toString())); peertube.setDislike(Integer.parseInt(resobj.get("dislikes").toString()));
peertube.setDuration(Integer.parseInt(resobj.get("duration").toString())); peertube.setDuration(Integer.parseInt(resobj.get("duration").toString()));
peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString())); peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString()));
try { if (resobj.has("commentsEnabled")) {
peertube.setCommentsEnabled(Boolean.parseBoolean(resobj.get("commentsEnabled").toString())); try {
} catch (Exception ignored) { peertube.setCommentsEnabled(Boolean.parseBoolean(resobj.get("commentsEnabled").toString()));
} catch (Exception e) {
e.printStackTrace();
}
} }
try { try {
@ -274,16 +279,25 @@ public class PeertubeAPI {
LinkedHashMap<Integer, String> category = new LinkedHashMap<>(); LinkedHashMap<Integer, String> category = new LinkedHashMap<>();
LinkedHashMap<Integer, String> license = new LinkedHashMap<>(); LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>(); LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>();
category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").get("label").toString()); if (!resobj.getJSONObject("category").isNull("id") && !resobj.getJSONObject("category").isNull("label")) {
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").get("label").toString()); category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").get("label").toString());
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").get("label").toString()); }
langue.put(resobj.getJSONObject("language").get("id").toString(), resobj.getJSONObject("language").get("label").toString()); if (!resobj.getJSONObject("licence").isNull("id") && !resobj.getJSONObject("licence").isNull("label")) {
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").get("label").toString());
}
if (!resobj.getJSONObject("privacy").isNull("id") && !resobj.getJSONObject("privacy").isNull("label")) {
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").get("label").toString());
}
if (!resobj.getJSONObject("privacy").isNull("id") && !resobj.getJSONObject("privacy").isNull("label")) {
langue.put(resobj.getJSONObject("privacy").get("id").toString(), resobj.getJSONObject("privacy").get("label").toString());
}
peertube.setCategory(category); peertube.setCategory(category);
peertube.setLicense(license); peertube.setLicense(license);
peertube.setLanguage(langue); peertube.setLanguage(langue);
peertube.setPrivacy(privacy); peertube.setPrivacy(privacy);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
@ -325,11 +339,13 @@ public class PeertubeAPI {
tags.add(value); tags.add(value);
} }
peertube.setTags(tags); peertube.setTags(tags);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
try { try {
peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel"))); peertube.setChannel(parseAccountResponsePeertube(resobj.getJSONObject("channel")));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString())); peertube.setSensitive(Boolean.parseBoolean(resobj.get("nsfw").toString()));
try { try {
@ -376,7 +392,8 @@ public class PeertubeAPI {
peertube.setLicense(license); peertube.setLicense(license);
peertube.setLanguage(langue); peertube.setLanguage(langue);
peertube.setPrivacy(privacy); peertube.setPrivacy(privacy);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
peertube.setResolution(resolutions); peertube.setResolution(resolutions);
} catch (JSONException e) { } catch (JSONException e) {
@ -413,13 +430,16 @@ public class PeertubeAPI {
type.put(resobj.getJSONObject("type").getInt("id"), resobj.getJSONObject("type").get("label").toString()); type.put(resobj.getJSONObject("type").getInt("id"), resobj.getJSONObject("type").get("label").toString());
playlist.setType(type); playlist.setType(type);
playlist.setPrivacy(privacy); playlist.setPrivacy(privacy);
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
try { try {
playlist.setUpdatedAt(Helper.stringToDate(context, resobj.getString("updatedAt"))); playlist.setUpdatedAt(Helper.stringToDate(context, resobj.getString("updatedAt")));
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
} catch (Exception ignored) { } catch (Exception e) {
e.printStackTrace();
} }
return playlist; return playlist;
} }
@ -583,7 +603,8 @@ public class PeertubeAPI {
String key = iter.next(); String key = iter.next();
try { try {
_languages.put(key, (String) languages.get(key)); _languages.put(key, (String) languages.get(key));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
} }
peertubeInformation.setLanguages(_languages); peertubeInformation.setLanguages(_languages);
@ -631,7 +652,8 @@ public class PeertubeAPI {
String key = itertrans.next(); String key = itertrans.next();
try { try {
_translations.put(key, (String) translations.get(key)); _translations.put(key, (String) translations.get(key));
} catch (JSONException ignored) { } catch (JSONException e) {
e.printStackTrace();
} }
} }
peertubeInformation.setTranslations(_translations); peertubeInformation.setTranslations(_translations);

View File

@ -32,7 +32,6 @@ import app.fedilab.android.helper.Helper;
import app.fedilab.android.sqlite.AccountDAO; import app.fedilab.android.sqlite.AccountDAO;
import app.fedilab.android.sqlite.Sqlite; import app.fedilab.android.sqlite.Sqlite;
@SuppressWarnings("unused")
public class PixelfedAPI { public class PixelfedAPI {
@ -42,7 +41,6 @@ public class PixelfedAPI {
private String prefKeyOauthTokenT; private String prefKeyOauthTokenT;
private APIResponse apiResponse; private APIResponse apiResponse;
private Error APIError; private Error APIError;
private int actionCode;
public PixelfedAPI(Context context) { public PixelfedAPI(Context context) {
this.context = context; this.context = context;
@ -114,8 +112,8 @@ public class PixelfedAPI {
pixelFedStory.setSeen(false); pixelFedStory.setSeen(false);
} }
pixelFedStory.setPixelFedStoryItems(parseStoryItems(jsonObject.getJSONArray("items"))); pixelFedStory.setPixelFedStoryItems(parseStoryItems(jsonObject.getJSONArray("items")));
} catch (JSONException ignored) { } catch (JSONException e) {
ignored.printStackTrace(); e.printStackTrace();
} }
return pixelFedStory; return pixelFedStory;
} }
@ -163,13 +161,13 @@ public class PixelfedAPI {
pixelFedStoryItem.setTime(new Date(jsonObject.getLong("time"))); pixelFedStoryItem.setTime(new Date(jsonObject.getLong("time")));
pixelFedStoryItem.setExpires_at(new Date(jsonObject.getLong("expires_at"))); pixelFedStoryItem.setExpires_at(new Date(jsonObject.getLong("expires_at")));
pixelFedStoryItem.setSeen(jsonObject.getBoolean("seen")); pixelFedStoryItem.setSeen(jsonObject.getBoolean("seen"));
} catch (JSONException ignored) { } catch (JSONException e) {
ignored.printStackTrace(); e.printStackTrace();
} }
return pixelFedStoryItem; return pixelFedStoryItem;
} }
/** /*
* Retrieves Pixelfed Own Stories *synchronously* * Retrieves Pixelfed Own Stories *synchronously*
* *
* @return APIResponse * @return APIResponse
@ -340,8 +338,8 @@ public class PixelfedAPI {
String errorM = jsonObject.get("error").toString(); String errorM = jsonObject.get("error").toString();
message = "Error " + statusCode + " : " + errorM; message = "Error " + statusCode + " : " + errorM;
} catch (JSONException e) { } catch (JSONException e) {
if (error.getMessage().split(".").length > 0) { if (error.getMessage().split("\\.").length > 0) {
String errorM = error.getMessage().split(".")[0]; String errorM = error.getMessage().split("\\.")[0];
message = "Error " + statusCode + " : " + errorM; message = "Error " + statusCode + " : " + errorM;
} }
} }