summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2024-01-27 17:58:14 +0100
committerThomas <tschneider.ac@gmail.com>2024-01-27 17:58:14 +0100
commitbba6a2edf157fcf780ae7e0a96b6af2117804b1c (patch)
treea44e2345a454426c6ddcfba0406643fa42bb92d4
parent7c5f1dccabb1a96aa7ce3dc672807fb4719d4386 (diff)
Fix a crash with profiles
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java23
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java1
2 files changed, 21 insertions, 3 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java
index 870ea680f..06d6e1684 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java
@@ -14,8 +14,12 @@ package app.fedilab.android.mastodon.client.entities.app;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
+import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
+import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
+
import android.content.ContentValues;
import android.content.Context;
+import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
@@ -24,6 +28,8 @@ import android.os.Looper;
import android.os.Parcel;
import android.util.Base64;
+import androidx.preference.PreferenceManager;
+
import com.google.gson.annotations.SerializedName;
import java.io.BufferedOutputStream;
@@ -35,6 +41,7 @@ import java.util.Date;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
+import app.fedilab.android.MainApplication;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.exception.DBException;
@@ -206,9 +213,15 @@ public class CachedBundle {
if (db == null) {
throw new DBException("db is null. Wrong initialization.");
}
- if (account == null || target_id == null) {
+ if (target_id == null) {
return null;
}
+ if (account == null) {
+ account = new BaseAccount();
+ SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ account.user_id = sharedpreferences.getString(PREF_USER_ID, null);
+ account.instance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
+ }
try {
Cursor c = db.query(Sqlite.TABLE_INTENT, null, Sqlite.COL_USER_ID + " = '" + account.user_id + "' AND "
+ Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND "
@@ -235,9 +248,15 @@ public class CachedBundle {
if (db == null) {
throw new DBException("db is null. Wrong initialization.");
}
- if (account == null || target_id == null) {
+ if (target_id == null) {
return null;
}
+ if (account == null) {
+ account = new BaseAccount();
+ SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ account.user_id = sharedpreferences.getString(PREF_USER_ID, null);
+ account.instance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
+ }
try {
Cursor c = db.query(Sqlite.TABLE_INTENT, null, Sqlite.COL_USER_ID + " = '" + account.user_id + "' AND "
+ Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND "
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
index d5a340910..ece06dd4b 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
@@ -375,7 +375,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
binding.swipeContainer.setRefreshing(false);
binding.swipeContainer.setEnabled(false);
}
-
if (arguments != null) {
long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {