本文整理汇总了Java中org.andengine.util.ActivityUtils类的典型用法代码示例。如果您正苦于以下问题:Java ActivityUtils类的具体用法?Java ActivityUtils怎么用?Java ActivityUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActivityUtils类属于org.andengine.util包,在下文中一共展示了ActivityUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateResources
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
@Override
public void onCreateResources(final OnCreateResourcesCallback pOnCreateResourcesCallback) {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
ActivityUtils.doProgressAsync(SimpleAsyncGameActivity.this, "Loading Resources...", android.R.drawable.ic_menu_rotate, new ProgressCallable<Void>() {
@Override
public Void call(final IProgressListener pProgressListener) throws Exception {
SimpleAsyncGameActivity.this.onCreateResourcesAsync(pProgressListener);
pProgressListener.onProgressChanged(100);
pOnCreateResourcesCallback.onCreateResourcesFinished();
return null;
}
}, new Callback<Void>() {
@Override
public void onCallback(final Void pCallbackValue) {
/* Nothing. */
}
});
}
});
}
示例2: onCreateScene
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
@Override
public void onCreateScene(final OnCreateSceneCallback pOnCreateSceneCallback) {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
ActivityUtils.doProgressAsync(SimpleAsyncGameActivity.this, "Loading Scene...", android.R.drawable.ic_menu_rotate, new ProgressCallable<Void>() {
@Override
public Void call(final IProgressListener pProgressListener) throws Exception {
final Scene scene = SimpleAsyncGameActivity.this.onCreateSceneAsync(pProgressListener);
pProgressListener.onProgressChanged(100);
pOnCreateSceneCallback.onCreateSceneFinished(scene);
return null;
}
}, new Callback<Void>() {
@Override
public void onCallback(final Void pCallbackValue) {
/* Nothing. */
}
});
}
});
}
示例3: onPopulateScene
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
@Override
public void onPopulateScene(final Scene pScene, final OnPopulateSceneCallback pOnPopulateSceneCallback) {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
ActivityUtils.doProgressAsync(SimpleAsyncGameActivity.this, "Populating Scene...", android.R.drawable.ic_menu_rotate, new ProgressCallable<Void>() {
@Override
public Void call(final IProgressListener pProgressListener) throws Exception {
SimpleAsyncGameActivity.this.onPopulateSceneAsync(pScene, pProgressListener);
pProgressListener.onProgressChanged(100);
pOnPopulateSceneCallback.onPopulateSceneFinished();
return null;
}
}, new Callback<Void>() {
@Override
public void onCallback(final Void pCallbackValue) {
/* Nothing. */
}
});
}
});
}
示例4: onPopulateScene
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
@Override
public void onPopulateScene(final Scene pScene, final OnPopulateSceneCallback pOnPopulateSceneCallback) {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
ActivityUtils.doProgressAsync(SimpleAsyncGameActivity.this, "Populating Scene...", android.R.drawable.ic_menu_rotate, new ProgressCallable<Void>() {
@Override
public Void call(final IProgressListener pProgressListener) throws Exception {
SimpleAsyncGameActivity.this.onPopulateSceneAsync(pScene, pProgressListener);
pProgressListener.onProgressChanged(100);
pOnPopulateSceneCallback.onPopulateSceneFinished();
return null;
}
}, new Callback<Void>() {
@Override
public void onCallback(final Void pCallbackValue) {
/* Nothing. */
}
});
}
});
}
示例5: onCreate
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frame_container);
ButterKnife.bind(this);
ActivityUtils.keepScreenOn(this);
String fragment;
Bundle extras = getIntent().getExtras();
if (extras != null) {
fragment = extras.getString(IntentKeys.FRAGMENT);
} else {
fragment = Fragments.GAME_FLOW_SELECT_LEVEL;
}
navigateTo(fragment);
_justCreated = true;
}
示例6: acquireWakeLock
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) {
if (pWakeLockOptions == WakeLockOptions.SCREEN_ON) {
ActivityUtils.keepScreenOn(this);
} else {
final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
this.mWakeLock = pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, Constants.DEBUGTAG);
try {
this.mWakeLock.acquire();
} catch (final SecurityException pSecurityException) {
Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !", pSecurityException);
}
}
}
示例7: applyEngineOptions
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
private void applyEngineOptions() {
final EngineOptions engineOptions = this.mEngine.getEngineOptions();
if (engineOptions.isFullscreen()) {
ActivityUtils.requestFullscreen(this);
}
if (engineOptions.getAudioOptions().needsMusic() || engineOptions.getAudioOptions().needsSound()) {
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
switch (engineOptions.getScreenOrientation()) {
case LANDSCAPE_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case LANDSCAPE_SENSOR:
if (SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
break;
case PORTRAIT_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case PORTRAIT_SENSOR:
if (SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
break;
}
}
示例8: toastOnUiThread
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
public void toastOnUiThread(final CharSequence pText, final int pDuration) {
if (ActivityUtils.isOnUiThread()) {
Toast.makeText(BaseActivity.this, pText, pDuration).show();
} else {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(BaseActivity.this, pText, pDuration).show();
}
});
}
}
示例9: loadMusic
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
public void loadMusic() throws IOException {
final String baseMusicPath = "mfx/";
final String musicFile = "lepeltheme.mod";
SoundFactory.setAssetBasePath(baseMusicPath);
mMenuClickSound = SoundFactory.createSoundFromAsset(mContext.getSoundManager(), mContext, "fwapfwap.ogg");
mExplosionSound = SoundFactory.createSoundFromAsset(mContext.getSoundManager(), mContext, "explosion.ogg");
mExplosionSound.setVolume(0.2f);
final ModPlayer mModPlayer = ModPlayer.getInstance();
File musicDir = new File(mContext.getFilesDir(), baseMusicPath);
if (!musicDir.isDirectory())
musicDir.mkdirs();
final File musicSrc = new File(musicDir, musicFile);
if (musicSrc.isFile()) {
((GameActivity)mContext).onModMusicLoaded(mModPlayer, musicSrc);
} else {
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
ActivityUtils.doAsync(mContext, "Loading music", "Please wait...", new Callable<Void>() {
@Override
public Void call() throws Exception {
FileUtils.copyToInternalStorage(mContext, baseMusicPath + musicFile, baseMusicPath + musicFile);
return null;
}
}, new Callback<Void>() {
@Override
public void onCallback(Void pCallbackValue) {
((GameActivity)mContext).onModMusicLoaded(mModPlayer, new File(baseMusicPath, musicFile));
}
});
}
});
}
}
示例10: acquireWakeLock
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) {
if(pWakeLockOptions == WakeLockOptions.SCREEN_ON) {
ActivityUtils.keepScreenOn(this);
} else {
final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
this.mWakeLock = pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, Constants.DEBUGTAG);
try {
this.mWakeLock.acquire();
} catch (final SecurityException pSecurityException) {
Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !", pSecurityException);
}
}
}
示例11: applyEngineOptions
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
private void applyEngineOptions() {
final EngineOptions engineOptions = this.mEngine.getEngineOptions();
if(engineOptions.isFullscreen()) {
ActivityUtils.requestFullscreen(this);
}
if(engineOptions.getAudioOptions().needsMusic() || engineOptions.getAudioOptions().needsSound()) {
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
switch(engineOptions.getScreenOrientation()) {
case LANDSCAPE_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case LANDSCAPE_SENSOR:
if(SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.LANDSCAPE_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
break;
case PORTRAIT_FIXED:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case PORTRAIT_SENSOR:
if(SystemUtils.SDK_VERSION_GINGERBREAD_OR_LATER) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
Debug.w(ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_SENSOR + " is not supported on this device. Falling back to " + ScreenOrientation.class.getSimpleName() + "." + ScreenOrientation.PORTRAIT_FIXED);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
break;
}
}
示例12: onCreate
import org.andengine.util.ActivityUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frame_container);
ButterKnife.bind(this);
ActivityUtils.keepScreenOn(this);
_gameClient = GoogleFlipGameApplication.getGameClient();
_multiplayerMode = MultiplayerMode.values()[Prefs.getInt(PrefKeys.MULTIPLAYER_MODE, 0)];
if (_multiplayerMode.equals(MultiplayerMode.CLIENT)) {
_clientService = GoogleFlipGameApplication.getBluetoothClientService();
_clientDeviceChangedListener = new DeviceChangeListenerAdapter() {
@Override
public void onDeviceRemoved(String deviceName, String address) {
handleConnectionLost();
}
};
}
_gameClientListener = new GameClientListenerAdapter() {
@Override
public void onClientsChanged(List<ClientVO> clients) {
checkConnectionLost();
}
};
String fragment;
Bundle extras = getIntent().getExtras();
if (extras != null) {
fragment = extras.getString(IntentKeys.FRAGMENT);
} else {
fragment = Fragments.GAME_FLOW_SCOREBOARD;
}
navigateTo(fragment);
}