移除androidx、support依赖,现在哪个版本的appcompat库都可以导入Aria

修复一个在xml中使用fragment导致的内存泄漏问题
This commit is contained in:
laoyuyu
2019-12-08 11:08:58 +08:00
parent 3871d8f056
commit d9ed7f87d2
45 changed files with 98 additions and 269 deletions

View File

@@ -56,8 +56,7 @@ public class SSLContextUtil {
* @param caPath 保存在assets目录下的CA证书完整路径
* @param protocol 连接协议
*/
public static SSLContext getSSLContextFromAssets(String caAlias, String caPath,
@ProtocolType String protocol) {
public static SSLContext getSSLContextFromAssets(String caAlias, String caPath, String protocol) {
if (TextUtils.isEmpty(caAlias) || TextUtils.isEmpty(caPath)) {
return null;
}
@@ -83,8 +82,7 @@ public class SSLContextUtil {
* @param caPath CA证书路径
* @param protocol 连接协议
*/
public static SSLContext getSSLContext(String caAlias, String caPath,
@ProtocolType String protocol) {
public static SSLContext getSSLContext(String caAlias, String caPath, String protocol) {
if (TextUtils.isEmpty(caAlias) || TextUtils.isEmpty(caPath)) {
return null;
}
@@ -105,8 +103,8 @@ public class SSLContextUtil {
/**
* @param cacheKey 别名 + 证书路径然后取md5
*/
private static SSLContext createContext(String caAlias, Certificate ca,
@ProtocolType String protocol, String cacheKey) {
private static SSLContext createContext(String caAlias, Certificate ca, String protocol,
String cacheKey) {
try {
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
@@ -154,7 +152,7 @@ public class SSLContextUtil {
/**
* 服务器证书不是由 CA 签署的而是自签署时获取默认的SSL
*/
public static SSLContext getDefaultSLLContext(@ProtocolType String protocol) {
public static SSLContext getDefaultSLLContext(String protocol) {
SSLContext sslContext = null;
try {
sslContext =

View File

@@ -27,9 +27,6 @@ package com.arialyy.aria.util;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import java.lang.ref.WeakReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -51,7 +48,7 @@ import java.util.concurrent.locks.ReentrantLock;
// hard reference to Callback. We need to keep callback in memory
private final ExecHandler mExec;
private Lock mLock = new ReentrantLock();
@SuppressWarnings("ConstantConditions") @VisibleForTesting final ChainedRef mRunnables =
@SuppressWarnings("ConstantConditions") final ChainedRef mRunnables =
new ChainedRef(mLock, null);
/**
@@ -76,7 +73,7 @@ import java.util.concurrent.locks.ReentrantLock;
*
* @param callback The callback interface in which to handle messages, or null.
*/
public WeakHandler(@Nullable Handler.Callback callback) {
public WeakHandler(Handler.Callback callback) {
mCallback = callback; // Hard referencing body
mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler
}
@@ -86,7 +83,7 @@ import java.util.concurrent.locks.ReentrantLock;
*
* @param looper The looper, must not be null.
*/
public WeakHandler(@NonNull Looper looper) {
public WeakHandler(Looper looper) {
mCallback = null;
mExec = new ExecHandler(looper);
}
@@ -98,7 +95,7 @@ import java.util.concurrent.locks.ReentrantLock;
* @param looper The looper, must not be null.
* @param callback The callback interface in which to handle messages, or null.
*/
public WeakHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) {
public WeakHandler(Looper looper, Handler.Callback callback) {
mCallback = callback;
mExec = new ExecHandler(looper, new WeakReference<>(callback));
}
@@ -113,7 +110,7 @@ import java.util.concurrent.locks.ReentrantLock;
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean post(@NonNull Runnable r) {
public final boolean post(Runnable r) {
return mExec.post(wrapRunnable(r));
}
@@ -133,7 +130,7 @@ import java.util.concurrent.locks.ReentrantLock;
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) {
public final boolean postAtTime(Runnable r, long uptimeMillis) {
return mExec.postAtTime(wrapRunnable(r), uptimeMillis);
}
@@ -367,7 +364,7 @@ import java.util.concurrent.locks.ReentrantLock;
return mExec.getLooper();
}
private WeakRunnable wrapRunnable(@NonNull Runnable r) {
private WeakRunnable wrapRunnable(Runnable r) {
//noinspection ConstantConditions
if (r == null) {
throw new NullPointerException("Runnable can't be null");
@@ -398,7 +395,7 @@ import java.util.concurrent.locks.ReentrantLock;
mCallback = callback;
}
@Override public void handleMessage(@NonNull Message msg) {
@Override public void handleMessage(Message msg) {
if (mCallback == null) {
return;
}
@@ -432,14 +429,14 @@ import java.util.concurrent.locks.ReentrantLock;
}
static class ChainedRef {
@Nullable ChainedRef next;
@Nullable ChainedRef prev;
@NonNull final Runnable runnable;
@NonNull final WeakRunnable wrapper;
ChainedRef next;
ChainedRef prev;
final Runnable runnable;
final WeakRunnable wrapper;
@NonNull Lock lock;
Lock lock;
public ChainedRef(@NonNull Lock lock, @NonNull Runnable r) {
public ChainedRef(Lock lock, Runnable r) {
this.runnable = r;
this.lock = lock;
this.wrapper = new WeakRunnable(new WeakReference<>(r), new WeakReference<>(this));
@@ -462,7 +459,7 @@ import java.util.concurrent.locks.ReentrantLock;
return wrapper;
}
public void insertAfter(@NonNull ChainedRef candidate) {
public void insertAfter(ChainedRef candidate) {
lock.lock();
try {
if (this.next != null) {
@@ -477,7 +474,7 @@ import java.util.concurrent.locks.ReentrantLock;
}
}
@Nullable public WeakRunnable remove(Runnable obj) {
public WeakRunnable remove(Runnable obj) {
lock.lock();
try {
ChainedRef curr = this.next; // Skipping head