app/src/main/java/me/zhanghai/android/douya/ui/RatioHeightRecyclerView.java
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*
* Copyright (c) 2015 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
* All Rights Reserved.
*/
package me.zhanghai.android.douya.ui;
import android.content.Context;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.TintTypedArray;
import android.util.AttributeSet;
import me.zhanghai.android.douya.R;
/**
* @deprecated Use {@link NestedRatioHeightRecyclerView} instead for most of the time.
*/
public class RatioHeightRecyclerView extends RecyclerView {
private float mRatio;
public RatioHeightRecyclerView(Context context) {
super(context);
init(null, 0);
}
public RatioHeightRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs, 0);
}
public RatioHeightRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs, defStyle);
}
private void init(AttributeSet attrs, int defStyle) {
TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
R.styleable.RatioHeightRecyclerView, defStyle, 0);
String ratio = a.getString(R.styleable.RatioHeightRecyclerView_ratio);
if (ratio != null) {
int colonIndex = ratio.indexOf(':');
if (colonIndex < 0) {
throw new IllegalArgumentException(
"ratio should be a string in the form \"width:height\": " + ratio);
}
int width = Integer.parseInt(ratio.substring(0, colonIndex));
int height = Integer.parseInt(ratio.substring(colonIndex + 1));
mRatio = (float) width / height;
}
a.recycle();
}
public float getRatio() {
return mRatio;
}
后面还有 28 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
