Skip to content

ausboyue/IntentLife

Repository files navigation

IntentLife

English | 简体中文

License platform jitpack Latest RepoSize CoreSize

Description

An android library that automatically binds data carried by the Intent or Bundle.

Download from Gradle

Add to your root build.gradle:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Add the dependency:

    dependencies {
          implementation 'com.github.ausboyue.IntentLife:intentlife:v1.0.4'
          annotationProcessor 'com.github.ausboyue.IntentLife:intentlife_compiler:v1.0.4'
    }

Get Started

ActivityA jump to ActivityB

  • ActivityA edit code maybe as below:
        User user = new User();
        user.setUserId("9527");
        user.setName("Cheny");
        user.setJob("android developer");

        Intent intent = new Intent(activityA, ActivityB.class);
        intent.putExtra("key_user", user);
        startActivity(intent);
  • ActivityB edit code as below:
public class ActivityB extends AppCompatActivity {
    @BindIntentKey("key_user")
    User mUser;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_secend);
        //  IntentLife inject
        IntentLife.bind(this);
        
        TextView tv_user_name = findViewById(R.id.tv_user_name);
        tv_user_name.setText(
                "Hello , I am " + mUser.getName()
                        + ".\nMy job is " + mUser.getJob() + ".");
    }
}

Framework support

Type of data

  • Support java eight basic data types and their arrays and collections
  • Classes that support the implementation of the Serializable interface
  • Support for classes that implement Parcelable interfaces and their arrays and collections
  • Support all data types supported by android Bundle

Interface scenario

  • Support jump between Activities
  • Support loading Fragments
  • Support for use in any class that needs to use data, such as the Presenter class in MVP design

Prompt

The target field should not have the private modifier, otherwise the data will not be bound with field.

Bugs Report

If you find any bug when using it, please contact me. Thanks for helping me making better.

About Author

Cheny - @ausboyue on GitHub, @www.icheny.cn

Other

Please give me some time to update the documentation ^_^

About

An android library that automatically binds data carried by the Intent or Bundle.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages