use of com.xabber.android.data.extension.mam.LoadHistorySettings in project xabber-android by redsolution.
the class ChatFragment method loadHistoryIfNeeded.
private void loadHistoryIfNeeded() {
AccountItem accountItem = AccountManager.getInstance().getAccount(this.account);
if (accountItem == null) {
return;
}
LoadHistorySettings loadHistorySettings = accountItem.getLoadHistorySettings();
if (loadHistorySettings != LoadHistorySettings.current && loadHistorySettings != LoadHistorySettings.all) {
return;
}
if (isRemoteHistoryRequested) {
return;
}
int visibleItemCount = layoutManager.getChildCount();
if (visibleItemCount == 0) {
return;
}
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
if (firstVisibleItemPosition / visibleItemCount <= 2) {
requestRemoteHistoryLoad();
return;
}
if (firstVisibleItemPosition < firstRemoteSyncedItemPosition) {
requestRemoteHistoryLoad();
return;
}
if (firstVisibleItemPosition - firstRemoteSyncedItemPosition < visibleItemCount * 2) {
requestRemoteHistoryLoad();
return;
}
}
use of com.xabber.android.data.extension.mam.LoadHistorySettings in project xabber-android by redsolution.
the class ChatFragment method onStart.
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
AccountItem accountItem = AccountManager.getInstance().getAccount(this.account);
if (accountItem != null) {
LoadHistorySettings loadHistorySettings = accountItem.getLoadHistorySettings();
if (loadHistorySettings == LoadHistorySettings.all || loadHistorySettings == LoadHistorySettings.current) {
if (!isRemoteHistoryRequested) {
MamManager.getInstance().requestLastHistoryByUser(getChat());
}
}
}
}
Aggregations