List of usage examples for android.app Activity overridePendingTransition
public void overridePendingTransition(int enterAnim, int exitAnim)
From source file:com.android.messaging.ui.UIIntentsImpl.java
@Override public void launchFullScreenPhotoViewer(final Activity activity, final Uri initialPhoto, final Rect initialPhotoBounds, final Uri photosUri) { final PhotoViewIntentBuilder builder = com.android.ex.photo.Intents.newPhotoViewIntentBuilder(activity, BuglePhotoViewActivity.class); builder.setPhotosUri(photosUri.toString()); builder.setInitialPhotoUri(initialPhoto.toString()); builder.setProjection(ConversationImagePartsView.PhotoViewQuery.PROJECTION); // Set the location of the imageView so that the photoviewer can animate from that location // to full screen. builder.setScaleAnimation(initialPhotoBounds.left, initialPhotoBounds.top, initialPhotoBounds.width(), initialPhotoBounds.height()); builder.setDisplayThumbsFullScreen(false); builder.setMaxInitialScale(8);// w w w . j a v a 2 s . co m activity.startActivity(builder.build()); activity.overridePendingTransition(0, 0); }
From source file:org.xbmc.kore.utils.UIUtils.java
/** * Fills the standard cast info list, consisting of a {@link android.widget.GridLayout} * with actor images and a Textview with the name and the role of the additional cast. * The number of actor presented on the {@link android.widget.GridLayout} is controlled * through the global setting, and only actors with images are presented. * The rest are presented in the additionalCastView TextView * * @param activity Activity//from www. j a v a 2s . co m * @param castList Cast list * @param castListView GridLayout on which too show actors that have images */ public static void setupCastInfo(final Activity activity, List<VideoType.Cast> castList, GridLayout castListView, final Intent allCastActivityLaunchIntent) { HostManager hostManager = HostManager.getInstance(activity); Resources resources = activity.getResources(); DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(displayMetrics); View.OnClickListener castListClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Utils.openImdbForPerson(activity, (String) v.getTag()); } }; castListView.removeAllViews(); int numColumns = castListView.getColumnCount(); int numRows = resources.getInteger(R.integer.cast_grid_view_rows); int maxCastPictures = numColumns * numRows; int layoutMarginPx = 2 * resources.getDimensionPixelSize(R.dimen.remote_content_hmargin); int imageMarginPx = 2 * resources.getDimensionPixelSize(R.dimen.image_grid_margin); int imageWidth = (displayMetrics.widthPixels - layoutMarginPx - numColumns * imageMarginPx) / numColumns; int imageHeight = (int) (imageWidth * 1.5); for (int i = 0; i < Math.min(castList.size(), maxCastPictures); i++) { VideoType.Cast actor = castList.get(i); View castView = LayoutInflater.from(activity).inflate(R.layout.grid_item_cast, castListView, false); ImageView castPicture = (ImageView) castView.findViewById(R.id.picture); TextView castName = (TextView) castView.findViewById(R.id.name); TextView castRole = (TextView) castView.findViewById(R.id.role); castView.getLayoutParams().width = imageWidth; castView.getLayoutParams().height = imageHeight; castView.setTag(actor.name); UIUtils.loadImageWithCharacterAvatar(activity, hostManager, actor.thumbnail, actor.name, castPicture, imageWidth, imageHeight); if ((i == maxCastPictures - 1) && (castList.size() > i + 1)) { View castNameGroup = castView.findViewById(R.id.cast_name_group); View allCastGroup = castView.findViewById(R.id.all_cast_group); TextView remainingCastCount = (TextView) castView.findViewById(R.id.remaining_cast_count); castNameGroup.setVisibility(View.GONE); allCastGroup.setVisibility(View.VISIBLE); remainingCastCount.setText(String.format(activity.getString(R.string.remaining_cast_count), castList.size() - maxCastPictures + 1)); castView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { activity.startActivity(allCastActivityLaunchIntent); activity.overridePendingTransition(R.anim.activity_in, R.anim.activity_out); } }); } else { castName.setText(actor.name); castRole.setText(actor.role); castView.setOnClickListener(castListClickListener); } castListView.addView(castView); } }
From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java
public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId, Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description, final TextView breadcrumb) { // Pull out the root layout of the dialog and set the background drawable, to be // faded in during the transition. final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0); twoPane.setVisibility(View.INVISIBLE); // If the appropriate data is embedded in the intent and there is an icon specified // in the content fragment, we animate the icon from its initial position to the final // position. Otherwise, we perform a simpler transition in which the ActionFragment // slides in and the ContentFragment text fields slide in. mIntroAnimationInProgress = true;/*from ww w.j a v a2 s . com*/ List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent()); TransitionImageAnimation ltransitionAnimation = null; final Uri iconUri; final int color; if (images != null && images.size() > 0) { if (iconResourceId != 0) { iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId)); } else if (iconResourceUri != null) { iconUri = iconResourceUri; } else { iconUri = null; } TransitionImage src = images.get(0); color = src.getBackground(); if (iconUri != null) { ltransitionAnimation = new TransitionImageAnimation(contentView); ltransitionAnimation.addTransitionSource(src); ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0) .interpolator(new DecelerateInterpolator(1f)); } } else { iconUri = null; color = 0; } final TransitionImageAnimation transitionAnimation = ltransitionAnimation; // Fade out the old activity, and hard cut the new activity. activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out); int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background); mBgDrawable.setColor(bgColor); mBgDrawable.setAlpha(0); twoPane.setBackground(mBgDrawable); // If we're animating the icon, we create a new ImageView in which to place the embedded // bitmap. We place it in the root layout to match its location in the previous activity. mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout); if (transitionAnimation != null) { transitionAnimation.listener(new TransitionImageAnimation.Listener() { @Override public void onRemovedView(TransitionImage src, TransitionImage dst) { if (icon != null) { //want to make sure that users still see at least the source image // if the dst image is too large to finish downloading before the // animation is done. Check if the icon is not visible. This mean // BaseContentFragement have not finish downloading the image yet. if (icon.getVisibility() != View.VISIBLE) { icon.setImageDrawable(src.getBitmap()); int intrinsicWidth = icon.getDrawable().getIntrinsicWidth(); LayoutParams lp = icon.getLayoutParams(); lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth; icon.setVisibility(View.VISIBLE); } icon.setAlpha(1f); } if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(1f); } onIntroAnimationFinished(); } }); icon.setAlpha(0f); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } // We need to defer the remainder of the animation preparation until the first // layout has occurred, as we don't yet know the final location of the icon. twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is actually not created // delay a little so we can make sure all hardware layer is created before // animation, in that way we can avoid the jittering of start animation twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY); } final Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!mFragment.isAdded()) { // We have been detached before this could run, so just bail return; } twoPane.setVisibility(View.VISIBLE); final int secondaryDelay = SLIDE_IN_DISTANCE; // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(secondaryDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); View actionFragmentView = activity.findViewById(mActionAreaId); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionFragmentView.getMeasuredWidth() : actionFragmentView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); if (icon != null && transitionAnimation != null) { // now we get the icon view in place, update the transition target TransitionImage target = new TransitionImage(); target.setUri(iconUri); target.createFromImageView(icon); if (icon.getBackground() instanceof ColorDrawable) { ColorDrawable d = (ColorDrawable) icon.getBackground(); target.setBackground(d.getColor()); } transitionAnimation.addTransitionTarget(target); transitionAnimation.startTransition(); } else if (icon != null) { prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), true /* is the icon */); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } } }; }); }
From source file:com.filemanager.free.activities.MainActivity.java
@SuppressLint("InflateParams") private void initialiseViews() { mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame); appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }// w w w . ja v a 2 s . co m if (displayImageOptions != null) { displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565).build(); } buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else { assert mDrawerLinear != null; mDrawerLinear.setBackgroundColor(Color.WHITE); } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); } View v = findViewById(R.id.fab_bg); if (theme1 == 1) { assert v != null; v.setBackgroundColor(Color.parseColor("#a6ffffff")); } assert v != null; v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) { assert divider != null; divider.setImageResource(R.color.divider); } else { assert divider != null; divider.setImageResource(R.color.divider_dark); } setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { assert settingsbutton != null; settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert settingsbutton != null; settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { assert appbutton != null; appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert appbutton != null; appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } //admob mAdView = (View) findViewById(R.id.ads); }
From source file:com.amaze.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from w w w . ja v a2 s . co m displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); if (theme1 == 1) v.setBackgroundColor(Color.parseColor("#a6ffffff")); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } }
From source file:com.igniva.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from w ww. j a va2s .c om displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); mFabBackground = findViewById(R.id.fab_bg); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); /*if (theme1 != 1) v.setBackgroundColor(Color.parseColor("#a6ffffff"));*/ v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (theme1 == 1) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(getResources().getColor(android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(getResources().getColor(android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void restartActivity(final Activity activity) { if (activity == null) return;/*from www. j a va 2s . c o m*/ final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; activity.finish(); activity.overridePendingTransition(enter_anim, exit_anim); activity.startActivity(activity.getIntent()); activity.overridePendingTransition(enter_anim, exit_anim); }