FragmentBuilder with only Optional Args will get Null Exception #30

Closed
Gautham opened this Issue Aug 27, 2015 · 8 comments

Comments

Projects
None yet
3 participants
@Gautham

Gautham commented Aug 27, 2015

If I set only optional attributes for FragmentBuilder, Ill get an exception at runtime because of the null-check. The null-check should be added only if there is atleast one non-optional argument specified.

On a side note, very useful project. Thanks for this :)

@sockeqwe

This comment has been minimized.

Show comment
Hide comment
@sockeqwe

sockeqwe Aug 27, 2015

Owner

I see, thanks for reporting!

Owner

sockeqwe commented Aug 27, 2015

I see, thanks for reporting!

@sockeqwe sockeqwe added the bug label Aug 27, 2015

@AndreasBoehm

This comment has been minimized.

Show comment
Hide comment
@AndreasBoehm

AndreasBoehm Oct 29, 2015

Contributor

I will try to create a PR for this because this bug is really annoying

Contributor

AndreasBoehm commented Oct 29, 2015

I will try to create a PR for this because this bug is really annoying

@sockeqwe

This comment has been minimized.

Show comment
Hide comment
@sockeqwe

sockeqwe Oct 29, 2015

Owner

@AndreasBoehm PR are very welcome. Otherwise I have planned to fix this during weekend amongst other things like native kotlin support etc.

Owner

sockeqwe commented Oct 29, 2015

@AndreasBoehm PR are very welcome. Otherwise I have planned to fix this during weekend amongst other things like native kotlin support etc.

@sockeqwe sockeqwe added this to the 3.0 milestone Oct 29, 2015

@sockeqwe

This comment has been minimized.

Show comment
Hide comment
@sockeqwe

sockeqwe Oct 29, 2015

Owner

I'm currently working on that, but I can't remember what exactly the issue was.
For instance:

 public class OnlyOptionalFragments extends Fragment {

  @Arg(required = false) int foo;

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentArgs.inject(this);
  }
}

Then, if I use OnlyOptionalFragment fragment = new OnlyOptionalFragmentBuilder().build() it works as expected. So this issue only occurs if you instantiate the fragment directly without the builder OnlyOptionalFragment fragment = new OnlyOptionalFragment(), right? Or am I missing something else?

Owner

sockeqwe commented Oct 29, 2015

I'm currently working on that, but I can't remember what exactly the issue was.
For instance:

 public class OnlyOptionalFragments extends Fragment {

  @Arg(required = false) int foo;

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentArgs.inject(this);
  }
}

Then, if I use OnlyOptionalFragment fragment = new OnlyOptionalFragmentBuilder().build() it works as expected. So this issue only occurs if you instantiate the fragment directly without the builder OnlyOptionalFragment fragment = new OnlyOptionalFragment(), right? Or am I missing something else?

@AndreasBoehm

This comment has been minimized.

Show comment
Hide comment
@AndreasBoehm

AndreasBoehm Oct 29, 2015

Contributor

Exactly, the problem only exists when you instantiate the fragment without the builder

Contributor

AndreasBoehm commented Oct 29, 2015

Exactly, the problem only exists when you instantiate the fragment without the builder

@sockeqwe

This comment has been minimized.

Show comment
Hide comment
@sockeqwe

sockeqwe Oct 29, 2015

Owner

All right, thanks! I will fix it now. Btw. I recommend to always use the builder see #32 to ensure that you get compile time errors if (one day) you will change the arguments of a certain fragment.

Owner

sockeqwe commented Oct 29, 2015

All right, thanks! I will fix it now. Btw. I recommend to always use the builder see #32 to ensure that you get compile time errors if (one day) you will change the arguments of a certain fragment.

@sockeqwe sockeqwe closed this in 1a91755 Oct 29, 2015

@AndreasBoehm

This comment has been minimized.

Show comment
Hide comment
@AndreasBoehm

AndreasBoehm Oct 30, 2015

Contributor

Is there an ETA for releasing 3.0?

Contributor

AndreasBoehm commented Oct 30, 2015

Is there an ETA for releasing 3.0?

@sockeqwe

This comment has been minimized.

Show comment
Hide comment
@sockeqwe

sockeqwe Oct 30, 2015

Owner

The only thing that is missing right now is support for kotlin, which I will hopefully implement tonight (after work). After having implemented this, i will release 3.0. So probably tomorrow it will be available in maven central. You can expect 3.0 be available by Monday at the latest...

Owner

sockeqwe commented Oct 30, 2015

The only thing that is missing right now is support for kotlin, which I will hopefully implement tonight (after work). After having implemented this, i will release 3.0. So probably tomorrow it will be available in maven central. You can expect 3.0 be available by Monday at the latest...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment