Tpamore / Tina
Licence: apache-2.0
a powerful android network library base on okhttp
Stars: ✭ 32
Programming Languages
java
68154 projects - #9 most used programming language
Projects that are alternatives of or similar to Tina
Easygo
基于Kotlin、OkHttp的声明式网络框架,像写HTML界面一样写网络调用代码
Stars: ✭ 40 (+25%)
Mutual labels: library, network, okhttp
Newnode
NewNode decentralized Content Distribution Network
Stars: ✭ 223 (+596.88%)
Mutual labels: library, network
Kau
An extensive collection of Kotlin Android Utils
Stars: ✭ 182 (+468.75%)
Mutual labels: library, utils
Ofxgpio
Library C++ for raspberrypi and orangepi, GPIO interfaces compatible with openframeworks.
Stars: ✭ 155 (+384.38%)
Mutual labels: library, network
Dublin Traceroute
Dublin Traceroute is a NAT-aware multipath tracerouting tool
Stars: ✭ 159 (+396.88%)
Mutual labels: library, network
Just
A library of dependency-free JavaScript functions that do just do one thing.
Stars: ✭ 3,837 (+11890.63%)
Mutual labels: library, utils
Ruffles
Lightweight and fully managed reliable UDP library.
Stars: ✭ 131 (+309.38%)
Mutual labels: library, network
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+16606.25%)
Mutual labels: network, okhttp
Netutils Linux
A suite of utilities simplilfying linux networking stack performance troubleshooting and tuning.
Stars: ✭ 664 (+1975%)
Mutual labels: utils, network
Librg
🚀 Making multi-player gamedev simpler since 2017
Stars: ✭ 813 (+2440.63%)
Mutual labels: library, network
Android Cookie Store
Android InMemory and persistent Cookie Store for HttpURLConnection and OkHttp, with extensions to easily sync cookies in Android WebViews.
Stars: ✭ 144 (+350%)
Mutual labels: library, okhttp
Easydeviceinfo
📱 [Android Library] Get device information in a super easy way.
Stars: ✭ 1,698 (+5206.25%)
Mutual labels: library, network
Txeh
Go library and CLI utilty for /etc/hosts management.
Stars: ✭ 181 (+465.63%)
Mutual labels: library, network
Chucker
🔎 An HTTP inspector for Android & OkHTTP (like Charles but on device)
Stars: ✭ 2,169 (+6678.13%)
Mutual labels: library, okhttp
Stdlib
✨ Standard library for JavaScript and Node.js. ✨
Stars: ✭ 2,749 (+8490.63%)
Mutual labels: library, utils
Androidutilcode
AndroidUtilCode 🔥 is a powerful & easy to use library for Android. This library encapsulates the functions that commonly used in Android development which have complete demo and unit test. By using it's encapsulated APIs, you can greatly improve the development efficiency. The program mainly consists of two modules which is utilcode, which is commonly used in development, and subutil which is rarely used in development, but the utils can be beneficial to simplify the main module. 🔥
Stars: ✭ 30,239 (+94396.88%)
Mutual labels: utils, network
Macfinder
An iOS Library that helps you find the MAC Address of a specific IP
Stars: ✭ 57 (+78.13%)
Mutual labels: library, network
Libqtshadowsocks
A lightweight and ultra-fast shadowsocks library written in C++14 with Qt framework
Stars: ✭ 1,455 (+4446.88%)
Mutual labels: library, network
Qsimpleupdater
Updater system for Qt applications
Stars: ✭ 429 (+1240.63%)
Mutual labels: library, network
Tina
Other: 中文版
Simple API Simple use
How to use
dependencies {
api 'com.tpa.client:tina:1.1.2'
annotationProcessor 'com.tpa.client:tina-compiler:1.0.0'
}
Proguard
## request
-keep public class * extends com.tpa.client.tina.model.TinaBaseRequest {
public void set*(***);
public *** get*();
public *** is*();
}
## response
-keep public class * extends ${BaseResponseClass} {
*;
}
init
public interface TinaConfig {
/** okhttpclient config **/
public @NonNull OkHttpClient getOkhttpClient();
/** mediaType config **/
public @NonNull MediaType getMediaType();
/** host url **/
public @NonNull String getHost();
public @Nonable TinaFilter getTinaFilter();
/** It is typically used to encrypt the request body data **/
public @Nullable TinaConvert getRequestConvert();
}
Tina.initConfig(tinaConfig);
Single request
The flow chart
@Post("url")
public class Reqest extends TinaBaseRequest{
private String name = "tqf";
private String sex = "man";
}
------------------------------------------------------
Reqest request = new Reqest();
Tina.build()
.call(request)
.callBack(new TinaSingleCallBack<Response>() {
@Override
public void onSuccess(Response response) {
}
@Override
public void onFail(TinaException e) {
}
})
.request();
Chain request
The flow chart
@Post("url")
public class Reqest extends TinaBaseRequest{
private String name = "tqf";
private String sex = "man";
}
------------------------------------------
Reqest request = new Reqest();
Tina.build(Tina.CHAINS)
.call(request)
.call(request)
.callBack(new TinaChainCallBack<TinaBaseResponse>() {
@Override
public Object onSuccess(Object feedbackResult,TinaBaseResponse response) {
return null;
}
@Override
public void onFail(TinaException e) {
}
})
.callBack(new TinaChainCallBack<TinaBaseResponse>() {
@Override
public Object onSuccess(Object feedbackResult, TinaBaseResponse response) {
return null;
}
@Override
public void onFail(TinaException e) {
}
})
.request();
TinaChainCallBack
- feedbackResult : The result passed from the previous request
- return : The result passed to the next request. If TinaChain.FUSING is returned, the chain request is interrupted.
Concurrent request
The flow chart
@Post("url")
public class Reqest extends TinaBaseRequest{
private String name = "tqf";
private String sex = "man";
}
----------------------------------------------------------
Reqest request = new Reqest();
Tina.build(Tina.CONCURRENT)
.call(request)
.call(request)
.callBack(new TinaSingleCallBack<TinaBaseResponse>() {
@Override
public void onSuccess(TinaBaseResponse response) {
}
@Override
public void onFail(TinaException e) {
}
})
.callBack(new TinaSingleCallBack<TinaBaseResponse>() {
@Override
public void onSuccess(TinaBaseResponse response) {
}
@Override
public void onFail(TinaException e) {
}
})
.request();
startCallBack and endCallBack
...
.startCallBack(new TinaStartCallBack() {
@Override
public void start() {
}
})
.endCallBack(new TinaEndCallBack() {
@Override
public void end() {
}
})
...
filter
Tina.build()
.filter(new TinaFilter() {
@Override
public TinaFilterResult filter(TinaBaseRequest request, byte[] body, Class expect) {
return null;
}
})
...
Customize the response class type
Tina.build()
.filter(BitmapFilter.build())
.callBack(request)
.callBack(new TinaSingleCallBack<Bitmap>() {
@Override
public void onSuccess(Bitmap bitmap) {
}
@Override
public void onFail(TinaException e) {
}
})
.request();
deamon
Tina.build()
.deamon(activity)
...
A request will be cancelled with the activity's destoryed
@AutoModel
how to use
@AutoMode
public class AnswererListResponse {
}
The @Automodel annotated resposne recursively loops around the entire response model, filling in all the empty objects.
Before
if(data != null && data.getData1() != null && data.getData1().getData2 != null){
do(data.getData1().getData2());
}
else{
//do somethings
}
After
do(data.getData1().getData2());
@IgnoreInfate
Ignore inject
@NumberScale
@AutoMode
public class Response {
@NumberScale(2)
private String data = 3.1415926; // 3.14
}
@NotNull
@AutoMode
public class Response {
@NotNull(message = "data field cannot be empty")
private String data;
}
Custom annotations
See the implementation of @notnull and @numberscale for details
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface NotNull {
public String message() default "";
}
public class NotNullHandler implements TinaAnnotationHandler<NotNull>{
@Override
public void hanld(NotNull annotation, Object host, Field field) throws TinaDataException{
try {
Object o = field.get(host);
if (o == null) {
throw new TinaDataException(annotation.message());
}
} catch (IllegalAccessException e) {
}
}
}
TinaAnnotationManager.getInstance().register(NotNull.class , new NotNullHandler());
@Cache
@Cache(key = "key" , expire = 1000 , unit = TimeUnit.SECONDS)
public class Request extends TinaBaseRequest {
}
Request request = new Request();
// If the cache is hit, no network request is called. Single CallBack
Tina.build()
.call(request)
.callBack(new TinaSingleCallBack<Response>() {
@Override
public void onSuccess(Response response) {
//response
}
@Override
public void onFail(TinaException exception) {
}
})
.request();
// A network request is called regardless of whether the cache is hit or not. Double CallBack
Tina.build()
.call(request)
.callBack(new TinaSingleCacheCallBack<Response>() {
@Override
public void onSuccess(Response response) {
//fresh response
}
@Override
public void onCache(Response response) {
//cache response
}
@Override
public void onFail(TinaException exception) {
}
})
.request();
about restful
support
POST
、GET
、PUT
、DELETE
、PATCH
。
Grammar 1
@Delete("/name/{name}/sex/{sex}")
public class Reqest extends TinaBaseRequest{
@Path("name")
private String name = "tqf";
@Path("sex")
private String sex = "man";
}
>>> DELETE /name/tqf/sex/man
Grammar 2
@Delete("/name/:name/sex/:sex")
public class Reqest extends TinaBaseRequest{
private String name = "tqf";
private String sex = "man";
}
>>> DELETE /name/tqf/sex/man
@Delete("/name/:name/sex/:sex?")
public class Reqest extends TinaBaseRequest{
private String name = "tqf";
private String sex = null;
}
>>> DELETE /name/tqf/sex
Multi-configuration support
@ConfigId("Pay")
class Config implements TinaConfig{
...
}
Tina.addConfig(new Config());
--- gradle clean build ---
/*
* Automatically generate PayTina
*/
PayTina.build()...
live templates
import
First, download the settings.jar and keep it local >>>>> settings.jar
Open AndroidStudio and select AndroidStudio - File - Import Setttings
Select the setting.jar
abbreviation
- tina_contract : Generate model contract
- tina_singleReq : Generate a simple request
- tina_singleReq2 : Generate simple requests with endCallBack and startCallBack
- tina_chainReq : Generate chain request
- tina_chainReq2 : Generate chain requests with endCallBack and startCallBack
- tina_concurrentReq : Generate a concurrent request
- tina_concurrentReq2 : Generate a concurrent request with endCallBack and startCallBack
Provided as a simple reference, live templates can be modified to suit your business needs
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].