@@ -2534,12 +2534,12 @@ private void checkUserButtons () {
2534
2534
}
2535
2535
}
2536
2536
2537
-
private SharedChatsController getCommonChatsController () {
2537
+
private SharedChatsController getCommonChatsController (@SharedChatsController.Mode int mode) {
2538
2538
ArrayList<SharedBaseController<?>> controllers = getControllers();
2539
2539
final int count = controllers.size();
2540
2540
for (int i = count - 1; i >= 0; i--) {
2541
2541
SharedBaseController<?> c = controllers.get(i);
2542
-
if (c instanceof SharedChatsController) {
2542
+
if (c instanceof SharedChatsController && ((SharedChatsController) c).getMode() == mode) {
2543
2543
return (SharedChatsController) c;
2544
2544
}
2545
2545
}
@@ -2566,7 +2566,7 @@ private void checkGroupsInCommon () {
2566
2566
return;
2567
2567
}
2568
2568
final boolean needGroups = userFull != null && userFull.groupInCommonCount > 0;
2569
-
final SharedChatsController existingGroupsController = getCommonChatsController();
2569
+
final SharedChatsController existingGroupsController = getCommonChatsController(SharedChatsController.Mode.GROUPS_IN_COMMON);
2570
2570
boolean hasGroups = existingGroupsController != null;
2571
2571
if (needGroups != hasGroups) {
2572
2572
if (needGroups) {
@@ -5816,7 +5816,8 @@ private ArrayList<SharedBaseController<?>> getControllers () {
5816
5816
} else {
5817
5817
fillMediaControllers(controllers, context, tdlib);
5818
5818
}
5819
-
getSimilarChatsCount(true);
5819
+
getSimilarChatsCount(false, true);
5820
+
getSimilarChatsCount(true, true);
5820
5821
} else {
5821
5822
controllers.add(new SharedRestrictionController(context, tdlib).setRestrictionReason(restrictionReason));
5822
5823
}
@@ -5826,7 +5827,9 @@ private ArrayList<SharedBaseController<?>> getControllers () {
5826
5827
case Mode.SECRET:
5827
5828
TdApi.UserFullInfo userFull = tdlib.cache().userFull(user.id);
5828
5829
if (userFull != null && userFull.groupInCommonCount > 0) {
5829
-
controllers.add(new SharedChatsController(context, tdlib));
5830
+
SharedChatsController c = new SharedChatsController(context, tdlib);
5831
+
c.setMode(SharedChatsController.Mode.GROUPS_IN_COMMON);
5832
+
controllers.add(c);
5830
5833
}
5831
5834
break;
5832
5835
case Mode.CHANNEL:
@@ -5880,18 +5883,23 @@ private void removeControllerTab (SharedBaseController<?> c) {
5880
5883
pagerAdapter.notifyDataSetChanged();
5881
5884
}
5882
5885
5883
-
private int similarChatCount;
5886
+
private int similarChatCount, similarBotsCount;
5884
5887
5885
-
private void setSimilarChatCount (int count) {
5888
+
private void setSimilarChatCount (boolean similarBots, int count) {
5886
5889
boolean needSimilarChats = count > 0;
5887
-
final SharedChatsController existingChatsController = getCommonChatsController();
5890
+
@SharedChatsController.Mode int targetMode = similarBots ? SharedChatsController.Mode.SIMILAR_BOTS : SharedChatsController.Mode.SIMILAR_CHANNELS;
5891
+
final SharedChatsController existingChatsController = getCommonChatsController(targetMode);
5888
5892
boolean hasSimilarChats = existingChatsController != null;
5889
-
this.similarChatCount = count;
5893
+
if (similarBots) {
5894
+
this.similarBotsCount = count;
5895
+
} else {
5896
+
this.similarChatCount = count;
5897
+
}
5890
5898
5891
5899
if (needSimilarChats != hasSimilarChats) {
5892
5900
if (needSimilarChats) {
5893
5901
SharedChatsController c = new SharedChatsController(context, tdlib);
5894
-
c.setMode(SharedChatsController.Mode.SIMILAR_CHANNELS);
5902
+
c.setMode(targetMode);
5895
5903
c.setTotalCountWithPremium(count);
5896
5904
addControllerTab(c);
5897
5905
} else {
@@ -5900,23 +5908,29 @@ private void setSimilarChatCount (int count) {
5900
5908
}
5901
5909
}
5902
5910
5903
-
private void getSimilarChatsCount (boolean returnLocal) {
5904
-
if (!isChannel() || isEditing()) {
5911
+
private void getSimilarChatsCount (boolean similarBots, boolean returnLocal) {
5912
+
if (isEditing()) {
5913
+
return;
5914
+
}
5915
+
if (similarBots ? (mode != Mode.USER && mode != Mode.SECRET) : !isChannel()) {
5905
5916
return;
5906
5917
}
5907
-
tdlib.send(new TdApi.GetChatSimilarChatCount(getChatId(), returnLocal), (similarChatCount, error) -> {
5918
+
TdApi.Function<TdApi.Count> function = similarBots ?
5919
+
new TdApi.GetBotSimilarBotCount(tdlib.chatUserId(getChatId()), returnLocal) :
5920
+
new TdApi.GetChatSimilarChatCount(getChatId(), returnLocal);
5921
+
tdlib.send(function, (similarChatCount, error) -> {
5908
5922
int count;
5909
5923
if (error != null) {
5910
-
Log.e("TDLib error getChatSimilarChatCount chatId:%d, returnLocal:%b: %s", getChatId(), returnLocal, TD.toErrorString(error));
5924
+
Log.e("TDLib error getChatSimilarChatCount chatId:%d, bots:%b returnLocal:%b: %s", getChatId(), similarBots, returnLocal, TD.toErrorString(error));
5911
5925
count = -1;
5912
5926
} else {
5913
5927
count = similarChatCount.count;
5914
5928
}
5915
-
runOnUiThreadOptional(() -> {
5916
-
setSimilarChatCount(count);
5917
-
});
5929
+
runOnUiThreadOptional(() ->
5930
+
setSimilarChatCount(similarBots, count)
5931
+
);
5918
5932
if (returnLocal && count == -1) {
5919
-
getSimilarChatsCount(false);
5933
+
getSimilarChatsCount(similarBots, false);
5920
5934
}
5921
5935
});
5922
5936
}
@@ -6295,6 +6309,9 @@ private CharSequence makeSubtitle (boolean isExpanded) {
6295
6309
case SharedChatsController.Mode.SIMILAR_CHANNELS: {
6296
6310
return Lang.pluralBold(R.string.xSimilarChannels, similarChatCount);
6297
6311
}
6312
+
case SharedChatsController.Mode.SIMILAR_BOTS: {
6313
+
return Lang.pluralBold(R.string.xSimilarBots, similarBotsCount);
6314
+
}
6298
6315
default:
6299
6316
throw new IllegalStateException();
6300
6317
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4