various progressbar usage fixes
remove unnecessary runOnUiThread from asynctask methods
This commit is contained in:
parent
2b25a9caec
commit
936935c019
@ -139,7 +139,14 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
|||||||
final boolean unreadOnly = ((MainActivity)getActivity()).getUnreadOnly();
|
final boolean unreadOnly = ((MainActivity)getActivity()).getUnreadOnly();
|
||||||
|
|
||||||
if (sessionId != null) {
|
if (sessionId != null) {
|
||||||
|
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setLoadingStatus(R.string.blank, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
HashMap<String,String> map = new HashMap<String,String>() {
|
HashMap<String,String> map = new HashMap<String,String>() {
|
||||||
{
|
{
|
||||||
put("op", "getFeeds");
|
put("op", "getFeeds");
|
||||||
@ -157,16 +164,18 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadingStatus(int status, boolean showProgress) {
|
public void setLoadingStatus(int status, boolean showProgress) {
|
||||||
TextView tv = (TextView)getView().findViewById(R.id.loading_message);
|
if (getView() != null) {
|
||||||
|
TextView tv = (TextView)getView().findViewById(R.id.loading_message);
|
||||||
if (tv != null) {
|
|
||||||
tv.setText(status);
|
if (tv != null) {
|
||||||
}
|
tv.setText(status);
|
||||||
|
}
|
||||||
View pb = getView().findViewById(R.id.loading_progress);
|
|
||||||
|
View pb = getView().findViewById(R.id.loading_progress);
|
||||||
if (pb != null) {
|
|
||||||
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
|
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();
|
Type listType = new TypeToken<List<Feed>>() {}.getType();
|
||||||
final List<Feed> feeds = gson.fromJson(content, listType);
|
final List<Feed> feeds = gson.fromJson(content, listType);
|
||||||
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
m_feeds.clear();
|
||||||
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);
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
MainActivity activity = (MainActivity)getActivity();
|
MainActivity activity = (MainActivity)getActivity();
|
||||||
|
@ -144,6 +144,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
|||||||
|
|
||||||
req.setOffset(skip);
|
req.setOffset(skip);
|
||||||
|
|
||||||
|
setLoadingStatus(R.string.blank, true);
|
||||||
|
|
||||||
HashMap<String,String> map = new HashMap<String,String>() {
|
HashMap<String,String> map = new HashMap<String,String>() {
|
||||||
{
|
{
|
||||||
put("op", "getHeadlines");
|
put("op", "getHeadlines");
|
||||||
@ -171,16 +173,18 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadingStatus(int status, boolean showProgress) {
|
public void setLoadingStatus(int status, boolean showProgress) {
|
||||||
TextView tv = (TextView)getView().findViewById(R.id.loading_message);
|
if (getView() != null) {
|
||||||
|
TextView tv = (TextView)getView().findViewById(R.id.loading_message);
|
||||||
if (tv != null) {
|
|
||||||
tv.setText(status);
|
if (tv != null) {
|
||||||
}
|
tv.setText(status);
|
||||||
|
}
|
||||||
View pb = getView().findViewById(R.id.loading_progress);
|
|
||||||
|
View pb = getView().findViewById(R.id.loading_progress);
|
||||||
if (pb != null) {
|
|
||||||
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
|
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();
|
Type listType = new TypeToken<List<Article>>() {}.getType();
|
||||||
final List<Article> articles = gson.fromJson(content, listType);
|
final List<Article> articles = gson.fromJson(content, listType);
|
||||||
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
if (m_offset == 0)
|
||||||
public void run() {
|
m_articles.clear();
|
||||||
|
|
||||||
if (m_offset == 0)
|
int last_position = m_articles.size();
|
||||||
m_articles.clear();
|
|
||||||
|
for (Article f : articles)
|
||||||
int last_position = m_articles.size();
|
m_articles.add(f);
|
||||||
|
|
||||||
for (Article f : articles)
|
m_adapter.notifyDataSetChanged();
|
||||||
m_articles.add(f);
|
|
||||||
|
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
||||||
m_adapter.notifyDataSetChanged();
|
|
||||||
|
if (list != null && m_offset != 0) {
|
||||||
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
list.setSelection(last_position+1);
|
||||||
|
}
|
||||||
if (list != null && m_offset != 0) {
|
|
||||||
list.setSelection(last_position+1);
|
MainActivity activity = (MainActivity)getActivity();
|
||||||
}
|
activity.setCanLoadMore(articles.size() >= 30);
|
||||||
|
activity.initMainMenu();
|
||||||
MainActivity activity = (MainActivity)getActivity();
|
|
||||||
activity.setCanLoadMore(articles.size() >= 30);
|
setLoadingStatus(R.string.blank, false);
|
||||||
activity.initMainMenu();
|
|
||||||
|
|
||||||
setLoadingStatus(R.string.blank, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MainActivity activity = (MainActivity)getActivity();
|
MainActivity activity = (MainActivity)getActivity();
|
||||||
|
Loading…
Reference in New Issue
Block a user