From 02cd3703bc3f8848bf04483c785af7bab528217f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 29 Nov 2011 07:12:43 +0300 Subject: [PATCH] disable refreshing when activity is paused --- src/org/fox/ttrss/FeedCategoriesFragment.java | 2 -- src/org/fox/ttrss/MainActivity.java | 31 +++++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index 5ef5b504..249d17da 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -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 { diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index a5ffc0ed..55df3ba8 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -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);