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 @Override
protected void onPostExecute(JsonElement result) { protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false); m_activity.setProgressBarVisibility(false);
super.onPostExecute(result); super.onPostExecute(result);

View File

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

View File

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

View File

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

View File

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