check if fragment is attached in fragment asynctasks

This commit is contained in:
Andrew Dolgov 2012-10-09 09:54:43 +04:00
parent cc3be7ed43
commit ac3dbd593a
5 changed files with 15 additions and 1 deletions

View File

@ -144,6 +144,8 @@ public class ArticlePager extends Fragment {
@Override
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false);
super.onPostExecute(result);

View File

@ -255,6 +255,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
@Override
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false);
if (result != null) {

View File

@ -343,6 +343,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
ApiRequest req = new ApiRequest(getActivity().getApplicationContext()) {
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
if (result != null) {
try {
@ -399,6 +401,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
@Override
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false);
if (result != null) {
@ -632,6 +636,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
}
protected void onPostExecute(Integer result) {
if (isDetached()) return;
m_adapter.notifyDataSetInvalidated();
}

View File

@ -368,6 +368,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
@Override
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false);
super.onPostExecute(result);

View File

@ -545,8 +545,10 @@ public class OnlineActivity extends CommonActivity {
ApiRequest req = new ApiRequest(getApplicationContext()) {
protected void onPostExecute(JsonElement result) {
if (hf.isAdded()) {
hf.refresh(false);
}
}
};
final String articleIds = articlesToIdString(articles);