|
|
@@ -6,6 +6,8 @@ import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.support.constraint.ConstraintLayout;
|
|
|
+import android.support.constraint.ConstraintSet;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.LinearSmoothScroller;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
@@ -25,6 +27,7 @@ import kr.co.zumo.app.lifeplus.bean.api.WithShownItemBean;
|
|
|
import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
|
|
|
import kr.co.zumo.app.lifeplus.helper.ScreenSizeHelper;
|
|
|
import kr.co.zumo.app.lifeplus.util.AppUtil;
|
|
|
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
import kr.co.zumo.app.lifeplus.util.TextUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
import kr.co.zumo.app.lifeplus.view.IEventListener;
|
|
|
@@ -51,6 +54,7 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
|
|
|
private View dim;
|
|
|
private TextView textViewPageNumber;
|
|
|
private Tutorial tutorial;
|
|
|
+ private ConstraintLayout container;
|
|
|
|
|
|
private RecyclerView.OnScrollListener scrollEventListener;
|
|
|
|
|
|
@@ -65,6 +69,7 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
|
|
|
dim = findViewById(R.id.view_dim_2);
|
|
|
textViewPageNumber = findViewById(R.id.text_view_page_number);
|
|
|
TextUtil.toBold(textViewPageNumber);
|
|
|
+ container = findViewById(R.id.layout_container);
|
|
|
|
|
|
//private String direction = null;
|
|
|
CustomPagerSnapHelper snapHelper = new CustomPagerSnapHelper();
|
|
|
@@ -162,15 +167,18 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
|
|
|
|
|
|
@Override
|
|
|
public void showOverviewTooltip() {
|
|
|
- OverviewTooltip tooltip = new OverviewTooltip(getActivity(), new IEventListener() {
|
|
|
- @Override
|
|
|
- public void onEvent(Event event) {
|
|
|
- presenter.onEvent(event);
|
|
|
- }
|
|
|
+ OverviewTooltip tooltip = new OverviewTooltip(getActivity(), event -> {
|
|
|
+ presenter.onEvent(event);
|
|
|
});
|
|
|
tooltip.show();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void setRatioScreen() {
|
|
|
+ ScreenSizeHelper sizeHelper = getHelper(ScreenSizeHelper.class);
|
|
|
+ setPaddingByRatio(container, recyclerViewContentsDetail, sizeHelper.getScreenWidth(), sizeHelper.getScreenHeight());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void setVisibleDotDotDot(boolean isVisible) {
|
|
|
actionBarHelper.setVisibleDotDotDot(isVisible);
|
|
|
@@ -322,4 +330,32 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
|
|
|
public int getCurrentPage() {
|
|
|
return layoutManager.findFirstVisibleItemPosition();
|
|
|
}
|
|
|
+
|
|
|
+ private void setPaddingByRatio(ConstraintLayout itemView, View targetView, int screenWidth, int screenHeight) {
|
|
|
+ final float baseRatio = 1.8f;
|
|
|
+ if ((float) screenHeight / screenWidth > baseRatio) {
|
|
|
+ int paddingTop = ResourceUtil.getDimension(R.dimen.action_bar_height) + ResourceUtil.getStatusBarHeightManual();
|
|
|
+ int modifiedHeight = screenHeight - paddingTop;
|
|
|
+ itemView.setPadding(0, paddingTop, 0, 0);
|
|
|
+
|
|
|
+ if ((float) modifiedHeight / screenWidth > baseRatio) {
|
|
|
+ // 상단 패딩 이후 여전히 비율이 안맞다면
|
|
|
+ // 이미지 비율을 9:16으로 조절해서 하단 여백을 남김
|
|
|
+
|
|
|
+ ViewGroup.LayoutParams lp = targetView.getLayoutParams();
|
|
|
+ lp.width = 0;
|
|
|
+ lp.height = 0;
|
|
|
+ targetView.setLayoutParams(lp);
|
|
|
+
|
|
|
+ ConstraintSet set = new ConstraintSet();
|
|
|
+ set.clone(itemView);
|
|
|
+ set.constrainDefaultHeight(targetView.getId(), ConstraintSet.MATCH_CONSTRAINT_SPREAD);
|
|
|
+ set.constrainDefaultWidth(targetView.getId(), ConstraintSet.MATCH_CONSTRAINT_SPREAD);
|
|
|
+ set.setVerticalBias(targetView.getId(), 0);
|
|
|
+ set.setDimensionRatio(targetView.getId(), "9:16");
|
|
|
+ set.applyTo(itemView);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|