NekoX/TMessagesProj/src/main/java/org/telegram/messenger/AccountInstance.java

99 lines
2.9 KiB
Java
Raw Normal View History

2019-05-14 14:08:05 +02:00
package org.telegram.messenger;
2019-07-18 15:01:39 +02:00
import android.content.SharedPreferences;
2021-03-12 13:37:39 +01:00
import android.util.SparseArray;
2019-07-18 15:01:39 +02:00
2019-05-14 14:08:05 +02:00
import org.telegram.tgnet.ConnectionsManager;
2021-03-12 13:37:39 +01:00
import java.util.concurrent.ConcurrentHashMap;
2019-05-14 14:08:05 +02:00
public class AccountInstance {
private int currentAccount;
2021-03-12 13:37:39 +01:00
private static SparseArray<AccountInstance> Instance = new SparseArray<>();
2019-05-14 14:08:05 +02:00
public static AccountInstance getInstance(int num) {
2021-03-12 13:37:39 +01:00
AccountInstance localInstance = Instance.get(num);
2019-05-14 14:08:05 +02:00
if (localInstance == null) {
synchronized (AccountInstance.class) {
2021-03-12 13:37:39 +01:00
localInstance = Instance.get(num);
2019-05-14 14:08:05 +02:00
if (localInstance == null) {
2021-03-12 13:37:39 +01:00
Instance.put(num, localInstance = new AccountInstance(num));
2019-05-14 14:08:05 +02:00
}
}
}
return localInstance;
}
public AccountInstance(int instance) {
currentAccount = instance;
}
public MessagesController getMessagesController() {
return MessagesController.getInstance(currentAccount);
}
public MessagesStorage getMessagesStorage() {
return MessagesStorage.getInstance(currentAccount);
}
public ContactsController getContactsController() {
return ContactsController.getInstance(currentAccount);
}
2019-07-18 15:01:39 +02:00
public MediaDataController getMediaDataController() {
return MediaDataController.getInstance(currentAccount);
2019-05-14 14:08:05 +02:00
}
public ConnectionsManager getConnectionsManager() {
return ConnectionsManager.getInstance(currentAccount);
}
public NotificationsController getNotificationsController() {
return NotificationsController.getInstance(currentAccount);
}
public NotificationCenter getNotificationCenter() {
return NotificationCenter.getInstance(currentAccount);
}
2019-07-18 15:01:39 +02:00
public LocationController getLocationController() {
return LocationController.getInstance(currentAccount);
}
2019-05-14 14:08:05 +02:00
public UserConfig getUserConfig() {
return UserConfig.getInstance(currentAccount);
}
2019-07-18 15:01:39 +02:00
public DownloadController getDownloadController() {
return DownloadController.getInstance(currentAccount);
}
public SendMessagesHelper getSendMessagesHelper() {
return SendMessagesHelper.getInstance(currentAccount);
}
public SecretChatHelper getSecretChatHelper() {
return SecretChatHelper.getInstance(currentAccount);
}
public StatsController getStatsController() {
return StatsController.getInstance(currentAccount);
}
public FileLoader getFileLoader() {
return FileLoader.getInstance(currentAccount);
}
public FileRefController getFileRefController() {
return FileRefController.getInstance(currentAccount);
}
public SharedPreferences getNotificationsSettings() {
return MessagesController.getNotificationsSettings(currentAccount);
}
2020-12-23 08:48:30 +01:00
public int getCurrentAccount() {
return currentAccount;
}
2019-05-14 14:08:05 +02:00
}