Skip to content

Light sized network library designed specifically, but not only, to be used by custom library projects.

License

Notifications You must be signed in to change notification settings

EitanSchwartz/light-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Taboola Android SDK

Platform

Table Of Contents

  1. Getting Started
  2. Proguard
  3. License

1. Getting Started

1.1. Minimum requirements

  • Android version 4.0 (android:minSdkVersion="14")

1.2. Incorporating the SDK

  1. Download and add the source code to your project. Notethat this library does not require additional dependencies.

  2. Include this line in your app’s AndroidManifest.xml to allow Internet access

<uses-permission android:name="android.permission.INTERNET" />
  1. In order to use optional network state checks, this library uses the NetworkInfo api. This requires the following permission
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />    

2. ProGuard

You can find proguard rules for Taboola LightNetwork in proguard-rules.pro file.

At this moment just add the following line:

-keep class com.taboola.lightnetwork.** { *; }

3. License

This program is licensed under the Apache 2.0 License Agreement (the “License Agreement”). By copying, using or redistributing this program, you agree with the terms of the License Agreement. The full text of the license agreement can be found at https://github.com/taboola/LightNetwork/blob/master/LICENSE. Copyright 2019 Taboola, Inc. All rights reserved.

4. Quick Use Guide

  1. Define a network interface
public interface SampleNetworkApi {      
  @GET("http://www.example.com/")
  public DynamicRequest sampleNetworkRequest1();

  
  @POST("https://www.example.com/")
  public DynamicRequest sampleNetworkRequest2();
}
  1. Create a DynamicRequest object out of that interface
// Define NetworkExecutable instance
NetworkExecutable networkExecutable = new NetworkExecutable(<networkManager>);

// Create network object
SampleNetworkApi sampleNetworkApi = networkExecutable.create(SampleNetworkApi.class);

// Access network API synchronously
sampleNetworkApi.sampleNetworkRequest1.execute();

// Access network API using a NetworkResponse callback
sampleNetworkApi.sampleNetworkRequest2.execute(new NetworkResponse(){..});

public interface SampleNetworkApi {
 DynamicRequest sampleNetworkRequest1();
 DynamicRequest sampleNetworkRequest2();
}
  1. Request definition tags

3.1. Using Available Protocols:

Currently all requests can either be Http Get or Http Post. To define the protocol, put the relevant annotation on top of defined method in your interface.

@GET - Perform HTTP GET request.
@GET("http://www.example.com/{mee}/{yaoo}")
@POST - Perform POST request.
@POST("https://postman-echo.com/post")

3.2. Using Available Annotations:

@Path - Replace path parameter in url.
@GET("http://www.example.com/{mee}/{yaoo}")
DynamicRequest getA(@Path("mee") String mee, @Path("yaoo") String yaoo);
@Query - Add key=value query pair in url.
@GET("https://www.example.com/")
DynamicRequest getB(@Query("hai") String ya);
@Body - Add JSONObject body to a POST request.
@POST("https://postman-echo.com/post")
DynamicRequest postA(@Body JSONObject jsonBody);

About

Light sized network library designed specifically, but not only, to be used by custom library projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages