Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tons of ProgressFragment.ensureContent errors #25

Open
Swisyn opened this issue Jan 19, 2015 · 3 comments
Open

Tons of ProgressFragment.ensureContent errors #25

Swisyn opened this issue Jan 19, 2015 · 3 comments

Comments

@Swisyn
Copy link

Swisyn commented Jan 19, 2015

Sometimes i get tons of error feedbacks from my users about the lib.

java.lang.IllegalStateException: Content view not yet created
at com.devspark.progressfragment.ProgressFragment.ensureContent(ProgressFragment.java:273)
at com.devspark.progressfragment.ProgressFragment.setContentEmpty(ProgressFragment.java:250)

My fragments like;
public class BusListFragment extends ProgressFragment {
private Context context;
private CardRecyclerView cardRecyclerView;
private View rootView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    setRetainInstance(true);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_mycards, container, false);
    context = getActivity();
    cardRecyclerView = (CardRecyclerView) rootView.findViewById(R.id.cardRecyclerView);
    return super.onCreateView(inflater, container, savedInstanceState);
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(rootView);
    if (stopId != null && location != null) {
        new getClosestBusListAsync(this).execute();
    }
}

}
and the task is like;
public class getClosestStopListAsync extends AsyncTask<Void, Void, String> {
ProgressFragment fragment;
Context context;
GoogleMap map;
LatLng location;

public getClosestStopListAsync(ProgressFragment fragment, LatLng location, GoogleMap map) {
    this.fragment = fragment;
    this.context = fragment.getActivity();
    this.location = location;
    this.map = map;
}

@Override
protected String doInBackground(Void... args0) {
    return new RequestHelper().getClosestStopList(PreferenceHelper.getCity(context), location.latitude, location.longitude);
}

@Override
protected void onPostExecute(String result) {
    super.onPostExecute(result);
    if (result != null) {
        map.clear();

        BusStop stopList = JsonHelper.getClosestStopList(result);
        if (stopList != null) {
            if (stopList.getResult().getCode().equals("0")) {
                if (stopList != null || stopList.getBusStopList().size() > 0) {
                    for (BusStop.BusStopItem busStop : stopList.getBusStopList()) {
                        map.addMarker(new MarkerOptions()
                                .position(new LatLng(Double.parseDouble(busStop.getLatitude()), Double.parseDouble(busStop.getLongitude())))
                                .title(busStop.getStopId() + " - " + busStop.getStopName() + " - " + busStop.getType())
                                .snippet(busStop.getRoutes())
                                .icon(BitmapDescriptorFactory.fromResource(R.drawable.stop)));
                    }
                    fragment.setContentEmpty(false);
                } else {
                    fragment.setContentEmpty(true);
                    fragment.setEmptyText(R.string.empty_list);
                }
            }
        }
        System.gc();
        fragment.setContentShown(true);
    }
}

}

how can it be possible that content view not yet created? OnActivityCreated is called after OnCreateView so that means views could be created?

How can i fix this issue? Thanks.

@mitsus
Copy link

mitsus commented May 8, 2015

HI Swisyn,
i've the same problem.
You were able to find a solution?

Thanks a lot

@Swisyn
Copy link
Author

Swisyn commented May 8, 2015

this is so useless library and i gave up to using it. I use progresslayout lib or multistateview lib. @mitsus

@casperbang
Copy link

We also have lots of issues with ensureContent errors, often associated with calls to setContentShown(false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants