Comments (15)
@PingForward please check out version 0.70-beta.1
Changes to apply:
- There is no more dependency on the extra module. Parceler has now native support. You need to have a dependency to Parceler!
- Delete converter in configuration
- Change @arg to @arg(parceler = true) before any element that you want to wrap and unwrap by Parceler.
Please let me know if everything is ok.
from activitystarter.
Why you choose this way? I mean why you define ParcelarArgConverter.class as one global config for all activties and fragments?
Why not to use it for every specified argument? This way give much more flexibility to the user
@arg(bundler = ParcelerArgsBundler.class)
from activitystarter.
I am using alternatives that are actually making your domain object Parcelable (like AutoParcel, PaperParcel or Smuggler) but if there is a need for that in the community then it might be added.
from activitystarter.
@MarcinMoskala https://github.com/johncarl81/parceler
this lib is really useful
But currently to use with your lib I need to make this:
MainActivityStarter.start(this,Parcels.wrap(mItem) );
public class MainActivity extends BaseActivity {
@Arg Parcelable mItemParcelable;
AnyItem mItem;
public void onCreate(Bundle bundle){
super.onCreate(bundle);
mItem = Parcels.unwrap(mItemParcelable);
}
}
from activitystarter.
if it's ready please update README, Thanks)
from activitystarter.
We really need the support for @Arg(bundler = ParcelerArgsBundler.class)
parceler library.
Check how its implemented in fragmentargs
from activitystarter.
After some analysis, I see two sensible options:
First is similar to what was implemented in fragmentargs, but it needs also a support for intent.
public class DateArgsBundler implements ArgsBundler<Date>{
@Override public void put(String key, Date value, Bundle bundle) {
bundle.putLong(key, value.getTime());
}
@Override public void put(String key, Date value, Intent intent) {
intent.putLongExtra(key, value.getTime());
}
@Override public Date get(String key, Bundle bundle) {
long timestamp = bundle.getLong(key);
return new Date(timestamp);
}
@Override public Date get(String key, Intent intent) {
long timestamp = intent.getLongExtra(key);
return new Date(timestamp);
}
}
Example usage:
@Arg(parcelar = DateArgsBundler) Date date;
The second option (much more difficult to implement) is to always change the type from not served to some served. For example:
public class DateTransformation implements ArgsTransformation<Date, Long>{
@Override public Long pack(Date value) {
return value.getTime()
}
@Override public Date unpack(Long timestamp) {
return new Date(timestamp);
}
}
Usage is the same. It would be also safer because the library is handling all other operations. But also much harder to implement.
What do you think about it? @Kolyall @PingForward
from activitystarter.
@MarcinMoskala I haven't experience on it
from activitystarter.
@MarcinMoskala
I don't think we need something special like the second variant in first version of the lib.
But its a good idea to encapsulate all get/put methods it parent interface/class.
from activitystarter.
Here is beta:
https://github.com/MarcinMoskala/ActivityStarter/tree/Introduce_arg_wrappers
from activitystarter.
🍾 Converters functionality is done 🍾
Here is wiki. It would be nice to have some feedback :)
@Kolyall @PingForward
from activitystarter.
@MarcinMoskala Thanks, it's great
But for what implements IsParcel
is needed? Can you remove it?
from activitystarter.
I could but there should be some distinction to allow to introduce other converters that are converting from Object type. If you want to avoid it then define just:
public class ParcelarArgConverter implements ArgConverter<Object, Parcelable> {
@Override
public Parcelable wrap(Object toWrap) {
return Parcels.wrap(toWrap);
}
@Override
public Object unwrap(Parcelable wrapped) {
return Parcels.unwrap(wrapped);
}
}
And define it as an converter:
@ActivityStarterConfig(converters = { ParcelarArgConverter.class })
from activitystarter.
@PingForward @MarcinMoskala I approve that @ActivityStarterConfig(converters = { ParcelarArgConverter.class })
should be replaced to @Arg(bundler = ParcelerArgsBundler.class)
for each field variable
from activitystarter.
@MarcinMoskala Great, cool!!! It works!
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
- Activity State not getting restored when the activity is killed and restored HOT 12
- 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
- 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.