Java Code Examples for com.watabou.noosa.Game#pushUiTask()

The following examples show how to use com.watabou.noosa.Game#pushUiTask() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Iap.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPurchasesUpdated() {
    checkPurchases();
    Accessory.check();

    if(mIapCallback!=null) {
        Game.pushUiTask(() -> {
            if(mIapCallback!=null) {
                mIapCallback.onPurchaseOk();
                mIapCallback = null;
            } else {
                EventCollector.logException("mIapCallback disappeared");
            }

        });
    }
}
 
Example 2
Source File: SociologistNPC.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void DownloadComplete(String file, final Boolean result) {
    Game.pushUiTask(() -> {
        if (!result) {
            reportError();
        } else {
            try {
                survey = JsonHelper.readJsonFromFile(FileSystem.getInternalStorageFile(SURVEY_JSON));

                Game.addToScene(new WndSurvey(survey));

            } catch (JSONException e) {
                reportError();
            }
        }
    });
}
 
Example 3
Source File: GLog.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private static void glog( String text, Object... args ) {
	if (args.length > 0) {
		text = Utils.format( text, args );
	}

	if(text.isEmpty()) {
		return;
	}

	if(BuildConfig.DEBUG) {
		Log.i(TAG, text);
	}

	final String finalText = text;
	Game.pushUiTask(() -> update.dispatch(finalText)
	);
}
 
Example 4
Source File: WndModSelect.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void UnzipComplete(final Boolean result) {
	Game.pushUiTask(() -> {
		if(unzipProgress!=null) {
			unzipProgress.hide();
			unzipProgress = null;
		}

		if (result) {
			Game.addToScene(new WndModSelect());
		} else {
			Game.addToScene(new WndError(Utils.format("unzipping %s failed", downloadTo)));
		}
	});

}
 
Example 5
Source File: DownloadProgressWindow.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void DownloadProgress(final String file, final Integer bytes) {
    Game.pushUiTask(() -> {
        if (progress == null) {
            progress = new WndMessage(Utils.EMPTY_STRING);
            Game.addToScene(progress);
        }
        if (progress.getParent() == Game.scene()) {
            progress.setText(Utils.format("%s  %4.2fMb", prefix, bytes / 1024f / 1024f));
        }
    });
}
 
Example 6
Source File: DownloadProgressWindow.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void DownloadComplete(final String file, final Boolean result) {
    Game.pushUiTask(() -> {
        if (progress != null) {
            progress.hide();
            progress = null;
        }

        onComplete.DownloadComplete(file, result);
    });
}
 
Example 7
Source File: WndSaveSlotSelect.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void returnToWork(boolean res) {
    Game.softPaused = false;

    Game.pushUiTask(() -> {
        if (!saving) {
            SaveUtils.loadGame(slot, Dungeon.hero.getHeroClass());
        } else {
            if (RemixedDungeon.donated() == 0 && RemixedDungeon.canDonate()) {

                if (Math.random() < 0.1) {
                    Game.pushUiTask(() -> {
                        Iap iap = Game.instance().iap;
                        if (iap != null && iap.isReady() || BuildConfig.DEBUG) {
                            EventCollector.logEvent(EventCollector.SAVE_ADS_EXPERIMENT, "DialogShown");
                            Hero.doOnNextAction = () -> Game.addToScene(new WndDontLikeAds());
                        } else {
                            EventCollector.logEvent(EventCollector.SAVE_ADS_EXPERIMENT, "DialogNotShownIapNotReady");
                        }
                    });
                }

            }
        }

    });
}
 
Example 8
Source File: WndModSelect.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void DownloadComplete(String url, final Boolean result) {
	Game.pushUiTask(() -> {
		if (result) {
			Game.execute(new UnzipTask(WndModSelect.this, downloadTo));
		} else {
			Game.addToScene(new WndError(Utils.format("Downloading %s failed", selectedMod)));
		}
	});
}
 
Example 9
Source File: WndModSelect.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void UnzipProgress(Integer unpacked) {
	Game.pushUiTask(() -> {
		if (unzipProgress == null) {
			unzipProgress = new WndMessage(Utils.EMPTY_STRING);
			Game.addToScene(unzipProgress);
		}
		if (unzipProgress.getParent() == Game.scene()) {
			unzipProgress.setText(Utils.format("Unpacking: %d", unpacked));
		}
	});
}
 
Example 10
Source File: ModsButton.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void DownloadComplete(String file, final Boolean result) {
    Game.pushUiTask(() -> {
        Game.addToScene(new WndModSelect());

        if (!result) {
            Game.toast("Mod list download failed :(");
        }
    });
}
 
Example 11
Source File: QuickSlot.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void refresh() {
    Game.pushUiTask(() -> {
        if(Dungeon.hero != null) {
            for (QuickSlot slot : slots) {
                slot.refreshSelf();
            }
        }
    });
}
 
Example 12
Source File: GoogleRewardVideoAds.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onRewardedVideoAdClosed() {
	Game.instance().runOnUiThread(GoogleRewardVideoAds.this::loadNextVideo);
	Game.pushUiTask(() -> returnTo.returnToWork(videoCompleted));
}