Skip to content

Commit

Permalink
FragmentIllust优化
Browse files Browse the repository at this point in the history
  • Loading branch information
CeuiLiSA committed Aug 24, 2020
1 parent a7a3507 commit 904f971
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/ceui/lisa/download/FileCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static File createGifZipFile(IllustsBean illustsBean) {
}

return new File(Shaft.sSettings.getGifZipPath(), deleteSpecialWords(
illustsBean.getTitle() + "_" + illustsBean.getId() + ".zip")
illustsBean.getTitle() + DASH + illustsBean.getId() + ".zip")
);
}

Expand All @@ -36,7 +36,7 @@ public static File createGifFile(IllustsBean illustsBean) {
}

return new File(Shaft.sSettings.getGifResultPath(), deleteSpecialWords(
illustsBean.getTitle() + "_" + illustsBean.getId() + ".gif")
illustsBean.getTitle() + DASH + illustsBean.getId() + ".gif")
);
}

Expand All @@ -47,7 +47,7 @@ public static File createGifParentFile(IllustsBean illustsBean) {
}

return new File(Shaft.sSettings.getGifUnzipPath() + deleteSpecialWords(
illustsBean.getTitle() + "_" + illustsBean.getId())
illustsBean.getTitle() + DASH + illustsBean.getId())
);
}

Expand Down Expand Up @@ -85,9 +85,9 @@ public static File createIllustFile(IllustsBean illustsBean, int index) {

private static String deleteSpecialWords(String before) {
if (!TextUtils.isEmpty(before)) {
String temp1 = before.replace("-", "_");
String temp2 = temp1.replace("/", "_");
String temp3 = temp2.replace(",", "_");
String temp1 = before.replace("-", DASH);
String temp2 = temp1.replace("/", DASH);
String temp3 = temp2.replace(",", DASH);
return temp3;
} else {
return "untitle_" + System.currentTimeMillis() + ".png";
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/ceui/lisa/fragments/FragmentIllust.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,22 @@ public boolean onTagClick(View view, int position, FlowLayout parent) {
baseBind.illustSize.setText("作品尺寸:" + illust.getWidth() + "px * " + illust.getHeight() + "px");
baseBind.illustId.setText("作品ID:" + illust.getId());
baseBind.userId.setText("画师ID:" + illust.getUser().getId());

final BottomSheetBehavior<?> sheetBehavior = BottomSheetBehavior.from(baseBind.coreLinear);

baseBind.coreLinear.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final int realHeight = baseBind.coreLinear.getHeight();
final int realHeight = baseBind.bottomBar.getHeight() +
baseBind.viewDivider.getHeight() +
baseBind.secondLinear.getHeight();
final int maxHeight = getResources().getDisplayMetrics().heightPixels * 3 / 4;
if (realHeight > maxHeight) {
ViewGroup.LayoutParams params = baseBind.coreLinear.getLayoutParams();
params.height = maxHeight;
baseBind.coreLinear.setLayoutParams(params);
}
ViewGroup.LayoutParams params = baseBind.coreLinear.getLayoutParams();
params.height = Math.min(realHeight, maxHeight);
baseBind.coreLinear.setLayoutParams(params);

final int bottomCardHeight = baseBind.bottomBar.getHeight();
final int deltaY = baseBind.coreLinear.getHeight() - baseBind.bottomBar.getHeight();
final int deltaY = realHeight - baseBind.bottomBar.getHeight();
sheetBehavior.setPeekHeight(bottomCardHeight, true);
baseBind.refreshLayout.setPadding(0, 0, 0, bottomCardHeight - DensityUtil.dp2px(16.0f));
sheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_illust.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/view_divider"
android:layout_marginStart="@dimen/tweenty_four_dp"
android:layout_marginEnd="@dimen/tweenty_four_dp"
android:background="#f3f4f5">
Expand All @@ -181,6 +182,7 @@

<LinearLayout
android:layout_width="match_parent"
android:id="@+id/second_linear"
android:layout_height="wrap_content"
android:orientation="vertical">

Expand Down

0 comments on commit 904f971

Please sign in to comment.