diff --git a/README.md b/README.md index 9b4a2d6..eba09b2 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ - [ ] `Save and restore all objects at runtime in RAM` - [ ] `Add a data branch (branches can be independent of the main branch) ` - [ ] `Imports data from Shared Preferences to Reactor` -- [ ] `Multiprocess support` @@ -28,6 +27,7 @@ Add to your root build.gradle : ```Groovy allprojects { repositories { + ... maven { url 'https://jitpack.io' } } } @@ -37,7 +37,7 @@ allprojects { Add the dependency : ```Groovy dependencies { - implementation 'com.github.dfmabbas:reactor:v1.2.1' + implementation 'com.github.dfmabbas:reactor:v1.2.3' } ``` @@ -48,21 +48,22 @@ dependencies { In `Kotlin` : ```Groovy -reactor = Reactor(context, Algorithm.AES) +reactor = Reactor(context) +reactor = Reactor(context, false) // disable encryption -// ----------------------------------------------------------- +----------------------------------------------------------- reactor.put("name", "abbas") reactor.put("age", 23) reactor.put("this", this::class.java) -// ----------------------------------------------------------- +----------------------------------------------------------- val name = reactor.get("name", "") val isDay = reactor.get("day", false) val thisClass = reactor.get("this", this::class.java) -// ----------------------------------------------------------- +----------------------------------------------------------- reactor.remove("day", false) reactor.clearAll() @@ -73,21 +74,22 @@ reactor.clearAll() In `Java` : ```Groovy -reactor = new Reactor(getContext(), Algorithm.AES); +reactor = new Reactor(getContext()); +reactor = new Reactor(getContext(), false); // disable encryption -// ----------------------------------------------------------- +----------------------------------------------------------- reactor.put("name", "abbas"); reactor.put("age", 23); reactor.put("array", new int[]{0, 0, 0}); -// ----------------------------------------------------------- +----------------------------------------------------------- String name = reactor.get("name", ""); Integer age = reactor.get("age", 0); int[] array = reactor.get("array", new int[]{0, 0, 0}); -// ----------------------------------------------------------- +----------------------------------------------------------- reactor.remove("age", 0); reactor.clearAll(); @@ -107,7 +109,7 @@ In `Java`: [sample code written with Java](sample/src/main/java/com/dfmabbas/sam ``` MIT License -Copyright (c) 2018 Abbas Naghdi (@dfmabbas) +Copyright (c) 2018 Abbas Naqdi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/library/build.gradle b/library/build.gradle index 2cb986f..92cc927 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -4,8 +4,8 @@ apply plugin: 'kotlin-android' def mini_api = 15 def compile_api = 28 def target_api = 28 -def version_code = 121 -def version_name = '1.2.1' +def version_code = 123 +def version_name = '1.2.3' android { compileSdkVersion compile_api @@ -31,4 +31,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1" } diff --git a/library/src/main/java/com/dfmabbas/reactor/handler/Reactor.kt b/library/src/main/java/com/dfmabbas/reactor/handler/Reactor.kt index abaab78..c1a2650 100644 --- a/library/src/main/java/com/dfmabbas/reactor/handler/Reactor.kt +++ b/library/src/main/java/com/dfmabbas/reactor/handler/Reactor.kt @@ -3,6 +3,7 @@ package com.dfmabbas.reactor.handler import android.content.Context import com.dfmabbas.reactor.helper.SerializationHelper import com.dfmabbas.reactor.security.SecurityController +import kotlinx.coroutines.* import java.io.Serializable class Reactor @JvmOverloads constructor( diff --git a/sample/build.gradle b/sample/build.gradle index 0026777..c3b1ce4 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -5,8 +5,8 @@ apply plugin: 'kotlin-android-extensions' def mini_api = 15 def compile_api = 28 def target_api = 28 -def version_code = 121 -def version_name = '1.2.1' +def version_code = 123 +def version_name = '1.2.3' android { compileSdkVersion compile_api diff --git a/sample/src/main/java/com/dfmabbas/sample/JavaSample.java b/sample/src/main/java/com/dfmabbas/sample/JavaSample.java index eeb3144..9ce3e3c 100644 --- a/sample/src/main/java/com/dfmabbas/sample/JavaSample.java +++ b/sample/src/main/java/com/dfmabbas/sample/JavaSample.java @@ -14,7 +14,7 @@ public class JavaSample extends Fragment { - private Reactor reactor = new Reactor(getContext()); + private Reactor reactor; @Override public View onCreateView(@NotNull LayoutInflater inflater, @@ -26,7 +26,10 @@ public View onCreateView(@NotNull LayoutInflater inflater, @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - view.findViewById(R.id.btn_java_click).setOnClickListener(view1 -> sampleCode()); + reactor = new Reactor(view.getContext()); + + view.findViewById(R.id.btn_java_click) + .setOnClickListener(v -> sampleCode()); } private void sampleCode() { diff --git a/sample/src/main/java/com/dfmabbas/sample/KotlinSample.kt b/sample/src/main/java/com/dfmabbas/sample/KotlinSample.kt index 9bc3388..72b8336 100644 --- a/sample/src/main/java/com/dfmabbas/sample/KotlinSample.kt +++ b/sample/src/main/java/com/dfmabbas/sample/KotlinSample.kt @@ -13,7 +13,7 @@ import kotlinx.android.synthetic.main.fragment_kotlin_sample.* class KotlinSample : Fragment() { - private val reactor = Reactor(context!!) + private lateinit var reactor: Reactor override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -27,7 +27,11 @@ class KotlinSample : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - btn_kotlin_click.setOnClickListener { sampleCode() } + reactor = Reactor(view.context) + + btn_kotlin_click.setOnClickListener { + sampleCode() + } } private fun sampleCode() { diff --git a/sample/src/main/res/layout/fragment_java_sample.xml b/sample/src/main/res/layout/fragment_java_sample.xml index 45d88ce..c1c41e2 100644 --- a/sample/src/main/res/layout/fragment_java_sample.xml +++ b/sample/src/main/res/layout/fragment_java_sample.xml @@ -1,14 +1,14 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:id="@+id/btn_java_click" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:text="@string/str_java"/> \ No newline at end of file diff --git a/sample/src/main/res/layout/fragment_kotlin_sample.xml b/sample/src/main/res/layout/fragment_kotlin_sample.xml index ff62ffc..224472b 100644 --- a/sample/src/main/res/layout/fragment_kotlin_sample.xml +++ b/sample/src/main/res/layout/fragment_kotlin_sample.xml @@ -1,14 +1,14 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:id="@+id/btn_kotlin_click" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:text="@string/str_kotlin"/> \ No newline at end of file diff --git a/sample/src/main/res/layout/main_view.xml b/sample/src/main/res/layout/main_view.xml index 17dd608..39ae65c 100644 --- a/sample/src/main/res/layout/main_view.xml +++ b/sample/src/main/res/layout/main_view.xml @@ -1,22 +1,23 @@ - - - + android:gravity="center" + android:orientation="vertical"> + android:id="@+id/kotlin_sample" + class="com.dfmabbas.sample.KotlinSample" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1"/> + + - \ No newline at end of file + \ No newline at end of file