sayyam/carouselview

Error when try change data on execution time

juanm4 opened this issue · 1 comments

Hello, I have a problem with library when I try change the data on execution time.
Well, I am trying change the views every minute, I mean, I have a timer that execute next code every minute:
getActivity().runOnUiThread(new Runnable() {
@OverRide
public void run() {
try {
messageArrayList = gson.fromJson(new MessageTask().execute("").get(), new TypeToken<ArrayList>(){}.getType());
customCarouselView = (CarouselView) rootView.findViewById(R.id.carouselView);
customCarouselView.setPageCount(2);
customCarouselView.setViewListener(new ViewListener() {
@OverRide
public View setViewForPosition(int position) {
View custom = inflater.inflate(R.layout.message_template, null);
TextView title = (TextView) custom.findViewById(R.id.title_message);
TextView body = (TextView) custom.findViewById(R.id.body_message);
title.setText(messageArrayList.get(position).getTitulo_mensaje());
body.setText(messageArrayList.get(position).getMensaje());
return custom;
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
});

But, If this code is executed on AsyncTask I get next error:
Theme: themes:{default=overlay:com.wsdeveloper.galaxy, iconPack:com.wsdeveloper.galaxy, fontPkg:com.wsdeveloper.galaxy, com.android.systemui=overlay:com.wsdeveloper.galaxy}
java.lang.RuntimeException: View must set ImageListener or ViewListener.
at com.synnapps.carouselview.CarouselView$CarouselPagerAdapter.instantiateItem(CarouselView.java:325)
at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1001)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1149)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1083)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:538)
at com.synnapps.carouselview.CarouselView.setData(CarouselView.java:231)
at com.synnapps.carouselview.CarouselView.setPageCount(CarouselView.java:411)
at com.isotader.claire.SummaryFragment$5.run(SummaryFragment.java:158)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5466)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

What happens here?

This error appears just in this line:
customCarouselView.setPageCount(2);

Thanks

First set Listner then set Pagecount