when paused, do not update widget more than once a minute (unless

finishing)
This commit is contained in:
Andrew Dolgov 2017-05-31 18:31:29 +03:00
parent 02810f6eee
commit 432228011c

View File

@ -38,6 +38,7 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
protected SharedPreferences m_prefs;
protected long m_lastRefresh = 0;
protected long m_lastWidgetRefresh = 0;
private boolean m_feedIsSelected = false;
private boolean m_userFeedSelected = false;
@ -64,6 +65,8 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
Application.getInstance().load(savedInstanceState);
m_lastWidgetRefresh = new Date().getTime();
m_drawerLayout = (DrawerLayout) findViewById(R.id.headlines_drawer);
if (m_drawerLayout != null) {
@ -476,11 +479,18 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
}
@Override
public void onStop() {
super.onStop();
public void onPause() {
super.onPause();
Date date = new Date();
if (isFinishing() || date.getTime() - m_lastWidgetRefresh > 60*1000) {
m_lastWidgetRefresh = date.getTime();
Intent updateWidgetIntent = new Intent(SmallWidgetProvider.ACTION_REQUEST_UPDATE);
sendBroadcast(updateWidgetIntent);
}
Intent updateWidgetIntent = new Intent(SmallWidgetProvider.ACTION_REQUEST_UPDATE);
sendBroadcast(updateWidgetIntent);
}
@Override