-
Notifications
You must be signed in to change notification settings - Fork 554
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
Conversation
@BenHenning PTAL. This PR mainly misses the functional part of audio component. Also, note that PR base branch is |
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.
app/src/main/java/org/oppia/app/player/state/audio/AudioFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/player/state/audio/AudioFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/player/state/audio/AudioFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/player/state/audio/LanguageDialogFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/player/state/audio/LanguageInterface.kt
Outdated
Show resolved
Hide resolved
@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. |
if (prev != null) { | ||
fragmentTransaction.remove(prev) | ||
} | ||
fragmentTransaction.addToBackStack(null) |
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.
Rather than relying on the backstack here, could we just retrieve the existing dialog via findFragmentByTag() and dismiss it, then show a new dialog?
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 have updated this code as per this resource but it almost looks like previous code, so not sure if it is correct.
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.
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)}" |
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.
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.
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.
Made changes as per link mentioned shifted logic part to AudioFragment
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.
Thanks--this looks good!
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.
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.
app/src/main/java/org/oppia/app/player/audio/LanguageDialogFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/player/audio/LanguageDialogFragment.kt
Outdated
Show resolved
Hide resolved
Also @rt4914 can you resolve the conflicts that are pending for this branch? |
@BenHenning PTAL |
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.
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() |
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.
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.
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.
That means this is correct right?
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.
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)}" |
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.
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.
Hi @BenHenning earlier one of commits related to ViewModel code missed, can you have a fresh look on this PR. |
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.
LGTM, though I think you should make the language code field observable so it automatically updates in the UI.
Merging this code to unlock James. This code does need improvements but that will be managed in another PR. |
Explanation
This PR contains the basic structure of AudioComponent mainly introduction of activities and fragments.
Things which needs to be implemented:
Checklist