fix: crash on 32+ accounts

This commit is contained in:
luvletter2333 2023-03-04 07:07:12 +08:00
parent afe1f215c8
commit cedce6813e
No known key found for this signature in database
GPG Key ID: 9EB7723F3A0ACF92
1 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package org.telegram.ui.Components.Paint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.util.SparseArray;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SharedConfig;
@ -33,7 +34,7 @@ public class PersistColorPalette {
); );
private final static Integer DEFAULT_MARKER_COLOR = 0xff0a84ff; private final static Integer DEFAULT_MARKER_COLOR = 0xff0a84ff;
private static PersistColorPalette[] instances = new PersistColorPalette[32]; private static SparseArray<PersistColorPalette> instances = new SparseArray<>();
private SharedPreferences mConfig; private SharedPreferences mConfig;
private List<Integer> colors = new ArrayList<>(COLORS_COUNT); private List<Integer> colors = new ArrayList<>(COLORS_COUNT);
@ -60,10 +61,10 @@ public class PersistColorPalette {
} }
public static PersistColorPalette getInstance(int currentAccount) { public static PersistColorPalette getInstance(int currentAccount) {
if (instances[currentAccount] == null) { if (instances.get(currentAccount) == null) {
instances[currentAccount] = new PersistColorPalette(currentAccount); instances.set(currentAccount, new PersistColorPalette(currentAccount));
} }
return instances[currentAccount]; return instances.get(currentAccount);
} }
public int getCurrentTextType() { public int getCurrentTextType() {