@@ -35,9 +35,9 @@ It brings structure to Android networking: explicit commands (GET/POST/PUT/PATCH
3535
3636## Highlights
3737
38- * ** Command Pattern** : ` GetCommand ` , ` PostCommand ` , ` PutCommand ` , ` PatchCommand ` , ` DeleteCommand ` , ` MultipartCommand ` .
38+ * ** Command Pattern** : ` HttpGet ` , ` HttpPost ` , ` HttpPut ` , ` HttpDelete ` , ` HttpMultipartUpload ` .
3939* ** CancellableFuture<T >** : Compose like ` CompletableFuture ` , cancel at will.
40- * ** Retry & Backoff** : 10+ strategies (Exponential, Jitter, CircuitBreaker, Payload-aware).
40+ * ** Retry & Backoff** : Multiple strategies (Exponential, Jitter, CircuitBreaker, Payload-aware).
4141* ** Interceptors** : Logging, Auth, Idempotency headers, custom.
4242* ** Response Parsing** : Pluggable (default: Gson, passthrough for raw strings).
4343* ** Service Layer** : Each domain use case (e.g., ` CreateTodoUseCase ` ) mapped to a ` Service ` implementation.
@@ -51,15 +51,8 @@ It brings structure to Android networking: explicit commands (GET/POST/PUT/PATCH
5151### 1) Configure NetworkManager
5252
5353``` java
54- OkHttpClient ok = new OkHttpClient .Builder ()
55- .connectTimeout(Duration . ofSeconds(10 ))
56- .readTimeout(Duration . ofSeconds(20 ))
57- .callTimeout(Duration . ofSeconds(30 ))
58- .retryOnConnectionFailure(true )
59- .build();
60-
6154NetworkManager nm = new NetworkManager .Builder ()
62- .factory(new OkHttpConnectionFactory (ok ))
55+ .factory(new HttpUrlConnectionFactory ( ))
6356 .parser(new GsonResponseParser ())
6457 .addInterceptor(new LoggingInterceptor ())
6558 .threadPoolSize(4 )
@@ -70,16 +63,14 @@ NetworkManager nm = new NetworkManager.Builder()
7063### 2) Define APIs
7164
7265``` java
73- public class TodoApi extends ABaseApi {
66+ public class TodoApi extends BaseApi {
7467 private static final String BASE_URL = " https://jsonplaceholder.typicode.com" ;
75- private static final Gson GSON = new Gson ();
7668
7769 public TodoApi (NetworkManager nm ) { super (BASE_URL , nm); }
7870
7971 public CancellableFuture<TodoDto > getTodoById (int id ) {
80- Type t = new TypeToken<TodoDto > () {}. getType();
81- ACommand cmd = new GetCommand (" /todos/" + id, null , null );
82- return send(cmd, t);
72+ HttpGet cmd = new HttpGet (" /todos/" + id, null , null );
73+ return send(cmd, TodoDto . class);
8374 }
8475}
8576```
@@ -134,7 +125,7 @@ Cancel easily in `onDestroy`:
134125* Customize per-command:
135126
136127``` java
137- ACommand cmd = new PostCommand (" /todos" , body, null )
128+ HttpPost cmd = new HttpPost (" /todos" , body, null )
138129 .withRetryPolicy(new PayloadSensitiveRetryPolicy (body. length(), 2 ));
139130```
140131
@@ -150,8 +141,11 @@ ACommand cmd = new PostCommand("/todos", body, null)
150141## Upload Support
151142
152143``` java
153- UploadApi api = new UploadApi (nm);
154- CancellableFuture<UploadResponse > up = api. uploadProfile(file, fields, headers);
144+ HttpMultipartUpload upload = new HttpMultipartUpload (" /profile" );
145+ upload. addFile(" avatar" , file);
146+ upload. addField(" userId" , " 42" );
147+
148+ CancellableFuture<UploadResponse > up = nm. execute(upload, UploadResponse . class);
155149```
156150
157151Payload-sensitive retry policy ensures large uploads are never retried blindly.
@@ -213,7 +207,7 @@ RetryPolicy policy = new RateLimitAwareRetryPolicy(
213207``` mermaid
214208flowchart TD
215209 %% Layers
216- subgraph "UI Layer"
210+ subgraph "UI Layer"
217211 direction TB
218212 UI["Android Activities & Adapters"]:::ui
219213 end
@@ -236,37 +230,44 @@ flowchart TD
236230
237231 subgraph "Network Core"
238232 direction TB
239- NetCore["NetworkManager, ABaseApi, Commands,\\nInterceptors, Parsers, Strategies"]:::network
233+ NetCore["NetworkManager, BaseApi, Http Commands,\nInterceptors, Parsers, Strategies"]:::network
234+ end
235+
236+ subgraph "Concurrency Core"
237+ direction TB
238+ ConcurrencyCore["CancellableFuture, AsyncExecutor"]:::concurrency
240239 end
241240
242241 subgraph "HTTP Adapter"
243242 direction TB
244243 HTTPAdapter["IHttpConnection & Factories"]:::http
245244 end
246245
247- External["External HTTP Endpoints\\ n(jsonplaceholder.typicode.com)"]:::external
246+ External["External HTTP Endpoints\n(jsonplaceholder.typicode.com)"]:::external
248247
249248 %% Data Flow
250249 UI -->|"calls UseCase.handle()"| Domain
251250 Domain -->|"invokes Service.handle()"| AppService
252251 AppService -->|"calls Api method"| API
253- API -->|"constructs ACommand "| NetCore
252+ API -->|"constructs HttpCommand "| NetCore
254253 NetCore -->|"uses IHttpConnectionAdapter"| HTTPAdapter
254+ NetCore -->|"manages async ops"| ConcurrencyCore
255255 HTTPAdapter -->|"sends HTTP request"| External
256256 External -->|"HTTP response"| HTTPAdapter
257257 HTTPAdapter -->|"returns raw response"| NetCore
258258 NetCore -->|"parses to DTO"| DTO
259259 DTO -->|"mapped to Domain Model"| Domain
260260 Domain -->|"CancellableFuture result"| UI
261261
262- %% Click Events
263- click UI "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit"
264- click Domain "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/domain"
265- click AppService "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/application/service"
266- click API "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/application/api"
267- click DTO "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/data/remote/dto"
268- click NetCore "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/net"
269- click HTTPAdapter "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/net/connection"
262+ %% Click Events (use plain URLs in Mermaid)
263+ click UI "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit" _blank
264+ click Domain "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/domain" _blank
265+ click AppService "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/application/service" _blank
266+ click API "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/application/api" _blank
267+ click DTO "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/data/remote/dto" _blank
268+ click NetCore "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/net" _blank
269+ click HTTPAdapter "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/net/connection" _blank
270+ click ConcurrencyCore "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/concurrent" _blank
270271
271272 %% Styles
272273 classDef ui fill:#AED6F1,stroke:#3498DB,color:#1B4F72,stroke-width:2px;
@@ -275,6 +276,7 @@ flowchart TD
275276 classDef api fill:#D2B4DE,stroke:#8E44AD,color:#4A235A,stroke-width:2px;
276277 classDef data fill:#D5DBDB,stroke:#7B7D7D,color:#1B2631,stroke-width:2px;
277278 classDef network fill:#F5B7B1,stroke:#E74C3C,color:#641E16,stroke-width:2px;
279+ classDef concurrency fill:#B1F5B7,stroke:#2ECC71,color:#1E6416,stroke-width:2px;
278280 classDef http fill:#D6EAF8,stroke:#5499C7,color:#1A5276,stroke-width:2px;
279281 classDef external fill:#ECECEC,stroke:#A6ACAF,color:#616A6B,stroke-width:2px;
280282```
0 commit comments