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 ...@@ -408,4 +408,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
public void onRecentChatsCalled() { public void onRecentChatsCalled() {
viewPager.setCurrentItem(chatViewerAdapter.getRecentChatsPosition(), true); viewPager.setCurrentItem(chatViewerAdapter.getRecentChatsPosition(), true);
} }
public ChatViewerAdapter getChatViewerAdapter() {
return chatViewerAdapter;
}
} }
...@@ -13,13 +13,12 @@ import com.xabber.android.data.message.AbstractChat; ...@@ -13,13 +13,12 @@ import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.ui.adapter.ChatListAdapter; import com.xabber.android.ui.adapter.ChatListAdapter;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RecentChatFragment extends ListFragment { public class RecentChatFragment extends ListFragment {
private RecentChatFragmentInteractionListener listener; private RecentChatFragmentInteractionListener listener;
private List<AbstractChat> initialChats = null;
public static RecentChatFragment newInstance() { public static RecentChatFragment newInstance() {
return new RecentChatFragment(); return new RecentChatFragment();
} }
...@@ -31,10 +30,6 @@ public class RecentChatFragment extends ListFragment { ...@@ -31,10 +30,6 @@ public class RecentChatFragment extends ListFragment {
public RecentChatFragment() { public RecentChatFragment() {
} }
public void setInitialChats(List<AbstractChat> initialChats) {
this.initialChats = initialChats;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -59,10 +54,8 @@ public class RecentChatFragment extends ListFragment { ...@@ -59,10 +54,8 @@ public class RecentChatFragment extends ListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState); super.onCreateView(inflater, container, savedInstanceState);
if (initialChats != null) { ArrayList<AbstractChat> activeChats = ((ChatViewer) getActivity()).getChatViewerAdapter().getActiveChats();
((ChatListAdapter) getListAdapter()).updateChats(initialChats); ((ChatListAdapter) getListAdapter()).updateChats(activeChats);
initialChats = null;
}
if (getListAdapter().isEmpty()) { if (getListAdapter().isEmpty()) {
Activity activity = getActivity(); Activity activity = getActivity();
......
...@@ -73,9 +73,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter { ...@@ -73,9 +73,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
int realPosition = getRealPagePosition(virtualPagePosition); int realPosition = getRealPagePosition(virtualPagePosition);
if (realPosition == 0) { if (realPosition == 0) {
RecentChatFragment activeChatFragment = RecentChatFragment.newInstance(); return RecentChatFragment.newInstance();
activeChatFragment.setInitialChats(activeChats);
return activeChatFragment;
} }
AbstractChat chat = activeChats.get(getChatIndexFromRealPosition(realPosition)); 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