Atomic


Source link: https://github.com/shiburagi/Atomic

Atomic

An android restful api/networking library using okhttp library as backbone.

Android 9.0+ support

Including In Your Project

If you are a Maven user you can easily include the library by specifying it as a dependency:

Maven

<dependency>
<groupId>com.infideap.atomic</groupId>
<artifactId>atomic</artifactId>
<version>0.0.3</version>
<type>pom</type> </dependency>

Gradle

dependencies {

 compile 'com.infideap.atomic:atomic:0.0.3' 
}

if the gradle unable to sync, you may include this line in project level gradle,

repositories {
  maven{

 url "https://dl.bintray.com/infideap2/Atomic/"  
}
 
}

or, you can include it by download this project and import /atomic as module.

How to use

POST

Atom.with(LoginActivity.this)
  .load("https://reqres.in/api/login")
  .setJsonPojoBody(loginRequest)
  .as(LoginResponse.class)
  .setCallback(new FutureCallback<LoginResponse>() {

@Override

public void onCompleted(Exception e, LoginResponse result) {

 if (e != null) {

  e.printStackTrace();

 
}
 else if (result.token != null) {

  Snackbar.make(v, "Pass : " + result.token, Snackbar.LENGTH_LONG).show();

 
}
 else if (result.error != null) {

  Snackbar.make(v, "Fail : " + result.error, Snackbar.LENGTH_LONG).show();

 
}

}

  
}
);

GET

Atom.with(LoginActivity.this)
  .load("https://reqres.in/api/users/2")
  .as(UserResponse.class)
  .setCallback(new FutureCallback<LoginResponse>() {

@Override

public void onCompleted(Exception e, UserResponse result) {

 if (e != null) {

  e.printStackTrace();

 
}
 else if (result.first_name != null) {

  Snackbar.make(v, "Pass : " + result.first_name, Snackbar.LENGTH_LONG).show();

 
}

 
}

  
}
);

Other, just add method after url on load()

Atom.with(LoginActivity.this)
  .load("https://reqres.in/api/users/2", Atom.DELETE_METHOD)
  .asString()
  .setCallback(new FutureCallback<String>() {

@Override

public void onCompleted(Exception e, String result) {

 if (e != null) {

  e.printStackTrace();

 
}
 else if (result != null) {

  Snackbar.make(v, "Pass : " + result, Snackbar.LENGTH_LONG).show();

 
}

 
}

  
}
);

Upload File

Atom.with(LoginActivity.this)
  .load("https://reqres.in/api/user/2")
  .setJsonPojoBody(userRequest)
  .setMultipartFile("uploadFile", new File("video.mp4"))
  //Optional: Upload Progress
  .uploadProgress(new ProgressCallback() {

@Override

public void onProgress(long uploaded, long total) {

 
}

  
}
)
  .as(UserResponse.class)
  .setCallback(new FutureCallback<UserResponse>() {

@Override

public void onCompleted(Exception e, UserResponse result) {

 if (e != null) {

  e.printStackTrace();

 
}

 
}

  
}
);

Download File

Atom.with(LoginActivity.this)
  .load("https://developer.android.com/_static/66ebbcad58/images/android/touchicon-180.png")
  //Optional: Progress
  .progress(new ProgressCallback() {

@Override

public void onProgress(long downloaded, long total) {

 
}

  
}
)
  .write(new File("android.png"))
  .setCallback(new FutureCallback<File>() {

@Override

public void onCompleted(Exception e, File result) {

 
}

  
}
);

Advance

Customize

OkHttpClient client =new OkHttpClient.Builder().addInterceptor(new Interceptor() {

  @Override
  public Response intercept(Chain chain) throws IOException {

return null;
  
}
 
}
).build();
 Atom.setClient(client);

Contact

For any enquiries, please send an email to [email protected].

License

Copyright 2016-2017 Shiburagi  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Android Runtime Permissions Library to support Android 6.0+

NetSugar is an Android + AOP framework. It was a way of Aspect-Oriented Programming with AspectJ(ApsectJ 5) on Android. It is an easy-use and lightweight framework to check network state.

Utilities for using RxJava with Realm.

Snacky is a small library to help you adding a Snackbar to your layout with ease. Snacky uses an easy builder pattern to build a Snackbar and gives you some template designs like ERROR, WARNING, INFO and SUCCESS as well as some customization options.

Android layout to show most common state templates like loading, empty, error etc. To do that all you need to is wrap the target area(view) with StatefulLayout.

Rx2Animations is a library with the main goal to make android animations more solid and cohesive.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes