-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,348 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
network-hooks-chucker/src/main/java/com/hss01248/network/chucker/OkhttpHookForChuck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.hss01248.network.chucker; | ||
|
||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import androidx.startup.Initializer; | ||
|
||
import com.hss01248.aop.network.hook.OkhttpAspect; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import okhttp3.Interceptor; | ||
import okhttp3.OkHttpClient; | ||
|
||
/** | ||
* @Despciption todo | ||
* @Author hss | ||
* @Date 21/02/2022 11:46 | ||
* @Version 1.0 | ||
*/ | ||
public class OkhttpHookForChuck implements OkhttpAspect.OkhttpHook, Initializer<String> { | ||
@Override | ||
public void beforeBuild(OkHttpClient.Builder builder) { | ||
List<Interceptor> interceptors1 = builder.interceptors(); | ||
boolean hasChucker = false; | ||
for (Interceptor interceptor : interceptors1) { | ||
/*if(interceptor instanceof ChuckInterceptor){ | ||
hasChucker = true; | ||
break; | ||
} else if(interceptor.getClass().getSimpleName().contains("Chuck")){ | ||
hasChucker = true; | ||
break; | ||
}*/ | ||
} | ||
|
||
if(!hasChucker){ | ||
// builder.addInterceptor(new ChuckInterceptor(Utils.getApp())); | ||
// builder.addInterceptor(new PrintCookieNetworkInterceptor()); | ||
} | ||
} | ||
|
||
@Override | ||
public String create(Context context) { | ||
Log.d("init","OkhttpHookForChucker.init start"); | ||
OkhttpAspect.addHook(new OkhttpHookForChuck()); | ||
return "OkhttpHookForChucker"; | ||
} | ||
|
||
@Override | ||
public List<Class<? extends Initializer<?>>> dependencies() { | ||
return new ArrayList<>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.