New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump gradle version #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
welcome 😎
oooh interesting, some lint failures with these gradle changes. we're gonna look into these tomorrow a.m. before merging |
I pushed a new commit to the branch. Now inheriting from AppCompatTextView in accordance with lint. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice nice!
Regarding that unused import. I remember Android Studio having a setting to automatically strip unused imports (at least mine does). Worth turning that on, and wondering if we can share that setting across all native engineers.
second lint issue is going to be a larger problem: Looks like this method is marked as hidden in the support api! |
… find existing fragments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few comments.
btw not sure if lisa has shown you this yet, but you can run all of the linting and checkstyle stuff locally by doing milkrun quality
.
return DiscoveryFragment.newInstance(position); | ||
public | ||
@NonNull | ||
Fragment getItem(final int position) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we keep all of the modifiers in the same line of the function.
did something in our check style say to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like something android studio does automatically when auto-completing override methods, cory and i are gonna pair this morning and i'll explain our code style!
return fragmentPosition == position; | ||
}) | ||
.subscribe(frag -> frag.takeCategories(categories)); | ||
fragmentMap.get(position).takeCategories(categories); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sooooooooo much better!
public | ||
@NonNull | ||
Fragment getItem(final int position) { | ||
DiscoveryFragment fragment = DiscoveryFragment.newInstance(position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like check style wants this to be final
. we like to final
all the things
@coryroy according to the lint output it's pointing at this line: pages.stream().forEach(page -> fragmentMap.get(page).clearPage()); I didn't catch this initially, but this isn't valid java 6 code because it's using java 8 features. we need to change this to the old school way. |
|
||
public final class DiscoveryPagerAdapter extends FragmentPagerAdapter { | ||
private final Delegate delegate; | ||
private final FragmentManager fragmentManager; | ||
private List<String> pageTitles; | ||
private Map<Integer, DiscoveryFragment> fragmentMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main question I have here is whether there are any issues with holding onto a reference to these fragments – can it potentially cause any issues with GC? I couldn't see a clear explanation on how this works from a scan of the docs, so would just hope that we have confidence that this would not cause issues with destroying fragments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christopherwright Good point. Do you think putting weak references in the map would be a better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few things
.gitignore
Outdated
@@ -27,8 +27,14 @@ proguard/ | |||
# Log Files | |||
*.log | |||
|
|||
# OSX files | |||
# OS generated files # | |||
###################### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think we should cut out this comment line, to match the rest of this file's style
.gitignore
Outdated
.DS_Store | ||
.DS_Store? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason why there's a ?
appended?
@@ -40,8 +38,11 @@ public void setPrimaryItem(final @NonNull ViewGroup container, final int positio | |||
} | |||
|
|||
@Override | |||
public @NonNull Fragment getItem(final int position) { | |||
return DiscoveryFragment.newInstance(position); | |||
@NonNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general, we put our nullability annotations right in front of the type which it is annotating, i.e.
public @NonNull DiscoveryFragment
i'll update our styleguide to include this, since it's something we discussed a while ago as a team but neglected to include in the styleguide!
@@ -44,7 +43,8 @@ | |||
|
|||
public DiscoveryFragment() {} | |||
|
|||
public static @NonNull Fragment newInstance(final int position) { | |||
@NonNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here with @NonNull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the auto-formatter messed this up as I didn't specifically change this. Is it possible to change the settings file so this doesn't happen on auto-format?
Dismissing my review as I will defer to @luoser for her final approval!
merged in some related changes, feedback is now addressed
alrighty, we're ready to rock n roll. for anyone on an older version of Android Studio, be sure to upgrade to 2.3.1! |
what
Originally the plan was simply to bump version of gradle to 2.3.1 and gradle wrapper to 3.3
This had some fall on effects as we were relying on:
fragmentManager.getFragments()
but this with the new gradle version this not shows correctly as hidden so we had to come up with another solution.
how
Keeping a static HashMap of the fragments by adapter position:
seems to work very well. WeakReferences were tried but it seemed to cause many problems with fragments disappearing on config changes.
Some important things with the implementation:
and also in the constructor for the adapter:
If you don't do the null check the map will get wiped out on rotate etc which you don't want as the fragments themselves are still around.