This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AppDetails Screenshot resizing and animation (#153)
* Resize screenshot viewpager based on screenshot size * Moved ScreenshotViewPager to details package * Added screenshot animations * Removed log and reverted auto formatting Closes #141
- Loading branch information
Showing
7 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/src/main/java/subreddit/android/appstore/screens/details/ScreenshotViewPager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package subreddit.android.appstore.screens.details; | ||
|
||
import android.content.Context; | ||
import android.graphics.Rect; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.support.v4.view.ViewPager; | ||
import android.util.AttributeSet; | ||
import android.util.TypedValue; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import subreddit.android.appstore.R; | ||
import subreddit.android.appstore.screens.details.ScreenshotsAdapter; | ||
|
||
/** | ||
* Created by andrewadams on 2017-09-29. | ||
*/ | ||
|
||
public class ScreenshotViewPager extends ViewPager { | ||
private ScreenshotsAdapter screenshotsAdapter; | ||
|
||
public ScreenshotViewPager(Context context) { | ||
super(context); | ||
} | ||
|
||
public ScreenshotViewPager(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
@Override | ||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
if (screenshotsAdapter != null) { | ||
View currentView = screenshotsAdapter.getCurrentView(); | ||
if (currentView != null) { | ||
ImageView imageView = (ImageView) currentView.findViewById(R.id.gallery_image); | ||
Drawable drawable = imageView.getDrawable(); | ||
if (drawable != null) { | ||
Rect drawableBounds = drawable.getBounds(); | ||
int height = drawableBounds.height(); | ||
int width = drawableBounds.width(); | ||
if (height > width) { | ||
int newHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics()); | ||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY); | ||
} else if (height < width) { | ||
int newHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 75, getResources().getDisplayMetrics()); | ||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY); | ||
} | ||
} | ||
} | ||
} | ||
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | ||
} | ||
|
||
@Override | ||
public void setAdapter(PagerAdapter adapter) { | ||
screenshotsAdapter = (ScreenshotsAdapter) adapter; | ||
super.setAdapter(adapter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<translate xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:duration="500" | ||
android:fromXDelta="100%p" | ||
android:toXDelta="0" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<translate xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:duration="500" | ||
android:fromXDelta="0" | ||
android:toXDelta="-100%p" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters