Example usage for android.view WindowManager getDefaultDisplay

List of usage examples for android.view WindowManager getDefaultDisplay

Introduction

In this page you can find the example usage for android.view WindowManager getDefaultDisplay.

Prototype

public Display getDefaultDisplay();

Source Link

Document

Returns the Display upon which this WindowManager instance will create new windows.

Usage

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

private Size fitToWidthAndKeepRatio(int width, int height) {
    WindowManager win = getWindowManager();
    Display d = win.getDefaultDisplay();
    int displayWidth = d.getWidth(); // Width of the actual device

    int fittedHeight = height;
    int fittedWidth = width;

    fittedHeight = displayWidth * fittedHeight / fittedWidth;
    fittedWidth = displayWidth;/* w  ww .jav a  2 s. c om*/

    return new Size(fittedWidth, fittedHeight);
}

From source file:com.zertinteractive.wallpaper.activities.DetailActivity.java

@SuppressWarnings("ConstantConditions")
@Override//from   w ww.  j  av a 2 s .  c o  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initActivityTransitions();
    setContentView(R.layout.activity_detail);

    String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
            MediaStore.Images.Media.DISPLAY_NAME };
    String selection = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " = ?";
    String[] selectionArgs = new String[] { TEMP_WALLPAPER_DIR };

    Cursor mImageCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,
            selection, selectionArgs, null);
    mImageCursor.moveToFirst();
    if (mImageCursor.getCount() == 1) {
        imageId = mImageCursor.getInt((mImageCursor.getColumnIndex(MediaStore.Images.Media._ID)));
        Log.e("CROP", "" + imageId);
        mImageCursor.close();
    }

    checkDir();
    timerTasks = new TimerTasks(context);

    ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE_SMALL);
    supportPostponeEnterTransition();

    superCategory = getIntent().getExtras().getInt(EXTRA_SUPER_CATEGORY);

    floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_set_as_wallpaper);
    floatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setAsWallpaper(imageId);
        }
    });

    toolbar = ((Toolbar) findViewById(R.id.toolbar));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setVisibility(View.GONE);

    String itemTitle = getIntent().getStringExtra(EXTRA_TITLE);

    progressBar = (ProgressBar) findViewById(R.id.progressBarImage);

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setTitle(itemTitle);
    collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent));

    imageView = (ImageView) findViewById(R.id.image);
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE_SMALL)).into(imageView, new Callback() {

        @SuppressWarnings("NewApi")
        @Override
        public void onSuccess() {
            Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();

            float ImageHieghtTemp = bitmap.getHeight();
            float ImageWidthTemp = bitmap.getWidth();

            Point size = new Point();
            WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            wm.getDefaultDisplay().getRealSize(size);
            float widthMain = size.x;
            float heightMain = size.y;

            imageView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
            int addWidth = imageView.getMeasuredWidth();

            //                        Display display = getWindowManager().getDefaultDisplay();
            //                        float widthMain = display.getWidth();
            //                        float heightMain = display.getHeight();

            Log.e(LOG_TAG, "IMAGE_MAIN : " + ImageWidthTemp + " : " + ImageHieghtTemp);

            float imageHeight = widthMain * ((float) (bitmap.getHeight()) / (float) (bitmap.getWidth()));
            float scaleXY = heightMain / imageHeight;

            if (scaleXY > 1.0007f) {
                Log.e(LOG_TAG, "SCALE FACTORE : " + scaleXY + " : " + 1.10454545f * scaleXY);
                scaleXY = 1.8f * scaleXY;
            }

            PhotoViewAttacher mAttacherTest = new PhotoViewAttacher(imageView, true, false);
            mAttacherTest.setZoomScale(scaleXY);
            mAttacherTest.setScale(scaleXY, (widthMain) / 2, heightMain / 2, true);

            Log.e(LOG_TAG, "DETAILS : " + widthMain + " : " + heightMain + " : " + scaleXY + " : "
                    + bitmap.getWidth() + " : " + bitmap.getHeight());

            Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
                public void onGenerated(Palette palette) {
                    applyPalette(palette);
                }
            });
        }

        @Override
        public void onError() {

        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window w = getWindow();
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    //        clearApplicationData();
    new ImageLoadTask().execute("");
    initDownloadComponents();

    mAdView = (AdView) findViewById(R.id.adViewFullImage);
    mAdView.setVisibility(View.GONE);

    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    // Start loading the ad in sthe background.
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mAdView.setVisibility(View.VISIBLE);
        }
    });

}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

private void enableParallaxEffect(ObservableScrollView scrollView, final View parallaxingView) {
    scrollView.setScrollViewListener(new ScrollViewListener() {
        @Override/*from   www. j a v a  2s  . com*/
        public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {

            WindowManager win = getWindowManager();
            Display d = win.getDefaultDisplay();
            int displayHeight = d.getHeight(); // Height of the actual device

            if (imageSize.getHeight() > displayHeight && photoViewAttacher != null) {
                float[] values = new float[9];
                photoViewAttacher.getDrawMatrix().getValues(values);
                float imageHeight = imageSize.getHeight();

                float diff = imageHeight / displayHeight;

                if (y > oldy) {
                    diff = -diff;
                }

                photoViewAttacher.onDrag(0, diff);

            } else {
                float pY = -(y / 3.0f);
                parallaxingView.setTranslationY(pY);
            }

        }
    });
}

From source file:org.telegram.ui.LaunchActivity.java

private void fixLayout() {
    if (containerView != null) {
        ViewTreeObserver obs = containerView.getViewTreeObserver();
        obs.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override// w w w .  ja va 2 s  .  co  m
            public void onGlobalLayout() {
                WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
                int rotation = manager.getDefaultDisplay().getRotation();

                int height;
                int currentActionBarHeight = getSupportActionBar().getHeight();
                if (currentActionBarHeight != Utilities.dp(48) && currentActionBarHeight != Utilities.dp(40)) {
                    height = currentActionBarHeight;
                } else {
                    height = Utilities.dp(48);
                    if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
                        height = Utilities.dp(40);
                    }
                }

                if (notificationView != null) {
                    notificationView.applyOrientationPaddings(
                            rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
                }

                if (Build.VERSION.SDK_INT < 16) {
                    containerView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                } else {
                    containerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }
            }
        });
    }
}

From source file:com.musenkishi.wally.activities.ImageDetailsActivity.java

/**
 * Animations animations animations./*  w  w  w. j a  v  a  2s .com*/
 */
private void toggleZoomImage() {

    int animationDuration = 400;

    if (isInFullscreen()) {
        scrollView.smoothScrollTo(0, (Integer) scrollView.getTag());
        photoViewAttacher.setScale(1.0f, true);
    } else {
        scrollView.setTag(scrollView.getScrollY());
        scrollView.smoothScrollTo(0, 0);
    }

    if (getSupportActionBar() != null) {
        getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight())
                .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500)
                .setInterpolator(new EaseInOutBezierInterpolator()).start();
    }

    findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f)
            .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start();

    int minimumAllowedHeight = getToolbar().getMeasuredHeight()
            + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive);

    if (imageSize.getHeight() < minimumAllowedHeight) {
        int topFrom;
        int topTo;
        if (isInFullscreen()) {
            topFrom = 0;
            topTo = getToolbar().getMeasuredHeight();
        } else {
            topFrom = photoLayoutHolder.getPaddingTop();
            topTo = 0;
        }
        ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo);
        topValueAnimator.setDuration(animationDuration);
        topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
        topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int val = (Integer) valueAnimator.getAnimatedValue();
                photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val,
                        photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom());
            }
        });
        topValueAnimator.start();
    }

    if (photoLayoutHolder.getTranslationY() > 0.0f) {
        photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator())
                .setDuration(animationDuration).start();
    }

    WindowManager win = getWindowManager();
    Display d = win.getDefaultDisplay();

    int from = photoView.getMeasuredHeight();
    int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight();

    ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to);
    valueAnimator.setDuration(animationDuration);
    valueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView
                    .getLayoutParams();
            toolbarParams.height = val;
            photoView.setLayoutParams(toolbarParams);
        }
    });
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            photoViewAttacher.setZoomable(true);
            photoView.setZoomable(true);
            photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
                @Override
                public void onPhotoTap(View view, float v, float v2) {
                    toggleZoomImage();
                }
            });
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    valueAnimator.start();

    int scrollTo = isInFullscreen() ? 0 : d.getHeight();

    scrollView.animate().y(scrollTo).setDuration(animationDuration)
            .setInterpolator(new EaseInOutBezierInterpolator()).start();

    isInFullscreen = !isInFullscreen;
}

