Comments (12)
The Intent obtained in the getIntent is the original one, it ignores all the changes made during the ActivityStarter.fill().
One way to fix this would be to save the state in the Bundle "outState" that is provided in the onSaveInstanceState. And use the bundle provided in the onCreate method to restore the state if present.
from activitystarter.
You are right. I made this change to allow saving state on property delegates (Kotlin). What do you think about the following generation proposition?
Original:
public class MainActivity extends Activity {
@Arg(optional = true) String name;
}
Generated:
public final class MainActivityStarter {
private static final String NAME_KEY = "com.example.activitystarter.nameStarterKey";
public static void fill(MainActivity activity) {
Intent intent = activity.getIntent();
if(intent.hasExtra(NAME_KEY))
activity.name = intent.getStringExtra(NAME_KEY);
}
public static void save(MainActivity activity, Bundle bundle) {
bundle.putString("com.example.activitystarter.nameStarterKey", activity.name);
}
//...
}
from activitystarter.
@danieldisu Can you check version issue_24-SNAPSHOT
compile 'com.github.MarcinMoskala:ActivityStarter:issue_24-SNAPSHOT'
from activitystarter.
Thank you for you fast response!!
I've tried it and is still not working, it's almost there!
The Save method now is 100% OK, but it's also needed to change the FILL method, to also receive the bundle, in order to load the saved info from it when present.
The thing is that you have to check if the bundle is null, if it's null load it from the intent, if not, load it from the bundle!
from activitystarter.
I think it should be ok in current SNAPSHOT
from activitystarter.
The generic method ActivityStarter.fill() still doesn't have the possibility to pass the bundle.
But using the ActivityNameStarter.fill(activity, bundle) method works like a charm!
Do you think it would be possible to add an overloaded method ActivityStarter.fill() that receives the Bundle?
from activitystarter.
In the published version, there is ActivityStarter.fill(this, savedInstanceState);
Sorry for the delay, but in the moment I am really overloaded with projects. Although I tested it and here you can see example usage.
from activitystarter.
Everything is working now!
Thanks!!
from activitystarter.
But this is not the solution because it does not allow Kotlin property delegates to read state from saved bundle. I am still working on this issue.
from activitystarter.
I see the problem, but it's going to be a hard one to crack because there is no way to access the savedInstanceState Bundle outside the lifecycle methods.
from activitystarter.
I see now that there is no way to do it. I will fill values if savedInstanceState is not null and if the property is read-write.
from activitystarter.
Today I finally had more time to fix this problem. From new version, Kotlin needs also fill
called for loading saved state (if we need it). I just distributed it in beta version 1.10
from activitystarter.
Related Issues (18)
- @Arg arguments HOT 3
- Replace @ActivityStarterConfig(converters = { ParcelarArgConverter.class }) to @Arg(bundler = ParcelarArgConverter.class) HOT 1
- How to parse list of enum? HOT 3
- Add Kotlin support HOT 1
- Crash on SupportFragment.onSaveInstanceState in Kotlin HOT 1
- MultiDex error
- Can't fetch data at HOT 2
- var ArrayList of Parcelable problem HOT 2
- Migration to androidx HOT 2
- Implement method .startActivityForResult HOT 5
- Incremental processor
- w: Runtime JAR files in the classpath should have the same version. HOT 5
- Still have NoSuchElementException in 1.12-beta2
- Crash when using Proguard
- Implement support for Parcels lib HOT 15
- Create private String KEY HOT 4
- Create any IntentBuilder to avoid generation of methods HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from activitystarter.