fix unlimited accounts
This commit is contained in:
parent
f002ddc261
commit
7dcb3abadc
@ -106,22 +106,16 @@ public class MediaDataController extends BaseController {
|
||||
|
||||
public static String SHORTCUT_CATEGORY = "org.telegram.messenger.SHORTCUT_SHARE";
|
||||
|
||||
private static SparseArray<MediaDataController> Instance = new SparseArray<>();
|
||||
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
|
||||
static {
|
||||
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
|
||||
lockObjects[i] = new Object();
|
||||
}
|
||||
}
|
||||
private static final SparseArray<MediaDataController> Instance = new SparseArray<>();
|
||||
private static final Object lockObject = new Object();
|
||||
|
||||
public static MediaDataController getInstance(int num) {
|
||||
MediaDataController localInstance = Instance.get(num);
|
||||
if (localInstance == null) {
|
||||
synchronized (lockObjects) {
|
||||
synchronized (lockObject) {
|
||||
localInstance = Instance.get(num);
|
||||
if (localInstance == null) {
|
||||
Instance.put(num, localInstance = new MediaDataController(num));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,12 +88,7 @@ public class MessagesStorage extends BaseController {
|
||||
private CountDownLatch openSync = new CountDownLatch(1);
|
||||
|
||||
private static SparseArray<MessagesStorage> Instance = new SparseArray();
|
||||
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
|
||||
static {
|
||||
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
|
||||
lockObjects[i] = new Object();
|
||||
}
|
||||
}
|
||||
private static final Object lockObject = new Object();
|
||||
private final static int LAST_DB_VERSION = 98;
|
||||
private boolean databaseMigrationInProgress;
|
||||
public boolean showClearDatabaseAlert;
|
||||
@ -102,7 +97,7 @@ public class MessagesStorage extends BaseController {
|
||||
public static MessagesStorage getInstance(int num) {
|
||||
MessagesStorage localInstance = Instance.get(num);
|
||||
if (localInstance == null) {
|
||||
synchronized (lockObjects[num]) {
|
||||
synchronized (lockObject) {
|
||||
localInstance = Instance.get(num);
|
||||
if (localInstance == null) {
|
||||
Instance.put(num, localInstance = new MessagesStorage(num));
|
||||
|
@ -148,17 +148,12 @@ public class NotificationsController extends BaseController {
|
||||
}
|
||||
|
||||
private static SparseArray<NotificationsController> Instance = new SparseArray<>();
|
||||
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
|
||||
static {
|
||||
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
|
||||
lockObjects[i] = new Object();
|
||||
}
|
||||
}
|
||||
private static final Object lockObject = new Object();
|
||||
|
||||
public static NotificationsController getInstance(int num) {
|
||||
NotificationsController localInstance = Instance.get(num);
|
||||
if (localInstance == null) {
|
||||
synchronized (lockObjects[num]) {
|
||||
synchronized (lockObject) {
|
||||
localInstance = Instance.get(num);
|
||||
if (localInstance == null) {
|
||||
Instance.put(num, localInstance = new NotificationsController(num));
|
||||
|
@ -23,7 +23,7 @@ public class UserConfig extends BaseController {
|
||||
|
||||
public static int selectedAccount;
|
||||
//public final static int MAX_ACCOUNT_DEFAULT_COUNT = 16;
|
||||
public final static int MAX_ACCOUNT_COUNT = 4;
|
||||
// public final static int MAX_ACCOUNT_COUNT = 4;
|
||||
|
||||
private final Object sync = new Object();
|
||||
private boolean configLoaded;
|
||||
@ -98,7 +98,7 @@ public class UserConfig extends BaseController {
|
||||
}
|
||||
|
||||
public static boolean hasPremiumOnAccounts() {
|
||||
for (int a = 0; a < MAX_ACCOUNT_COUNT; a++) {
|
||||
for (int a : SharedConfig.activeAccounts) {
|
||||
if (AccountInstance.getInstance(a).getUserConfig().isClientActivated() && AccountInstance.getInstance(a).getUserConfig().getUserConfig().isPremium()) {
|
||||
return true;
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class UserConfig extends BaseController {
|
||||
editor.remove("user");
|
||||
}
|
||||
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.NotificationsController;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
@ -83,7 +84,7 @@ public class DrawerUserCell extends FrameLayout implements NotificationCenter.No
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
|
||||
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++){
|
||||
for (int i : SharedConfig.activeAccounts) {
|
||||
NotificationCenter.getInstance(i).addObserver(this, NotificationCenter.currentUserPremiumStatusChanged);
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
|
||||
@ -92,7 +93,7 @@ public class DrawerUserCell extends FrameLayout implements NotificationCenter.No
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++){
|
||||
for (int i : SharedConfig.activeAccounts) {
|
||||
NotificationCenter.getInstance(i).removeObserver(this, NotificationCenter.currentUserPremiumStatusChanged);
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
|
||||
|
Loading…
Reference in New Issue
Block a user