Coder Social home page Coder Social logo

Comments (15)

MarcinMoskala avatar MarcinMoskala commented on June 21, 2024 3

@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.

thats-bot avatar thats-bot commented on June 21, 2024 1

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.

MarcinMoskala avatar MarcinMoskala commented on June 21, 2024

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.

Kolyall avatar Kolyall commented on June 21, 2024

@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.

Kolyall avatar Kolyall commented on June 21, 2024

if it's ready please update README, Thanks)

from activitystarter.

thats-bot avatar thats-bot commented on June 21, 2024

We really need the support for @Arg(bundler = ParcelerArgsBundler.class) parceler library.
Check how its implemented in fragmentargs

from activitystarter.

MarcinMoskala avatar MarcinMoskala commented on June 21, 2024

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.

Kolyall avatar Kolyall commented on June 21, 2024

@MarcinMoskala I haven't experience on it

from activitystarter.

thats-bot avatar thats-bot commented on June 21, 2024

@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.

MarcinMoskala avatar MarcinMoskala commented on June 21, 2024

Here is beta:
https://github.com/MarcinMoskala/ActivityStarter/tree/Introduce_arg_wrappers

from activitystarter.

MarcinMoskala avatar MarcinMoskala commented on June 21, 2024

🍾 Converters functionality is done 🍾
Here is wiki. It would be nice to have some feedback :)
@Kolyall @PingForward

from activitystarter.

Kolyall avatar Kolyall commented on June 21, 2024

@MarcinMoskala Thanks, it's great
But for what implements IsParcel is needed? Can you remove it?

from activitystarter.

MarcinMoskala avatar MarcinMoskala commented on June 21, 2024

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.

Kolyall avatar Kolyall commented on June 21, 2024

@PingForward @MarcinMoskala I approve that @ActivityStarterConfig(converters = { ParcelarArgConverter.class }) should be replaced to @Arg(bundler = ParcelerArgsBundler.class) for each field variable

from activitystarter.

Kolyall avatar Kolyall commented on June 21, 2024

@MarcinMoskala Great, cool!!! It works!

from activitystarter.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.