diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java index 68aecec3..d9f093e8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java @@ -144,7 +144,7 @@ public class NotificationsListFragment extends BaseStatusListFragment{ return; Bundle args=new Bundle(); args.putString("account", accountID); - args.putParcelable("status", Parcels.wrap(status)); + args.putParcelable("status", Parcels.wrap(status.clone())); if(status.inReplyToAccountId!=null && knownAccounts.containsKey(status.inReplyToAccountId)) args.putParcelable("inReplyToAccount", Parcels.wrap(knownAccounts.get(status.inReplyToAccountId))); Nav.go(getActivity(), ThreadFragment.class, args); diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/BaseModel.java b/mastodon/src/main/java/org/joinmastodon/android/model/BaseModel.java index e68026c9..b2ec8898 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/BaseModel.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/BaseModel.java @@ -8,8 +8,9 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import androidx.annotation.CallSuper; +import androidx.annotation.NonNull; -public abstract class BaseModel{ +public abstract class BaseModel implements Cloneable{ @CallSuper public void postprocess() throws ObjectValidationException{ try{ @@ -23,4 +24,14 @@ public abstract class BaseModel{ } }catch(IllegalAccessException ignore){} } + + @NonNull + @Override + public Object clone(){ + try{ + return super.clone(); + }catch(CloneNotSupportedException x){ + throw new RuntimeException(x); + } + } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/PushSubscription.java b/mastodon/src/main/java/org/joinmastodon/android/model/PushSubscription.java index 82b6b62a..fd0cc2a1 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/PushSubscription.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/PushSubscription.java @@ -30,10 +30,7 @@ public class PushSubscription extends BaseModel implements Cloneable{ @NonNull @Override public PushSubscription clone(){ - PushSubscription copy=null; - try{ - copy=(PushSubscription) super.clone(); - }catch(CloneNotSupportedException ignore){} + PushSubscription copy=(PushSubscription) super.clone(); copy.alerts=alerts.clone(); return copy; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java index 8bc1c03c..3b36ef89 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java @@ -9,6 +9,8 @@ import org.parceler.Parcel; import java.time.Instant; import java.util.List; +import androidx.annotation.NonNull; + @Parcel public class Status extends BaseModel implements DisplayItemsParent{ @RequiredField @@ -176,4 +178,12 @@ public class Status extends BaseModel implements DisplayItemsParent{ strippedText=HtmlParser.strip(content); return strippedText; } + + @NonNull + @Override + public Status clone(){ + Status copy=(Status) super.clone(); + copy.spoilerRevealed=false; + return copy; + } }