Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.github.akhasoft:yakhont-support

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.akhasoft:yakhont-support

The high-level Android components for data loading, location, lifecycle callbacks and many more

  • 0.9.19
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source
Яхонт делает невозможноеYakhont - break limits now

Yakhont: high-level Android components for data loading, location, lifecycle callbacks and many more

Yakhont is an Android high-level library offering developer-defined callbacks, loader wrappers, fully automatic cache, location-awareness, dynamic permissions handling, lifecycle debug classes, advanced logging and many more helpful developer-oriented issues.

Now you can load data in just one line of code (please refer to the simplified demo for working example):

new Retrofit2CoreLoadBuilder<>(/* your parameters */).create().startLoading();

And take location in just a couple of lines (the working example is in the simplified demo too):

@CallbacksInherited(LocationCallbacks.class)
public class YourActivity extends Activity implements LocationListener {
    @Override
    public void onLocationChanged(Location location, Date date) {
        // your code here
    }
}

Yakhont extends the Application.ActivityLifecycleCallbacks approach to support your own callbacks creation, that allows to customize handling of almost every lifecycle state of your Activities and Fragments - and even without changing their sources (especially useful for libraries developers).

The powerful loader wrappers, which (in simplest, but very typical case) allows loading data in one line of code, are abstracting you away from things like loaders management, data binding and caching, progress dialogs (fully customizable), errors handling and low-level threading; don't miss the swipe refresh and both Rx and Rx2 support too.

In short, the data loaders features are:

  • fully asynchronous
  • forced timeouts
  • automatic and absolutely transparent cache
  • both RxJava and RxJava 2 support
  • both Retrofit and Retrofit 2 support
  • swipe-to-refresh
  • device orientation changing support
  • fully customizable GUI progress (via Dagger 2)
  • and last but not least: if Retrofit does not meet your requirements, support for any other libraries can be added easily

In addition, there are the location features which includes:

  • both new (FusedLocationProviderClient-based) and old (GoogleApiClient-based) Google Location API support
  • completely auto (but fully customizable via callbacks) permission handling
  • tons of boilerplate code are not needed anymore - just annotate your Activity
  • Rx support (both RxJava and RxJava 2)

So, the features Yakhont provides are:

  • powerful (but very easy in use) data loaders
  • self-configurable transparent cache which adjusts database structure 'on the fly'
  • out-of-the-box location awareness: just annotate your Activity and you're done
  • dynamic permissions handling, powered by user-defined callbacks
  • debug classes with strict mode and lifecycle logging - for all kinds of Activities and Fragments (can be enabled even for 3rd-party components via simple, but effective Yakhont preprocessor)
  • advanced logging with e-mail support (auto-disabled in release builds) and more.

All Activities and Fragments are supported: it's not necessary to derive them from any predefined ones (with one exception - you will need it for lifecycle debug).

The Yakhont AAR is about 320 KB (except the full version, which is about 530 KB).

Yakhont supports Android 2.3 (API level 9) and above (core version requires Android 3.0 (API level 11) as a minimum).

Note: Location API requires Android 4.0 (API level 14); please visit Android Developers Blog for more information.

Demo and Releases

Demo applications are available for download from the latest release.

Versions

  • core: works with native Android Fragments
  • support: works with support Fragments (android.support.v4.app.Fragment etc.)
  • full: core + support + debug classes for most of Activities and Fragments

Usage

Add the following to your build.gradle (you can use build.gradle files from demo and simplified demo as working examples).

  1. Update the buildscript section:
buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
       
        classpath 'akha.yakhont.weaver:yakhont-weaver:0.9.19'
        classpath 'org.javassist:javassist:3.20.0-GA'
    }
}
  1. After your apply plugin: 'com.android.application' insert the following:
apply plugin: 'com.neenbedankt.android-apt'
  1. Update the dependencies section:
