-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from zeoflow/activity-fragment
Lifecycle Activity-Fragment
- Loading branch information
Showing
12 changed files
with
134 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
app/src/main/java/com/zeoflow/eyejet/demo/MainActivityRepository.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/zeoflow/eyejet/demo/MainFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.zeoflow.eyejet.demo; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.lifecycle.Observer; | ||
|
||
import com.zeoflow.app.Fragment; | ||
import com.zeoflow.eyejet.Eyejet; | ||
import com.zeoflow.eyejet.EyejetField; | ||
import com.zeoflow.eyejet.annotation.EyejetScope; | ||
import com.zeoflow.eyejet.annotation.ShareProperty; | ||
import com.zeoflow.eyejet.demo.databinding.FragmentMainBinding; | ||
|
||
@EyejetScope | ||
public class MainFragment extends Fragment | ||
{ | ||
|
||
@ShareProperty("user") | ||
public static EyejetField<User> user = new EyejetField<>(); | ||
private FragmentMainBinding binding; | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) | ||
{ | ||
binding = FragmentMainBinding.inflate(inflater, container, false); | ||
View view = binding.getRoot(); | ||
return view; | ||
} | ||
|
||
@Override | ||
public void onCreate(@Nullable Bundle savedInstanceState) | ||
{ | ||
super.onCreate(savedInstanceState); | ||
|
||
Eyejet.shareLifecycle( | ||
this, | ||
this | ||
); | ||
|
||
user.observe(this, new Observer<User>() | ||
{ | ||
@SuppressLint("SetTextI18n") | ||
@Override | ||
public void onChanged(User user) | ||
{ | ||
if (user == null) | ||
{ | ||
return; | ||
} | ||
binding.txtV.setText("txt: " + user.id + " > " + user.firstName); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:background="#212121"> | ||
|
||
<TextView | ||
android:id="@+id/txtV" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:textColor="#ffffff" | ||
android:textSize="20sp" | ||
android:layout_marginTop="10dp"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters