Android Simple Jump Page Tool Example Explanation
- 2021-12-11 18:55:40
- OfStack
Origin of things
activity or fragment every time you jump to pass a value, are you tired of passing parameters?
Then if there is a lot of data, your code will be miserable, even if it is well designed, it will be very painful. So today I recommend a tool for you
Compare it with our native jump
Compare:
1. Comparison of jump modes
Intenti=new Intent(this,MainActivity.class);
startActivity(i);
vs
ApMainActivity.getInstance().start(this);
// Send
Intenti=new Intent(this,MainActivity.class);
Bundle bundle = new Bundle();
bundle.putInt("message", "123");
i.putExtra("Bundle", bundle);
startActivity(i);
// Receive
String s=bundle.getString("message","");
vs
// Send
ApMainActivity.getInstance().setMessage("123").start(this);
// Receive
AutoJ.inject(this);
AutoPage
github Address https://github.com/smartbackme/AutoPage
If you think it's good, github will give you a star
Android Easy Jump Tool
Note: There must be two requirements androidxkotlin & java
# # # # # # # # # # # # # # # # # # # # # # # #
project: gradle configuration for build. gradle project
buildscript {
repositories {
maven { url 'https://dl.bintray.com/297165331/AutoPage'}
}
Add the following configuration to each module you need to make easy jumps
Your project must support kapt
kotlin kapt
apply plugin: 'kotlin-kapt'
implementation 'com.kangaroo:autopage:1.0.2'
kapt 'com.kangaroo:autopage-processor:1.0.2'
Focus
@ AutoPage can only be prefixed with Ap on fields or classes for quick jumps
kotlin:
The fields must be labeled @ JvmField and @ AutoPageonCreate. Add AutoJ. inject (this) to the page you need to jump to
java:
The field must be marked @ AutoPageonCreate. Add AutoJ. inject (this) to the page you need to jump to
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # in Activity
Example 1
A simple jump
@AutoPage
class SimpleJump1Activity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_simple_jump1)
}
}
After that, call
ApSimpleJump1Activity.getInstance().start(this)
Example 2
Simple jump with parameters
class MainActivity2 : AppCompatActivity() {
@AutoPage
@JvmField
var message:String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main2)
AutoJ.inject(this)
findViewById<TextView>(R.id.text).text = message
}
}
After that, call
ApMainActivity2.getInstance().setMessage("123").start(this)
Example 3:
Jump with result
ApMainActivity.getInstance().start(this);
0
After that, call
ApMainActivity.getInstance().start(this);
1
# # # # # # # # # # # # # # in fragment
ApMainActivity.getInstance().start(this);
2
After that, call
ApFragmentSimpleFragment.getInstance().setMessage("134").build()