mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-25 13:07:20 +00:00
clean
This commit is contained in:
parent
543019f93c
commit
88ae3a9d93
@ -18,8 +18,6 @@ object AvatarPlaceholderGenerator {
|
|||||||
fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable {
|
fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable {
|
||||||
val hash: Long
|
val hash: Long
|
||||||
if (hashString.length >= 12 && hashString.matches(Regex("^[0-9A-Fa-f]+\$"))) {
|
if (hashString.length >= 12 && hashString.matches(Regex("^[0-9A-Fa-f]+\$"))) {
|
||||||
val sha = getSha512(hashString)
|
|
||||||
val test = sha.substring(0 until 12)
|
|
||||||
hash = getSha512(hashString).substring(0 until 12).toLong(16)
|
hash = getSha512(hashString).substring(0 until 12).toLong(16)
|
||||||
} else {
|
} else {
|
||||||
hash = 0
|
hash = 0
|
||||||
|
@ -21,6 +21,8 @@ import android.content.Context;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
@ -42,6 +44,8 @@ import network.loki.messenger.BuildConfig;
|
|||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
|
private static volatile Handler handler;
|
||||||
|
|
||||||
public static String join(String[] list, String delimiter) {
|
public static String join(String[] list, String delimiter) {
|
||||||
return join(Arrays.asList(list), delimiter);
|
return join(Arrays.asList(list), delimiter);
|
||||||
}
|
}
|
||||||
@ -144,4 +148,24 @@ public class Util {
|
|||||||
public static boolean isMmsCapable(Context context) {
|
public static boolean isMmsCapable(Context context) {
|
||||||
return (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) || OutgoingLegacyMmsConnection.isConnectionPossible(context);
|
return (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) || OutgoingLegacyMmsConnection.isConnectionPossible(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMainThread() {
|
||||||
|
return Looper.myLooper() == Looper.getMainLooper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runOnMain(final @NonNull Runnable runnable) {
|
||||||
|
if (isMainThread()) runnable.run();
|
||||||
|
else getHandler().post(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Handler getHandler() {
|
||||||
|
if (handler == null) {
|
||||||
|
synchronized (Util.class) {
|
||||||
|
if (handler == null) {
|
||||||
|
handler = new Handler(Looper.getMainLooper());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user