Giter VIP home page Giter VIP logo

arghttp's Introduction

ArgHttp

An android http library with less code.

Builds:

Gradle

To always build from the latest commit with all updates. Add the JitPack repository:

(path:\to\your\projects\MainFolderOfYourProject\build.gradle)

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

And the dependency to (app) build.gradle:

(path:\to\your\projects\MainFolderOfYourProject\app\build.gradle)

dependencies {
    compile 'com.github.mergehez:ArgHttp:master-SNAPSHOT'
}

How to use

Usage of this library is very simple. By typing one function, you can send server request, you can post data to server and you can retrieve data by posting data to server. The use of these three functions is as follows:

Server request:

new ArgHttp().get(urlGet, serverSideErrorText, new CallGisti() {
    @Override
    public void agahi(ArgHttp context, String response) {
        // Check if there is an error
        if(context.isError()){
            // Display error message
        }else{
            // Parse the response. You can look at my sample application to understand better
        }
    }
});

Parameters:

  • urlGet: url of the script that you want to get data from
  • serverSideErrorText: you should check errors on server side, if an error occures you should print a specific text. You will define this text in this parameter.
  • CallGisti: is an interface that bring the response of server

Post:

PostValues pvs = new PostValues().add("book-title","Book1").add("book-author","Mergehez");
new ArgHttp().post(urlPost, serverSideErrorText, pvs, new CallGisti() {
    @Override
    public void agahi(ArgHttp context, String response) {
        if(context.isError()){
            // Display error message
        }else{
            // Display the "successfully executed" or 'anything else' message
        }
    }
});

Parameters:

  • urlPost: url of the script that you want to post the data to
  • serverSideErrorText: you should check errors on server side, if an error occures you should print a specific text. You will define this text in this parameter.
  • pvs: is your posted data. It a PostValues variable. Look at the above code line to understand better.
  • CallGisti: is an interface that bring the response of server

Post and Get Response:

PostValues pvs = new PostValues().add("book-author","Mergehez");
new ArgHttp().postAndGet(urlPost, serverSideErrorText, pvs, new CallGisti() {
    @Override
    public void agahi(ArgHttp context, String response) {
        if(context.isError()){
            // Display error message
        }else{
            // Parse the response. You can look at my sample application to understand better
        }
    }
});

Parameters:

  • urlPost: url of the script that you want to post the data to
  • serverSideErrorText: you should check errors on server side, if an error occures you should print a specific text. You will define this text in this parameter.
  • pvs: is your posted data. It a PostValues variable. Look at the above code line to understand better.
  • CallGisti: is an interface that bring the response of server

arghttp's People

Contributors

mergehez avatar

Stargazers

 avatar

Watchers

 avatar  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.