From source file:com.jp.miaulavirtual.DisplayMessageActivity.java

@SuppressWarnings("deprecation")
public void setRestrictedOrientation() {
    /* We don't want change screen orientation */
    //---get the current display info---
    WindowManager wm = getWindowManager();
    Display d = wm.getDefaultDisplay();
    if (d.getWidth() > d.getHeight()) {
        //---change to landscape mode---
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {//from  www .j  av  a  2s.co  m
        //---change to portrait mode---
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }
}

From source file:com.mobilyzer.util.PhoneUtils.java

/**
 * Returns true if the phone is in landscape mode.
 *//* w  ww  .j ava2s . c  o  m*/
public boolean isLandscape() {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    return display.getWidth() > display.getHeight();
}

From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java

public static int getOrientation() {

    WindowManager w = (WindowManager) mContext.getSystemService(WINDOW_SERVICE);

    return w.getDefaultDisplay().getRotation();

}

From source file:com.vonglasow.michael.satstat.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    defaultUEH = Thread.getDefaultUncaughtExceptionHandler();

    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            Context c = getApplicationContext();
            File dumpDir = c.getExternalFilesDir(null);
            DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT);
            fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
            String fileName = String.format("satstat-%s.log", fmt.format(new Date(System.currentTimeMillis())));

            File dumpFile = new File(dumpDir, fileName);
            PrintStream s;//from   w  w w .ja  va2  s .  c om
            try {
                InputStream buildInStream = getResources().openRawResource(R.raw.build);
                s = new PrintStream(dumpFile);
                s.append("SatStat build: ");

                int i;
                try {
                    i = buildInStream.read();
                    while (i != -1) {
                        s.write(i);
                        i = buildInStream.read();
                    }
                    buildInStream.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }

                s.append("\n\n");
                e.printStackTrace(s);
                s.flush();
                s.close();

                Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                Uri contentUri = Uri.fromFile(dumpFile);
                mediaScanIntent.setData(contentUri);
                c.sendBroadcast(mediaScanIntent);
            } catch (FileNotFoundException e2) {
                e2.printStackTrace();
            }
            defaultUEH.uncaughtException(t, e);
        }
    });

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
    prefUnitType = mSharedPreferences.getBoolean(Const.KEY_PREF_UNIT_TYPE, prefUnitType);
    prefKnots = mSharedPreferences.getBoolean(Const.KEY_PREF_KNOTS, prefKnots);
    prefCoord = Integer
            .valueOf(mSharedPreferences.getString(Const.KEY_PREF_COORD, Integer.toString(prefCoord)));
    prefUtc = mSharedPreferences.getBoolean(Const.KEY_PREF_UTC, prefUtc);
    prefCid = mSharedPreferences.getBoolean(Const.KEY_PREF_CID, prefCid);
    prefCid2 = mSharedPreferences.getBoolean(Const.KEY_PREF_CID2, prefCid2);
    prefWifiSort = Integer
            .valueOf(mSharedPreferences.getString(Const.KEY_PREF_WIFI_SORT, Integer.toString(prefWifiSort)));
    prefMapOffline = mSharedPreferences.getBoolean(Const.KEY_PREF_MAP_OFFLINE, prefMapOffline);
    prefMapPath = mSharedPreferences.getString(Const.KEY_PREF_MAP_PATH, prefMapPath);

    ActionBar actionBar = getSupportActionBar();

    setContentView(R.layout.activity_main);

    // Find out default screen orientation
    Configuration config = getResources().getConfiguration();
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    int rot = wm.getDefaultDisplay().getRotation();
    isWideScreen = (config.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (rot == Surface.ROTATION_0 || rot == Surface.ROTATION_180)
            || config.orientation == Configuration.ORIENTATION_PORTRAIT
                    && (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270));
    Log.d(TAG, "isWideScreen=" + Boolean.toString(isWideScreen));

    // Create the adapter that will return a fragment for each of the
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    Context ctx = new ContextThemeWrapper(getApplication(), R.style.AppTheme);
    mTabLayout = new TabLayout(ctx);
    LinearLayout.LayoutParams mTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    mTabLayout.setLayoutParams(mTabLayoutParams);

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        TabLayout.Tab newTab = mTabLayout.newTab();
        newTab.setIcon(mSectionsPagerAdapter.getPageIcon(i));
        mTabLayout.addTab(newTab);
    }

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(mTabLayout);

    mTabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
    mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));

    // This is needed by the mapsforge library.
    AndroidGraphicFactory.createInstance(this.getApplication());

    // Get system services for event delivery
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mOrSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    mAccSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mGyroSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    mMagSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    mLightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    mProximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    mPressureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);
    mHumiditySensor = sensorManager.getDefaultSensor(Sensor.TYPE_RELATIVE_HUMIDITY);
    mTempSensor = sensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE);
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

