mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
using bsh for stetho repl
This commit is contained in:
parent
dc441bc752
commit
7b5a53bf95
@ -35,7 +35,7 @@ allprojects {
|
||||
subprojects {
|
||||
buildscript {
|
||||
ext {
|
||||
kotlinVersion = '1.1.4-3'
|
||||
kotlinVersion = '1.1.50'
|
||||
pluginVersions = [
|
||||
AndroidSvgDrawable: '3.0.0',
|
||||
PlayServices : '3.1.1',
|
||||
@ -58,7 +58,7 @@ subprojects {
|
||||
Mime4J : '0.7.2',
|
||||
OkHttp : '3.8.1',
|
||||
Stetho : '1.5.0',
|
||||
OSMDroid : '5.6.4',
|
||||
OSMDroid : '5.6.5',
|
||||
LeakCanary : '1.5.1',
|
||||
TwitterText : '1.14.7',
|
||||
MediaViewerLibrary : '0.9.23',
|
||||
@ -79,6 +79,7 @@ subprojects {
|
||||
ACRA : '4.9.2',
|
||||
AbstractTask : '0.9.5',
|
||||
Dagger : '2.11',
|
||||
StethoBeanShellREPL : '0.1',
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ android {
|
||||
signingConfig signingConfigs.twidere
|
||||
}
|
||||
|
||||
multiDexEnabled true
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
resValue("bool", "debug", "true")
|
||||
@ -97,6 +98,7 @@ android {
|
||||
signingConfig signingConfigs.twidere
|
||||
}
|
||||
|
||||
multiDexEnabled true
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
@ -171,7 +173,7 @@ dependencies {
|
||||
|
||||
debugImplementation "com.facebook.stetho:stetho:${libVersions['Stetho']}"
|
||||
debugImplementation "com.facebook.stetho:stetho-okhttp3:${libVersions['Stetho']}"
|
||||
debugImplementation "com.facebook.stetho:stetho-js-rhino:${libVersions['Stetho']}"
|
||||
debugImplementation "com.github.mariotaku:StethoBeanShellREPL:${libVersions['StethoBeanShellREPL']}"
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${libVersions['LeakCanary']}"
|
||||
debugImplementation('com.jayway.jsonpath:json-path:2.2.0') {
|
||||
exclude group: 'net.minidev', module: 'json-smart'
|
||||
|
@ -21,26 +21,20 @@ package org.mariotaku.twidere.util;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.facebook.stetho.DumperPluginsProvider;
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.facebook.stetho.dumpapp.DumperPlugin;
|
||||
import com.facebook.stetho.okhttp3.StethoInterceptor;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import com.squareup.leakcanary.RefWatcher;
|
||||
|
||||
import org.mariotaku.stethoext.bsh.BshRuntimeReplFactoryBuilder;
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.util.net.NoIntercept;
|
||||
import org.mariotaku.twidere.util.stetho.AccountsDumperPlugin;
|
||||
import org.mariotaku.twidere.util.stetho.UserStreamDumperPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/27.
|
||||
@ -55,29 +49,23 @@ public class DebugModeUtils {
|
||||
public static void initForOkHttpClient(final OkHttpClient.Builder builder) {
|
||||
final StethoInterceptor interceptor = new StethoInterceptor();
|
||||
|
||||
builder.addNetworkInterceptor(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
if (chain.request().tag() == NoIntercept.INSTANCE) {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
return interceptor.intercept(chain);
|
||||
builder.addNetworkInterceptor(chain -> {
|
||||
if (chain.request().tag() == NoIntercept.INSTANCE) {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
return interceptor.intercept(chain);
|
||||
});
|
||||
}
|
||||
|
||||
public static void initForApplication(final Application application) {
|
||||
Stetho.initialize(Stetho.newInitializerBuilder(application)
|
||||
.enableDumpapp(new DumperPluginsProvider() {
|
||||
@Override
|
||||
public Iterable<DumperPlugin> get() {
|
||||
return new Stetho.DefaultDumperPluginsBuilder(application)
|
||||
.provide(new AccountsDumperPlugin(application))
|
||||
.provide(new UserStreamDumperPlugin(application))
|
||||
.finish();
|
||||
}
|
||||
})
|
||||
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(application))
|
||||
.enableDumpapp(() -> new Stetho.DefaultDumperPluginsBuilder(application)
|
||||
.provide(new AccountsDumperPlugin(application))
|
||||
.provide(new UserStreamDumperPlugin(application))
|
||||
.finish())
|
||||
.enableWebKitInspector(() -> new Stetho.DefaultInspectorModulesBuilder(application)
|
||||
.runtimeRepl(new BshRuntimeReplFactoryBuilder(application).build())
|
||||
.finish())
|
||||
.build());
|
||||
initLeakCanary(application);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.restfu
|
||||
|
||||
import org.mariotaku.restfu.exception.RestException
|
||||
|
||||
inline val RestException.statusCode: Int get() = response?.status ?: -1
|
Loading…
x
Reference in New Issue
Block a user