mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 02:37:46 +00:00
Fix search header rendering after rotation.
The sticky header cache was keeping views across rotations, causing them to render incorrectly afterwards. I added a method to invalidate the header layouts after rotation. Fixes #7890.
This commit is contained in:
parent
44f5cc9070
commit
626e6930a5
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.search;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -11,7 +12,6 @@ import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -41,8 +41,9 @@ public class SearchFragment extends Fragment implements SearchListAdapter.EventL
|
||||
public static final String TAG = "SearchFragment";
|
||||
public static final String EXTRA_LOCALE = "locale";
|
||||
|
||||
private TextView noResultsView;
|
||||
private RecyclerView listView;
|
||||
private TextView noResultsView;
|
||||
private RecyclerView listView;
|
||||
private StickyHeaderDecoration listDecoration;
|
||||
|
||||
private SearchViewModel viewModel;
|
||||
private SearchListAdapter listAdapter;
|
||||
@ -90,10 +91,12 @@ public class SearchFragment extends Fragment implements SearchListAdapter.EventL
|
||||
noResultsView = view.findViewById(R.id.search_no_results);
|
||||
listView = view.findViewById(R.id.search_list);
|
||||
|
||||
listAdapter = new SearchListAdapter(GlideApp.with(this), this, locale);
|
||||
listAdapter = new SearchListAdapter(GlideApp.with(this), this, locale);
|
||||
listDecoration = new StickyHeaderDecoration(listAdapter, false, false);
|
||||
|
||||
listView.setAdapter(listAdapter);
|
||||
listView.addItemDecoration(listDecoration);
|
||||
listView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
listView.addItemDecoration(new StickyHeaderDecoration(listAdapter, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -118,6 +121,16 @@ public class SearchFragment extends Fragment implements SearchListAdapter.EventL
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (listDecoration != null) {
|
||||
listDecoration.invalidateLayouts();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onConversationClicked(@NonNull ThreadRecord threadRecord) {
|
||||
ConversationListActivity conversationList = (ConversationListActivity) getActivity();
|
||||
|
@ -181,6 +181,10 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration {
|
||||
((LinearLayoutManager)parent.getLayoutManager()).getReverseLayout();
|
||||
}
|
||||
|
||||
public void invalidateLayouts() {
|
||||
headerCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* The adapter to assist the {@link StickyHeaderDecoration} in creating and binding the header views.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user