Skip to content

Commit

Permalink
Merge pull request #5 from zeoflow/modules-deployed
Browse files Browse the repository at this point in the history
Populated repository with `eyejet` modules
  • Loading branch information
teogor authored Apr 12, 2021
2 parents 59a7795 + 7a1f87b commit 0061e88
Show file tree
Hide file tree
Showing 63 changed files with 3,283 additions and 2 deletions.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Eyejet
Lifecycle-aware shared observable data holder class.
Lifecycle-aware shared observable data holder class for android.

### 1. Depend on our library

Eyejet Library is available through Maven Repository.
To use it:

1. Open the `build.gradle` file for your application.
2. Make sure that the `repositories` section includes Maven Repository
`mavenCentral()`. For example:
```groovy
allprojects {
repositories {
mavenCentral()
}
}
```

3. Add the library to the `dependencies` section:
```groovy
dependencies {
// ...
// declare eyejet version
def eyejet_version = "x.y.z"
// Eyejet Library
implementation("com.zeoflow:eyejet:$eyejet_version")
// Optional - the eyejet library works without these dependencies
implementation("com.zeoflow:eyejet-annotation:$eyejet_version")
implementation("com.zeoflow:eyejet-arch:$eyejet_version")
// ...
}
```

## License
Copyright (C) 2021 ZeoFlow S.R.L.

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.

## 🏆 Contributors 🏆

Expand Down
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
applicationId "com.zeoflow.eyejet.demo"
versionCode 1
versionName "1.0.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation("com.zeoflow:zson:1.3.0")
implementation("com.zeoflow:flow-kit:1.5.1")
implementation("com.zeoflow:material-elements:2.4.1")

implementation("com.zeoflow:parcelled-runtime:1.1.0")
annotationProcessor("com.zeoflow:parcelled-compiler:1.1.0")

implementation project(":eyejet")
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
23 changes: 23 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.zeoflow.eyejet.demo">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".ThirdActivity" />
<activity android:name=".SecondActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions app/src/main/java/com/zeoflow/eyejet/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.zeoflow.eyejet.demo;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.zeoflow.app.Activity;

import java.util.Random;

public class MainActivity extends Activity
{

private final MainActivityRepository repository = new MainActivityRepository(this);

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TextView txtV = findViewById(R.id.txtV);
findViewById(R.id.button).setOnClickListener(v -> configureNewActivity(SecondActivity.class).start());
repository.user.observe(this, obj -> txtV.setText("txt: " + obj.id + " > " + obj.firstName));
repository.user.setValue(
User.create(
new Random().nextInt(99999999),
"Teodor",
"Grigor"
)
);
}

@Override
protected void onResume()
{
super.onResume();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.zeoflow.eyejet.demo;

import androidx.lifecycle.LifecycleOwner;

import com.zeoflow.eyejet.Eyejet;
import com.zeoflow.eyejet.EyejetField;
import com.zeoflow.eyejet.annotation.ShareProperty;

@UserScope // custom scope
public class MainActivityRepository
{

@ShareProperty("user")
public EyejetField<User> user = new EyejetField<>();

public MainActivityRepository(LifecycleOwner lifecycleOwner)
{
Eyejet.shareLifecycle(
this,
lifecycleOwner
);
}
}
49 changes: 49 additions & 0 deletions app/src/main/java/com/zeoflow/eyejet/demo/SecondActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.zeoflow.eyejet.demo;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.zeoflow.app.Activity;
import com.zeoflow.eyejet.Eyejet;
import com.zeoflow.eyejet.EyejetField;
import com.zeoflow.eyejet.annotation.ShareProperty;
import com.zeoflow.eyejet.annotation.ShareType;

import java.util.Random;

@UserScope
public class SecondActivity extends Activity
{

@ShareProperty(value = "user", shareType = ShareType.KEEP_ACTIVE)
public EyejetField<User> user = new EyejetField<>();

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Eyejet.shareLifecycle(this, this);
TextView txtV = findViewById(R.id.txtV);
user.observe(this, obj -> txtV.setText("txt: " + obj.id + " > " + obj.firstName));
user.setValue(
User.create(
new Random().nextInt(99999999),
"Teodor",
"Grigor"
)
);
findViewById(R.id.button).setOnClickListener(v -> configureNewActivity(ThirdActivity.class).start());
}

@Override
protected void onResume()
{
super.onResume();
}

}
47 changes: 47 additions & 0 deletions app/src/main/java/com/zeoflow/eyejet/demo/ThirdActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.zeoflow.eyejet.demo;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.zeoflow.app.Activity;
import com.zeoflow.eyejet.Eyejet;
import com.zeoflow.eyejet.EyejetField;
import com.zeoflow.eyejet.annotation.ShareProperty;
import com.zeoflow.eyejet.annotation.ShareType;

@UserScope
public class ThirdActivity extends Activity
{

@ShareProperty(value = "user", shareType = ShareType.ON_FIRST_USE)
public EyejetField<User> user = new EyejetField<>();

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Eyejet.shareLifecycle(this, this);
TextView txtV = findViewById(R.id.txtV);
user.observe(this, obj -> txtV.setText("txt: " + obj.id + " > " + obj.firstName));
// user.setValue(
// User.create(
// new Random().nextInt(99999999),
// "Teodor",
// "Grigor"
// )
// );
findViewById(R.id.button).setOnClickListener(v -> configureNewActivity(ThirdActivity.class).start());
}

@Override
protected void onResume()
{
super.onResume();
}

}
64 changes: 64 additions & 0 deletions app/src/main/java/com/zeoflow/eyejet/demo/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.zeoflow.eyejet.demo;

import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.zeoflow.eyejet.demo.Parcelled_User;
import com.zeoflow.parcelled.Default;
import com.zeoflow.parcelled.Parcelled;
import com.zeoflow.parcelled.ParcelledVersion;

import org.jetbrains.annotations.NotNull;

@Parcelled(version = 1)
public abstract class User implements Parcelable
{

@Default(code = "0")
public int id;

@Nullable
@Default(code = "null")
public String firstName;

@ParcelledVersion(after = 1, before = 2)
@Nullable
public String lastName;

public static User create(
int id,
@NonNull String firstName,
@NonNull String lastName
)
{
return new Parcelled_User(id, firstName, lastName);
}

@Override
public boolean equals(Object other)
{
if (this == other)
{
return true;
}

if (!(other instanceof User))
{
return false;
}

User o = (User) other;

return id == o.id;
}

@NotNull
@Override
public String toString()
{
return "User{$ID}" + id;
}

}
13 changes: 13 additions & 0 deletions app/src/main/java/com/zeoflow/eyejet/demo/UserScope.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.zeoflow.eyejet.demo;

import com.zeoflow.eyejet.annotation.EyejetScope;

import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@EyejetScope
@Retention(RUNTIME)
public @interface UserScope
{
}
Loading

0 comments on commit 0061e88

Please sign in to comment.