AddObject callback

Started by kPoirier, April 10, 2013, 09:41:01 AM

Previous topic - Next topic

kPoirier

Hi,

I search a method to use a callback with a method addObject in World's class.


public void myFunction(){
  ob= Loader.loadSerializedObject(...);
  world.addObject(ob);
}


I want to display a progress dialog while my function works. But addObject seems use an other thread.

How shall we do it?

Thanks.

EgonOlsen

I don't get the question. addObject adds an object to a collection of objects. There's no other thread or anything involved. It's a simple and basic operation.

kPoirier

#2
In fact, I want to display a progress dialog while adding and loading an object.

I have this in my three dimensions activity :


final ProgressDialog pg = new ProgressDialog(this);
pg.setTitle("Chargement...");
pg.setCancelable(false);
pg.show();

choice.applyOn3DWorld(this.mRenderer.getWorld(), this, new CallBack() {
@Override
public void callbackSuccess() {
pg.hide();
}
@Override
public void callbackError() {
//Nothing to do
}
});


And i have this in my "Choice" class :


public void applyOn3DWorld(...){
Object3D ob3D = null;
try {
ob3D = Loader.loadSerializedObject(new FileInputStream(TabConstant.PATH_TO_3D_MODEL + ob.getFile()));
world.addObject(ob3D);
callback.callbackSuccess();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}


If i launch the code, we never see the progress dialog. It's because "callbackSuccess()" is immediately called (i suppose that "loadSerializedObject" or "addObject" works with thread).
But, on the tablet, the model appears several seconds later whereas progress dialog is already closed.

Sorry for my bad english. I'am French.

Edit :

I put a breakpoint on "pg.hide()". I should see the progress dialog. But no...
There are possible problems to show progress dialog over a GLView ?