Merge remote-tracking branch 'mastodon/master'

# Conflicts:
#	mastodon/build.gradle
#	mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java
This commit is contained in:
LucasGGamerM
2023-09-28 15:19:32 -03:00
7 changed files with 45 additions and 19 deletions

View File

@@ -361,7 +361,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
pager.setAdapter(new ProfilePagerAdapter());
pager.getLayoutParams().height=getResources().getDisplayMetrics().heightPixels;
pager.setVisibility(View.GONE); // Prevents a strange NPE when search is opened on the search tab. Shown in onShown()
scrollView.setScrollableChildSupplier(this::getScrollableRecyclerView);
scrollView.getViewTreeObserver().addOnGlobalLayoutListener(this::updateMetadataHeight);
@@ -756,7 +755,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
followingCount.setText(UiUtils.abbreviateNumber(account.followingCount));
followersLabel.setText(getResources().getQuantityString(R.plurals.followers, (int)Math.min(999, account.followersCount)));
followingLabel.setText(getResources().getQuantityString(R.plurals.following, (int)Math.min(999, account.followingCount)));
if (account.followersCount < 0) followersBtn.setVisibility(View.GONE);
if (account.followingCount < 0) followingBtn.setVisibility(View.GONE);
if (account.followersCount < 0 || account.followingCount < 0)
@@ -1425,19 +1424,11 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
return actionButton.getVisibility()==View.VISIBLE && actionButtonWrap.getTop()+actionButtonWrap.getHeight()>scrollView.getScrollY();
}
@Override
protected void onShown(){
super.onShown();
pager.setVisibility(View.VISIBLE);
}
private class ProfilePagerAdapter extends RecyclerView.Adapter<SimpleViewHolder>{
@NonNull
@Override
public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
FrameLayout view=tabViews[viewType];
if (view.getParent() != null) ((ViewGroup)view.getParent()).removeView(view);
view.setVisibility(View.VISIBLE);
FrameLayout view=new FrameLayout(parent.getContext());
view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return new SimpleViewHolder(view);
}
@@ -1445,8 +1436,13 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
@Override
public void onBindViewHolder(@NonNull SimpleViewHolder holder, int position){
Fragment fragment=getFragmentForPage(position);
FrameLayout fragmentView=tabViews[position];
fragmentView.setVisibility(View.VISIBLE);
if(fragmentView.getParent() instanceof ViewGroup parent)
parent.removeView(fragmentView);
((FrameLayout)holder.itemView).addView(fragmentView);
if(!fragment.isAdded()){
getChildFragmentManager().beginTransaction().add(holder.itemView.getId(), fragment).commit();
getChildFragmentManager().beginTransaction().add(fragmentView.getId(), fragment).commit();
holder.itemView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
@Override
public boolean onPreDraw(){

View File

@@ -119,6 +119,9 @@ public class ZoomPanView extends FrameLayout implements ScaleGestureDetector.OnS
int width=right-left;
int height=bottom-top;
if(width==0 || height==0)
return;
float scale=Math.min(width/(float)child.getWidth(), height/(float)child.getHeight());
minScale=scale;
maxScale=Math.max(3f, height/(float)child.getHeight());
@@ -306,8 +309,6 @@ public class ZoomPanView extends FrameLayout implements ScaleGestureDetector.OnS
}, 1f).setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_ALPHA));
}
}else{
if(animatingTransition)
Log.w(TAG, "updateViewTransform: ", new Throwable().fillInStackTrace());
child.setScaleX(matrixValues[Matrix.MSCALE_X]);
child.setScaleY(matrixValues[Matrix.MSCALE_Y]);
child.setTranslationX(matrixValues[Matrix.MTRANS_X]);

View File

@@ -15,7 +15,7 @@ public class MediaGridLayout extends ViewGroup{
private static final int GAP=2; // dp
private PhotoLayoutHelper.TiledLayoutResult tiledLayout;
private int[] columnStarts=new int[10], columnEnds=new int[10], rowStarts=new int[10], rowEnds=new int[10];
private int[] columnStarts, columnEnds, rowStarts, rowEnds;
public MediaGridLayout(Context context){
this(context, null);
@@ -41,6 +41,14 @@ public class MediaGridLayout extends ViewGroup{
width=Math.round(width*(tiledLayout.width/(float)PhotoLayoutHelper.MAX_WIDTH));
}
if(rowStarts==null || rowStarts.length<tiledLayout.rowSizes.length){
rowStarts=new int[tiledLayout.rowSizes.length];
rowEnds=new int[tiledLayout.rowSizes.length];
}
if(columnStarts==null || columnStarts.length<tiledLayout.columnSizes.length){
columnStarts=new int[tiledLayout.columnSizes.length];
columnEnds=new int[tiledLayout.columnSizes.length];
}
int offset=0;
for(int i=0;i<tiledLayout.columnSizes.length;i++){
columnStarts[i]=offset;
@@ -73,7 +81,7 @@ public class MediaGridLayout extends ViewGroup{
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b){
if(tiledLayout==null)
if(tiledLayout==null || rowStarts==null)
return;
int maxWidth=UiUtils.MAX_WIDTH;