various progressbar usage fixes
remove unnecessary runOnUiThread from asynctask methods
This commit is contained in:
parent
2b25a9caec
commit
936935c019
@ -140,6 +140,13 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
|||||||
|
|
||||||
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) {
|
if (tv != null) {
|
||||||
tv.setText(status);
|
tv.setText(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
View pb = getView().findViewById(R.id.loading_progress);
|
View pb = getView().findViewById(R.id.loading_progress);
|
||||||
|
|
||||||
if (pb != null) {
|
if (pb != null) {
|
||||||
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
|
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)
|
for (Feed f : feeds)
|
||||||
m_feeds.add(f);
|
m_feeds.add(f);
|
||||||
|
|
||||||
sortFeeds();
|
sortFeeds();
|
||||||
|
|
||||||
if (m_feeds.size() == 0)
|
if (m_feeds.size() == 0)
|
||||||
setLoadingStatus(R.string.error_no_feeds, false);
|
setLoadingStatus(R.string.error_no_feeds, false);
|
||||||
else
|
else
|
||||||
setLoadingStatus(R.string.blank, false);
|
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) {
|
if (tv != null) {
|
||||||
tv.setText(status);
|
tv.setText(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
View pb = getView().findViewById(R.id.loading_progress);
|
View pb = getView().findViewById(R.id.loading_progress);
|
||||||
|
|
||||||
if (pb != null) {
|
if (pb != null) {
|
||||||
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
|
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();
|
|
||||||
|
|
||||||
int last_position = m_articles.size();
|
for (Article f : articles)
|
||||||
|
m_articles.add(f);
|
||||||
|
|
||||||
for (Article f : articles)
|
m_adapter.notifyDataSetChanged();
|
||||||
m_articles.add(f);
|
|
||||||
|
|
||||||
m_adapter.notifyDataSetChanged();
|
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
||||||
|
|
||||||
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
if (list != null && m_offset != 0) {
|
||||||
|
list.setSelection(last_position+1);
|
||||||
|
}
|
||||||
|
|
||||||
if (list != null && m_offset != 0) {
|
MainActivity activity = (MainActivity)getActivity();
|
||||||
list.setSelection(last_position+1);
|
activity.setCanLoadMore(articles.size() >= 30);
|
||||||
}
|
activity.initMainMenu();
|
||||||
|
|
||||||
MainActivity activity = (MainActivity)getActivity();
|
setLoadingStatus(R.string.blank, false);
|
||||||
activity.setCanLoadMore(articles.size() >= 30);
|
|
||||||
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