mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
invalidate sticky header cache only on screen orientation changes
This commit is contained in:
@@ -190,7 +190,7 @@ public class ContactSelectionListFragment extends Fragment
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
listDecoration.invalidateLayouts();
|
||||
listDecoration.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
private void handleSelectAll() {
|
||||
|
||||
@@ -219,7 +219,7 @@ public class ConversationFragment extends Fragment
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
dateDecoration.invalidateLayouts();
|
||||
dateDecoration.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void onNewIntent() {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
listDecoration.invalidateLayouts();
|
||||
listDecoration.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,7 +124,7 @@ public class SearchFragment extends Fragment implements SearchListAdapter.EventL
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (listDecoration != null) {
|
||||
listDecoration.invalidateLayouts();
|
||||
listDecoration.onConfigurationChanged(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build.VERSION;
|
||||
@@ -28,6 +29,7 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration {
|
||||
private final StickyHeaderAdapter adapter;
|
||||
private final boolean renderInline;
|
||||
private boolean sticky;
|
||||
private int screenOrientation;
|
||||
|
||||
/**
|
||||
* @param adapter the sticky header adapter to use
|
||||
@@ -163,13 +165,7 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration {
|
||||
}
|
||||
|
||||
private int getChildY(RecyclerView parent, View child) {
|
||||
if (VERSION.SDK_INT < 11) {
|
||||
Rect rect = new Rect();
|
||||
parent.getChildVisibleRect(child, rect, null);
|
||||
return rect.top;
|
||||
} else {
|
||||
return (int)ViewCompat.getY(child);
|
||||
}
|
||||
return (int) child.getY();
|
||||
}
|
||||
|
||||
protected int getHeaderHeightForLayout(View header) {
|
||||
@@ -181,6 +177,13 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration {
|
||||
((LinearLayoutManager)parent.getLayoutManager()).getReverseLayout();
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration configuration) {
|
||||
if (this.screenOrientation != configuration.orientation) {
|
||||
this.screenOrientation = configuration.orientation;
|
||||
invalidateLayouts();
|
||||
}
|
||||
}
|
||||
|
||||
public void invalidateLayouts() {
|
||||
headerCache.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user