Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

65 Commits

Repository files navigation

hook-android Download

Android client for hook.

#How to Use

Configure as a depedency

In your application build.gradle file, add the following lines:

dependencies {
// ...
compile 'com.doubleleft.hook:hook-android-client:0.2.3'
}

Setup

Contextcontext = this;
StringappId = "1";
StringappKey = "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d";
Stringendpoint = "http://localhost:4665/";
Clientclient = newClient(context, endpoint, appKey, appId);

Create Collection Item

JSONObjectdata = newJSONObject();
data.put("name", "My Book Name");
data.put("edition", 1.0);
client.collection("books").create(data, newJsonHttpResponseHandler() {
@OverridepublicvoidonSuccess(intstatusCode, Header[] headers, JSONObjectresponse) {
Log.d("success: ", response.toString());
}
@OverridepublicvoidonFailure(intstatusCode, Header[] headers, Throwablethrowable, JSONObjecterrorResponse) {
Log.d("failure: ", errorResponse.toString());
}
});

Fetching (and filtering) items

client.collection("books").where("edition", 1).get(newJsonHttpResponseHandler() {
@OverridepublicvoidonSuccess(intstatusCode, Header[] headers, JSONObjectresponse) {
Log.d("success: ", response.toString());
}
@OverridepublicvoidonFailure(intstatusCode, Header[] headers, Throwablethrowable, JSONObjecterrorResponse) {
Log.d("failure: ", errorResponse.toString());
}
});

Other available methods

  • sort
  • where
  • limit
  • offset
  • increment
  • decrement
  • avg
  • max
  • min
  • sum

Authentication: create user

JSONObjectdata = newJSONObject();
data.put("email", "gabriel@doubleleft.com");
data.put("name", "Gabriel Laet");
data.put("password", "123");
client.auth.register(data, newJsonHttpResponseHandler() {...});

Once the user is created, you don't need to verify/login again. The library also takes care to store the current user internally.

Authentication: login user

JSONObjectdata = newJSONObject();
data.put("email", "gabriel@doubleleft.com");
data.put("password", "123");
client.auth.login(data, newJsonHttpResponseHandler() {...});

Authentication: other methods

  • forgotPassword
  • resetPassword
  • logout
  • getAuthToken
  • hasAuthToken

Contributing

Creating a new release version

cd Hook
gradle generateRelease

Log-in on bintray, create a new version. Click on "Upload Files", from the recently version created, and attach the .zip file genereated via gradle generateRelease task. Make sure to select "Explode this archive" from the "Attached Files" list.

License

MIT

About

Android client for hook

Resources

Stars

10 stars

Watchers

14 watching

Forks

Releases

Packages

Contributors

Languages