summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-11-27 12:57:34 +0300
committerAndrew Dolgov <[email protected]>2011-11-27 12:57:34 +0300
commit936935c01975f26bbf8cf7dd15f52872aacc8d4c (patch)
tree0b1e08c73f0d789e01faf31e769c2de7742b7e1f /src
parent2b25a9caec1a017f727539e57124d169ccfd25a8 (diff)
various progressbar usage fixes
remove unnecessary runOnUiThread from asynctask methods
Diffstat (limited to 'src')
-rw-r--r--src/org/fox/ttrss/FeedsFragment.java57
-rw-r--r--src/org/fox/ttrss/HeadlinesFragment.java71
2 files changed, 66 insertions, 62 deletions
diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java
index 8e84aec1..2e0a7665 100644
--- a/src/org/fox/ttrss/FeedsFragment.java
+++ b/src/org/fox/ttrss/FeedsFragment.java
@@ -139,7 +139,14 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
final boolean unreadOnly = ((MainActivity)getActivity()).getUnreadOnly();
if (sessionId != null) {
-
+
+ getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ setLoadingStatus(R.string.blank, true);
+ }
+ });
+
HashMap<String,String> map = new HashMap<String,String>() {
{
put("op", "getFeeds");
@@ -157,16 +164,18 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
}
public void setLoadingStatus(int status, boolean showProgress) {
- TextView tv = (TextView)getView().findViewById(R.id.loading_message);
-
- if (tv != null) {
- tv.setText(status);
- }
-
- View pb = getView().findViewById(R.id.loading_progress);
-
- if (pb != null) {
- pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
+ if (getView() != null) {
+ TextView tv = (TextView)getView().findViewById(R.id.loading_message);
+
+ if (tv != null) {
+ tv.setText(status);
+ }
+
+ View pb = getView().findViewById(R.id.loading_progress);
+
+ if (pb != null) {
+ pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
+ }
}
}
@@ -187,22 +196,18 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
Type listType = new TypeToken<List<Feed>>() {}.getType();
final List<Feed> feeds = gson.fromJson(content, listType);
- getActivity().runOnUiThread(new Runnable() {
- public void run() {
- m_feeds.clear();
-
- for (Feed f : feeds)
- m_feeds.add(f);
-
- sortFeeds();
-
- if (m_feeds.size() == 0)
- setLoadingStatus(R.string.error_no_feeds, false);
- else
- setLoadingStatus(R.string.blank, false);
+ m_feeds.clear();
+
+ for (Feed f : feeds)
+ m_feeds.add(f);
+
+ sortFeeds();
+
+ if (m_feeds.size() == 0)
+ setLoadingStatus(R.string.error_no_feeds, false);
+ else
+ setLoadingStatus(R.string.blank, false);
- }
- });
}
} else {
MainActivity activity = (MainActivity)getActivity();
diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java
index 1185e350..d6c7ae1c 100644
--- a/src/org/fox/ttrss/HeadlinesFragment.java
+++ b/src/org/fox/ttrss/HeadlinesFragment.java
@@ -144,6 +144,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
req.setOffset(skip);
+ setLoadingStatus(R.string.blank, true);
+
HashMap<String,String> map = new HashMap<String,String>() {
{
put("op", "getHeadlines");
@@ -171,16 +173,18 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
}
public void setLoadingStatus(int status, boolean showProgress) {
- TextView tv = (TextView)getView().findViewById(R.id.loading_message);
-
- if (tv != null) {
- tv.setText(status);
- }
-
- View pb = getView().findViewById(R.id.loading_progress);
-
- if (pb != null) {
- pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
+ if (getView() != null) {
+ TextView tv = (TextView)getView().findViewById(R.id.loading_message);
+
+ if (tv != null) {
+ tv.setText(status);
+ }
+
+ View pb = getView().findViewById(R.id.loading_progress);
+
+ if (pb != null) {
+ pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
+ }
}
}
@@ -202,32 +206,27 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
Type listType = new TypeToken<List<Article>>() {}.getType();
final List<Article> articles = gson.fromJson(content, listType);
- getActivity().runOnUiThread(new Runnable() {
- public void run() {
-
- if (m_offset == 0)
- m_articles.clear();
-
- int last_position = m_articles.size();
-
- for (Article f : articles)
- m_articles.add(f);
-
- m_adapter.notifyDataSetChanged();
-
- ListView list = (ListView)getView().findViewById(R.id.headlines);
-
- if (list != null && m_offset != 0) {
- list.setSelection(last_position+1);
- }
-
- MainActivity activity = (MainActivity)getActivity();
- activity.setCanLoadMore(articles.size() >= 30);
- activity.initMainMenu();
-
- setLoadingStatus(R.string.blank, false);
- }
- });
+ if (m_offset == 0)
+ m_articles.clear();
+
+ int last_position = m_articles.size();
+
+ for (Article f : articles)
+ m_articles.add(f);
+
+ m_adapter.notifyDataSetChanged();
+
+ ListView list = (ListView)getView().findViewById(R.id.headlines);
+
+ if (list != null && m_offset != 0) {
+ list.setSelection(last_position+1);
+ }
+
+ MainActivity activity = (MainActivity)getActivity();
+ activity.setCanLoadMore(articles.size() >= 30);
+ activity.initMainMenu();
+
+ setLoadingStatus(R.string.blank, false);
}
} else {
MainActivity activity = (MainActivity)getActivity();