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