@Override protected void onCreate(Bundle savedInstanceState) { ActionBarUtil.compatibleDeviceWithSB(this); requestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); ActionBarUtil.setXiaomiFilterDisplayOptions(getSupportActionBar(), false); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_trans)); Bundle extras = getIntent().getExtras(); title = extras.getString("title"); getSupportActionBar().setTitle(title); aid = extras.getInt("aid"); mList = extras.getStringArrayList(EXTRA_IMAGES); int index = extras.getInt(EXTRA_INDEX, 0); MobclickAgent.onEvent(this, "view_big_pic"); setContentView(R.layout.activity_images); indexText = (TextView) findViewById(R.id.index); if (ActionBarUtil.hasSB() && getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { setInfoBottomMargin( getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height)); } pager = (MyViewPager) findViewById(R.id.pager); pager.setAdapter(new ImageAdapter(getSupportFragmentManager(), mList)); pager.setOffscreenPageLimit(1); pager.setOnPageChangeListener(this); pager.setCurrentItem(index); onPageSelected(index); }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (ActionBarUtil.hasSB()) { if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { setInfoBottomMargin(0); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { setInfoBottomMargin( getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height)); } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.image, menu); MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar); if (ActionBarUtil.hasSB()) { MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_NEVER); } ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(actionItem); actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); actionProvider.setShareIntent(createShareIntent()); return super.onCreateOptionsMenu(menu); }