Git Product home page Git Product logo

wp-api-v2-client-android's Introduction

README

WP-API v2 Android

An Android library for the WP REST API v2

(Currently supports WP REST API Version 2.0-beta12)

This library contains the necessary REST calls to interact with the WP REST API and also a database for storing the WP objects. It also contains some custom REST calls that expand WP REST API which can be found in the following plugin: WP REST API Afrozaar Extras

Dependencies

Wordpress

Android

Usage - REST interface

Initiate a new WpClientRetrofit object, for example:

String baseUrl = "http://example.com"
String username = "myuser"
String password = "mypass"
boolean debug = true;

WpClientRetrofit client = new WpClientRetrofit(baseUrl, username, password, debug);

The individual REST calls can then be made using the client.

There are 2 ways of calling the REST interfaces; using the Callback mechanism or directly.

  • Using the Callbacks allow you specify a callback object that will be called when the REST call has finished
public void createPost(Post post, WordPressRestResponse<Post> callback);
  • The direct method returns the Call object and you'll need to manually execute it and parse the response.
public Call<Post> createPost(Post post);

The callback method can be used on the MainThread, while the other one will need to be executed on a background thread.

WIP: Not all calls has both methods implemented yet

Database & Models

The library includes a database and related model classes for storing the WP objects. The majority of the base WP object models are supported plus support for having multiple sites.

  • WordPressContract : Contains database schema for all tables, including helper methods for inserting/updating content.
  • WordPressDatabase : SqlLiteOpenHelper subclass for working with database file.

There are also POC/WIP tasks for working with the database and make it easier to run queries without blocking the Main thread and impacting performance. The com.afozaar.wp_api_v2_client_android.data.tasks package contains a base AsyncTask for doing database operations including subtasks for CRUD operations. These tasks uses callbacks to notify the app when their operations have finished.

wp-api-v2-client-android's People

Contributors

masekind avatar

Watchers

James Cloos 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.