mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-29 00:14:12 +01:00
Speed up Conversations Overview with UI thread
This commit is contained in:
parent
e73245e6e8
commit
fce0c72a51
1 changed files with 18 additions and 15 deletions
|
@ -309,21 +309,22 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
||||||
this.mSwipeEscapeVelocity = getResources().getDimension(R.dimen.swipe_escape_velocity);
|
this.mSwipeEscapeVelocity = getResources().getDimension(R.dimen.swipe_escape_velocity);
|
||||||
this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversations_overview, container, false);
|
this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversations_overview, container, false);
|
||||||
this.binding.fab.setOnClickListener((view) -> StartConversationActivity.launch(getActivity()));
|
this.binding.fab.setOnClickListener((view) -> StartConversationActivity.launch(getActivity()));
|
||||||
|
activity.runOnUiThread(() -> {
|
||||||
this.conversationsAdapter = new ConversationAdapter(this.activity, this.conversations);
|
this.conversationsAdapter = new ConversationAdapter(this.activity, this.conversations);
|
||||||
if (this.conversations.size() > 0) {
|
if (!this.conversations.isEmpty()) {
|
||||||
this.activity.xmppConnectionService.updateNotificationChannels();
|
this.activity.xmppConnectionService.updateNotificationChannels();
|
||||||
}
|
|
||||||
this.conversationsAdapter.setConversationClickListener((view, conversation) -> {
|
|
||||||
if (activity instanceof OnConversationSelected) {
|
|
||||||
((OnConversationSelected) activity).onConversationSelected(conversation);
|
|
||||||
} else {
|
|
||||||
Log.w(ConversationsOverviewFragment.class.getCanonicalName(), "Activity does not implement OnConversationSelected");
|
|
||||||
}
|
}
|
||||||
|
this.conversationsAdapter.setConversationClickListener((view, conversation) -> {
|
||||||
|
if (activity instanceof OnConversationSelected) {
|
||||||
|
((OnConversationSelected) activity).onConversationSelected(conversation);
|
||||||
|
} else {
|
||||||
|
Log.w(ConversationsOverviewFragment.class.getCanonicalName(), "Activity does not implement OnConversationSelected");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.binding.list.setAdapter(this.conversationsAdapter);
|
||||||
|
this.binding.list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||||
|
registerForContextMenu(this.binding.list);
|
||||||
});
|
});
|
||||||
this.binding.list.setAdapter(this.conversationsAdapter);
|
|
||||||
this.binding.list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
|
||||||
registerForContextMenu(this.binding.list);
|
|
||||||
if (activity.xmppConnectionService != null && !activity.xmppConnectionService.getBooleanPreference("hide_donation_snackbar", R.bool.hide_donation_snackbar)) {
|
if (activity.xmppConnectionService != null && !activity.xmppConnectionService.getBooleanPreference("hide_donation_snackbar", R.bool.hide_donation_snackbar)) {
|
||||||
askForDonationSnackbar();
|
askForDonationSnackbar();
|
||||||
}
|
}
|
||||||
|
@ -521,7 +522,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.activity.xmppConnectionService.populateWithOrderedConversations(this.conversations);
|
this.activity.xmppConnectionService.populateWithOrderedConversations(this.conversations);
|
||||||
if (this.conversations.size() > 0) {
|
if (!this.conversations.isEmpty()) {
|
||||||
this.activity.xmppConnectionService.updateNotificationChannels();
|
this.activity.xmppConnectionService.updateNotificationChannels();
|
||||||
}
|
}
|
||||||
Conversation removed = this.swipedConversation.peek();
|
Conversation removed = this.swipedConversation.peek();
|
||||||
|
@ -532,7 +533,9 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
||||||
pendingActionHelper.execute();
|
pendingActionHelper.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.conversationsAdapter.notifyDataSetChanged();
|
activity.runOnUiThread(() -> {
|
||||||
|
this.conversationsAdapter.notifyDataSetChanged();
|
||||||
|
});
|
||||||
ScrollState scrollState = pendingScrollState.pop();
|
ScrollState scrollState = pendingScrollState.pop();
|
||||||
if (scrollState != null) {
|
if (scrollState != null) {
|
||||||
setScrollPosition(scrollState);
|
setScrollPosition(scrollState);
|
||||||
|
|
Loading…
Add table
Reference in a new issue