Giter Club home page Giter Club logo

anitaa1990 / optimize Goto Github PK

View Code? Open in Web Editor NEW
36.0 9.0 15.0 297 KB

Android library for displaying data based on JSON configuration fetched from server. With this library, you can kiss goodbye to string.xml, dimen.xml, arrays.xml. Keep all your string/integer/array config in one file. The library will automatically fetch the data from the url you provide.

Java 100.00%
android-library android-development workmanager httpurlconnection abtesting dimens json backend

optimize's Introduction

Optimize

API Android Arsenal
Android library for displaying data based on JSON configuration fetched from server.

With this library, you can kiss goodbye to string.xml, dimen.xml, arrays.xml. Keep all your string/integer/array config in one file. The library will automatically fetch the data from the url you provide.

How it works?

Have you ever had to work on an app, make it production ready and upload it to PlayStore. Then there comes a tiny modification where you need to change the text in a screen or the color of a button in another screen? Or perhaps we need to change the number of times a certain background task should run? Or maybe change the time a certain task is executed? Or maybe your case is similar to mine and we need to keep the error messages and the default app messages the same as displayed in the web. Or in the ios version of the app. So there is a single file that all 3 systems can reuse.
For example, all my app messages are kept in string.xml file. Suppose they were kept in a json file in the backend.
And everytime the app is opened the latest data is downloaded and cached locally in the app.

For example, in the sample app, you will see the url that I have given is
https://s3-ap-southeast-1.amazonaws.com/android-optimize/optimize.json
This is used to fetch my data from the backend asynchrously and cache it in app.
Everytime the app is opened the data is fetched and based on the whether the content is changed or not, the data is cached locally.
Note: The library is implemented using the Work Manager API provided by Google.

How to integrate the library in your app?

Gradle Dependecy

dependencies {
        implementation 'com.an.optimize:optimize:0.1.0'
}

Maven Dependecy

<dependency>
  <groupId>com.an.optimize</groupId>
  <artifactId>optimize</artifactId>
  <version>0.1.0</version>
  <type>pom</type>
</dependency>

Usage

Step 1: Add the internet permission in the Android Manifest file
<uses-permission android:name="android.permission.INTERNET" />

Step 2: Add the following code to your Application class or your Main Activity file
Optimize.getInstance().init(getApplicationContext(), "<Add the url of the json file>");

Step 3: All you have to do now to display a value from the json file is to call the below code
String stringData = Optimize.getInstance().getStringValue("<the name of the param key>", "<Default value to be displayed in case the backend data does not contain this key>");

//The same can be applied for Integers:
Optimize.getInstance().getIntegerValue("<the name of the param key>", <Default value in case the backend data does not contain this key>);

//The same can be applied for Double:
Double doubleData = Optimize.getInstance().getDoubleValue("<the name of the param key>", 0.00);

//The same can be applied for Boolean:
Boolean booleanData = Optimize.getInstance().getBooleanValue("boolean_data", false);

//The same can be applied for Number:
Number floatData = Optimize.getInstance().getNumberValue("float_data", -1.1);

//The same can be applied for a List:
List<String> listData = Optimize.getInstance().getList("list_data", Collections.emptyList());

And that's it! It's super simple.

optimize's People

Contributors

anitaa1990 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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