refactor: move fake attachment to attachment class
This commit is contained in:
parent
f482b4bfe9
commit
cb3b893f72
|
@ -365,23 +365,11 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||||
Drawable drawable=cover.getDrawable();
|
Drawable drawable=cover.getDrawable();
|
||||||
if(drawable==null || drawable instanceof ColorDrawable)
|
if(drawable==null || drawable instanceof ColorDrawable)
|
||||||
return;
|
return;
|
||||||
new PhotoViewer(getActivity(), createFakeAttachments(instance.thumbnail, drawable), 0,
|
new PhotoViewer(getActivity(), Attachment.createFakeAttachments(instance.thumbnail, drawable), 0,
|
||||||
new SingleImagePhotoViewerListener(cover, cover, null, this, () -> {
|
new SingleImagePhotoViewerListener(cover, cover, null, this, () -> {
|
||||||
}, () -> drawable, null, null));
|
}, () -> drawable, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Attachment> createFakeAttachments(String url, Drawable drawable){
|
|
||||||
Attachment att=new Attachment();
|
|
||||||
att.type=Attachment.Type.IMAGE;
|
|
||||||
att.url=url;
|
|
||||||
att.meta=new Attachment.Metadata();
|
|
||||||
att.meta.width=drawable.getIntrinsicWidth();
|
|
||||||
att.meta.height=drawable.getIntrinsicHeight();
|
|
||||||
return Collections.singletonList(att);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setFields(ArrayList<AccountField> fields){
|
public void setFields(ArrayList<AccountField> fields){
|
||||||
metadataListData=fields;
|
metadataListData=fields;
|
||||||
if (adapter != null) adapter.notifyDataSetChanged();
|
if (adapter != null) adapter.notifyDataSetChanged();
|
||||||
|
@ -400,11 +388,7 @@ public class InstanceInfoFragment extends LoaderFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(BaseViewHolder holder, int position){
|
public void onBindViewHolder(BaseViewHolder holder, int position){
|
||||||
if(position<metadataListData.size()){
|
holder.bind(metadataListData.get(position));
|
||||||
holder.bind(metadataListData.get(position));
|
|
||||||
}else{
|
|
||||||
holder.bind(null);
|
|
||||||
}
|
|
||||||
super.onBindViewHolder(holder, position);
|
super.onBindViewHolder(holder, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1143,16 +1143,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Attachment> createFakeAttachments(String url, Drawable drawable){
|
|
||||||
Attachment att=new Attachment();
|
|
||||||
att.type=Attachment.Type.IMAGE;
|
|
||||||
att.url=url;
|
|
||||||
att.meta=new Attachment.Metadata();
|
|
||||||
att.meta.width=drawable.getIntrinsicWidth();
|
|
||||||
att.meta.height=drawable.getIntrinsicHeight();
|
|
||||||
return Collections.singletonList(att);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onNotifyButtonClick(View v) {
|
private void onNotifyButtonClick(View v) {
|
||||||
UiUtils.performToggleAccountNotifications(getActivity(), account, accountID, relationship, actionButton, this::setNotifyProgressVisible, this::updateRelationship);
|
UiUtils.performToggleAccountNotifications(getActivity(), account, accountID, relationship, actionButton, this::setNotifyProgressVisible, this::updateRelationship);
|
||||||
}
|
}
|
||||||
|
@ -1165,7 +1155,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
if(ava==null)
|
if(ava==null)
|
||||||
return;
|
return;
|
||||||
int radius=V.dp(25);
|
int radius=V.dp(25);
|
||||||
currentPhotoViewer=new PhotoViewer(getActivity(), createFakeAttachments(account.avatar, ava), 0,
|
currentPhotoViewer=new PhotoViewer(getActivity(), Attachment.createFakeAttachments(account.avatar, ava), 0,
|
||||||
new SingleImagePhotoViewerListener(avatar, avatarBorder, new int[]{radius, radius, radius, radius}, this, ()->currentPhotoViewer=null, ()->ava, null, null));
|
new SingleImagePhotoViewerListener(avatar, avatarBorder, new int[]{radius, radius, radius, radius}, this, ()->currentPhotoViewer=null, ()->ava, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1167,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
Drawable drawable=cover.getDrawable();
|
Drawable drawable=cover.getDrawable();
|
||||||
if(drawable==null || drawable instanceof ColorDrawable)
|
if(drawable==null || drawable instanceof ColorDrawable)
|
||||||
return;
|
return;
|
||||||
currentPhotoViewer=new PhotoViewer(getActivity(), createFakeAttachments(account.header, drawable), 0,
|
currentPhotoViewer=new PhotoViewer(getActivity(), Attachment.createFakeAttachments(account.header, drawable), 0,
|
||||||
new SingleImagePhotoViewerListener(cover, cover, null, this, ()->currentPhotoViewer=null, ()->drawable, ()->avatarBorder.setTranslationZ(2), ()->avatarBorder.setTranslationZ(0)));
|
new SingleImagePhotoViewerListener(cover, cover, null, this, ()->currentPhotoViewer=null, ()->drawable, ()->avatarBorder.setTranslationZ(2), ()->avatarBorder.setTranslationZ(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import org.parceler.Parcel;
|
||||||
import org.parceler.ParcelConstructor;
|
import org.parceler.ParcelConstructor;
|
||||||
import org.parceler.ParcelProperty;
|
import org.parceler.ParcelProperty;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Parcel
|
@Parcel
|
||||||
|
@ -44,6 +46,16 @@ public class Attachment extends BaseModel{
|
||||||
blurhashPlaceholder=new BlurHashDrawable(placeholder, getWidth(), getHeight());
|
blurhashPlaceholder=new BlurHashDrawable(placeholder, getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static List<Attachment> createFakeAttachments(String url, Drawable drawable){
|
||||||
|
Attachment att=new Attachment();
|
||||||
|
att.type=Attachment.Type.IMAGE;
|
||||||
|
att.url=url;
|
||||||
|
att.meta=new Attachment.Metadata();
|
||||||
|
att.meta.width=drawable.getIntrinsicWidth();
|
||||||
|
att.meta.height=drawable.getIntrinsicHeight();
|
||||||
|
return Collections.singletonList(att);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getWidth(){
|
public int getWidth(){
|
||||||
if(meta==null)
|
if(meta==null)
|
||||||
|
|
Loading…
Reference in New Issue