disable refreshing when activity is paused
This commit is contained in:
parent
9a4c7a2ce8
commit
02cd3703bc
@ -14,7 +14,6 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -28,7 +27,6 @@ import android.widget.TextView;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class FeedCategoriesFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener {
|
||||
|
@ -315,23 +315,18 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
||||
Intent refresh = new Intent(this, MainActivity.class);
|
||||
startActivity(refresh);
|
||||
finish();
|
||||
}
|
||||
} else if (m_sessionId != null) {
|
||||
m_refreshTask = new RefreshTask();
|
||||
m_refreshTimer = new Timer("Refresh");
|
||||
|
||||
m_refreshTimer.schedule(m_refreshTask, 60*1000L, 120*1000L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (m_refreshTask != null) {
|
||||
m_refreshTask.cancel();
|
||||
m_refreshTask = null;
|
||||
}
|
||||
|
||||
if (m_refreshTimer != null) {
|
||||
m_refreshTimer.cancel();
|
||||
m_refreshTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -603,6 +598,22 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (m_refreshTask != null) {
|
||||
m_refreshTask.cancel();
|
||||
m_refreshTask = null;
|
||||
}
|
||||
|
||||
if (m_refreshTimer != null) {
|
||||
m_refreshTimer.cancel();
|
||||
m_refreshTimer = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loginSuccess() {
|
||||
findViewById(R.id.loading_container).setVisibility(View.INVISIBLE);
|
||||
findViewById(R.id.main).setVisibility(View.VISIBLE);
|
||||
|
Loading…
Reference in New Issue
Block a user