Octodroid


Source link: https://github.com/rejasupotaro/octodroid

Octodroid

Android toolkit for the GitHub API using RxJava and RxAndroid.

Getting Started

Let's start with a tangible example of how this library works.

GitHub.client().searchRepositories("Android")

.map(Response::entity)

.map(SearchResult::getItems)

.subscribe(repositories -> ...);

As you can see, we lose the callbacks. Fundamentally, RxJava is the Observer pattern, with for manipulating and transforming the stream of data our Observables emit. The Observable emits events, while the Observer subscribes and receives them. In the example above, The .subscribe() call adds an Observer to the Observable and the requests are made.

You should unsubscribe it when Activity is destroyed.

@Override public void onDestroy() {

  subscription.unsubscribe();

  super.onDestroy();
 
}

If you use ViewObservable of RxAndroid, you don't need to call unsubscribe() explicitly. ViewObservable calls unsubscribe() automatically when view is detached.

ViewObservable.bindView(view, GitHub.client().user())

.subscribe(user -> ...);

APIs

GitHub.client().user("rejasupotaro") GitHub.client().search() GitHub.client().searchRepositories("Android") GitHub.client().hottestRepositories() GitHub.client().userRepos()  // You can access these API if you have authenticated GitHub.client().user() GitHub.client().notifications()

Authentication

// You can give access token OAuth2 GitHub.client().authorize("access_token");
 // or use basic authentication GitHub.client().authorize("username", "password");
  GitHub.client().user()

.map(Response::entity)

.subscribe(user -> ...);

Set User-Agent

GitHub.client().userAgent(userAgent);

Enable Cache-Control

CacheControl cacheControl = new CacheControl.Builder()

// cache file is required

.file(context)

  // use /data/data/package.name/cache/octodroid_response_cache when given context //

  .file(dir, "file_name")

// or give dir and file name //

  .file(file)

// or give file

.maxCacheSize(3 * 1024 * 1024) // default max cache size is 3MB

.maxStale(28 * 24 * 60 * 60)
// default max stale is 3 weeks

.build();
  ApiClient apiClient = new ApiClient();
 apiClient.cache(cacheControl);
  GitHub.initialize(apiClient);

Download

Download the latest JAR or grab via gradle:

compile 'com.rejasupotaro:octodroid:0.1.2'

Resources

A helper library for keeping and maintaining the state of Chronometers.

Fast and easy to use NoSQL data storage.

An Android/Java Library to create short URL's using Google's URL Shortener.

An Android TagView library. You can customize awesome TagView by using this library.

InkPageIndicator created by Nick Butcher for Plaid and back-ported for API 16+.

This plugin helps you to easily handle variant specific settings with yaml format.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes