GithubHelp home page GithubHelp logo

sharvari-woxi / api-calling-flow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rohitsurwase/api-calling-flow

0.0 0.0 0.0 606 KB

An Android library which can help you simplify handling different scenarios while calling an API (Web Service) in Android App.

License: Apache License 2.0

Java 100.00%

api-calling-flow's Introduction

Android Arsenal Project Status: Active โ€“ The project has reached a stable, usable state and is being actively developed.

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.

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.0'
  ...
}

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.

License

Copyright 2017 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!

api-calling-flow's People

Contributors

rohitsurwase avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.