List of usage examples for android.os Bundle getByte
@Override public byte getByte(String key)
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ???/*ww w . j a v a 2s . co m*/ * * @param savedInstanceState Bundle */ private void loadActivitySavedData(Bundle savedInstanceState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { String fieldName = f.getName(); @SuppressWarnings("rawtypes") Class cls = f.getType(); if (cls == int.class || cls == Integer.class) { f.setInt(this, savedInstanceState.getInt(fieldName)); } else if (String.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getString(fieldName)); } else if (Serializable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getSerializable(fieldName)); } else if (cls == long.class || cls == Long.class) { f.setLong(this, savedInstanceState.getLong(fieldName)); } else if (cls == short.class || cls == Short.class) { f.setShort(this, savedInstanceState.getShort(fieldName)); } else if (cls == boolean.class || cls == Boolean.class) { f.setBoolean(this, savedInstanceState.getBoolean(fieldName)); } else if (cls == byte.class || cls == Byte.class) { f.setByte(this, savedInstanceState.getByte(fieldName)); } else if (cls == char.class || cls == Character.class) { f.setChar(this, savedInstanceState.getChar(fieldName)); } else if (CharSequence.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getCharSequence(fieldName)); } else if (cls == float.class || cls == Float.class) { f.setFloat(this, savedInstanceState.getFloat(fieldName)); } else if (cls == double.class || cls == Double.class) { f.setDouble(this, savedInstanceState.getDouble(fieldName)); } else if (String[].class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getStringArray(fieldName)); } else if (Parcelable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getParcelable(fieldName)); } else if (Bundle.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getBundle(fieldName)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } }
From source file:com.near.chimerarevo.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instanceState = savedInstanceState;/*from w ww.j av a 2s. c o m*/ if (!getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE).getBoolean("hasTutorialShown", false)) startActivity(new Intent(this, TutorialActivity.class)); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true; } else isLandscapeLarge = false; mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer_list); mFooter = LayoutInflater.from(this).inflate(R.layout.drawer_list_footer, mDrawerList, false); mDrawerList.addFooterView(mFooter); mShadow = findViewById(R.id.drop_shadow); if (!isLandscapeLarge) { mDrawerList.addHeaderView( LayoutInflater.from(this).inflate(R.layout.drawer_list_header, mDrawerList, false), null, false); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) SysUtils.setTopStatusMargin(this, mDrawerLayout); } mDrawerList.setGroupIndicator(null); mDrawerList.setOnGroupClickListener(this); mDrawerList.setOnChildClickListener(this); mDrawerList.setOnGroupExpandListener(this); mMenuAdapter = new MenuAdapter(this); mDrawerList.setAdapter(mMenuAdapter); if (!isLandscapeLarge) { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, getToolbar(), R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); } mFooter.findViewById(R.id.unlock_premium_btn).setVisibility(View.GONE); try { mHelper = new IabHelper(this, Constants.LICENSE_KEY); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { isLicensed = result.isSuccess(); if (isLicensed) mHelper.queryInventoryAsync(MainActivity.this); else SysUtils.toggleAppWidgets(MainActivity.this, false); } }); } catch (Exception e) { e.printStackTrace(); } if (savedInstanceState != null) { prevSelection = savedInstanceState.getByte("prevSelection"); mMenuAdapter.toggleSelection(0); if (prevSelection != 2) mMenuAdapter.toggleSelection(prevSelection); selectMenuItem(prevSelection); } else selectMenuItem(0); }