Skip to content

Commit

Permalink
界面微调 (takagen99#164)
Browse files Browse the repository at this point in the history
1.页面圆角R值统一
2.搜索页面动态设置宽度,防止图片超出背景
  • Loading branch information
NaclFire authored Sep 29, 2024
1 parent 2820da6 commit 2a3af7f
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ private List<VodSeriesGroup> getSeriesGroupList() {
e.printStackTrace();
}
return arrayList;
}
}

private void setTextShow(TextView view, String tag, String info) {
if (info == null || info.trim().isEmpty()) {
Expand Down
136 changes: 81 additions & 55 deletions app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.bean.Movie;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.ImgUtil;

import java.util.ArrayList;
Expand All @@ -36,7 +36,7 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
//由于部分电视机使用glide报错
if (!TextUtils.isEmpty(item.pic)) {
item.pic=item.pic.trim();
ImgUtil.load(item.pic, ivThumb, 14);
ImgUtil.load(item.pic, ivThumb, (int) App.getInstance().getResources().getDimension(R.dimen.vs_5));
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
}
Expand Down Expand Up @@ -77,7 +77,7 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
ImageView ivThumb = helper.getView(R.id.ivThumb);
//由于部分电视机使用glide报错
if (!TextUtils.isEmpty(item.pic)) {
ImgUtil.load(item.pic, ivThumb, 14);
ImgUtil.load(item.pic, ivThumb, (int) App.getInstance().getResources().getDimension(R.dimen.vs_5));
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import com.chad.library.adapter.base.BaseViewHolder;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.bean.VodInfo;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.ImgUtil;

import java.util.ArrayList;

/**
Expand Down Expand Up @@ -79,7 +80,7 @@ protected void convert(BaseViewHolder helper, VodInfo item) {
//由于部分电视机使用glide报错
if (!TextUtils.isEmpty(item.pic)) {
// takagen99 : Use Glide instead
ImgUtil.load(item.pic, ivThumb, 14);
ImgUtil.load(item.pic, ivThumb, (int) App.getInstance().getResources().getDimension(R.dimen.vs_5));
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import com.chad.library.adapter.base.BaseViewHolder;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.bean.Movie;
import com.github.tvbox.osc.bean.SourceBean;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.ImgUtil;
import com.orhanobut.hawk.Hawk;
Expand Down Expand Up @@ -59,7 +59,7 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
//由于部分电视机使用glide报错
if (!TextUtils.isEmpty(item.pic)) {
// takagen99 : Use Glide instead
ImgUtil.load(item.pic, ivThumb, 14);
ImgUtil.load(item.pic, ivThumb, (int) App.getInstance().getResources().getDimension(R.dimen.vs_5));
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.github.tvbox.osc.ui.adapter;

import android.text.TextUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.recyclerview.widget.GridLayoutManager;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.bean.Movie;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.ImgUtil;
Expand All @@ -15,29 +19,48 @@
import java.util.ArrayList;

public class SearchAdapter extends BaseQuickAdapter<Movie.Video, BaseViewHolder> {
private int searchWidth;

public SearchAdapter() {
super(Hawk.get(HawkConfig.SEARCH_VIEW, 0) == 0 ? R.layout.item_search_lite : R.layout.item_search, new ArrayList<>());
searchWidth = Hawk.get(HawkConfig.SEARCH_RESULT_WIDTH, -1);
}

@Override
protected void convert(BaseViewHolder helper, Movie.Video item) {
// lite
if (Hawk.get(HawkConfig.SEARCH_VIEW, 0) == 0) {
helper.setText(R.id.tvName, String.format("%s %s %s %s", ApiConfig.get().getSource(item.sourceKey).getName(), item.name, item.type == null ? "" : item.type, item.note == null ? "" : item.note));
} else {// with preview
} else {// with preview\
helper.setText(R.id.tvName, item.name);
helper.setText(R.id.tvSite, ApiConfig.get().getSource(item.sourceKey).getName());
helper.setVisible(R.id.tvNote, item.note != null && !item.note.isEmpty());
if (item.note != null && !item.note.isEmpty()) {
helper.setText(R.id.tvNote, item.note);
}
FrameLayout flRootView = helper.getView(R.id.fl_root_view);
// 动态设置item宽度
if (searchWidth == -1) {
searchWidth = Hawk.get(HawkConfig.SEARCH_RESULT_WIDTH, -1);
if (searchWidth != -1) {
setItemWidth(flRootView);
}
} else {
setItemWidth(flRootView);
}
ImageView ivThumb = helper.getView(R.id.ivThumb);
if (!TextUtils.isEmpty(item.pic)) {
// takagen99 : Use Glide instead
ImgUtil.load(item.pic, ivThumb, 14);
ImgUtil.load(item.pic, ivThumb, (int) App.getInstance().getResources().getDimension(R.dimen.vs_5));
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
}
}
}

private void setItemWidth(FrameLayout view) {
GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
layoutParams.width = searchWidth;
view.setLayoutParams(layoutParams);
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/github/tvbox/osc/util/HawkConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ public static boolean isDebug() {
return Hawk.get(DEBUG_OPEN, false);
}
public static boolean hotVodDelete;

public static final String SEARCH_RESULT_WIDTH = "search_result_width"; // 搜索结果view宽度
}
18 changes: 8 additions & 10 deletions app/src/main/java/com/github/tvbox/osc/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

public class StringUtils {

public static boolean isEmpty( CharSequence str) {
public static boolean isEmpty(CharSequence str) {
return str == null || str.length() == 0;
}

public static boolean isNotEmpty( CharSequence str) {
public static boolean isNotEmpty(CharSequence str) {
return !isEmpty(str);
}

Expand All @@ -38,22 +38,20 @@ public static boolean isNotEmpty(Object obj) {
return !isEmpty(obj);
}

private static final String U2028 = new String(new byte[]{ (byte)0xE2, (byte)0x80, (byte)0xA8 });
private static final String U2029 = new String(new byte[]{ (byte)0xE2, (byte)0x80, (byte)0xA9 });
private static final String U2028 = new String(new byte[]{(byte) 0xE2, (byte) 0x80, (byte) 0xA8});
private static final String U2029 = new String(new byte[]{(byte) 0xE2, (byte) 0x80, (byte) 0xA9});

/**
* Escape JavaString string
*
* @param line unescaped string
* @return escaped string
*/
public static String escapeJavaScriptString(final String line)
{
public static String escapeJavaScriptString(final String line) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < line.length(); i++)
{
for (int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
switch (c)
{
switch (c) {
case '"':
case '\'':
case '\\':
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/shape_thumb_bottom_name.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="@dimen/vs_10"
android:bottomRightRadius="@dimen/vs_10" />
android:bottomLeftRadius="@dimen/vs_5"
android:bottomRightRadius="@dimen/vs_5" />
<solid android:color="@color/color_000000_60" />
</shape>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/shape_thumb_note.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_000000_60" />
<corners android:radius="5mm" />
<corners android:radius="@dimen/vs_5" />
</shape>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/shape_thumb_year.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_000000_60" />
<corners android:radius="5mm" />
<corners android:radius="@dimen/vs_5" />
</shape>
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/shape_user_focus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape>
<corners android:radius="10mm" />
<stroke android:width="2mm" android:color="@color/color_FFFFFF" />
<corners android:radius="@dimen/vs_5" />
<stroke android:width="@dimen/vs_2" android:color="@color/color_FFFFFF" />
<solid android:color="@color/color_3D3D3D_45" />
</shape>
</item>
<item android:state_focused="false">
<shape>
<corners android:radius="10mm" />
<corners android:radius="@dimen/vs_5" />
<solid android:color="@color/color_3D3D3D_45"/>
</shape>
</item>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_search.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fl_root_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_user_focus"
android:focusable="true"
android:padding="@dimen/vs_1">

<FrameLayout
android:layout_width="@dimen/vs_214"
android:layout_width="match_parent"
android:layout_height="@dimen/vs_280">

<ImageView
Expand Down

0 comments on commit 2a3af7f

Please sign in to comment.