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

cnw-fix-425 #427

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/src/main/java/org/glucosio/android/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.glucosio.android.adapter.HomePagerAdapter;
import org.glucosio.android.analytics.Analytics;
import org.glucosio.android.db.DatabaseHandler;
import org.glucosio.android.fragment.HistoryFragment;
import org.glucosio.android.presenter.ExportPresenter;
import org.glucosio.android.presenter.MainPresenter;
import org.glucosio.android.tools.LocaleHelper;
Expand Down Expand Up @@ -166,6 +167,7 @@ public void onPageSelected(int position) {
public void onPageScrollStateChanged(int state) {

}

});

FloatingActionButton fabAddReading = findViewById(R.id.activity_main_fab_add_reading);
Expand Down Expand Up @@ -272,6 +274,28 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
analytics.reportScreen("Main Activity");
}

@Override
protected void onResume() {
/* Added this method to ensure that new data is shown after being added by other activities
example - while viewing HbA1c history, use calculator to add reading. The new reading
wasn't being shown on the history until the user navigated away from the history page
and came back, and it should refresh with data IMHO
*/
super.onResume();

if (viewPager != null && homePagerAdapter != null) {
int currentPage = viewPager.getCurrentItem();
if (currentPage == 1) { // assumption - history tab is always position 1
HistoryFragment historyFragment = homePagerAdapter.getHistoryFragment();
Copy link
Contributor

Choose a reason for hiding this comment

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

You can override onResume in the History fragment and reload data there. However, it is not a super great solution since it will happen also when the user locked the screen, the user opened another app, etc.

if (historyFragment != null) {
historyFragment.reloadFragmentAdapter();
}
}
}


}

private void openRemindersActivity() {
Intent intent = new Intent(this, RemindersActivity.class);
startActivity(intent);
Expand Down Expand Up @@ -793,4 +817,6 @@ private boolean checkPlayServices() {
private void showErrorDialogPlayServices() {
Toast.makeText(getApplicationContext(), R.string.activity_main_error_play_services, Toast.LENGTH_SHORT).show();
}


}