Skip to content
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

Fix part of #17: Exploration Player Audio Component (Part 4) #105

Merged
merged 25 commits into from
Sep 19, 2019

Conversation

rt4914
Copy link
Contributor

@rt4914 rt4914 commented Sep 16, 2019

Explanation

This PR contains the basic structure of AudioComponent mainly introduction of activities and fragments.

Things which needs to be implemented:

  1. AudioControllerFragment and ViewModel.
  2. Everything related to interaction is pending.

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • x ] The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is assigned to an appropriate reviewer.

@rt4914
Copy link
Contributor Author

rt4914 commented Sep 16, 2019

@BenHenning PTAL. This PR mainly misses the functional part of audio component. Also, note that PR base branch is exploration-player-1-base.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rt4914! I'd like to do one more pass on this.

@jamesxu0 I suggest you also do a review pass on this.

@rt4914
Copy link
Contributor Author

rt4914 commented Sep 17, 2019

@BenHenning @jamesxu0 This PR cannot be merged and is still pending. Refer to email that I have sent you. But this PR is the base and can be taken ahead from here.

@rt4914 rt4914 assigned BenHenning and unassigned rt4914 Sep 17, 2019
if (prev != null) {
fragmentTransaction.remove(prev)
}
fragmentTransaction.addToBackStack(null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than relying on the backstack here, could we just retrieve the existing dialog via findFragmentByTag() and dismiss it, then show a new dialog?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this code as per this resource but it almost looks like previous code, so not sure if it is correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my later thread. I was hoping we could use dismiss() on the dialog fragment, but your solution is more correct so we'll keep this.

android:textSize="14sp"
android:textStyle="bold"
android:text="@{viewModel.audioLanguageCode}"
android:onClick="@{(v) -> viewModel.languageSelectionClicked(fragmentManager)}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this feels a bit odd to me. Can we call a method on the fragment, instead? It feels safer to keep fragment transactions isolated to fragment classes, and view models probably shouldn't really do much logic if possible. It's easier to verify fragments as correct, so we should push logic to those as much as possible.

Per https://stackoverflow.com/a/54312819/3689782 this seems possible. I suppose we can bind just about anything in the binding object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes as per link mentioned shifted logic part to AudioFragment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks--this looks good!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry I misunderstood--let's only perform the transaction in AudioFragment and not ViewModel. The current code is still calling languageSelectionClicked() in ViewModel, and this code should instead be in AudioFragment.

@BenHenning
Copy link
Member

Also @rt4914 can you resolve the conflicts that are pending for this branch?

@BenHenning BenHenning assigned rt4914 and unassigned BenHenning Sep 18, 2019
@BenHenning BenHenning changed the title Fix part of #17: Exploration Player Audio Component (Part 4) [Blocked: #5] Fix #130: Exploration Player Audio Component (Part 4) [Blocked: #5] Sep 18, 2019
@BenHenning BenHenning changed the title Fix #130: Exploration Player Audio Component (Part 4) [Blocked: #5] Fix part of #17: Exploration Player Audio Component (Part 4) Sep 18, 2019
@rt4914 rt4914 assigned BenHenning and unassigned rt4914 Sep 18, 2019
@rt4914
Copy link
Contributor Author

rt4914 commented Sep 18, 2019

@BenHenning PTAL

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rt4914. Just one thing needs to be removed and this looks good to submit.

fun languageSelectionClicked(fragmentManager: FragmentManager) {
val previousFragment = fragmentManager.findFragmentByTag(TAG_DIALOG)
if (previousFragment != null) {
fragmentManager.beginTransaction().remove(previousFragment).commitNow()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I really think it would be nicer to use dismiss(), but I just looked through the AndroidX code and it appears dismiss() is not synchronous (it uses commit() internally), so this is unfortunately necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means this is correct right?

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed one thing that we should fix before submission.

android:textSize="14sp"
android:textStyle="bold"
android:text="@{viewModel.audioLanguageCode}"
android:onClick="@{(v) -> viewModel.languageSelectionClicked(fragmentManager)}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry I misunderstood--let's only perform the transaction in AudioFragment and not ViewModel. The current code is still calling languageSelectionClicked() in ViewModel, and this code should instead be in AudioFragment.

@BenHenning BenHenning assigned rt4914 and unassigned BenHenning Sep 18, 2019
@rt4914 rt4914 changed the base branch from exploration-player-1-base to develop September 19, 2019 03:53
@rt4914
Copy link
Contributor Author

rt4914 commented Sep 19, 2019

Sorry, I missed one thing that we should fix before submission.

Hi @BenHenning earlier one of commits related to ViewModel code missed, can you have a fresh look on this PR.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I think you should make the language code field observable so it automatically updates in the UI.

@rt4914
Copy link
Contributor Author

rt4914 commented Sep 19, 2019

Merging this code to unlock James. This code does need improvements but that will be managed in another PR.

@rt4914 rt4914 merged commit 4711fd5 into develop Sep 19, 2019
@rt4914 rt4914 deleted the exploration-player-4-audio branch September 25, 2019 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants