fix and refactor
This commit is contained in:
parent
d9d6e82770
commit
c588edf3b6
@ -54,6 +54,8 @@ import java.util.Collections;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import tw.nekomimi.nekogram.FilterPopup;
|
||||
|
||||
public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
private Context mContext;
|
||||
@ -163,7 +165,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
|
||||
boolean hasContacts = false;
|
||||
if (hasHints) {
|
||||
count += 2 + MessagesController.getInstance(currentAccount).hintDialogs.size();
|
||||
} else if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && dialogsCount == 0 && folderId == 0) {
|
||||
} else if (FilterPopup.DialogType.isDialogsType(dialogsType) && dialogsCount == 0 && folderId == 0) {
|
||||
if (ContactsController.getInstance(currentAccount).contacts.isEmpty() && ContactsController.getInstance(currentAccount).isLoadingContacts()) {
|
||||
onlineContacts = null;
|
||||
return (currentCount = 0);
|
||||
@ -291,7 +293,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
hasHints = folderId == 0 && (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && !isOnlySelect && !MessagesController.getInstance(currentAccount).hintDialogs.isEmpty();
|
||||
hasHints = folderId == 0 && FilterPopup.DialogType.isDialogsType(dialogsType) && !isOnlySelect && !MessagesController.getInstance(currentAccount).hintDialogs.isEmpty();
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -438,7 +440,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
|
||||
cell.useSeparator = (i != getItemCount() - 1);
|
||||
}
|
||||
cell.fullSeparator = dialog.pinned && nextDialog != null && !nextDialog.pinned;
|
||||
if (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType)) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(dialog.id == openedDialogId);
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import tw.nekomimi.nekogram.FilterPopup;
|
||||
|
||||
public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
private Context mContext;
|
||||
@ -331,7 +333,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
||||
add = true;
|
||||
}
|
||||
}
|
||||
} else if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) || dialogsType == 3) {
|
||||
} else if (FilterPopup.DialogType.isDialogsType(dialogsType) || dialogsType == 3) {
|
||||
if (!encryptedToLoad.contains(high_id)) {
|
||||
encryptedToLoad.add(high_id);
|
||||
add = true;
|
||||
@ -518,7 +520,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
||||
chatsToLoad.add(-lower_id);
|
||||
}
|
||||
}
|
||||
} else if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) || dialogsType == 3) {
|
||||
} else if (FilterPopup.DialogType.isDialogsType(dialogsType) || dialogsType == 3) {
|
||||
if (!encryptedToLoad.contains(high_id)) {
|
||||
encryptedToLoad.add(high_id);
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ import org.telegram.ui.DialogsActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import tw.nekomimi.nekogram.FilterPopup;
|
||||
|
||||
public class DialogCell extends BaseCell {
|
||||
|
||||
public static class CustomDialog {
|
||||
@ -989,7 +991,7 @@ public class DialogCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
|
||||
if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && MessagesController.getInstance(currentAccount).isProxyDialog(currentDialogId, true)) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType) && MessagesController.getInstance(currentAccount).isProxyDialog(currentDialogId, true)) {
|
||||
drawPinBackground = true;
|
||||
timeString = LocaleController.getString("UseProxySponsor", R.string.UseProxySponsor);
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
swipingFolder = false;
|
||||
return 0;
|
||||
}
|
||||
if (!onlySelect && (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && slidingView == null && recyclerView.getAdapter() == dialogsAdapter && viewHolder.itemView instanceof DialogCell) {
|
||||
if (!onlySelect && (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 12)) && slidingView == null && recyclerView.getAdapter() == dialogsAdapter && viewHolder.itemView instanceof DialogCell) {
|
||||
DialogCell dialogCell = (DialogCell) viewHolder.itemView;
|
||||
long dialogId = dialogCell.getDialogId();
|
||||
if (actionBar.isActionModeShowed()) {
|
||||
@ -661,7 +661,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
messagesCount = arguments.getInt("messagesCount", 0);
|
||||
}
|
||||
|
||||
if (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType)) {
|
||||
askAboutContacts = MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true);
|
||||
SharedConfig.loadProxyList();
|
||||
}
|
||||
@ -1800,7 +1800,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
actionBar.openSearchField(searchString, false);
|
||||
}
|
||||
|
||||
if (!onlySelect && (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11))) {
|
||||
if (!onlySelect && FilterPopup.DialogType.isDialogsType(dialogsType)) {
|
||||
FragmentContextView fragmentLocationContextView = new FragmentContextView(context, this, true);
|
||||
contentView.addView(fragmentLocationContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
|
||||
|
||||
@ -2075,7 +2075,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
private boolean hasHiddenArchive() {
|
||||
return listView.getAdapter() == dialogsAdapter && !onlySelect
|
||||
&& (dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11))
|
||||
&& FilterPopup.DialogType.isDialogsType(dialogsType)
|
||||
&& folderId == 0
|
||||
&& FilterPopup.getInstance(currentAccount).hasHiddenArchive(dialogsType);
|
||||
}
|
||||
@ -2973,7 +2973,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
if (dialogsListFrozen) {
|
||||
return;
|
||||
}
|
||||
if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && getMessagesController().getDialogs(folderId).isEmpty()) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType) && getMessagesController().getDialogs(folderId).isEmpty()) {
|
||||
if (dialogsAdapter != null) {
|
||||
dialogsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
@ -2981,7 +2981,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
updateVisibleRows(0);
|
||||
}
|
||||
} else if (id == NotificationCenter.openedChatChanged) {
|
||||
if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && AndroidUtilities.isTablet()) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType) && AndroidUtilities.isTablet()) {
|
||||
boolean close = (Boolean) args[1];
|
||||
long dialog_id = (Long) args[0];
|
||||
if (close) {
|
||||
@ -3190,11 +3190,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
} else {
|
||||
if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0) {
|
||||
cell.checkCurrentDialogIndex(dialogsListFrozen);
|
||||
if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && AndroidUtilities.isTablet()) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType) && AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
||||
}
|
||||
} else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) {
|
||||
if ((dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 11)) && AndroidUtilities.isTablet()) {
|
||||
if (FilterPopup.DialogType.isDialogsType(dialogsType) && AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
||||
}
|
||||
} else {
|
||||
|
@ -420,6 +420,9 @@ public class FilterPopup {
|
||||
}
|
||||
|
||||
public static class DialogType {
|
||||
public static boolean isDialogsType(int dialogsType) {
|
||||
return dialogsType == 0 || (dialogsType >= 7 && dialogsType <= 12);
|
||||
}
|
||||
public static final int All = 0;
|
||||
public static final int Users = 7;
|
||||
public static final int Groups = 8;
|
||||
|
Loading…
Reference in New Issue
Block a user