diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryItemViewModel.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryItemViewModel.kt index ae7fd8f5b56..cb28de75047 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryItemViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryItemViewModel.kt @@ -11,7 +11,7 @@ import org.oppia.android.domain.translation.TranslationController /** Completed story view model for the recycler view in [CompletedStoryListFragment]. */ class CompletedStoryItemViewModel( private val activity: AppCompatActivity, - private val internalProfileId: Int, + private val profileId: ProfileId, val completedStory: CompletedStory, val entityType: String, private val intentFactoryShim: IntentFactoryShim, @@ -33,7 +33,7 @@ class CompletedStoryItemViewModel( /** Called when user clicks on CompletedStoryItem. */ fun onCompletedStoryItemClicked() { routeToTopicPlayStory( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId, completedStory.classroomId, completedStory.topicId, completedStory.storyId diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt index fe2d803f0a7..6d4fe12f3d9 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt @@ -21,8 +21,8 @@ class CompletedStoryListActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - val internalProfileId: Int = intent?.extractCurrentUserProfileId()?.internalId ?: -1 - completedStoryListActivityPresenter.handleOnCreate(internalProfileId) + val profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.getDefaultInstance() + completedStoryListActivityPresenter.handleOnCreate(profileId) } companion object { diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityPresenter.kt index de44ee70a2c..cb0cebfc2fa 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityPresenter.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.completedstorylist import androidx.appcompat.app.AppCompatActivity import org.oppia.android.R import org.oppia.android.app.activity.ActivityScope +import org.oppia.android.app.model.ProfileId import javax.inject.Inject /** The presenter for [CompletedStoryListActivity]. */ @@ -12,7 +13,7 @@ class CompletedStoryListActivityPresenter @Inject constructor( ) { /** Initializes views for [CompletedStoryListActivity] and binds [CompletedStoryListFragment]. */ - fun handleOnCreate(internalProfileId: Int) { + fun handleOnCreate(profileId: ProfileId) { activity.setContentView(R.layout.completed_story_list_activity) if (getCompletedStoryListFragment() == null) { activity @@ -20,7 +21,7 @@ class CompletedStoryListActivityPresenter @Inject constructor( .beginTransaction() .add( R.id.completed_story_list_fragment_placeholder, - CompletedStoryListFragment.newInstance(internalProfileId), + CompletedStoryListFragment.newInstance(profileId), CompletedStoryListFragment.COMPLETED_STORY_LIST_FRAGMENT_TAG ).commitNow() } diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt index 4f11f4df5e1..e1f0bb3b4aa 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt @@ -20,8 +20,7 @@ class CompletedStoryListFragment : InjectableFragment() { const val COMPLETED_STORY_LIST_FRAGMENT_TAG = "COMPLETED_STORY_LIST_FRAGMENT_TAG" /** Returns a new [CompletedStoryListFragment] to display corresponding to the specified profile ID. */ - fun newInstance(internalProfileId: Int): CompletedStoryListFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + fun newInstance(profileId: ProfileId): CompletedStoryListFragment { return CompletedStoryListFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) @@ -47,11 +46,10 @@ class CompletedStoryListFragment : InjectableFragment() { "Expected arguments to be passed to CompletedStoryListFragment" } val profileId = arguments.extractCurrentUserProfileId() - val internalProfileId = profileId.internalId return completedStoryListFragmentPresenter.handleCreateView( inflater, container, - internalProfileId + profileId ) } } diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt index ed1a566d4de..02b2ae9cd68 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt @@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.recyclerview.widget.GridLayoutManager import org.oppia.android.R +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.recyclerview.BindableAdapter import org.oppia.android.databinding.CompletedStoryItemBinding import org.oppia.android.databinding.CompletedStoryListFragmentBinding @@ -26,9 +27,9 @@ class CompletedStoryListFragmentPresenter @Inject constructor( fun handleCreateView( inflater: LayoutInflater, container: ViewGroup?, - internalProfileId: Int + profileId: ProfileId ): View? { - viewModel.setProfileId(internalProfileId) + viewModel.setProfileId(profileId) binding = CompletedStoryListFragmentBinding .inflate( diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt index 678d91b02ce..e2a02cc711d 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt @@ -26,13 +26,11 @@ class CompletedStoryListViewModel @Inject constructor( private val translationController: TranslationController, @StoryHtmlParserEntityType private val entityType: String ) : ObservableViewModel() { - /** [internalProfileId] needs to be set before any of the live data members can be accessed. */ - private var internalProfileId: Int = -1 + /** [profileId] needs to be set before any of the live data members can be accessed. */ + private var profileId: ProfileId = ProfileId.getDefaultInstance() private val completedStoryListResultLiveData: LiveData> by lazy { - topicController.getCompletedStoryList( - ProfileId.newBuilder().setInternalId(internalProfileId).build() - ).toLiveData() + topicController.getCompletedStoryList(profileId).toLiveData() } private val completedStoryLiveData: LiveData by lazy { @@ -45,8 +43,8 @@ class CompletedStoryListViewModel @Inject constructor( } /** Sets internalProfileId to this ViewModel. */ - fun setProfileId(internalProfileId: Int) { - this.internalProfileId = internalProfileId + fun setProfileId(profileId: ProfileId) { + this.profileId = profileId } private fun processCompletedStoryListResult( @@ -74,7 +72,7 @@ class CompletedStoryListViewModel @Inject constructor( completedStoryList.completedStoryList.map { completedStory -> CompletedStoryItemViewModel( activity, - internalProfileId, + profileId, completedStory, entityType, intentFactoryShim,