使用TabLayout和ViewPager挂起嵌套片段中的所有线程,并关闭应用程序而不会出现任何崩溃对话框

时间:2016-02-03 11:32:04

标签: android android-fragments android-tablayout

$scope.$on('event_name', function () { //data required to pass in parent controller }); MainActivityFragments,其中包含使用自定义TabLayoutViewPager的嵌套片段。每个Fragment嵌套片段都会使用ListViewWebServices显示数据。

它们的一个片段是:

public class IndicesFragment extends android.support.v4.app.Fragment {

public static IndicesFragment newInstance() {
    return new IndicesFragment();
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.equity_activity, container, false);
    act = this.getActivity();
    return view;
}


public void onActivityCreated(Bundle savedInstanceState1) {
    super.onActivityCreated(savedInstanceState1);
    setHasOptionsMenu(true);
    list = (ListView) view.findViewById(R.id.list_equity);
    if (Utils.isNetworkAvailable(getActivity())) {
        if (catListDao.size() > 0) {
            adapter = new AdvisorsAdapter(act, R.layout.custom_equity, catListDao, 0);
            list.setAdapter(adapter);
        } else {
            if (!isViewShown) {
                new FetchAllData(getActivity(), 3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
        }
    } else {
        CustomToast toast = new CustomToast(getActivity(), "There is no internet connection!");
    }
}

@Override
public void onResume() {
    super.onResume();
    Constants.check_fragment_visible = 1;
    if (Constants.check_reload) {
        if (Utils.isNetworkAvailable(getActivity())) {
            new FetchAllData(getActivity(), 3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            CustomToast toast = new CustomToast(getActivity(), "There is no internet connection!");
        }
    }
    if (adapter != null) adapter.notifyDataSetChanged();

}

当我们从Dialog更改Activity并且从{{1}的另一个片段调用此嵌套片段时,我的应用程序在没有任何Fragment的情况下崩溃它被冻结在那里,嵌套片段的结果突然在那里被打开了。挂起线程的 StackTrace 就像:

MainActivity

0 个答案:

没有答案