Fix an error

This commit is contained in:
tom79 2019-12-15 17:33:15 +01:00
parent adcefa4df4
commit 904b3fa7db
4 changed files with 17 additions and 18 deletions

View File

@ -138,6 +138,6 @@ dependencies {
implementation 'com.github.penfeizhou.android.animation:gif:1.1.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.github.smarteist:autoimageslider:1.3.2'
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0'
implementation 'com.jaredrummler:cyanea:1.0.2'
}

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.ActionMode;
import android.view.View;
import android.widget.Toast;
@ -22,6 +23,7 @@ import com.vanniktech.emoji.one.EmojiOneProvider;
import java.util.Timer;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.helper.Helper;
import es.dmoral.toasty.Toasty;
@ -48,7 +50,7 @@ public class BaseActivity extends CyaneaAppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
/* if (BuildConfig.DEBUG) {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
@ -63,7 +65,7 @@ public class BaseActivity extends CyaneaAppCompatActivity {
.penaltyLog()
.penaltyDeath()
.build());
}*/
}
canShowActionMode = true;
super.onCreate(savedInstanceState);

View File

@ -5161,13 +5161,7 @@ public class API {
filters = parseFilters(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (JSONException e) {
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
e.printStackTrace();
}
apiResponse.setFilters(filters);
@ -5190,13 +5184,7 @@ public class API {
filters.add(filter);
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (JSONException e) {
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
e.printStackTrace();
}
apiResponse.setFilters(filters);

View File

@ -184,7 +184,8 @@ public class HttpsConnection {
}
if (Build.VERSION.SDK_INT >= 21) {
OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(timeout, TimeUnit.SECONDS).cache(new Cache(context.getCacheDir(), cacheSize));
Cache cache = new Cache(context.getCacheDir(), cacheSize);
OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(timeout, TimeUnit.SECONDS).cache(cache);
if (proxy != null) {
builder.proxy(proxy);
}
@ -212,6 +213,14 @@ public class HttpsConnection {
} else {
throw new HttpsConnectionException(code, error);
}
} finally {
if (!cache.isClosed()) {
try {
cache.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}else{