Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anitaa1990/Optimize
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.
https://github.com/anitaa1990/Optimize
abtesting android-development android-library backend dimens httpurlconnection json workmanager
Last synced: 5 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/anitaa1990/Optimize
- Owner: anitaa1990
- Created: 2018-05-25T14:51:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-20T11:44:46.000Z (over 5 years ago)
- Last Synced: 2024-08-01T21:47:24.196Z (3 months ago)
- Topics: abtesting, android-development, android-library, backend, dimens, httpurlconnection, json, workmanager
- Language: Java
- Homepage:
- Size: 290 KB
- Stars: 36
- Watchers: 9
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-android - Optimize - Android library for displaying data based on JSON configuration fetched from server. With this library, you can kiss goodbye to string.xm… (Uncategorized / Uncategorized)
README
# Optimize
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
```gradle
dependencies {
implementation 'com.an.optimize:optimize:0.1.0'
}
```Maven Dependecy
```xmlcom.an.optimize
optimize
0.1.0
pom```
Usage
Step 1: Add the internet permission in the Android Manifest file```xml
```
Step 2: Add the following code to your Application class or your Main Activity file
```java
Optimize.getInstance().init(getApplicationContext(), "");
```Step 3: All you have to do now to display a value from the json file is to call the below code
```java
String stringData = Optimize.getInstance().getStringValue("", "");//The same can be applied for Integers:
Optimize.getInstance().getIntegerValue("", );//The same can be applied for Double:
Double doubleData = Optimize.getInstance().getDoubleValue("", 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 listData = Optimize.getInstance().getList("list_data", Collections.emptyList());
```
And that's it! It's super simple.