├── annotations
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── java
│ ├── annotations
│ ├── Body.java
│ ├── Parameter.java
│ ├── ResultType.java
│ ├── DescribeClass.java
│ ├── DescribeTypes.java
│ ├── ConversionStrategy.java
│ ├── NotBindable.java
│ ├── RPCMethod.java
│ ├── Describe.java
│ ├── DefaultParameters.java
│ ├── DefaultParameter.java
│ └── RPCMethodScope.java
│ └── clearnet
│ └── annotations
│ ├── Body.java
│ ├── ResultType.java
│ ├── Parameter.java
│ ├── ConversionStrategy.java
│ ├── NotBindable.java
│ ├── RPCMethod.java
│ ├── DefaultParameters.java
│ ├── DefaultParameter.java
│ └── RPCMethodScope.java
├── clearnet
├── .gitignore
├── src
│ ├── test
│ │ └── java
│ │ │ └── clearnet
│ │ │ ├── help
│ │ │ ├── TestObject.kt
│ │ │ ├── TestRequestsForSingleScope.java
│ │ │ ├── TestConverterExecutor.kt
│ │ │ ├── executors.kt
│ │ │ ├── TestCacheProvider.kt
│ │ │ ├── TestRequestCallback.kt
│ │ │ ├── TrampolineExecutor.kt
│ │ │ ├── CoreBlocksTest.kt
│ │ │ ├── GsonTestSerializer.kt
│ │ │ ├── BatchTestRequestExecutor.kt
│ │ │ ├── stubs.kt
│ │ │ ├── TestCoreBlocks.kt
│ │ │ └── TestRequests.java
│ │ │ ├── StrategyMergerTest.kt
│ │ │ ├── SubscribeOnRequestsTest.kt
│ │ │ ├── TasksAutoBindSyncTest.kt
│ │ │ ├── SimpleHeaderObserverTest.kt
│ │ │ ├── TasksAutoBindTest.kt
│ │ │ ├── RPCRequestBuildingTest.kt
│ │ │ ├── InvocationStrategyTest.kt
│ │ │ ├── ConversionStrategiesTest.kt
│ │ │ └── BatchRequestTest.kt
│ └── main
│ │ └── java
│ │ └── clearnet
│ │ ├── error
│ │ ├── InterruptFlowRequest.kt
│ │ ├── HTTPCodeError.kt
│ │ ├── UnknownExternalException.kt
│ │ ├── NetworkException.java
│ │ ├── ResponseErrorException.java
│ │ ├── ConversionException.java
│ │ ├── ValidationException.java
│ │ └── ClearNetworkException.java
│ │ ├── blocks
│ │ ├── InitialBlock.kt
│ │ ├── DeliverErrorBlock.kt
│ │ ├── DeliverResultBlock.kt
│ │ ├── SaveToCacheBlock.kt
│ │ ├── GetFromCacheBlock.kt
│ │ └── GetFromNetBlock.kt
│ │ ├── annotations
│ │ ├── NoBatch.java
│ │ └── InvocationStrategy.java
│ │ ├── InvocationBlockType.kt
│ │ ├── known_conversion_strategies.kt
│ │ ├── RPCRequest.kt
│ │ ├── utils.kt
│ │ ├── SimpleHeadersObserver.kt
│ │ ├── InvocationStrategy.kt
│ │ ├── Wrapper.java
│ │ ├── models.kt
│ │ ├── CoreTask.kt
│ │ ├── Core.kt
│ │ ├── interfaces.kt
│ │ └── ExecutorWrapper.kt
└── build.gradle
├── processors
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── java
│ └── processors
│ ├── BaseProcessor.java
│ └── RpcResourcesGenerator.java
├── clearnetandroid
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── clearnet
│ │ │ └── android
│ │ │ ├── kutils.kt
│ │ │ ├── SqliteCacheProvider.kt
│ │ │ ├── CallbackHolder.kt
│ │ │ └── NotNullFieldsValidator.kt
│ ├── test
│ │ └── java
│ │ │ └── clearnet
│ │ │ └── android
│ │ │ ├── help
│ │ │ ├── JavaModel.java
│ │ │ ├── ImmediateExecutor.kt
│ │ │ ├── TestConverterExecutor.kt
│ │ │ ├── TestRequests.java
│ │ │ ├── GsonTestSerializer.kt
│ │ │ └── stubs.kt
│ │ │ ├── NotNullKotlinFieldsValidatorTest.kt
│ │ │ └── CallbackHolderTest.kt
│ └── androidTest
│ │ └── java
│ │ └── clearnet
│ │ └── android
│ │ └── SqliteCacheProviderTest.kt
├── CHANGELOG.md
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.MD
├── local.properties
├── gradle.properties
├── CHANGELOG.md
├── gradlew.bat
├── gradlew
└── LICENCE
/annotations/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/clearnet/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/processors/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/clearnetandroid/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':clearnet', ':annotations', ':processors', ':clearnetandroid'
2 |
--------------------------------------------------------------------------------
/clearnet/src/test/java/clearnet/help/TestObject.kt:
--------------------------------------------------------------------------------
1 | package clearnet.help
2 |
3 | data class TestObject(var test: Int)
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mailru/clearnet/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/clearnetandroid/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Clearnet Android
3 |
4 |
--------------------------------------------------------------------------------
/annotations/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 |
3 | sourceCompatibility = JavaVersion.VERSION_1_7
4 | targetCompatibility = JavaVersion.VERSION_1_7
--------------------------------------------------------------------------------
/clearnetandroid/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/README.MD:
--------------------------------------------------------------------------------
1 | # Описание
2 | Сетевой пакет clearnet служит для работы приложений с API, в т.ч. по стандарту RPC, поддерживают кеширование и сериализацию данных, работу с потоками.
--------------------------------------------------------------------------------
/clearnetandroid/src/test/java/clearnet/android/help/JavaModel.java:
--------------------------------------------------------------------------------
1 | package clearnet.android.help;
2 |
3 | public class JavaModel {
4 | public String required;
5 | public String optional;
6 | }
7 |
--------------------------------------------------------------------------------
/clearnet/src/test/java/clearnet/help/TestRequestsForSingleScope.java:
--------------------------------------------------------------------------------
1 | package clearnet.help;
2 |
3 | import annotations.RPCMethodScope;
4 |
5 | @RPCMethodScope("test")
6 | public interface TestRequestsForSingleScope {
7 | void tryIt();
8 | }
9 |
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/error/InterruptFlowRequest.kt:
--------------------------------------------------------------------------------
1 | package clearnet.error
2 |
3 | class InterruptFlowRequest(message: String) : ClearNetworkException(message) {
4 |
5 | init {
6 | kind = KIND.INTERRUPT_FLOW_REQUESTED
7 | }
8 | }
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/error/HTTPCodeError.kt:
--------------------------------------------------------------------------------
1 | package clearnet.error
2 |
3 | class HTTPCodeError(val code: Int, val response: String?) : ClearNetworkException("Http code error: $code") {
4 | init {
5 | kind = KIND.HTTP_CODE
6 | }
7 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/clearnetandroid/src/test/java/clearnet/android/help/ImmediateExecutor.kt:
--------------------------------------------------------------------------------
1 | package clearnet.android.help
2 |
3 | import java.util.concurrent.Executor
4 |
5 | object ImmediateExecutor : Executor {
6 | override fun execute(task: Runnable) {
7 | task.run()
8 | }
9 | }
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/error/UnknownExternalException.kt:
--------------------------------------------------------------------------------
1 | package clearnet.error
2 |
3 | class UnknownExternalException (message: String?) : ClearNetworkException(message) {
4 |
5 | init {
6 | kind = ClearNetworkException.KIND.UNKNOWN_EXTERNAL_ERROR
7 | }
8 | }
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/blocks/InitialBlock.kt:
--------------------------------------------------------------------------------
1 | package clearnet.blocks
2 |
3 | import clearnet.InvocationBlockType
4 | import clearnet.interfaces.IInvocationBlock
5 |
6 | object InitialBlock : IInvocationBlock {
7 | override val invocationBlockType = InvocationBlockType.INITIAL
8 | }
--------------------------------------------------------------------------------
/processors/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | sourceCompatibility = JavaVersion.VERSION_1_7
3 | targetCompatibility = JavaVersion.VERSION_1_7
4 |
5 | dependencies {
6 | compile project(':annotations')
7 | compile 'com.squareup:javapoet:1.8.0'
8 | compile 'com.google.auto.service:auto-service:1.0-rc3'
9 | }
10 |
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/error/NetworkException.java:
--------------------------------------------------------------------------------
1 | package clearnet.error;
2 |
3 | import java.io.IOException;
4 |
5 | public class NetworkException extends ClearNetworkException {
6 | {
7 | kind = KIND.NETWORK;
8 | }
9 |
10 | public NetworkException(IOException cause){
11 | super(cause);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/Body.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.PARAMETER)
10 | public @interface Body {
11 | }
12 |
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/error/ResponseErrorException.java:
--------------------------------------------------------------------------------
1 | package clearnet.error;
2 |
3 | public class ResponseErrorException extends ClearNetworkException {
4 | public final Object error;
5 |
6 | {
7 | kind = KIND.RESPONSE_ERROR;
8 | }
9 |
10 | public ResponseErrorException(Object error){
11 | this.error = error;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/annotations/src/main/java/clearnet/annotations/Body.java:
--------------------------------------------------------------------------------
1 | package clearnet.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.PARAMETER)
10 | public @interface Body {
11 | }
12 |
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/annotations/NoBatch.java:
--------------------------------------------------------------------------------
1 | package clearnet.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface NoBatch {
11 | }
12 |
--------------------------------------------------------------------------------
/clearnetandroid/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # v1.1.1
2 | - Удаление retrolambda
3 |
4 | # v1.1
5 | - Поддержка clearnet 2.0
6 |
7 | # v1.0.3
8 | - Добавлено inline `wrap` расширение для еще большего сахара
9 |
10 | # v1.0.2
11 | - Добавлены экстеншены на `Callbackholder` для сахарного wrap-инга на котлиновские лямбды
12 | - Добавлены экстеншены `hold` на `Disposable` и `Subscriber` для небольшого сахара
--------------------------------------------------------------------------------
/clearnet/src/test/java/clearnet/help/TestConverterExecutor.kt:
--------------------------------------------------------------------------------
1 | package clearnet.help
2 |
3 | import clearnet.interfaces.IConverterExecutor
4 | import clearnet.model.PostParams
5 |
6 | class TestConverterExecutor : IConverterExecutor {
7 | var lastParams: PostParams? = null
8 |
9 | override fun executePost(postParams: PostParams) {
10 | lastParams = postParams
11 | }
12 | }
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/Parameter.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.PARAMETER)
10 | public @interface Parameter {
11 | String value();
12 | }
13 |
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/ResultType.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface ResultType {
11 | Class value();
12 | }
13 |
--------------------------------------------------------------------------------
/clearnet/src/test/java/clearnet/help/executors.kt:
--------------------------------------------------------------------------------
1 | package clearnet.help
2 |
3 | import java.util.concurrent.Executor
4 |
5 | object ImmediateExecutor : Executor {
6 | override fun execute(task: Runnable) {
7 | task.run()
8 | }
9 | }
10 |
11 | object MultiThreadExecutor : Executor {
12 | override fun execute(command: Runnable) {
13 | Thread(command).start()
14 | }
15 | }
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/DescribeClass.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 |
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | @Target(ElementType.TYPE)
10 | @Retention(RetentionPolicy.SOURCE)
11 | public @interface DescribeClass {
12 | Class types();
13 | }
14 |
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/DescribeTypes.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 |
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | @Target(ElementType.FIELD)
10 | @Retention(RetentionPolicy.SOURCE)
11 | public @interface DescribeTypes {
12 | String[] value();
13 | }
14 |
--------------------------------------------------------------------------------
/clearnetandroid/src/test/java/clearnet/android/help/TestConverterExecutor.kt:
--------------------------------------------------------------------------------
1 | package clearnet.android.help
2 |
3 | import clearnet.interfaces.IConverterExecutor
4 | import clearnet.model.PostParams
5 |
6 | class TestConverterExecutor : IConverterExecutor {
7 | var lastParams: PostParams? = null
8 |
9 | override fun executePost(postParams: PostParams) {
10 | lastParams = postParams
11 | }
12 | }
--------------------------------------------------------------------------------
/annotations/src/main/java/clearnet/annotations/ResultType.java:
--------------------------------------------------------------------------------
1 | package clearnet.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface ResultType {
11 | Class value();
12 | }
13 |
--------------------------------------------------------------------------------
/annotations/src/main/java/clearnet/annotations/Parameter.java:
--------------------------------------------------------------------------------
1 | package clearnet.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.PARAMETER)
10 | public @interface Parameter {
11 | String value();
12 | }
13 |
--------------------------------------------------------------------------------
/clearnet/src/main/java/clearnet/error/ConversionException.java:
--------------------------------------------------------------------------------
1 | package clearnet.error;
2 |
3 | public class ConversionException extends ClearNetworkException {
4 | {
5 | kind = KIND.CONVERSION;
6 | }
7 |
8 | public ConversionException(Throwable cause){
9 | super(cause);
10 | }
11 |
12 | public ConversionException(String message, Throwable cause){
13 | super(message, cause);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Wed Jan 30 12:07:38 MSK 2019
8 | ndk.dir=/Users/t.aliev/Library/Android/sdk/ndk-bundle
9 | sdk.dir=/Users/t.aliev/Library/Android/sdk
10 |
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/ConversionStrategy.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface ConversionStrategy {
11 | Class value();
12 |
13 | String parameter() default "";
14 | }
15 |
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/NotBindable.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Disallows callbacks to auto or manual binding to running tasks
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target(ElementType.METHOD)
13 | public @interface NotBindable {
14 | }
15 |
--------------------------------------------------------------------------------
/annotations/src/main/java/annotations/RPCMethod.java:
--------------------------------------------------------------------------------
1 | package annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Represents the full name of an rpc method
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target(ElementType.METHOD)
13 | public @interface RPCMethod {
14 | String value();
15 | }
16 |
--------------------------------------------------------------------------------
/clearnetandroid/src/test/java/clearnet/android/help/TestRequests.java:
--------------------------------------------------------------------------------
1 | package clearnet.android.help;
2 |
3 | import annotations.RPCMethodScope;
4 | import clearnet.interfaces.RequestCallback;
5 | import io.reactivex.Observable;
6 |
7 | public interface TestRequests {
8 | @RPCMethodScope("test")
9 | void requestWithCallback(RequestCallback