/**
 * Animations animations animations.//from  ww  w  . ja v a2  s  .  c om
 */
private void toggleZoomImage() {

    int animationDuration = 400;

    if (isInFullscreen()) {
        scrollView.smoothScrollTo(0, (Integer) scrollView.getTag());
        if (photoViewAttacher != null) {
            photoViewAttacher.cleanup();
            photoViewAttacher = null;
            photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        }
    } else {
        scrollView.setTag(scrollView.getScrollY());
        scrollView.smoothScrollTo(0, 0);

        if (photoViewAttacher == null) {
            photoViewAttacher = new PhotoViewAttacher(photoView);
            photoViewAttacher.setZoomable(true);
            photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP);
        }
    }

    if (getSupportActionBar() != null) {
        getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight())
                .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500)
                .setInterpolator(new EaseInOutBezierInterpolator()).start();
    }

    findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f)
            .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start();

    int minimumAllowedHeight = getToolbar().getMeasuredHeight()
            + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive);

    if (imageSize.getHeight() < minimumAllowedHeight) {
        int topFrom;
        int topTo;
        if (isInFullscreen()) {
            topFrom = 0;
            topTo = getToolbar().getMeasuredHeight();
        } else {
            topFrom = photoLayoutHolder.getPaddingTop();
            topTo = 0;
        }
        ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo);
        topValueAnimator.setDuration(animationDuration);
        topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
        topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int val = (Integer) valueAnimator.getAnimatedValue();
                photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val,
                        photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom());
            }
        });
        topValueAnimator.start();
    }

    if (photoLayoutHolder.getTranslationY() != 0.0f) {
        photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator())
                .setDuration(animationDuration).start();
    }

    WindowManager win = getWindowManager();
    Display d = win.getDefaultDisplay();

    int from = photoView.getMeasuredHeight();
    int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight();

    ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to);
    valueAnimator.setDuration(animationDuration);
    valueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView
                    .getLayoutParams();
            toolbarParams.height = val;
            photoView.setLayoutParams(toolbarParams);
        }
    });
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (photoViewAttacher != null) {
                photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
                    @Override
                    public void onPhotoTap(View view, float v, float v2) {
                        toggleZoomImage();
                    }
                });
            }
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    valueAnimator.start();

    int scrollTo = isInFullscreen() ? 0 : d.getHeight();

    scrollView.animate().y(scrollTo).setDuration(animationDuration)
            .setInterpolator(new EaseInOutBezierInterpolator()).start();

    isInFullscreen = !isInFullscreen;
}