f2prateek/dart

DH2.1 to DH3 migration questions

Closed this issue · 4 comments

Hi,

I currently doing a migration from DH2.1 to DH 3.1.3 in one big bang. I have a few questions about DH3.

  1. Do fragments need NavigationModels? I am getting the error DartModel class PoBoxDetailFragment does not follow the naming convention: my.package.TargetComponentNavigationModel.

PoBoxDetailFragment : KBaseFragment() {

@BindExtra(EXTRA_PO_BOX_ADDRESS)
lateinit var poBox: CollectionPoint

@BindExtra(EXTRA_PO_BOX_RESULT)
lateinit var leaseResult: PoBoxLease

}

  1. In DH2.1 you could use @HensonNavigable for activities that didn't have any extras so you could you Henson to create the intent. Is there any equivalent in DH3 without creating empty navigation model?

  2. In DH2.1 you could inject a fragment with a bundle e.g.
    Dart.inject(this@IneligibilityDialogFragment, this)
    I could not find any equivalent in DH3

  3. I am using Android X with jetifier turned on however it doesn't seem to replace the fragment with the Android x version. Just wondering if you are using Android X?

error: no suitable method found for bind(BaseFragment)
Dart.bind(this);
^
method Dart.bind(Activity) is not applicable
(argument mismatch; BaseFragment cannot be converted to Activity)
method Dart.bind(Fragment) is not applicable
(argument mismatch; BaseFragment cannot be converted to Fragment)

Appreciate your response.

Hi @markchristopherng !

  1. Yes, with D&H3 all components where you want to be able to navigate to must use NavigationModels. That way we encapsulate our navigation info in one single place. It also allows D&H3 to be compatible with modularized apps.

  2. You need to create a NavigationModel as well.

  3. There are 2 ways to bind NavigationModels at runtime on the version 3:

class MyFragment {
    @DartModel MyFragmentNavigationModel nm;

   onCreate() {
       Dart.bind(this); // It will create the navigation model and bind the fields inside it to the fragment arguments.
   }
}
class MyFragment {
    MyFragmentNavigationModel nm = new MyFragmentNavigationModel();

   onCreate() {
       Dart.bindNavigationModel(nm, this); // It will bind the fields inside the navigation model to the fragment arguments.
   }
}

I think you are looking for the second one option.

  1. Actually this is an issue, we never updated it and we should have. The fix is just to update the reference inside the Dart class. You wanna give it a try and open a PR?

Hi Daniel, thanks for answering all our questions really promptly. It's going to save us a lot of time. We will try to put a PR for issue 4. Just wondering why jeftifier failed to convert it to Android X.

Cause we are actually using the one from android.app 😅...

At Groupon we do not bind fragment extras, so we didn't encounter the issue...

I spoke to a few of the other senior developers in our team and we are going down the approach of removing the @InjectExra now @BindView annotations from our fragments, we believe that is a cleaner solution than creating NavigationModels. Thanks again for your assistance.