summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortom79 <tschneider.ac@gmail.com>2020-04-16 12:22:48 +0200
committertom79 <tschneider.ac@gmail.com>2020-04-16 12:22:48 +0200
commit255834256104be51f9155a2ca0178c122ce08b61 (patch)
treeef2ab2110d14e5b6066f9f637579092a4d072ea8
parent142e601e71f133266eed24b406a1683ad387dc98 (diff)
Fix some crashes
-rw-r--r--app/src/main/java/app/fedilab/android/activities/AboutActivity.java36
-rw-r--r--app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java2
-rw-r--r--app/src/main/java/app/fedilab/android/drawers/NotificationsListAdapter.java44
-rw-r--r--app/src/main/java/app/fedilab/android/drawers/ReactionAdapter.java4
-rw-r--r--app/src/main/java/app/fedilab/android/helper/Helper.java2
-rw-r--r--app/src/main/java/app/fedilab/android/sqlite/TimelineCacheDAO.java5
6 files changed, 52 insertions, 41 deletions
diff --git a/app/src/main/java/app/fedilab/android/activities/AboutActivity.java b/app/src/main/java/app/fedilab/android/activities/AboutActivity.java
index 1b175403c..1d56b6ad7 100644
--- a/app/src/main/java/app/fedilab/android/activities/AboutActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/AboutActivity.java
@@ -305,25 +305,27 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
if (error != null) {
return;
}
- for (int i = 0; i < developers.size(); i++) {
- if (developers.get(i).getId() != null && developers.get(i).getId().equals(relationship.getId())) {
- developers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
- accountSearchWebAdapterDeveloper.notifyDataSetChanged();
- break;
+ if (relationship != null) {
+ for (int i = 0; i < developers.size(); i++) {
+ if (developers.get(i).getId() != null && developers.get(i).getId().equals(relationship.getId())) {
+ developers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
+ accountSearchWebAdapterDeveloper.notifyDataSetChanged();
+ break;
+ }
}
- }
- for (int i = 0; i < contributors.size(); i++) {
- if (contributors.get(i).getId() != null && contributors.get(i).getId().equals(relationship.getId())) {
- contributors.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
- accountSearchWebAdapterContributors.notifyDataSetChanged();
- break;
+ for (int i = 0; i < contributors.size(); i++) {
+ if (contributors.get(i).getId() != null && contributors.get(i).getId().equals(relationship.getId())) {
+ contributors.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
+ accountSearchWebAdapterContributors.notifyDataSetChanged();
+ break;
+ }
}
- }
- for (int i = 0; i < uxuidesigners.size(); i++) {
- if (uxuidesigners.get(i).getId() != null && uxuidesigners.get(i).getId().equals(relationship.getId())) {
- uxuidesigners.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
- accountSearchWebAdapterUxUiDesigners.notifyDataSetChanged();
- break;
+ for (int i = 0; i < uxuidesigners.size(); i++) {
+ if (uxuidesigners.get(i).getId() != null && uxuidesigners.get(i).getId().equals(relationship.getId())) {
+ uxuidesigners.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
+ accountSearchWebAdapterUxUiDesigners.notifyDataSetChanged();
+ break;
+ }
}
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
index cda080777..1fd81f6fb 100644
--- a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
@@ -2047,7 +2047,7 @@ public abstract class BaseMainActivity extends BaseActivity
@Override
public void onRetrieveRelationship(Relationship relationship, Error error) {
if (dialogReleaseNoteView != null && developers != null && developers.size() > 0) {
- if (!relationship.isFollowing()) {
+ if (relationship != null && !relationship.isFollowing()) {
TextView dev_follow_title = dialogReleaseNoteView.findViewById(R.id.dev_follow_title);
if (dev_follow_title != null) {
dev_follow_title.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/app/fedilab/android/drawers/NotificationsListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/NotificationsListAdapter.java
index f87383615..8aec4ae91 100644
--- a/app/src/main/java/app/fedilab/android/drawers/NotificationsListAdapter.java
+++ b/app/src/main/java/app/fedilab/android/drawers/NotificationsListAdapter.java
@@ -532,28 +532,30 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.rated.removeAllViews();
List<Integer> ownvotes = poll.getOwn_votes();
int j = 0;
- for (PollOptions pollOption : poll.getOptionsList()) {
- View item = inflater.inflate(R.layout.layout_poll_item, new LinearLayout(context), false);
- double value = ((double) (pollOption.getVotes_count() * 100) / (double) poll.getVoters_count());
- TextView poll_item_percent = item.findViewById(R.id.poll_item_percent);
- TextView poll_item_text = item.findViewById(R.id.poll_item_text);
- ProgressBar poll_item_value = item.findViewById(R.id.poll_item_value);
- poll_item_percent.setText(String.format("%s %%", String.valueOf((int) value)));
- poll_item_text.setText(pollOption.getTitle(), TextView.BufferType.SPANNABLE);
- poll_item_value.setProgress((int) value);
- holder.rated.addView(item);
- if (pollOption.getVotes_count() == greaterValue) {
- poll_item_percent.setTypeface(null, Typeface.BOLD);
- poll_item_text.setTypeface(null, Typeface.BOLD);
- }
- if (ownvotes.contains(j)) {
- Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_check_poll);
- assert img != null;
- img.setColorFilter(ContextCompat.getColor(context, R.color.cyanea_accent_reference), PorterDuff.Mode.SRC_IN);
- img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f));
- poll_item_text.setCompoundDrawables(null, null, img, null);
+ if ( poll.getOptionsList() != null) {
+ for (PollOptions pollOption : poll.getOptionsList()) {
+ View item = inflater.inflate(R.layout.layout_poll_item, new LinearLayout(context), false);
+ double value = ((double) (pollOption.getVotes_count() * 100) / (double) poll.getVoters_count());
+ TextView poll_item_percent = item.findViewById(R.id.poll_item_percent);
+ TextView poll_item_text = item.findViewById(R.id.poll_item_text);
+ ProgressBar poll_item_value = item.findViewById(R.id.poll_item_value);
+ poll_item_percent.setText(String.format("%s %%", String.valueOf((int) value)));
+ poll_item_text.setText(pollOption.getTitle(), TextView.BufferType.SPANNABLE);
+ poll_item_value.setProgress((int) value);
+ holder.rated.addView(item);
+ if (pollOption.getVotes_count() == greaterValue) {
+ poll_item_percent.setTypeface(null, Typeface.BOLD);
+ poll_item_text.setTypeface(null, Typeface.BOLD);
+ }
+ if (ownvotes != null && ownvotes.contains(j)) {
+ Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_check_poll);
+ assert img != null;
+ img.setColorFilter(ContextCompat.getColor(context, R.color.cyanea_accent_reference), PorterDuff.Mode.SRC_IN);
+ img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f));
+ poll_item_text.setCompoundDrawables(null, null, img, null);
+ }
+ j++;
}
- j++;
}
} else {
if (poll.isMultiple()) {
diff --git a/app/src/main/java/app/fedilab/android/drawers/ReactionAdapter.java b/app/src/main/java/app/fedilab/android/drawers/ReactionAdapter.java
index e011d23b4..c42ad2cc9 100644
--- a/app/src/main/java/app/fedilab/android/drawers/ReactionAdapter.java
+++ b/app/src/main/java/app/fedilab/android/drawers/ReactionAdapter.java
@@ -27,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
+import java.util.ArrayList;
import java.util.List;
import app.fedilab.android.R;
@@ -44,6 +45,9 @@ public class ReactionAdapter extends RecyclerView.Adapter {
ReactionAdapter(List<Reaction> reactions) {
this.reactions = reactions;
+ if( reactions == null){
+ this.reactions = new ArrayList<>();
+ }
}
@NonNull
diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java
index ee5e6fb8a..4eb32d700 100644
--- a/app/src/main/java/app/fedilab/android/helper/Helper.java
+++ b/app/src/main/java/app/fedilab/android/helper/Helper.java
@@ -1054,7 +1054,7 @@ public class Helper {
DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
assert dm != null;
return dm.enqueue(request);
- } catch (IllegalStateException e) {
+ } catch (Exception e) {
Toasty.error(context, context.getString(R.string.error_destination_path), Toast.LENGTH_LONG).show();
e.printStackTrace();
return -1;
diff --git a/app/src/main/java/app/fedilab/android/sqlite/TimelineCacheDAO.java b/app/src/main/java/app/fedilab/android/sqlite/TimelineCacheDAO.java
index fd06b6952..b4301bd4b 100644
--- a/app/src/main/java/app/fedilab/android/sqlite/TimelineCacheDAO.java
+++ b/app/src/main/java/app/fedilab/android/sqlite/TimelineCacheDAO.java
@@ -98,7 +98,10 @@ public class TimelineCacheDAO {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = Helper.getLiveInstance(context);
- return db.delete(Sqlite.TABLE_TIMELINE_CACHE, Sqlite.COL_STATUS_ID + " = \"" + statusId + "\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId + "\"", null);
+ try {
+ return db.delete(Sqlite.TABLE_TIMELINE_CACHE, Sqlite.COL_STATUS_ID + " = \"" + statusId + "\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId + "\"", null);
+ }catch (Exception ignored){}
+ return -1;
}