Show "in reply to" and add a custom emoji helper
This commit is contained in:
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.model.Account;
|
||||
import org.joinmastodon.android.model.DisplayItemsParent;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
import org.joinmastodon.android.ui.displayitems.FooterStatusDisplayItem;
|
||||
@@ -22,6 +23,7 @@ import org.joinmastodon.android.ui.photoviewer.PhotoViewer;
|
||||
import org.joinmastodon.android.ui.photoviewer.PhotoViewerHost;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -40,6 +42,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
protected DisplayItemsAdapter adapter;
|
||||
protected String accountID;
|
||||
protected PhotoViewer currentPhotoViewer;
|
||||
protected HashMap<String, Account> knownAccounts=new HashMap<>();
|
||||
|
||||
public BaseStatusListFragment(){
|
||||
super(20);
|
||||
@@ -59,6 +62,9 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
@Override
|
||||
public void onAppendItems(List<T> items){
|
||||
super.onAppendItems(items);
|
||||
for(T s:items){
|
||||
addAccountToKnown(s);
|
||||
}
|
||||
for(T s:items){
|
||||
displayItems.addAll(buildDisplayItems(s));
|
||||
}
|
||||
@@ -73,6 +79,9 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
protected void prependItems(List<T> items){
|
||||
data.addAll(0, items);
|
||||
int offset=0;
|
||||
for(T s:items){
|
||||
addAccountToKnown(s);
|
||||
}
|
||||
for(T s:items){
|
||||
List<StatusDisplayItem> toAdd=buildDisplayItems(s);
|
||||
displayItems.addAll(offset, toAdd);
|
||||
@@ -91,6 +100,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
}
|
||||
|
||||
protected abstract List<StatusDisplayItem> buildDisplayItems(T s);
|
||||
protected abstract void addAccountToKnown(T s);
|
||||
|
||||
@Override
|
||||
protected void onHidden(){
|
||||
@@ -324,5 +334,15 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
public ImageLoaderRequest getImageRequest(int position, int image){
|
||||
return displayItems.get(position).getImageRequest(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(@NonNull BindableViewHolder<StatusDisplayItem> holder){
|
||||
if(holder instanceof ImageLoaderViewHolder){
|
||||
int count=holder.getItem().getImageCount();
|
||||
for(int i=0;i<count;i++){
|
||||
((ImageLoaderViewHolder) holder).clearImage(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class NotificationsFragment extends BaseStatusListFragment<Notification>{
|
||||
case FAVORITE -> getString(R.string.user_favorited, n.account.displayName);
|
||||
case POLL -> getString(R.string.poll_ended);
|
||||
case STATUS -> getString(R.string.user_posted, n.account.displayName);
|
||||
});
|
||||
}, n.account.emojis, R.drawable.ic_fluent_arrow_reply_20_filled);
|
||||
if(n.status!=null){
|
||||
ArrayList<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, n.status, accountID, n);
|
||||
ArrayList<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts);
|
||||
items.add(0, titleItem);
|
||||
return items;
|
||||
}else{
|
||||
@@ -41,6 +41,14 @@ public class NotificationsFragment extends BaseStatusListFragment<Notification>{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAccountToKnown(Notification s){
|
||||
if(!knownAccounts.containsKey(s.account.id))
|
||||
knownAccounts.put(s.account.id, s.account);
|
||||
if(s.status!=null && !knownAccounts.containsKey(s.status.account.id))
|
||||
knownAccounts.put(s.status.account.id, s.status.account);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLoadData(int offset, int count){
|
||||
new GetNotifications(offset>0 ? getMaxID() : null, count)
|
||||
|
||||
@@ -16,7 +16,13 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
|
||||
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
||||
return StatusDisplayItem.buildItems(this, s, accountID, s);
|
||||
return StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAccountToKnown(Status s){
|
||||
if(!knownAccounts.containsKey(s.account.id))
|
||||
knownAccounts.put(s.account.id, s.account);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user