dependencies {
    compile  'com.google.dagger:dagger:2.10'
    apt      'com.google.dagger:dagger-compiler:2.10'
    provided 'javax.annotation:jsr250-api:1.0'

    compile  'com.android.support:appcompat-v7:25.3.1'

    compile  'com.github.akhasoft:yakhont:0.9.19'
}

If you're using location API, add the line below:

dependencies {
    compile  'com.google.android.gms:play-services-location:11.0.4'
}

And for the Retrofit2 the following lines are required:

dependencies {
    compile  'com.squareup.retrofit2:retrofit:2.3.0'
    compile  'com.squareup.retrofit2:converter-gson:2.3.0'
}
  1. The code below forced to compile release version only. If you want to compile the debug version, please replace 'debug' with 'release':
android.variantFilter { variant ->
    if (variant.buildType.name == 'debug') {
        variant.setIgnore(true);
    }
}
  1. The code which runs Yakhont Weaver:
String[] weaverConfigFiles = null
boolean weaverDebug = false, weaverAddConfig = true
android.registerTransform(new akha.yakhont.weaver.WeaverTransform(weaverDebug, android.defaultConfig.applicationId,
    android.bootClasspath.join(File.pathSeparator), weaverConfigFiles, weaverAddConfig))

Or (to avoid using the Transform API) you can try the following:

String[] weaverConfigFiles = null
boolean weaverDebug = false, weaverAddConfig = true
android.applicationVariants.all { variant ->
    JavaCompile javaCompile = variant.javaCompile
    javaCompile.doLast {
        new akha.yakhont.weaver.Weaver().run(weaverDebug, android.defaultConfig.applicationId,
            javaCompile.destinationDir.toString(), javaCompile.classpath.asPath,
            android.bootClasspath.join(File.pathSeparator), weaverConfigFiles, weaverAddConfig)
    }
}

Here the Yakhont Weaver manipulates the Java bytecode just compiled, which makes possible to alternate classes implementation (e.g. add callbacks to Activities and Fragments) without changing their source code.

Note: the Google "Jack and Jill" technology is not supporting bytecode manipulation (at least, for the moment).

Weaver configuration

By default the Yakhont weaver uses configuration file from it's JAR, but you can specify your own configuration(s) as a parameter (see above). The "weaverAddConfig = true" means adding your configuration (if not null) to the default one; "weaverAddConfig = false" forces the Yakhont weaver to replace default configuration with yours (even if null).

Proguard

ProGuard directives are included in the Yakhont libraries. The Android Plugin for Gradle automatically appends these directives to your ProGuard configuration.

Anyway, it's strongly advised also to keep your model and Retrofit API as follows (it's just an example from the Yakhont Demo, so please update it according to your application's packages names):

-keep class akha.yakhont.demo.model.** { *; }
-keep interface akha.yakhont.demo.retrofit.** { *; }

Build

To check out and build the Yakhont source, issue the following commands:

$ git clone git@github.com:akhasoft/Yakhont.git
$ cd Yakhont
$ ./gradlew build

To do a clean build, run the commands below:

$ ./gradlew --configure-on-demand yakhont-weaver:clean yakhont-weaver:build
$ ./gradlew --configure-on-demand yakhont:clean yakhont:build
$ ./gradlew --configure-on-demand yakhont-demo:clean yakhont-demo:build
$ ./gradlew --configure-on-demand yakhont-demo-simple:clean yakhont-demo-simple:build

Note: you may need to update your Android SDK before building.

To avoid some lint issues (in Android Studio, when running Analyze -> Inspect Code):

  • add yakhont.link,yakhont.see to File -> Settings -> Editor -> Inspections -> Java -> Javadoc issues -> Declaration has Javadoc problems -> Additional Javadoc Tags
  • add yakhont.dic to File -> Settings -> Editor -> Spelling -> Dictionaries

Communication

Documentation

Known Issues

Not yet.

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

LICENSE

Copyright (C) 2015-2017 akha, a.k.a. Alexander Kharitonov

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.

FAQs

Package last updated on 20 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc