java类android.support.annotation.StyleRes的实例源码

HostListActivity.java 文件源码 项目:GitHub 阅读 27 收藏 0 点赞 0 评论 0
@Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
    HostViewHolder hostHolder = (HostViewHolder) holder;

    HostBean host = hosts.get(position);
    hostHolder.host = host;
    if (host == null) {
        // Well, something bad happened. We can't continue.
        Log.e("HostAdapter", "Host bean is null!");
        hostHolder.nickname.setText("Error during lookup");
    } else {
        hostHolder.nickname.setText(host.getNickname());
    }

    switch (this.getConnectedState(host)) {
    case STATE_UNKNOWN:
        hostHolder.icon.setImageState(new int[] { }, true);
        hostHolder.icon.setContentDescription(null);
        if (Build.VERSION.SDK_INT >= 16) {
            hideFromAccessibility(hostHolder.icon, true);
        }
        break;
    case STATE_CONNECTED:
        hostHolder.icon.setImageState(new int[] { android.R.attr.state_checked }, true);
        hostHolder.icon.setContentDescription(getString(R.string.image_description_connected));
        if (Build.VERSION.SDK_INT >= 16) {
            hideFromAccessibility(hostHolder.icon, false);
        }
        break;
    case STATE_DISCONNECTED:
        hostHolder.icon.setImageState(new int[] { android.R.attr.state_expanded }, true);
        hostHolder.icon.setContentDescription(getString(R.string.image_description_disconnected));
        if (Build.VERSION.SDK_INT >= 16) {
            hideFromAccessibility(hostHolder.icon, false);
        }
        break;
    default:
        Log.e("HostAdapter", "Unknown host state encountered: " + getConnectedState(host));
    }

    @StyleRes final int chosenStyleFirstLine;
    @StyleRes final int chosenStyleSecondLine;
    if (HostDatabase.COLOR_RED.equals(host.getColor())) {
        chosenStyleFirstLine = R.style.ListItemFirstLineText_Red;
        chosenStyleSecondLine = R.style.ListItemSecondLineText_Red;
    } else if (HostDatabase.COLOR_GREEN.equals(host.getColor())) {
        chosenStyleFirstLine = R.style.ListItemFirstLineText_Green;
        chosenStyleSecondLine = R.style.ListItemSecondLineText_Green;
    } else if (HostDatabase.COLOR_BLUE.equals(host.getColor())) {
        chosenStyleFirstLine = R.style.ListItemFirstLineText_Blue;
        chosenStyleSecondLine = R.style.ListItemSecondLineText_Blue;
    } else {
        chosenStyleFirstLine = R.style.ListItemFirstLineText;
        chosenStyleSecondLine = R.style.ListItemSecondLineText;
    }

    hostHolder.nickname.setTextAppearance(context, chosenStyleFirstLine);
    hostHolder.caption.setTextAppearance(context, chosenStyleSecondLine);

    CharSequence nice = context.getString(R.string.bind_never);
    if (host.getLastConnect() > 0) {
        nice = DateUtils.getRelativeTimeSpanString(host.getLastConnect() * 1000);
    }

    hostHolder.caption.setText(nice);
}
BaseDialog.java 文件源码 项目:GitHub 阅读 26 收藏 0 点赞 0 评论 0
public void setAnimationStyle(@StyleRes int animRes) {
    Window window = dialog.getWindow();
    if (window != null) {
        window.setWindowAnimations(animRes);
    }
}
TextViewCompat.java 文件源码 项目:letv 阅读 21 收藏 0 点赞 0 评论 0
public void setTextAppearance(TextView textView, @StyleRes int resId) {
    TextViewCompatDonut.setTextAppearance(textView, resId);
}
EasyPopup.java 文件源码 项目:GitHub 阅读 24 收藏 0 点赞 0 评论 0
public <T extends EasyPopup> T setAnimationStyle(@StyleRes int animationStyle) {
    this.mAnimationStyle = animationStyle;
    return (T) this;
}
EraseFrameLayout.java 文件源码 项目:EraseView-Android 阅读 24 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public EraseFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
}
DrawCameraView.java 文件源码 项目:QuickDrawEverywhere 阅读 22 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public DrawCameraView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    initCameraView();
}
CalendarView.java 文件源码 项目:DateTimePicker 阅读 37 收藏 0 点赞 0 评论 0
@StyleRes
int getWeekDayTextAppearance();
NavigationView.java 文件源码 项目:boohee_v5.6 阅读 30 收藏 0 点赞 0 评论 0
public void setItemTextAppearance(@StyleRes int resId) {
    this.mPresenter.setItemTextAppearance(resId);
}
CalendarView.java 文件源码 项目:DateTimePicker 阅读 34 收藏 0 点赞 0 评论 0
@StyleRes
int getDateTextAppearance();
TextViewCompat.java 文件源码 项目:letv 阅读 23 收藏 0 点赞 0 评论 0
public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) {
    IMPL.setTextAppearance(textView, resId);
}


问题


面经


文章

微信
公众号

扫码关注公众号