Commit d9a6560a authored by Grigory Fedorov's avatar Grigory Fedorov

Orientation change recent chats fragment fix.

parent 3ba35b20
......@@ -408,4 +408,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
public void onRecentChatsCalled() {
viewPager.setCurrentItem(chatViewerAdapter.getRecentChatsPosition(), true);
}
public ChatViewerAdapter getChatViewerAdapter() {
return chatViewerAdapter;
}
}
......@@ -13,13 +13,12 @@ import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.ui.adapter.ChatListAdapter;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.List;
public class RecentChatFragment extends ListFragment {
private RecentChatFragmentInteractionListener listener;
private List<AbstractChat> initialChats = null;
public static RecentChatFragment newInstance() {
return new RecentChatFragment();
}
......@@ -31,10 +30,6 @@ public class RecentChatFragment extends ListFragment {
public RecentChatFragment() {
}
public void setInitialChats(List<AbstractChat> initialChats) {
this.initialChats = initialChats;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -59,10 +54,8 @@ public class RecentChatFragment extends ListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
if (initialChats != null) {
((ChatListAdapter) getListAdapter()).updateChats(initialChats);
initialChats = null;
}
ArrayList<AbstractChat> activeChats = ((ChatViewer) getActivity()).getChatViewerAdapter().getActiveChats();
((ChatListAdapter) getListAdapter()).updateChats(activeChats);
if (getListAdapter().isEmpty()) {
Activity activity = getActivity();
......
......@@ -73,9 +73,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
int realPosition = getRealPagePosition(virtualPagePosition);
if (realPosition == 0) {
RecentChatFragment activeChatFragment = RecentChatFragment.newInstance();
activeChatFragment.setInitialChats(activeChats);
return activeChatFragment;
return RecentChatFragment.newInstance();
}
AbstractChat chat = activeChats.get(getChatIndexFromRealPosition(realPosition));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment