Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix: Handle multiple exceptions on CourseUnitNavigationActivity (#1766)
Browse files Browse the repository at this point in the history
- Added temporary empty list checks UnitLists
- handle onRestoreInstanceState.
fixes: LEARNER-9264
  • Loading branch information
omerhabib26 authored Mar 24, 2023
1 parent c71282d commit 44ab1cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ protected void onCreate(Bundle arg0) {
restore(bundle);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
restore(savedInstanceState);
}

@Override
protected void onResume() {
super.onResume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ protected void onResume() {

@Override
public void navigatePreviousComponent() {
if (pagerAdapter.getItemCount() == 0) {
return;
}
int index = pager2.getCurrentItem();
if (index > 0) {
pager2.setCurrentItem(index - 1);
Expand All @@ -226,6 +229,9 @@ public void navigatePreviousComponent() {

@Override
public void navigateNextComponent() {
if (pagerAdapter.getItemCount() == 0) {
return;
}
int index = pager2.getCurrentItem();
if (index < pagerAdapter.getItemCount() - 1) {
pager2.setCurrentItem(index + 1);
Expand Down Expand Up @@ -316,6 +322,10 @@ private void setCurrentUnit(CourseComponent component) {
}

private void tryToUpdateForEndOfSequential() {
if (pagerAdapter.getItemCount() == 0) {
return;
}

int curIndex = pager2.getCurrentItem();
setCurrentUnit(pagerAdapter.getUnit(curIndex));

Expand Down Expand Up @@ -390,15 +400,13 @@ private void updateDataModel() {
if (refreshCourse) {
initAdapter();
}
if (pagerAdapter != null)
pagerAdapter.notifyDataSetChanged();

if (index >= 0) {
pager2.setCurrentItem(index, false);
tryToUpdateForEndOfSequential();
}

if (pagerAdapter != null)
pagerAdapter.notifyDataSetChanged();

}

@Override
Expand Down

0 comments on commit 44ab1cc

Please sign in to comment.