Skip to content

Commit

Permalink
committed to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
arshanaqdi committed Feb 28, 2019
1 parent 071cc70 commit 3c78843
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 51 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`



Expand All @@ -28,6 +27,7 @@ Add to your root build.gradle :
```Groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Expand All @@ -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'
}
```

Expand All @@ -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()
Expand All @@ -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();
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions sample/src/main/java/com/dfmabbas/sample/JavaSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down
8 changes: 6 additions & 2 deletions sample/src/main/java/com/dfmabbas/sample/KotlinSample.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand All @@ -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() {
Expand Down
16 changes: 8 additions & 8 deletions sample/src/main/res/layout/fragment_java_sample.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.AppCompatButton
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" />
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"/>

</FrameLayout>
16 changes: 8 additions & 8 deletions sample/src/main/res/layout/fragment_kotlin_sample.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.AppCompatButton
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" />
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"/>

</FrameLayout>
33 changes: 17 additions & 16 deletions sample/src/main/res/layout/main_view.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<fragment
android:id="@+id/kotlin_sample"
class="com.dfmabbas.sample.KotlinSample"
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
android:gravity="center"
android:orientation="vertical">

<fragment
android:id="@+id/java_sample"
class="com.dfmabbas.sample.JavaSample"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
android:id="@+id/kotlin_sample"
class="com.dfmabbas.sample.KotlinSample"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>

<fragment
android:id="@+id/java_sample"
class="com.dfmabbas.sample.JavaSample"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>

</android.support.v7.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>

0 comments on commit 3c78843

Please sign in to comment.