Author Topic: AddObject callback  (Read 1643 times)

Offline kPoirier

  • byte
  • *
  • Posts: 2
    • View Profile
AddObject callback
« on: April 10, 2013, 09:41:01 am »
Hi,

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

Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: AddObject callback
« Reply #1 on: April 10, 2013, 10:28:54 am »
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.

Offline kPoirier

  • byte
  • *
  • Posts: 2
    • View Profile
Re: AddObject callback
« Reply #2 on: April 10, 2013, 10:52:59 am »
In fact, I want to display a progress dialog while adding and loading an object.

I have this in my three dimensions activity :

Code: [Select]
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 :

Code: [Select]
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 ?
« Last Edit: April 10, 2013, 11:18:40 am by kPoirier »