pref: 优化平板设备判断方法
This commit is contained in:
parent
f25b9a6e0f
commit
2a44a4fb1c
Binary file not shown.
|
|
@ -71,7 +71,7 @@ public class PersonalizedFeedAdapter extends MultiBaseAdapter<PersonalizedBean.T
|
|||
|
||||
private int getMaxWidth() {
|
||||
int maxWidth = BaseApplication.ScreenInfo.EXACT_SCREEN_WIDTH - DisplayUtil.dp2px(mContext, 56);
|
||||
if (mContext.getResources().getBoolean(R.bool.is_tablet)) {
|
||||
if (ExtensionsKt.isTablet(mContext)) {
|
||||
if (ExtensionsKt.isLandscape(mContext.getResources().getConfiguration())) {
|
||||
return maxWidth / 3;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
|
|||
import com.alibaba.android.vlayout.layout.StaggeredGridLayoutHelper;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.huanchengfly.tieba.post.BaseApplication;
|
||||
import com.huanchengfly.tieba.post.ExtensionsKt;
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
import com.huanchengfly.tieba.post.activities.ThreadActivity;
|
||||
import com.huanchengfly.tieba.post.adapters.base.BaseMultiTypeDelegateAdapter;
|
||||
|
|
@ -60,7 +61,7 @@ public class NewForumAdapter extends BaseMultiTypeDelegateAdapter<ForumPageBean.
|
|||
@NonNull
|
||||
@Override
|
||||
public LayoutHelper onCreateLayoutHelper() {
|
||||
if (getContext().getResources().getBoolean(R.bool.is_tablet)) {
|
||||
if (ExtensionsKt.isTablet(getContext())) {
|
||||
return new StaggeredGridLayoutHelper(2);
|
||||
} else {
|
||||
return new LinearLayoutHelper();
|
||||
|
|
@ -86,7 +87,7 @@ public class NewForumAdapter extends BaseMultiTypeDelegateAdapter<ForumPageBean.
|
|||
|
||||
private int getMaxWidth() {
|
||||
int maxWidth = BaseApplication.ScreenInfo.EXACT_SCREEN_WIDTH - DisplayUtil.dp2px(getContext(), 40);
|
||||
if (getContext().getResources().getBoolean(R.bool.is_tablet)) {
|
||||
if (ExtensionsKt.isTablet(getContext())) {
|
||||
return maxWidth / 2;
|
||||
}
|
||||
return maxWidth;
|
||||
|
|
@ -94,7 +95,7 @@ public class NewForumAdapter extends BaseMultiTypeDelegateAdapter<ForumPageBean.
|
|||
|
||||
private int getGridHeight() {
|
||||
int maxWidth = BaseApplication.ScreenInfo.EXACT_SCREEN_WIDTH - DisplayUtil.dp2px(getContext(), 70);
|
||||
if (getContext().getResources().getBoolean(R.bool.is_tablet)) {
|
||||
if (ExtensionsKt.isTablet(getContext())) {
|
||||
maxWidth = maxWidth / 2;
|
||||
}
|
||||
return maxWidth / 3;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.huanchengfly.tieba.post.ExtensionsKt;
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||
|
|
@ -38,7 +39,7 @@ public class ForumDivider extends RecyclerView.ItemDecoration implements Tintabl
|
|||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int position = parent.getChildAdapterPosition(view) - 1;
|
||||
if (parent.getResources().getBoolean(R.bool.is_tablet)) {
|
||||
if (ExtensionsKt.isTablet(parent.getContext())) {
|
||||
if (position % 2 == 0) {
|
||||
outRect.set(0, 0, mDividerHeight / 2, mDividerHeight);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ import androidx.annotation.CallSuper
|
|||
import androidx.fragment.app.Fragment
|
||||
import butterknife.ButterKnife
|
||||
import butterknife.Unbinder
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.interfaces.BackHandledInterface
|
||||
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
||||
import com.huanchengfly.tieba.post.isLandscape
|
||||
import com.huanchengfly.tieba.post.isPortrait
|
||||
import com.huanchengfly.tieba.post.isTablet
|
||||
import com.huanchengfly.tieba.post.utils.AppPreferencesUtils
|
||||
import com.huanchengfly.tieba.post.utils.HandleBackUtil
|
||||
import kotlinx.coroutines.*
|
||||
|
|
@ -191,7 +191,7 @@ abstract class BaseFragment : Fragment(), BackHandledInterface, CoroutineScope {
|
|||
}
|
||||
|
||||
protected val isTablet: Boolean
|
||||
get() = attachContext.resources.getBoolean(R.bool.is_tablet)
|
||||
get() = attachContext.isTablet
|
||||
|
||||
protected val isPortrait: Boolean
|
||||
get() = attachContext.resources.configuration.isPortrait
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class MainForumListFragment : BaseFragment(), Refreshable, Toolbar.OnMenuItemCli
|
|||
appPreferences.listSingle -> {
|
||||
1
|
||||
}
|
||||
resources.getBoolean(R.bool.is_tablet) -> {
|
||||
attachContext.isTablet -> {
|
||||
3
|
||||
}
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
android:layout_alignParentBottom="true"
|
||||
app:bottomNavigationBackgroundTint="@color/default_color_nav"
|
||||
app:elevation="4dp"
|
||||
app:itemIconTintList="@drawable/bottom_item_icon_tint_list"
|
||||
app:itemTextTintList="@drawable/bottom_item_icon_tint_list"
|
||||
app:itemIconTintList="@color/bottom_item_icon_tint_list"
|
||||
app:itemTextTintList="@color/bottom_item_icon_tint_list"
|
||||
app:labelVisibilityMode="unlabeled"
|
||||
app:menu="@menu/navbar_main" />
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
<resources>
|
||||
<bool name="is_tablet">true</bool>
|
||||
</resources>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<resources>
|
||||
<bool name="is_tablet">false</bool>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue