List of usage examples for android.os Bundle getByte
@Override public byte getByte(String key)
From source file:com.fenlisproject.elf.core.framework.ElfBinder.java
public static void bindFragmentArgument(Fragment receiver) { Field[] fields = receiver.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true);/* w ww .j av a 2 s . c om*/ FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class); if (fragmentArgument != null) { try { Bundle bundle = receiver.getArguments(); if (bundle != null) { Class<?> type = field.getType(); if (type == Boolean.class || type == boolean.class) { field.set(receiver, bundle.getBoolean(fragmentArgument.value())); } else if (type == Byte.class || type == byte.class) { field.set(receiver, bundle.getByte(fragmentArgument.value())); } else if (type == Character.class || type == char.class) { field.set(receiver, bundle.getChar(fragmentArgument.value())); } else if (type == Double.class || type == double.class) { field.set(receiver, bundle.getDouble(fragmentArgument.value())); } else if (type == Float.class || type == float.class) { field.set(receiver, bundle.getFloat(fragmentArgument.value())); } else if (type == Integer.class || type == int.class) { field.set(receiver, bundle.getInt(fragmentArgument.value())); } else if (type == Long.class || type == long.class) { field.set(receiver, bundle.getLong(fragmentArgument.value())); } else if (type == Short.class || type == short.class) { field.set(receiver, bundle.getShort(fragmentArgument.value())); } else if (type == String.class) { field.set(receiver, bundle.getString(fragmentArgument.value())); } else if (type == Boolean[].class || type == boolean[].class) { field.set(receiver, bundle.getBooleanArray(fragmentArgument.value())); } else if (type == Byte[].class || type == byte[].class) { field.set(receiver, bundle.getByteArray(fragmentArgument.value())); } else if (type == Character[].class || type == char[].class) { field.set(receiver, bundle.getCharArray(fragmentArgument.value())); } else if (type == Double[].class || type == double[].class) { field.set(receiver, bundle.getDoubleArray(fragmentArgument.value())); } else if (type == Float[].class || type == float[].class) { field.set(receiver, bundle.getFloatArray(fragmentArgument.value())); } else if (type == Integer[].class || type == int[].class) { field.set(receiver, bundle.getIntArray(fragmentArgument.value())); } else if (type == Long[].class || type == long[].class) { field.set(receiver, bundle.getLongArray(fragmentArgument.value())); } else if (type == Short[].class || type == short[].class) { field.set(receiver, bundle.getShortArray(fragmentArgument.value())); } else if (type == String[].class) { field.set(receiver, bundle.getStringArray(fragmentArgument.value())); } else if (Serializable.class.isAssignableFrom(type)) { field.set(receiver, bundle.getSerializable(fragmentArgument.value())); } else if (type == Bundle.class) { field.set(receiver, bundle.getBundle(fragmentArgument.value())); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:ua.com.spasetv.testintuitions.FragResultExercises.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); this.activity = activity; this.res = getActivity().getResources(); dataBaseHelper = new DataBaseHelper(activity); Bundle bundle = this.getArguments(); if (bundle != null) { this.idFragment = bundle.getInt(ID_FRAGMENT); this.correctAnswers = bundle.getByte(CORRECT_ANSW); }/*from ww w. j a va 2s .co m*/ // try { // onExerciseFinishListener = (OnExerciseFinishListener) activity; // } catch (ClassCastException e) { // throw new ClassCastException(activity.toString() // + " must implement OnExerciseFinishListener"); // } new Ads(getActivity()).showAd(); }
From source file:com.frostwire.android.gui.fragments.BrowsePeerFragment.java
@Override public Loader<Object> onCreateLoader(int id, Bundle args) { if (id == LOADER_FILES_ID && args != null) { return createLoaderFiles(args.getByte("fileType")); }/*from w w w .j av a 2 s . com*/ return null; }
From source file:paulscode.android.mupen64plusae.cheat.CheatEditorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAppData = new AppData(this); mGlobalPrefs = new GlobalPrefs(this, mAppData); mGlobalPrefs.enforceLocale(this); // Get the ROM header info Bundle extras = getIntent().getExtras(); if (extras == null) throw new Error("ROM path must be passed via the extras bundle when starting CheatEditorActivity"); mRomCrc = extras.getString(ActivityHelper.Keys.ROM_CRC); mRomHeaderName = extras.getString(ActivityHelper.Keys.ROM_HEADER_NAME); mRomCountryCode = extras.getByte(ActivityHelper.Keys.ROM_COUNTRY_CODE); setContentView(R.layout.cheat_editor); reload(mRomCrc, mRomCountryCode);//from ww w . j a v a 2s .c o m findViewById(R.id.imgBtnChtAdd).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Add a cheat mSelectedCheat = -1; int stringId = R.string.cheatEditor_edit1; EditCheatDialog editCheatDialogFragment = EditCheatDialog.newInstance(getString(stringId), null, null, null, null, getCheatTitles()); FragmentManager fm = getSupportFragmentManager(); editCheatDialogFragment.show(fm, STATE_CHEAT_EDIT_DIALOG_FRAGMENT); } }); findViewById(R.id.imgBtnChtAddAvanced).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Add a cheat mSelectedCheat = -1; int stringId = R.string.cheatEditor_edit2; EditCheatAdvancedDialog editCheatDialogFragment = EditCheatAdvancedDialog .newInstance(getString(stringId), null, null, null, null, getCheatTitles()); FragmentManager fm = getSupportFragmentManager(); editCheatDialogFragment.show(fm, STATE_CHEAT_EDIT_DIALOG_FRAGMENT); } }); //default state is cancelled unless we save setResult(RESULT_CANCELED, null); }
From source file:it.sineo.android.tileMapEditor.TileMap.java
public TileMap(Bundle b) { name = b.getString("name"); rows = b.getInt("rows"); columns = b.getInt("columns"); scale = b.getFloat("scale"); xOff = b.getFloat("xOff"); yOff = b.getFloat("yoff"); tilePaths = new String[rows][columns]; tileBitmaps = new Bitmap[rows][columns]; tileAngles = new byte[rows][columns]; tileMatrices = new Matrix[rows][columns]; for (int idxRow = 0; idxRow < rows; idxRow++) { for (int idxCol = 0; idxCol < columns; idxCol++) { if (b.containsKey("paths_" + idxRow + "_" + idxCol)) { tilePaths[idxRow][idxCol] = b.getString("paths_" + idxRow + "_" + idxCol); tileAngles[idxRow][idxCol] = b.getByte("angles_" + idxRow + "_" + idxCol); }/*from www. j av a2s .c om*/ } } }
From source file:com.frostwire.android.gui.fragments.MyFilesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { lastFileType = savedInstanceState.getByte(EXTRA_LAST_FILE_TYPE_CLICKED); clickFileTypeTab(lastFileType);/*from ww w . j a v a 2s .c o m*/ } setRetainInstance(true); }
From source file:paulscode.android.mupen64plusae.persistent.GamePrefsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get the ROM path and MD5 that was passed to the activity final Bundle extras = getIntent().getExtras(); if (extras == null) throw new Error("ROM path and MD5 must be passed via the extras bundle"); mRomPath = extras.getString(ActivityHelper.Keys.ROM_PATH); mRomMd5 = extras.getString(ActivityHelper.Keys.ROM_MD5); mRomCrc = extras.getString(ActivityHelper.Keys.ROM_CRC); mRomHeaderName = extras.getString(ActivityHelper.Keys.ROM_HEADER_NAME); mRomGoodName = extras.getString(ActivityHelper.Keys.ROM_GOOD_NAME); mLegacySaveName = extras.getString(ActivityHelper.Keys.ROM_LEGACY_SAVE); mRomCountryCode = extras.getByte(ActivityHelper.Keys.ROM_COUNTRY_CODE); if (TextUtils.isEmpty(mRomMd5)) throw new Error("MD5 must be passed via the extras bundle"); // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed // mMogaController.init(); MogaHack.init(mMogaController, this); // Get app data and user preferences mAppData = new AppData(this); mGlobalPrefs = new GlobalPrefs(this, mAppData); mGamePrefs = new GamePrefs(this, mRomMd5, mRomCrc, mRomHeaderName, mRomGoodName, RomHeader.countryCodeToSymbol(mRomCountryCode), mAppData, mGlobalPrefs, mLegacySaveName); mGlobalPrefs.enforceLocale(this); mPrefs = getSharedPreferences(mGamePrefs.sharedPrefsName, MODE_PRIVATE); // Get the detailed info about the ROM mRomDatabase = RomDatabase.getInstance(); if (!mRomDatabase.hasDatabaseFile()) { mRomDatabase.setDatabaseFile(mAppData.mupen64plus_ini); }//from w w w. ja v a 2 s .c om mRomDetail = mRomDatabase.lookupByMd5WithFallback(mRomMd5, new File(mRomPath), mRomCrc); // Load user preference menu structure from XML and update view addPreferencesFromResource(mGamePrefs.sharedPrefsName, R.xml.preferences_game); }
From source file:paulscode.android.mupen64plusae.game.GameActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i("GameActivity", "onCreate"); super.setTheme(android.support.v7.appcompat.R.style.Theme_AppCompat_NoActionBar); //Allow volume keys to control media volume if they are not mapped final SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean volKeyMapped = mPreferences.getBoolean("inputVolumeMappable", false); final AppData appData = new AppData(this); final GlobalPrefs globalPrefs = new GlobalPrefs(this, appData); if (!volKeyMapped && globalPrefs.audioPlugin.enabled) { setVolumeControlStream(AudioManager.STREAM_MUSIC); }//w w w . j av a 2 s. co m mControllers = new ArrayList<>(); mMogaController = Controller.getInstance(this); // Get the intent data final Bundle extras = this.getIntent().getExtras(); if (extras == null) throw new Error("ROM path and MD5 must be passed via the extras bundle when starting GameActivity"); mRomPath = extras.getString(ActivityHelper.Keys.ROM_PATH); mRomMd5 = extras.getString(ActivityHelper.Keys.ROM_MD5); mRomCrc = extras.getString(ActivityHelper.Keys.ROM_CRC); String romHeaderName = extras.getString(ActivityHelper.Keys.ROM_HEADER_NAME); byte romCountryCode = extras.getByte(ActivityHelper.Keys.ROM_COUNTRY_CODE); String artPath = extras.getString(ActivityHelper.Keys.ROM_ART_PATH); String romGoodName = extras.getString(ActivityHelper.Keys.ROM_GOOD_NAME); String legacySaveName = extras.getString(ActivityHelper.Keys.ROM_LEGACY_SAVE); boolean doRestart = extras.getBoolean(ActivityHelper.Keys.DO_RESTART, false); if (TextUtils.isEmpty(mRomPath) || TextUtils.isEmpty(mRomMd5)) throw new Error("ROM path and MD5 must be passed via the extras bundle when starting GameActivity"); // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed // mMogaController.init(); MogaHack.init(mMogaController, this); // Get app data and user preferences mGlobalPrefs = new GlobalPrefs(this, appData); mGamePrefs = new GamePrefs(this, mRomMd5, mRomCrc, romHeaderName, romGoodName, RomHeader.countryCodeToSymbol(romCountryCode), appData, mGlobalPrefs, legacySaveName); String cheatArgs = mGamePrefs.getCheatArgs(); mAutoSaveManager = new GameAutoSaveManager(mGamePrefs, mGlobalPrefs.maxAutoSaves); mGlobalPrefs.enforceLocale(this); final Window window = this.getWindow(); // Enable full-screen mode window.setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN); window.setFlags(LayoutParams.FLAG_LAYOUT_IN_SCREEN, LayoutParams.FLAG_LAYOUT_IN_SCREEN); // Keep screen from going to sleep window.setFlags(LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON); // Set the screen orientation this.setRequestedOrientation(mGlobalPrefs.displayOrientation); // If the orientation changes, the screensize info changes, so we must refresh dependencies mGlobalPrefs = new GlobalPrefs(this, appData); mGamePrefs = new GamePrefs(this, mRomMd5, mRomCrc, romHeaderName, romGoodName, RomHeader.countryCodeToSymbol(romCountryCode), appData, mGlobalPrefs, legacySaveName); mFirstStart = true; //TODO: Figure out why we call this in the middle super.onCreate(savedInstanceState); // Lay out content and get the views this.setContentView(R.layout.game_activity); mSurface = (GameSurface) this.findViewById(R.id.gameSurface); mOverlay = (GameOverlay) this.findViewById(R.id.gameOverlay); mDrawerLayout = (GameDrawerLayout) this.findViewById(R.id.drawerLayout); mGameSidebar = (GameSidebar) this.findViewById(R.id.gameSidebar); // Don't darken the game screen when the drawer is open mDrawerLayout.setScrimColor(0x0); // Make the background solid black mSurface.getRootView().setBackgroundColor(0xFF000000); mSurface.SetGameSurfaceCreatedListener(this); if (!TextUtils.isEmpty(artPath) && new File(artPath).exists()) mGameSidebar.setImage(new BitmapDrawable(this.getResources(), artPath)); mGameSidebar.setTitle(romGoodName); // Initialize the objects and data files interfacing to the emulator core CoreInterface.initialize(this, mSurface, mGamePrefs, mRomPath, mRomMd5, cheatArgs, doRestart); // Handle events from the side bar mGameSidebar.setActionHandler(this, R.menu.game_drawer); //Reload menus ReloadAllMenus(); // Listen to game surface events (created, changed, destroyed) mSurface.getHolder().addCallback(this); // Update the GameSurface size mSurface.getHolder().setFixedSize(mGamePrefs.videoRenderWidth, mGamePrefs.videoRenderHeight); final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams(); params.width = Math.round(mGamePrefs.videoSurfaceWidth * (mGamePrefs.videoSurfaceZoom / 100.f)); params.height = Math.round(mGamePrefs.videoSurfaceHeight * (mGamePrefs.videoSurfaceZoom / 100.f)); if ((mGlobalPrefs.displayOrientation & 1) == 1) params.gravity = mGlobalPrefs.displayPosition | Gravity.CENTER_HORIZONTAL; else params.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; mSurface.setLayoutParams(params); // Initialize the screen elements if (mGamePrefs.isTouchscreenEnabled || mGlobalPrefs.isFpsEnabled) { // The touch map and overlay are needed to display frame rate and/or controls mTouchscreenMap = new VisibleTouchMap(this.getResources()); mTouchscreenMap.load(mGamePrefs.touchscreenSkin, mGamePrefs.touchscreenProfile, mGamePrefs.isTouchscreenAnimated, mGlobalPrefs.isFpsEnabled, mGlobalPrefs.touchscreenScale, mGlobalPrefs.touchscreenTransparency); mOverlay.initialize(mTouchscreenMap, !mGamePrefs.isTouchscreenHidden, mGlobalPrefs.isFpsEnabled, mGamePrefs.isAnalogHiddenWhenSensor, mGamePrefs.isTouchscreenAnimated); } // Initialize user interface devices initControllers(mOverlay); // Override the peripheral controllers' key provider, to add some extra // functionality mOverlay.setOnKeyListener(this); if (savedInstanceState == null) { // Show the drawer at the start and have it hide itself // automatically mDrawerLayout.openDrawer(GravityCompat.START); mDrawerLayout.postDelayed(new Runnable() { @Override public void run() { mDrawerLayout.closeDrawer(GravityCompat.START); } }, 1000); } mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerClosed(View arg0) { NativeExports.emuResume(); } @Override public void onDrawerOpened(View arg0) { NativeExports.emuPause(); ReloadAllMenus(); } @Override public void onDrawerSlide(View arg0, float arg1) { } @Override public void onDrawerStateChanged(int newState) { } }); }
From source file:net.alexjf.tmm.fragments.DateIntervalBarFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_dateinterval_bar, container, false); dateIntervalTypes = getResources().getStringArray(R.array.date_intervals_values); dateIntervalSpinner = (Spinner) v.findViewById(R.id.interval_spinner); startDateButton = (Button) v.findViewById(R.id.start_button); endDateButton = (Button) v.findViewById(R.id.end_button); customSelector = v.findViewById(R.id.custom_selector); int selectedSpinnerPos = 0; if (savedInstanceState != null) { try {/*w w w .ja v a 2 s. com*/ startDate.setTime(dateTimeFormat.parse(savedInstanceState.getString(KEY_CURRENTSTARTDATE))); } catch (ParseException e) { Log.e("TMM", "Error parsing saved start date", e); } try { endDate.setTime(dateTimeFormat.parse(savedInstanceState.getString(KEY_CURRENTENDDATE))); } catch (ParseException e) { Log.e("TMM", "Error parsing saved end date", e); } selectedSpinnerPos = savedInstanceState.getInt(KEY_SPINNERSELECTION); startDateBeingEdited = savedInstanceState.getByte(KEY_STARTDATEEDIT) == 1; } else { PreferenceManager prefManager = PreferenceManager.getInstance(); String prefDateInterval = prefManager.readUserStringPreference(PREFKEY_DEFAULTTIMEINTERVAL, null); if (prefDateInterval != null) { selectedSpinnerPos = Arrays.asList(dateIntervalTypes).indexOf(prefDateInterval); } } dateIntervalSpinner.setSelection(selectedSpinnerPos, false); final int positionToSelect = selectedSpinnerPos; // Hack to ignore initial onItemSelecteds due to layout and measure dateIntervalSpinner.post(new Runnable() { public void run() { dateIntervalSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setDateInterval(position); notifyDatesChanged(); } public void onNothingSelected(AdapterView<?> parent) { } }); setDateInterval(positionToSelect); notifyDatesChanged(); } }); datePicker = (DatePickerFragment) getFragmentManager().findFragmentByTag(TAG_DATEPICKER); if (datePicker == null) { datePicker = new DatePickerFragment(); } datePicker.setListener(this); startDateButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { try { datePicker.setDate(dateFormat.parse(startDateButton.getText().toString())); } catch (ParseException e) { } startDateBeingEdited = true; datePicker.show(getFragmentManager(), TAG_DATEPICKER); } }); endDateButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { try { datePicker.setDate(dateFormat.parse(endDateButton.getText().toString())); } catch (ParseException e) { } startDateBeingEdited = false; datePicker.show(getFragmentManager(), TAG_DATEPICKER); } }); return v; }
From source file:com.facebook.LegacyTokenCacheTest.java
@Test public void testAllTypes() { Bundle originalBundle = new Bundle(); putBoolean(BOOLEAN_KEY, originalBundle); putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle); putByte(BYTE_KEY, originalBundle);/*from w ww .ja v a 2s.co m*/ putByteArray(BYTE_ARRAY_KEY, originalBundle); putShort(SHORT_KEY, originalBundle); putShortArray(SHORT_ARRAY_KEY, originalBundle); putInt(INT_KEY, originalBundle); putIntArray(INT_ARRAY_KEY, originalBundle); putLong(LONG_KEY, originalBundle); putLongArray(LONG_ARRAY_KEY, originalBundle); putFloat(FLOAT_KEY, originalBundle); putFloatArray(FLOAT_ARRAY_KEY, originalBundle); putDouble(DOUBLE_KEY, originalBundle); putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle); putChar(CHAR_KEY, originalBundle); putCharArray(CHAR_ARRAY_KEY, originalBundle); putString(STRING_KEY, originalBundle); putStringList(STRING_LIST_KEY, originalBundle); originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB); ensureApplicationContext(); LegacyTokenHelper cache = new LegacyTokenHelper(RuntimeEnvironment.application); cache.save(originalBundle); LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application); Bundle cachedBundle = cache2.load(); assertEquals(originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY)); assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY), cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY)); assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY)); assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY)); assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY)); assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY)); assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY)); assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY)); assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY)); assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY)); assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY)); assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY), cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY)); assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY)); assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY)); assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY)); assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(STRING_LIST_KEY)); assertEquals(originalBundle.getSerializable(SERIALIZABLE_KEY), cachedBundle.getSerializable(SERIALIZABLE_KEY)); }