Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

Related tags

Utility android java api
Overview

Android Arsenal Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.

GitHub stars

API Calling Flow

API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service) in Android.

Download example App here or checkout example.

Features

  • Internal Network State Checking.
  • On screen Setting's shortcuts to enable Wi-FI or Mobile Data.
  • Hide unloaded screen during API call and show progress bar with white or transparent background.
  • "Try Again" same API after enabling Network connection.
  • Call API only if the Network connection is enabled.
  • Remove progress bar after successfully loading data on screen.
  • Show full-screen errors to users and hide unloaded screen from user for better user experience.

Setup

In your Project's build.gradle file:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
		...
	}
}

In your Application's or Module's build.gradle file:

dependencies {
  ...
  compile 'com.github.RohitSurwase.API-Calling-Flow:api-calling-flow:1.1'
  ...
}

Screenshots

Case 1. when Network connection is not available-

Network Connection is not available Setting's shortcut to enable Network Connection
Network Connection is not available Setting's shortcut to enable Network Connection

Case 2. When Network connection is available and API is successful-

Network Connection is available API requested API successful, data loaded
Network Connection is available API requested API successful, data loaded

Case 3. When Network connection is available but API is failed-

Network Connection is available API requested API failed, error shown
Network Connection is available API requested API failed, error shown

Code Example

Refer to the example for complete implementation and usage.

  • Step 1: Get reference to root layout of Activity or Fragment. Root layout can be any ViewGroup

Example-

RelativeLayout parentLayout = (RelativeLayout) findViewById(R.id.rootLayout);
  • Step 2: Crete Object of ApiCallingFlow and implement methods.

    • 1st parameter - context
    • 2nd parameter - parentLayout from step 1
    • 3rd parameter - true for transparent background, false for default white background
  • Step 3: Pass function to call current API on click of try again.

      private void requestTestApi() {
      ...
    
      ApiCallingFlow apiCallingFlow = new ApiCallingFlow(this, parentLayout, false) {
      	@Override
      	public void callCurrentApiHere() {
      		//Step 3: Pass function to call current API
      		requestTestApi();
      	}
      };
    
      ...
      }
    
  • Step 4: Get current Network state using apiCallingFlow.getNetworkState() and request API accordingly.

  • Step 5: Call apiCallingFlow.onSuccessResponse() in API success function.

  • Step 6: Call apiCallingFlow.onErrorResponse() in API error function.

Customizations

Change progressbar color according to your app theme. By default progrebar has R.color.colorAccent color But if you want to customize it, you can do it by passing additional parameter to the function.

...
ApiCallingFlow apiCallingFlow = new ApiCallingFlow(this, parentLayout, false, R.color.progressBarColor) {
...

License

Copyright 2017-18 Rohit Surwase

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.

Contributing to API Calling Flow Library

Just make pull request. You are in!

You might also like...
Very easy to use wrapper library for Android SharePreferences

Treasure English document Treasure是一个Android平台上基于SharePreferences的偏好存储库,只需要定义接口,无需编写实现,默认支持Serializable和Parcelable。运行时0反射,不仅使用方便而且性能和原生写法几乎无差别。 使用方法 1

A simple and easy to use stopwatch and timer library for android

TimeIt Now with Timer support! A simple and easy to use stopwatch and timer library for android Introduction A stopwatch can be a very important widge

Compose easy forms validation library

Compose EasyForms Focus on building your form UI while the library do the heavy work for you. Features Built in support for most of the Form widgets i

A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

An Android App which is capable of accessing system apps
An Android App which is capable of accessing system apps

Android_Project_Kotlin In this Project I am building an Android App which is capable of accessing system apps. This project is written in Kotlin and I

[] Easy async loading for Android's ListView/GridView

NOTE: Smoothie's API is not final yet. Although the library is fairly funcional, this is still beta-quality code. Do not rely on it for production cod

Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.

PrivacyStreams PrivacyStreams is an Android library for easy and privacy-friendly personal data access and processing. It offers a functional programm

Easy SharedPreference Engine foR ANDROid

esperandro Easy SharedPreference Engine foR ANDROid What? esperandro makes it simple to use SharedPreferences in a nicer and less error-prone way. Wit

It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Releases(1.1)
Owner
Rohit Surwase
Techie by Birth. Writer by Hobby. Observer by Nature. Unpredictable by Character. Android Developer (Google Certified) by Profession.
Rohit Surwase
A convenient library to show a shimmer effect while loading data

A convenient library to show a shimmer effect while loading data. Easily convert your current view with a slick skeleton loading animation just by wrapping your view.

Justin Guedes 11 Apr 28, 2022
Screen Capture Utils - A plugin to handle screen capture events on android and ios

Screen Capture Utils A plugin to handle screen capture events on android and ios ?? Initialize SDK late ScreenCaptureUtils screenCaptureUtils;

Chiziaruhoma Ogbonda 41 Apr 12, 2022
A DSL to handle soft keyboard visibility change event written in Kotlin.

About A DSL to handle soft keyboard visibility change event written in Kotlin. How to use? Step 1. Add it in your root build.gradle at the end of repo

Vinícius Oliveira 17 Jan 7, 2023
SPIDlibraryAndroid is a library for logging in via SPID through several different identity providers.

SPIDlibraryAndroid SPIDlibraryAndroid is a library for logging in via SPID through several different identity providers.

INPS 98 Dec 15, 2022
Bar Service Kotlin Client

A simple starter service client written in Kotlin against generated models (protos)A simple starter service client written in Kotlin against generated models (protos)

Logesh Dinakaran 0 Nov 9, 2021
λRPC allows using code with high-order functions as a service

λRPC Simple native RPC with high order functions support. Inspired by @altavir and Communicator. λRPC allows using code with high-order functions as a

Andrey Stoyan 5 May 18, 2022
Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

Mauricio Togneri 13 Aug 29, 2022
A logger with a small, extensible API which provides utility on top of Android's normal Log class.

This is a logger with a small, extensible API which provides utility on top of Android's normal Log class. I copy this class into all the little apps

Jake Wharton 9.8k Dec 30, 2022
Fuzzy string matching for Kotlin (JVM, native, JS, Web Assembly) - port of Fuzzy Wuzzy Python lib

FuzzyWuzzy-Kotlin Fuzzy string matching for Kotlin (JVM, iOS) - fork of the Java fork of of Fuzzy Wuzzy Python lib. For use in on JVM, Android, or Kot

WillowTree, LLC 54 Nov 8, 2022
:iphone: [Android Library] Get device information in a super easy way.

EasyDeviceInfo Android library to get device information in a super easy way. The library is built for simplicity and approachability. It not only eli

Nishant Srivastava 1.7k Dec 22, 2022