@android.support.annotation.IdRes

Here are the examples of the java api @android.support.annotation.IdRes taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

62 Examples 7

19 Source : ItemDetailActivity.java
with MIT License
from ZafraniTechLLC

@IdRes
@Override
protected int getContentView() {
    return R.id.activity_itemdetails_content;
}

19 Source : CircularReveal.java
with Apache License 2.0
from yongjhih

/**
 * A transition which shows/hides a view with a circular clipping mask. Callers should provide the
 * center point of the reveal either {@link #setCenter(Point) directly} or by
 * {@link #centerOn(View) specifying} another view to center on; otherwise the target {@code view}'s
 * pivot point will be used.
 */
public clreplaced CircularReveal extends Visibility {

    private Point center;

    private float startRadius;

    private float endRadius;

    @IdRes
    private int centerOnId = View.NO_ID;

    private View centerOn;

    public CircularReveal() {
        super();
    }

    public CircularReveal(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircularReveal);
        startRadius = a.getDimension(R.styleable.CircularReveal_startRadius, 0f);
        endRadius = a.getDimension(R.styleable.CircularReveal_endRadius, 0f);
        centerOnId = a.getResourceId(R.styleable.CircularReveal_centerOn, View.NO_ID);
        a.recycle();
    }

    /**
     * The center point of the reveal or conceal, relative to the target {@code view}.
     */
    public void setCenter(@NonNull Point center) {
        this.center = center;
    }

    /**
     * Center the reveal or conceal on this view.
     */
    public void centerOn(@NonNull View source) {
        centerOn = source;
    }

    /**
     * Sets the radius that <strong>reveals</strong> start from.
     */
    public void setStartRadius(float startRadius) {
        this.startRadius = startRadius;
    }

    /**
     * Sets the radius that <strong>conceals</strong> end at.
     */
    public void setEndRadius(float endRadius) {
        this.endRadius = endRadius;
    }

    @Override
    public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
        if (view == null || view.getHeight() == 0 || view.getWidth() == 0)
            return null;
        ensureCenterPoint(sceneRoot, view);
        return new AnimUtils.NoPauseAnimator(ViewAnimationUtils.createCircularReveal(view, center.x, center.y, startRadius, getFullyRevealedRadius(view)));
    }

    @Override
    public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
        if (view == null || view.getHeight() == 0 || view.getWidth() == 0)
            return null;
        ensureCenterPoint(sceneRoot, view);
        return new AnimUtils.NoPauseAnimator(ViewAnimationUtils.createCircularReveal(view, center.x, center.y, getFullyRevealedRadius(view), endRadius));
    }

    private void ensureCenterPoint(ViewGroup sceneRoot, View view) {
        if (center != null)
            return;
        if (centerOn != null || centerOnId != View.NO_ID) {
            View source;
            if (centerOn != null) {
                source = centerOn;
            } else {
                source = sceneRoot.findViewById(centerOnId);
            }
            if (source != null) {
                // use window location to allow views in diff hierarchies
                int[] loc = new int[2];
                source.getLocationInWindow(loc);
                int srcX = loc[0] + (source.getWidth() / 2);
                int srcY = loc[1] + (source.getHeight() / 2);
                view.getLocationInWindow(loc);
                center = new Point(srcX - loc[0], srcY - loc[1]);
            }
        }
        // else use the pivot point
        if (center == null) {
            center = new Point(Math.round(view.getPivotX()), Math.round(view.getPivotY()));
        }
    }

    private float getFullyRevealedRadius(@NonNull View view) {
        return (float) Math.hypot(Math.max(center.x, view.getWidth() - center.x), Math.max(center.y, view.getHeight() - center.y));
    }
}

19 Source : CircularReveal.java
with Apache License 2.0
from vpaliy

public clreplaced CircularReveal extends Visibility {

    private Point center;

    private float startRadius;

    private float endRadius;

    @IdRes
    private int centerOnId = View.NO_ID;

    private View centerOn;

    public CircularReveal() {
        super();
    }

    public CircularReveal(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircularReveal);
        startRadius = a.getDimension(R.styleable.CircularReveal_startRadius, 0f);
        endRadius = a.getDimension(R.styleable.CircularReveal_endRadius, 0f);
        centerOnId = a.getResourceId(R.styleable.CircularReveal_centerOn, View.NO_ID);
        a.recycle();
    }

    /**
     * The center point of the reveal or conceal, relative to the target {@code view}.
     */
    public void setCenter(@NonNull Point center) {
        this.center = center;
    }

    /**
     * Center the reveal or conceal on this view.
     */
    public void centerOn(@NonNull View source) {
        centerOn = source;
    }

    /**
     * Sets the radius that <strong>reveals</strong> start from.
     */
    public void setStartRadius(float startRadius) {
        this.startRadius = startRadius;
    }

    /**
     * Sets the radius that <strong>conceals</strong> end at.
     */
    public void setEndRadius(float endRadius) {
        this.endRadius = endRadius;
    }

    @Override
    public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
        if (view == null || view.getHeight() == 0 || view.getWidth() == 0)
            return null;
        ensureCenterPoint(sceneRoot, view);
        return new PauseLessAnimator(ViewAnimationUtils.createCircularReveal(view, center.x, center.y, startRadius, getFullyRevealedRadius(view)));
    }

    @Override
    public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
        if (view == null || view.getHeight() == 0 || view.getWidth() == 0)
            return null;
        ensureCenterPoint(sceneRoot, view);
        return new PauseLessAnimator(ViewAnimationUtils.createCircularReveal(view, center.x, center.y, getFullyRevealedRadius(view), endRadius));
    }

    private void ensureCenterPoint(ViewGroup sceneRoot, View view) {
        if (center != null)
            return;
        if (centerOn != null || centerOnId != View.NO_ID) {
            View source;
            if (centerOn != null) {
                source = centerOn;
            } else {
                source = sceneRoot.findViewById(centerOnId);
            }
            if (source != null) {
                // use window location to allow views in diff hierarchies
                int[] loc = new int[2];
                source.getLocationInWindow(loc);
                int srcX = loc[0] + (source.getWidth() / 2);
                int srcY = loc[1] + (source.getHeight() / 2);
                view.getLocationInWindow(loc);
                center = new Point(srcX - loc[0], srcY - loc[1]);
            }
        }
        // else use the pivot point
        if (center == null) {
            center = new Point(Math.round(view.getPivotX()), Math.round(view.getPivotY()));
        }
    }

    private float getFullyRevealedRadius(@NonNull View view) {
        return (float) Math.hypot(Math.max(center.x, view.getWidth() - center.x), Math.max(center.y, view.getHeight() - center.y));
    }
}

19 Source : YGuider.java
with Apache License 2.0
from totond

/**
 * 扫描框风格的新手引导
 */
public clreplaced YGuider {

    public static final String TAG = "guiderview";

    private Activity mActivity;

    private FrameLayout mContentView;

    private MaskLayout mMask;

    // 用于存放扫描目标区域
    private ArrayList<RectF> mScanRegions;

    // 用于存放扫描目标View
    private ArrayList<ScanTarget> mScanTargets;

    private int mContentLocationX = 0, mContentLocationY = 0;

    private boolean mIsGuiding = false;

    // PopupWindow相关属性
    private String defaultJumpText, defaultNextText;

    // 要获取的ContentView的ID
    @IdRes
    private int mContentId;

    public YGuider(Activity activity) {
        this(activity, android.R.id.content);
    }

    /**
     * YGuider构造方法
     * @param activity 传入Activity主要是为了可以获取DecorView
     * @param contentId 用于找到需要遮罩的Layout
     */
    public YGuider(Activity activity, @IdRes int contentId) {
        mActivity = activity;
        mContentId = contentId;
        init();
    }

    private void init() {
        // 通过DecorView获取
        FrameLayout decorView = (FrameLayout) mActivity.getWindow().getDecorView();
        mContentView = (FrameLayout) decorView.findViewById(mContentId);
        mScanRegions = new ArrayList<>();
        mScanTargets = new ArrayList<>();
        defaultJumpText = mActivity.getResources().getString(R.string.text_jump);
        defaultNextText = mActivity.getResources().getString(R.string.text_next);
        buildMask();
    }

    private void buildMask() {
        mMask = new MaskLayout(mActivity, this);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        mMask.setLayoutParams(layoutParams);
        // 绑定列表
        mMask.setScanTargets(mScanTargets);
    }

    /**
     * 设置MaskLayout的父Layout,调用此方法会重置YGuider
     * @param contentId 父Layout的ID
     */
    public void setContentId(int contentId) {
        this.mContentId = contentId;
        init();
    }

    /**
     * 开始Guide
     */
    public void startGuide() {
        if (!mIsGuiding) {
            mIsGuiding = true;
            mContentView.addView(mMask);
        }
    }

    /**
     * 增加一个扫描区域
     * @param targetView 目标View
     * @param text 说明文字
     * @param wOffsetX 弹出窗口的X位置偏移量(初始位置为目标View中间)
     * @param wOffsetY 弹出窗口的Y位置偏移量(初始位置为目标View正下方)
     */
    public void addNextTarget(View targetView, String text, int wOffsetX, int wOffsetY) {
        ScanTarget scanTarget = new ScanTarget(targetView, text, wOffsetX, wOffsetY);
        mScanTargets.add(scanTarget);
    }

    /**
     * 增加一个扫描区域
     * @param targetView 目标View
     * @param text 说明文字
     * @param wOffsetX 弹出窗口的X位置偏移量(初始位置为目标View中间)
     * @param wOffsetY 弹出窗口的Y位置偏移量(初始位置为目标View正下方)
     * @param wWidth 弹出窗口的宽度
     * @param wHeight 弹出窗口的高度
     */
    public void addNextTarget(View targetView, String text, int wOffsetX, int wOffsetY, int wWidth, int wHeight) {
        ScanTarget scanTarget = new ScanTarget(targetView, text, wOffsetX, wOffsetY);
        scanTarget.setWindowWidth(wWidth);
        scanTarget.setWindowHeight(wHeight);
        mScanTargets.add(scanTarget);
    }

    /**
     * 增加一个扫描区域
     * @param targetView 目标View
     * @param text 说明文字
     * @param wOffsetX 弹出窗口的X位置偏移量(初始位置为目标View中间)
     * @param wOffsetY 弹出窗口的Y位置偏移量(初始位置为目标View正下方)
     * @param wWidth 弹出窗口的宽度
     * @param wHeight 弹出窗口的高度
     * @param jumpText 跳过选项的文字
     * @param nextText 下一步选项的文字
     */
    public void addNextTarget(View targetView, String text, int wOffsetX, int wOffsetY, int wWidth, int wHeight, String jumpText, String nextText) {
        ScanTarget scanTarget = new ScanTarget(targetView, text, wOffsetX, wOffsetY);
        scanTarget.setWindowWidth(wWidth);
        scanTarget.setWindowHeight(wHeight);
        scanTarget.setJumpText(jumpText);
        scanTarget.setNextText(nextText);
        mScanTargets.add(scanTarget);
    }

    /**
     * 增加一个扫描区域
     * @param targetRegion 目标区域的坐标矩阵
     * @param text 说明文字
     * @param wOffsetX 弹出窗口的X位置偏移量(初始位置为目标View中间)
     * @param wOffsetY 弹出窗口的Y位置偏移量(初始位置为目标View正下方)
     */
    public void addNextTarget(RectF targetRegion, String text, int wOffsetX, int wOffsetY) {
        ScanTarget scanTarget = new ScanTarget(targetRegion, text, wOffsetX, wOffsetY);
        mScanTargets.add(scanTarget);
    }

    /**
     * 增加一个扫描区域
     * @param targetRegion 目标区域的坐标矩阵
     * @param text 说明文字
     * @param wOffsetX 弹出窗口的X位置偏移量(初始位置为目标View中间)
     * @param wOffsetY 弹出窗口的Y位置偏移量(初始位置为目标View正下方)
     * @param wWidth 弹出窗口的宽度
     * @param wHeight 弹出窗口的高度
     */
    public void addNextTarget(RectF targetRegion, String text, int wOffsetX, int wOffsetY, int wWidth, int wHeight) {
        ScanTarget scanTarget = new ScanTarget(targetRegion, text, wOffsetX, wOffsetY);
        scanTarget.setWindowWidth(wWidth);
        scanTarget.setWindowHeight(wHeight);
        mScanTargets.add(scanTarget);
    }

    /**
     * 增加一个扫描区域
     * @param targetRegion 目标区域的坐标矩阵
     * @param text 说明文字
     * @param wOffsetX 弹出窗口的X位置偏移量(初始位置为目标View中间)
     * @param wOffsetY 弹出窗口的Y位置偏移量(初始位置为目标View正下方)
     * @param wWidth 弹出窗口的宽度
     * @param wHeight 弹出窗口的高度
     * @param jumpText 跳过选项的文字
     * @param nextText 下一步选项的文字
     */
    public void addNextTarget(RectF targetRegion, String text, int wOffsetX, int wOffsetY, int wWidth, int wHeight, String jumpText, String nextText) {
        ScanTarget scanTarget = new ScanTarget(targetRegion, text, wOffsetX, wOffsetY);
        scanTarget.setWindowWidth(wWidth);
        scanTarget.setWindowHeight(wHeight);
        scanTarget.setJumpText(jumpText);
        scanTarget.setNextText(nextText);
        mScanTargets.add(scanTarget);
    }

    /**
     * 增加一些Target
     * @param targets 一些ScanTarget对象
     */
    public void addTarget(ScanTarget... targets) {
        for (ScanTarget target : targets) {
            mScanTargets.add(target);
        }
    }

    /**
     * 进入下一个引导
     */
    public void startNextGuide() {
        mMask.onNext();
    }

    /**
     * 移除目标
     * @param index 目标的index
     * @return 移除目标成功与否
     */
    public boolean removeTarget(int index) {
        if (index >= 0 && index < mScanTargets.size()) {
            mScanTargets.remove(index);
            return true;
        }
        return false;
    }

    /**
     * 清除所有扫描目标
     */
    public void clearTargets() {
        mScanTargets.clear();
    }

    /**
     * 判断在当前ContentView是否已经初始化宽高属性
     * 如果是,则直接获取目标View的位置信息,写入目标列表
     * 如果不是,则等到ContentView初始化宽高属性之后再获取,因为它会等子View全部Layout完了再进行Layout
     */
    public void prepare() {
    // ViewTreeObserver observerD = mContentView.getViewTreeObserver();
    // if (mContentView.getWidth() != 0 && mContentView.getHeight() != 0) {
    // prepareTargets();
    // }else {
    // observerD.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // mContentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
    // prepareTargets();
    // }
    // });
    // }
    }

    // 获取ContentView在屏幕位置,相对Window的坐标坐标系
    public void checkContentLocation() {
        int[] contentLocation = { 0, 0 };
        mContentView.getLocationInWindow(contentLocation);
        mContentLocationX = contentLocation[0];
        mContentLocationY = contentLocation[1];
    }

    // 用于将目标View转为目标坐标区域
    private void prepareTargets() {
        checkContentLocation();
        for (ScanTarget scanTarget : mScanTargets) {
            if (!scanTarget.getIsRegion()) {
            // scanTarget.setRegion(getViewLocationRectF(scanTarget.getTargetView()));
            // 迁移区域.因为需要的区域是相对于ContentView的坐标系的,getLocationInWindow()获取的坐标是相对于Window的坐标系的
            // 所以要用在Window坐标系里面的,View的坐标减去mContentView的坐标,就得到View相对于mContentView的坐标了
            // scanTarget.getRegion().offset(-mContentLocationX, -mContentLocationY);
            // mScanRegions.add(scanTarget.viewToRegion(-mContentLocationX, -mContentLocationY));
            }
        // //设置跳过和下一步的字符
        // if (scanTarget.getJumpText() == null) {
        // scanTarget.setJumpText(defaultJumpText);
        // }
        // if (scanTarget.getNextText() == null) {
        // scanTarget.setNextText(defaultNextText);
        // }
        }
    }

    // 获取View的位置矩阵,相对于Window的坐标系
    private RectF getViewLocationRectF(View view) {
        int[] location = { 0, 0 };
        view.getLocationInWindow(location);
        return new RectF(location[0], location[1], location[0] + view.getWidth(), location[1] + view.getHeight());
    }

    /**
     * 退出新手引导
     */
    public void cancelGuide() {
        if (mIsGuiding) {
            mMask.exit();
        }
    }

    public int getContentLocationX() {
        return mContentLocationX;
    }

    public int getContentLocationY() {
        return mContentLocationY;
    }

    /**
     * 设置扫描框动画刷新的时间间隔,默认值是20
     * @param refreshTime 单位是ms
     */
    public void setMaskRefreshTime(int refreshTime) {
        mMask.setRefreshTime(refreshTime);
    }

    /**
     * 设置扫描框移动动画的持续时间,默认值是500
     * @param moveDuration 单位是ms
     */
    public void setMaskMoveDuration(int moveDuration) {
        mMask.setMoveDuration(moveDuration);
    }

    /**
     * 设置扫描框扩大动画的持续时间,默认值是500
     * @param expandDuration 单位是ms
     */
    public void setExpandDuration(int expandDuration) {
        mMask.setExpandDuration(expandDuration);
    }

    /**
     * 设置遮罩层的颜色,最后是设置成透明的,默认颜色是#aa222222
     * @param color 颜色
     */
    public void setMaskColor(@ColorInt int color) {
        mMask.setMackColor(color);
    }

    /**
     * 设置画扫描框的画笔
     * @param paint 画笔
     */
    public void setMaskPaint(Paint paint) {
        mMask.setsPaint(paint);
    }

    /**
     * 设置弹窗里面TextView文字出现的速度,默认值是100
     * @param refreshTime 每次增加文字的时间间隔,单位ms
     */
    public void setWindowTyperRefreshTime(int refreshTime) {
        mMask.getWindow().setTyperRefreshTime(refreshTime);
    }

    /**
     * 弹窗里面说明文字的字体大小,默认值是18sp
     * @param size 字体大小
     */
    public void setWindowTyperTextSize(int size) {
        mMask.getWindow().setTyperTextSize(size);
    }

    /**
     * 设置弹窗里面TextView文字的增长速度,默认值是1
     * @param increase 每次增加多少个字符
     */
    public void setWindowTyperIncrease(int increase) {
        mMask.getWindow().setTyperIncrease(increase);
    }

    /**
     * 设置跳过按钮的文字
     * @param jumpText 跳过文字
     */
    public void setJumpText(String jumpText) {
        defaultJumpText = jumpText;
    }

    public String getJumpText() {
        return defaultJumpText;
    }

    /**
     * 设置下一步按钮的文字
     * @param nextText 下一步文字
     */
    public void setNextText(String nextText) {
        defaultNextText = nextText;
    }

    public String getNextText() {
        return defaultNextText;
    }

    /**
     * 设置弹窗背景
     * @param idRes 背景DrawableId
     */
    public void setWindowBackground(@DrawableRes int idRes) {
        mMask.getWindow().setContentBackgroundId(idRes);
    }

    /**
     * 设置跳过和下一步按钮文字大小
     * @param size 文字字体大小
     */
    public void setWindowJumpAndNextTextSize(int size) {
        mMask.getWindow().setTvSize(size);
    }

    /**
     * 设置自定义弹窗布局
     * 注意新的布局要有TyperTextView类,id设置为ttv_tips
     * 跳过按钮和下一步按钮可以选择实现,但是有的话id请分别设置为tv_jump和tv_next,其他可以自定义
     * @param layouId 布局的id
     */
    public void setWindowContent(@LayoutRes int layouId) {
        mMask.getWindow().setContent(layouId);
    }

    public void setIsGuiding(boolean isGuiding) {
        mIsGuiding = isGuiding;
    }

    public boolean getIsPreparing() {
        return mIsGuiding;
    }

    /**
     * 设置点击回调
     * @param guiderClickListener 可以传入OnGuiderClickListener和OnGuiderListener的子类
     */
    public void setOnGuiderClickListener(OnGuiderClickListener guiderClickListener) {
        mMask.setOnGuiderClickListener(guiderClickListener);
    }

    /**
     * 设置状态回调
     * @param onGuiderChangedListener 可以传入OnGuiderChangedListener和OnGuiderListener的子类
     */
    public void setOnGuiderChangedListener(OnGuiderChangedListener onGuiderChangedListener) {
        mMask.setOnGuiderChangedListener(onGuiderChangedListener);
    }

    /**
     * 设置状态所有回调
     * @param onGuiderListener 可以传入OnGuiderListener的子类
     */
    public void setOnGuiderListener(OnGuiderListener onGuiderListener) {
        mMask.setOnGuiderListener(onGuiderListener);
    }
}

19 Source : MultiSheetView.java
with GNU General Public License v3.0
from timusus

@IdRes
public int getMainContainerResId() {
    return R.id.mainContainer;
}

19 Source : Bookmark.java
with Apache License 2.0
from thekirankumar

/**
 * Created by kiran.kumar on 24/01/18.
 */
public clreplaced Bookmark extends RealmObject {

    private String replacedle;

    private String faviconPath;

    @IdRes
    private int faviconResource;

    private String url;

    private byte[] thumbnail;

    private byte[] favicon;

    private long createdAt;

    @IdRes
    private int thumbnailResource;

    private boolean preventDelete;

    public Bookmark() {
    }

    public Bookmark(String replacedle, String faviconPath, String url) {
        this.replacedle = replacedle;
        this.faviconPath = faviconPath;
        this.url = url;
        this.createdAt = url.hashCode();
    }

    public Bookmark(String replacedle, int faviconRes, String url, int thumbnailRes) {
        this.replacedle = replacedle;
        this.faviconResource = faviconRes;
        this.url = url;
        this.thumbnailResource = thumbnailRes;
        this.preventDelete = true;
        this.createdAt = url.hashCode();
    }

    public boolean isPreventDelete() {
        return preventDelete;
    }

    public void setPreventDelete(boolean preventDelete) {
        this.preventDelete = preventDelete;
    }

    public int getFaviconResource() {
        return faviconResource;
    }

    public void setFaviconResource(int faviconResource) {
        this.faviconResource = faviconResource;
    }

    public int getThumbnailResource() {
        return thumbnailResource;
    }

    public void setThumbnailResource(int thumbnailResource) {
        this.thumbnailResource = thumbnailResource;
    }

    public long getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(long createdAt) {
        this.createdAt = createdAt;
    }

    public byte[] getFavicon() {
        return favicon;
    }

    public void setFavicon(byte[] favicon) {
        this.favicon = favicon;
    }

    public byte[] getThumbnail() {
        return thumbnail;
    }

    public void setThumbnail(byte[] thumbnail) {
        this.thumbnail = thumbnail;
    }

    public String getreplacedle() {
        return replacedle;
    }

    public void setreplacedle(String replacedle) {
        this.replacedle = replacedle;
    }

    public String getFaviconPath() {
        return faviconPath;
    }

    public void setFaviconPath(String faviconPath) {
        this.faviconPath = faviconPath;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}

19 Source : NodeViewSwitcher.java
with GNU General Public License v3.0
from saantiaguilera

/**
 * Created by saguilera on 6/10/17.
 */
public clreplaced NodeViewSwitcher implements NodeSwitcher<View> {

    @NonNull
    private WeakReference<Activity> contextR;

    @IdRes
    private int resId;

    /**
     * Since only one of the views is visible at a time, we keep them in memory so the state isnt lost.
     * This shouldnt affect memory, unless you load your view with all the bussiness logic and such
     */
    @NonNull
    private Map<Long, View> views;

    public NodeViewSwitcher(@NonNull Activity context, @IdRes int resId) {
        this.contextR = new WeakReference<>(context);
        this.resId = resId;
        this.views = new HashMap<>();
    }

    private void findTypeOrThrow(@NonNull Clreplaced<?> clazz) {
        boolean isClreplacedAView = View.clreplaced.isreplacedignableFrom(clazz);
        if (!isClreplacedAView) {
            throw new IllegalStateException("Provided clreplaced: " + clazz.getName() + " isnt a subtype of: " + View.clreplaced.getName());
        }
    }

    @Nullable
    private ViewGroup getParent() {
        return contextR.get() == null ? null : (ViewGroup) contextR.get().findViewById(resId);
    }

    @Nullable
    private View createView(Clreplaced<?> clazz, long identifier) {
        if (views.get(identifier) != null) {
            // If the view was already created, return it!
            return views.get(identifier);
        }
        try {
            Context context = contextR.get();
            if (context == null) {
                throw new ActivityNotFoundException("Activity has been removed, so this will be removed too");
            }
            Constructor constructor = clazz.getConstructor(Context.clreplaced);
            View view = (View) constructor.newInstance(contextR.get());
            views.put(identifier, view);
            return view;
        } catch (ActivityNotFoundException ex) {
            // Silent, we are not existing anymore
            return null;
        } catch (Exception e) {
            throw new RuntimeException("View constructor for node clreplaced doesnt exist. Please provide <init>(Context) constructor.", e);
        }
    }

    @Nullable
    private View moveView(@NonNull Clreplaced<?> clazz, @Router.Direction int how, long id) {
        final ViewGroup parent = getParent();
        View nodeView = createView(clazz, id);
        if (parent != null && nodeView != null) {
            final View before = parent.getChildCount() > 0 ? parent.getChildAt(0) : null;
            if (before == null) {
                // If theres no view in the parent, add one directly without just alpha anim
                parent.addView(nodeView);
                nodeView.setAlpha(0f);
                nodeView.animate().setDuration(400).alpha(1f).setListener(null).start();
            } else {
                if (before == nodeView) {
                    // They are the same...
                    return nodeView;
                }
                before.animate().setDuration(400).xBy(how == Router.DIRECTION_BACKWARD ? parent.getWidth() : -parent.getWidth()).alpha(0f).setListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(final Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(final Animator animation) {
                        parent.removeView(before);
                    }

                    @Override
                    public void onAnimationCancel(final Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(final Animator animation) {
                    }
                }).start();
                parent.addView(nodeView);
                nodeView.setX(how == Router.DIRECTION_BACKWARD ? -parent.getWidth() : parent.getWidth());
                nodeView.setAlpha(0f);
                nodeView.animate().setDuration(400).xBy(how == Router.DIRECTION_BACKWARD ? parent.getWidth() : -parent.getWidth()).alpha(1f).setListener(null).start();
            }
        }
        return nodeView;
    }

    @Nullable
    public View commit(@NonNull Clreplaced<?> clazz, @Router.Direction int how, long identifier) {
        findTypeOrThrow(clazz);
        return moveView(clazz, how, identifier);
    }

    @Override
    public void clearAll() {
        views.clear();
    }
}

19 Source : NodeFragmentSwitcher.java
with GNU General Public License v3.0
from saantiaguilera

/**
 * Created by saguilera on 6/10/17.
 */
public clreplaced NodeFragmentSwitcher implements NodeSwitcher<Fragment> {

    @NonNull
    private WeakReference<FragmentActivity> contextR;

    @IdRes
    private int resId;

    public NodeFragmentSwitcher(@NonNull FragmentActivity context, @IdRes int resId) {
        this.contextR = new WeakReference<>(context);
        this.resId = resId;
    }

    private void findTypeOrThrow(@NonNull Clreplaced<?> clazz) {
        boolean isClreplacedAFragment = Fragment.clreplaced.isreplacedignableFrom(clazz);
        if (!isClreplacedAFragment) {
            throw new IllegalStateException("Provided clreplaced: " + clazz.getName() + " isnt a subtype of: " + Fragment.clreplaced.getName());
        }
    }

    @Nullable
    private Fragment createFragment(Clreplaced<?> clazz, long identifier) {
        try {
            FragmentActivity context = contextR.get();
            Fragment fragment;
            if (context == null) {
                throw new ActivityNotFoundException("Activity has been removed, so this will be removed too");
            }
            fragment = context.getSupportFragmentManager().findFragmentByTag(String.valueOf(identifier));
            if (fragment == null) {
                return Fragment.instantiate(context, clazz.getName());
            } else {
                return fragment;
            }
        } catch (ActivityNotFoundException ex) {
            // Silent, we are not existing anymore
            return null;
        }
    }

    @Nullable
    @Override
    public Fragment commit(@NonNull final Clreplaced<?> clazz, @Router.Direction final int how, final long identifier) {
        findTypeOrThrow(clazz);
        Fragment fragment = createFragment(clazz, identifier);
        if (fragment != null) {
            FragmentActivity context = contextR.get();
            FragmentTransaction transaction = context.getSupportFragmentManager().beginTransaction();
            switch(how) {
                case Router.DIRECTION_FORWARD:
                    transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
                    break;
                case Router.DIRECTION_BACKWARD:
                    transaction.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right);
                    break;
            }
            transaction.replace(resId, fragment, String.valueOf(identifier));
            transaction.commit();
        }
        return fragment;
    }

    @Override
    public void clearAll() {
    // Nothing to do..
    }
}

19 Source : CheckGroup.java
with MIT License
from rongcloud

/**
 * Returns the identifier of the selected radio button in this group. Upon empty selection, the
 * returned value is View.NO_ID.
 *
 * @return the unique id of the selected radio button in this group
 * @attr ref android.R.styleable#CheckGroup_checkedButton
 * @see #check(int)
 * @see #clearCheck()
 */
@IdRes
public int getCheckedCheckBoxId() {
    return mCheckedId;
}

19 Source : BeautyBoxGroup.java
with MIT License
from rongcloud

/**
 * Returns the identifier of the selected radio button in this group. Upon empty selection, the
 * returned value is -1.
 *
 * @return the unique id of the selected radio button in this group
 * @see #check(int)
 * @see #clearCheck()
 * @attr ref android.R.styleable#BeautyBoxGroup_checkedButton
 */
@IdRes
public int getCheckedBeautyBoxId() {
    return mCheckedId;
}

19 Source : CheckGroup.java
with Apache License 2.0
from pili-engineering

/**
 * <p>Returns the identifier of the selected radio button in this group.
 * Upon empty selection, the returned value is View.NO_ID.</p>
 *
 * @return the unique id of the selected radio button in this group
 * @attr ref android.R.styleable#CheckGroup_checkedButton
 * @see #check(int)
 * @see #clearCheck()
 */
@IdRes
public int getCheckedCheckBoxId() {
    return mCheckedId;
}

19 Source : BeautyBoxGroup.java
with Apache License 2.0
from pili-engineering

/**
 * <p>Returns the identifier of the selected radio button in this group.
 * Upon empty selection, the returned value is -1.</p>
 *
 * @return the unique id of the selected radio button in this group
 *
 * @see #check(int)
 * @see #clearCheck()
 *
 * @attr ref android.R.styleable#BeautyBoxGroup_checkedButton
 */
@IdRes
public int getCheckedBeautyBoxId() {
    return mCheckedId;
}

19 Source : SettingsObject.java
with Apache License 2.0
from or-dvir

/**
 * @return the id of the {@link TextView} which is being used as this {@link SettingsObject}s'
 * replacedle
 */
@IdRes
public int getTextViewreplacedleId() {
    return textViewreplacedleId;
}

19 Source : SettingsObject.java
with Apache License 2.0
from or-dvir

/**
 * @return the id of the root view which contains this entire {@link SettingsObject}.
 * (the type of view depends on the {@link SettingsObject}).<br></br>
 * use this method to gain access to individual views inside this {@link SettingsObject}
 * e.g. View root = findViewById(mySettingsObject.getRootId());
 * textViewSummary = root.findViewById(mySettingsObject.getTextViewSummaryId());
 */
@IdRes
public int getRootId() {
    return individualSettingsRootId;
}

19 Source : BooleanSettingsObject.java
with Apache License 2.0
from or-dvir

/**
 * @return the id of the {@link CompoundButton} which
 * this {@link BooleanSettingsObject} holds
 * (e.g. {@link android.widget.CheckBox} and {@link android.widget.Switch})
 */
@IdRes
public int getCompoundButtonId() {
    return compoundButtonId;
}

19 Source : SelectAnimatorDuration.java
with Apache License 2.0
from nickbutcher

@IdRes
private int getScaleItemId(@FloatRange(from = 0.0, to = 10.0) float scale) {
    if (scale <= 0f) {
        return R.id.scale_off;
    } else if (scale <= 0.5f) {
        return R.id.scale_0_5;
    } else if (scale <= 1f) {
        return R.id.scale_1;
    } else if (scale <= 1.5f) {
        return R.id.scale_1_5;
    } else if (scale <= 2f) {
        return R.id.scale_2;
    } else if (scale <= 5f) {
        return R.id.scale_5;
    } else {
        return R.id.scale_10;
    }
}

19 Source : SimpleSearchDialogCompat.java
with Apache License 2.0
from mirrajabi

@IdRes
@Override
protected int getRecyclerViewId() {
    return R.id.rv_items;
}

19 Source : SimpleSearchDialogCompat.java
with Apache License 2.0
from mirrajabi

@IdRes
@Override
protected int getSearchBoxId() {
    return R.id.txt_search;
}

19 Source : ContactSearchDialogCompat.java
with Apache License 2.0
from mirrajabi

@IdRes
@Override
protected int getRecyclerViewId() {
    return ir.mirrajabi.searchdialog.R.id.rv_items;
}

19 Source : ContactSearchDialogCompat.java
with Apache License 2.0
from mirrajabi

@IdRes
@Override
protected int getSearchBoxId() {
    return ir.mirrajabi.searchdialog.R.id.txt_search;
}

19 Source : SelectedView.java
with Apache License 2.0
from michaelprimez

/**
 * Created by michael on 1/14/17.
 */
public clreplaced SelectedView implements Parcelable {

    private View mView;

    private int mPosition;

    @IdRes
    private long mId;

    public SelectedView(View view, int position, @IdRes long id) {
        mView = view;
        mPosition = position;
        mId = id;
    }

    public View getView() {
        return mView;
    }

    public void setView(View view) {
        mView = view;
    }

    public int getPosition() {
        return mPosition;
    }

    public void setPosition(int position) {
        mPosition = position;
    }

    public long getId() {
        return mId;
    }

    public void setId(@IdRes long id) {
        mId = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClreplaced() != o.getClreplaced())
            return false;
        SelectedView that = (SelectedView) o;
        if (mPosition != that.mPosition)
            return false;
        if (mId != that.mId)
            return false;
        return mView != null ? mView.equals(that.mView) : that.mView == null;
    }

    @Override
    public int hashCode() {
        int result = mView != null ? mView.hashCode() : 0;
        result = 31 * result + mPosition;
        result = 31 * result + (int) (mId ^ (mId >>> 32));
        return result;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<SelectedView> CREATOR = new Creator<SelectedView>() {

        @Override
        public SelectedView createFromParcel(Parcel in) {
            return new SelectedView(in);
        }

        @Override
        public SelectedView[] newArray(int size) {
            return new SelectedView[size];
        }
    };

    protected SelectedView(Parcel in) {
        mPosition = in.readInt();
        mId = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mPosition);
        dest.writeLong(mId);
    }
}

19 Source : SimilarLoadingView.java
with Apache License 2.0
from mbakgun

public clreplaced SimilarLoadingView extends View {

    private static final int MAX_PROGRESS_VALUE = 1450;

    private static final int PROGRESS_TIME = 2000;

    private static final int MAX_ALPHA = 70;

    private Paint paint = new Paint();

    private double hexHeight;

    private double hexWidth;

    private double hexPadding = 0;

    private float actualProgress = 0;

    private int maxAlpha = MAX_ALPHA;

    @IdRes
    private int loadingDrawable;

    private int animationTime = PROGRESS_TIME;

    private int color;

    private int cornerRadius;

    private AnimatorSet indeterminateAnimator;

    public SimilarLoadingView(Context context) {
        super(context);
    }

    public SimilarLoadingView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SimilarLoadingView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initAttributes(attrs, defStyle);
        initPaint();
    }

    private void initAttributes(AttributeSet attrs, int defStyle) {
        final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SimilarLoadingView, defStyle, 0);
        animationTime = a.getInteger(R.styleable.SimilarLoadingView_similar_animDuration, PROGRESS_TIME);
        maxAlpha = a.getInteger(R.styleable.SimilarLoadingView_similar_maxAlpha, MAX_ALPHA);
        color = a.getColor(R.styleable.SimilarLoadingView_similar_color, Color.BLACK);
        cornerRadius = a.getInteger(R.styleable.SimilarLoadingView_similar_cornerRadius, 0);
        loadingDrawable = a.getResourceId(R.styleable.SimilarLoadingView_similar_loadingDrawable, -1);
        a.recycle();
    }

    private void initPaint() {
        paint.setAlpha(0);
        paint.setPathEffect(new CornerPathEffect(cornerRadius));
        paint.setColor(color);
        paint.setStyle(Paint.Style.FILL);
        paint.setAntiAlias(true);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        startAnimation();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        stopAnimation();
    }

    @Override
    public void setVisibility(int visibility) {
        int currentVisibility = getVisibility();
        super.setVisibility(visibility);
        if (visibility != currentVisibility) {
            if (visibility == View.VISIBLE) {
                resetAnimator();
            } else if (visibility == View.GONE || visibility == View.INVISIBLE) {
                stopAnimation();
            }
        }
    }

    private void startAnimation() {
        resetAnimator();
    }

    private void stopAnimation() {
        actualProgress = 0;
        if (indeterminateAnimator != null) {
            indeterminateAnimator.cancel();
            indeterminateAnimator = null;
        }
    }

    private void resetAnimator() {
        if (indeterminateAnimator != null && indeterminateAnimator.isRunning()) {
            indeterminateAnimator.cancel();
        }
        ValueAnimator progressAnimator = ValueAnimator.ofFloat(0, MAX_PROGRESS_VALUE);
        progressAnimator.setDuration(animationTime);
        progressAnimator.setInterpolator(new LinearInterpolator());
        progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                actualProgress = (Float) animation.getAnimatedValue();
                invalidate();
            }
        });
        indeterminateAnimator = new AnimatorSet();
        indeterminateAnimator.play(progressAnimator);
        indeterminateAnimator.addListener(new AnimatorListenerAdapter() {

            boolean wasCancelled = false;

            @Override
            public void onAnimationCancel(Animator animation) {
                wasCancelled = true;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!wasCancelled) {
                    resetAnimator();
                }
            }
        });
        indeterminateAnimator.start();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        double viewWidth = MeasureSpec.getSize(widthMeasureSpec);
        double viewHeight = MeasureSpec.getSize(heightMeasureSpec);
        double widthC = convertDpToPixel(200, getRootView().getContext()) / viewWidth;
        double heightC = convertDpToPixel(220, getRootView().getContext()) / viewHeight;
        hexWidth = (viewWidth / 4.125 * widthC);
        hexHeight = (viewHeight / 3.5 * heightC);
        hexPadding = viewHeight / 23;
        setMeasuredDimension((int) (viewWidth / 1.385 * widthC), (int) (viewHeight * heightC));
    }

    @SuppressLint("DrawAllocation")
    @Override
    protected void onDraw(Canvas canvas) {
        paint.setShader(new BitmapShader(BitmapFactory.decodeResource(getResources(), getHexagonImage(1)), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
        // 1
        Path hexPath = hiveRect(hexWidth / 2, hexPadding, hexWidth * 3 / 2, hexHeight + hexPadding);
        paint.setAlpha(getAlpha(1, actualProgress));
        canvas.drawPath(hexPath, paint);
        // 2
        hexPath = hiveRect(hexWidth * 3 / 2, hexPadding, hexWidth * 5 / 2, hexHeight + hexPadding);
        paint.setAlpha(getAlpha(2, actualProgress));
        canvas.drawPath(hexPath, paint);
        // 6
        hexPath = hiveRect(0, hexHeight * 3 / 4 + hexPadding, hexWidth, hexHeight * 7 / 4 + hexPadding);
        paint.setAlpha(getAlpha(6, actualProgress));
        canvas.drawPath(hexPath, paint);
        // 7
        hexPath = hiveRect(hexWidth, hexHeight * 3 / 4 + hexPadding, hexWidth * 2, hexHeight * 7 / 4 + hexPadding);
        paint.setAlpha(getAlpha(7, actualProgress));
        canvas.drawPath(hexPath, paint);
        // 3
        hexPath = hiveRect(hexWidth * 2, hexHeight * 3 / 4 + hexPadding, hexWidth * 3, hexHeight * 7 / 4 + hexPadding);
        paint.setAlpha(getAlpha(3, actualProgress));
        canvas.drawPath(hexPath, paint);
        // 5
        hexPath = hiveRect(hexWidth / 2, hexHeight * 6 / 4 + hexPadding, hexWidth * 3 / 2, hexHeight * 10 / 4 + hexPadding);
        paint.setAlpha(getAlpha(5, actualProgress));
        canvas.drawPath(hexPath, paint);
        // 4
        hexPath = hiveRect(hexWidth * 3 / 2, hexHeight * 6 / 4 + hexPadding, hexWidth * 5 / 2, hexHeight * 10 / 4 + hexPadding);
        paint.setAlpha(getAlpha(4, actualProgress));
        canvas.drawPath(hexPath, paint);
    }

    private int getHexagonImage(int position) {
        if (position <= 1) {
            return loadingDrawable;
        } else {
            return color;
        }
    }

    private int getAlpha(int num, float progress) {
        float alpha;
        if (progress > num * 100) {
            alpha = maxAlpha;
        } else {
            int min = (num - 1) * 100;
            alpha = (progress - min) > 0 ? progress - min : 0;
            alpha = alpha * maxAlpha / 100;
        }
        if (progress > 700) {
            float fadeProgress = progress - 700;
            if (fadeProgress > num * 100) {
                alpha = 0;
            } else {
                int min = (num - 1) * 100;
                alpha = (fadeProgress - min) > 0 ? fadeProgress - min : 0;
                alpha = maxAlpha - alpha * maxAlpha / 100;
            }
        }
        if (progress > 1400) {
            alpha = 0;
        }
        return (int) alpha;
    }

    private Path hiveRect(double left, double top, double right, double bottom) {
        Path path = new Path();
        double height = Math.abs(bottom - top);
        double width = Math.abs(right - left);
        double r = width > height ? height : width;
        r = r / 2;
        float x = (float) ((right - left) / 2 + left);
        float y = (float) top;
        int edge = (int) (r * Math.sqrt(3) / 2);
        path.moveTo(x, y);
        x = x + edge;
        y = (float) (y + r / 2);
        path.lineTo(x, y);
        y = (float) (y + r);
        path.lineTo(x, y);
        x = x - edge;
        y = (float) (y + r / 2);
        path.lineTo(x, y);
        x = x - edge;
        y = (float) (y - r / 2);
        path.lineTo(x, y);
        y = (float) (y - r);
        path.lineTo(x, y);
        path.close();
        return path;
    }

    public static float convertDpToPixel(float dp, Context context) {
        Resources resources = context.getResources();
        DisplayMetrics metrics = resources.getDisplayMetrics();
        float px = dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
        return px;
    }
}

19 Source : NavOptions.java
with Apache License 2.0
from lulululbj

/**
 * NavOptions stores special options for navigate actions
 */
public clreplaced NavOptions {

    static final int LAUNCH_SINGLE_TOP = 0x1;

    static final int LAUNCH_DOreplacedENT = 0x2;

    static final int LAUNCH_CLEAR_TASK = 0x4;

    private static final String KEY_NAV_OPTIONS = "android-support-nav:navOptions";

    private static final String KEY_LAUNCH_MODE = "launchMode";

    private static final String KEY_POP_UP_TO = "popUpTo";

    private static final String KEY_POP_UP_TO_INCLUSIVE = "popUpToInclusive";

    private static final String KEY_ENTER_ANIM = "enterAnim";

    private static final String KEY_EXIT_ANIM = "exitAnim";

    private static final String KEY_POP_ENTER_ANIM = "popEnterAnim";

    private static final String KEY_POP_EXIT_ANIM = "popExitAnim";

    /**
     * Add the {@link #getPopEnterAnim() pop enter} and {@link #getPopExitAnim() pop exit}
     * animation to an Intent for later usage with
     * {@link #applyPopAnimationsToPendingTransition(Activity)}.
     * <p>
     * This is automatically called for you by {@link ActivityNavigator}.
     * </p>
     *
     * @param intent Intent being started with the given NavOptions
     * @param navOptions NavOptions containing the pop animations.
     * @see #applyPopAnimationsToPendingTransition(Activity)
     * @see #getPopEnterAnim()
     * @see #getPopExitAnim()
     */
    public static void addPopAnimationsToIntent(@NonNull Intent intent, @Nullable NavOptions navOptions) {
        if (navOptions != null) {
            intent.putExtra(KEY_NAV_OPTIONS, navOptions.toBundle());
        }
    }

    /**
     * Apply any pop animations in the Intent of the given Activity to a pending transition.
     * This should be used in place of  {@link Activity#overridePendingTransition(int, int)}
     * to get the appropriate pop animations.
     * @param activity An activity started from the {@link ActivityNavigator}.
     * @see #addPopAnimationsToIntent(Intent, NavOptions)
     * @see #getPopEnterAnim()
     * @see #getPopExitAnim()
     */
    public static void applyPopAnimationsToPendingTransition(@NonNull Activity activity) {
        Intent intent = activity.getIntent();
        if (intent == null) {
            return;
        }
        Bundle bundle = intent.getBundleExtra(KEY_NAV_OPTIONS);
        if (bundle != null) {
            NavOptions navOptions = NavOptions.fromBundle(bundle);
            int popEnterAnim = navOptions.getPopEnterAnim();
            int popExitAnim = navOptions.getPopExitAnim();
            if (popEnterAnim != -1 || popExitAnim != -1) {
                popEnterAnim = popEnterAnim != -1 ? popEnterAnim : 0;
                popExitAnim = popExitAnim != -1 ? popExitAnim : 0;
                activity.overridePendingTransition(popEnterAnim, popExitAnim);
            }
        }
    }

    private int mLaunchMode;

    @IdRes
    private int mPopUpTo;

    private boolean mPopUpToInclusive;

    @AnimRes
    @AnimatorRes
    private int mEnterAnim;

    @AnimRes
    @AnimatorRes
    private int mExitAnim;

    @AnimRes
    @AnimatorRes
    private int mPopEnterAnim;

    @AnimRes
    @AnimatorRes
    private int mPopExitAnim;

    NavOptions(int launchMode, @IdRes int popUpTo, boolean popUpToInclusive, @AnimRes @AnimatorRes int enterAnim, @AnimRes @AnimatorRes int exitAnim, @AnimRes @AnimatorRes int popEnterAnim, @AnimRes @AnimatorRes int popExitAnim) {
        mLaunchMode = launchMode;
        mPopUpTo = popUpTo;
        mPopUpToInclusive = popUpToInclusive;
        mEnterAnim = enterAnim;
        mExitAnim = exitAnim;
        mPopEnterAnim = popEnterAnim;
        mPopExitAnim = popExitAnim;
    }

    /**
     * Whether this navigation action should launch as single-top (i.e., there will be at most
     * one copy of a given destination on the top of the back stack).
     * <p>
     * This functions similarly to how {@link android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP}
     * works with activites.
     */
    public boolean shouldLaunchSingleTop() {
        return (mLaunchMode & LAUNCH_SINGLE_TOP) != 0;
    }

    /**
     * Whether this navigation action should launch the destination in a new doreplacedent.
     * <p>
     * This functions similarly to how {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOreplacedENT}
     * works with activites.
     * @deprecated As per the {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOreplacedENT}
     * doreplacedentation, it is recommended to use {@link android.R.attr#doreplacedentLaunchMode} on an
     * Activity you wish to launch as a new doreplacedent.
     */
    @Deprecated
    public boolean shouldLaunchDoreplacedent() {
        return (mLaunchMode & LAUNCH_DOreplacedENT) != 0;
    }

    /**
     * Whether this navigation action should clear the entire back stack
     * <p>
     * This functions similarly to how {@link android.content.Intent#FLAG_ACTIVITY_CLEAR_TASK}
     * works with activites.
     * @deprecated This is synonymous with {@link #getPopUpTo()} with the root of the graph and
     * using {@link #isPopUpToInclusive()}.
     */
    @Deprecated
    public boolean shouldClearTask() {
        return (mLaunchMode & LAUNCH_CLEAR_TASK) != 0;
    }

    /**
     * The destination to pop up to before navigating. When set, all non-matching destinations
     * should be popped from the back stack.
     * @return the destinationId to pop up to, clearing all intervening destinations
     * @see Builder#setPopUpTo
     * @see #isPopUpToInclusive
     */
    @IdRes
    public int getPopUpTo() {
        return mPopUpTo;
    }

    /**
     * Whether the destination set in {@link #getPopUpTo} should be popped from the back stack.
     * @see Builder#setPopUpTo
     * @see #getPopUpTo
     */
    public boolean isPopUpToInclusive() {
        return mPopUpToInclusive;
    }

    /**
     * The custom enter Animation/Animator that should be run.
     * @return the resource id of a Animation or Animator or -1 if none.
     */
    @AnimRes
    @AnimatorRes
    public int getEnterAnim() {
        return mEnterAnim;
    }

    /**
     * The custom exit Animation/Animator that should be run.
     * @return the resource id of a Animation or Animator or -1 if none.
     */
    @AnimRes
    @AnimatorRes
    public int getExitAnim() {
        return mExitAnim;
    }

    /**
     * The custom enter Animation/Animator that should be run when this destination is
     * popped from the back stack.
     * @return the resource id of a Animation or Animator or -1 if none.
     * @see #applyPopAnimationsToPendingTransition(Activity)
     */
    @AnimRes
    @AnimatorRes
    public int getPopEnterAnim() {
        return mPopEnterAnim;
    }

    /**
     * The custom exit Animation/Animator that should be run when this destination is
     * popped from the back stack.
     * @return the resource id of a Animation or Animator or -1 if none.
     * @see #applyPopAnimationsToPendingTransition(Activity)
     */
    @AnimRes
    @AnimatorRes
    public int getPopExitAnim() {
        return mPopExitAnim;
    }

    @NonNull
    private Bundle toBundle() {
        Bundle b = new Bundle();
        b.putInt(KEY_LAUNCH_MODE, mLaunchMode);
        b.putInt(KEY_POP_UP_TO, mPopUpTo);
        b.putBoolean(KEY_POP_UP_TO_INCLUSIVE, mPopUpToInclusive);
        b.putInt(KEY_ENTER_ANIM, mEnterAnim);
        b.putInt(KEY_EXIT_ANIM, mExitAnim);
        b.putInt(KEY_POP_ENTER_ANIM, mPopEnterAnim);
        b.putInt(KEY_POP_EXIT_ANIM, mPopExitAnim);
        return b;
    }

    @NonNull
    private static NavOptions fromBundle(@NonNull Bundle b) {
        return new NavOptions(b.getInt(KEY_LAUNCH_MODE, 0), b.getInt(KEY_POP_UP_TO, 0), b.getBoolean(KEY_POP_UP_TO_INCLUSIVE, false), b.getInt(KEY_ENTER_ANIM, -1), b.getInt(KEY_EXIT_ANIM, -1), b.getInt(KEY_POP_ENTER_ANIM, -1), b.getInt(KEY_POP_EXIT_ANIM, -1));
    }

    /**
     * Builder for constructing new instances of NavOptions.
     */
    public static clreplaced Builder {

        int mLaunchMode;

        @IdRes
        int mPopUpTo;

        boolean mPopUpToInclusive;

        @AnimRes
        @AnimatorRes
        int mEnterAnim = -1;

        @AnimRes
        @AnimatorRes
        int mExitAnim = -1;

        @AnimRes
        @AnimatorRes
        int mPopEnterAnim = -1;

        @AnimRes
        @AnimatorRes
        int mPopExitAnim = -1;

        public Builder() {
        }

        /**
         * Launch a navigation target as single-top if you are making a lateral navigation
         * between instances of the same target (e.g. detail pages about similar data items)
         * that should not preserve history.
         *
         * @param singleTop true to launch as single-top
         */
        @NonNull
        public Builder setLaunchSingleTop(boolean singleTop) {
            if (singleTop) {
                mLaunchMode |= LAUNCH_SINGLE_TOP;
            } else {
                mLaunchMode &= ~LAUNCH_SINGLE_TOP;
            }
            return this;
        }

        /**
         * Launch a navigation target as a doreplacedent if you want it to appear as its own
         * entry in the system Overview screen. If the same doreplacedent is launched multiple times
         * it will not create a new task, it will bring the existing doreplacedent task to the front.
         *
         * <p>If the user presses the system Back key from a new doreplacedent task they will land
         * on their previous task. If the user reached the doreplacedent task from the system Overview
         * screen they will be taken to their home screen.</p>
         *
         * @param launchDoreplacedent true to launch a new doreplacedent task
         * @deprecated As per the {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOreplacedENT}
         * doreplacedentation, it is recommended to use {@link android.R.attr#doreplacedentLaunchMode} on an
         * Activity you wish to launch as a new doreplacedent.
         */
        @Deprecated
        @NonNull
        public Builder setLaunchDoreplacedent(boolean launchDoreplacedent) {
            if (launchDoreplacedent) {
                mLaunchMode |= LAUNCH_DOreplacedENT;
            } else {
                mLaunchMode &= ~LAUNCH_DOreplacedENT;
            }
            return this;
        }

        /**
         * Clear the entire task before launching this target. If you are launching as a
         * {@link #setLaunchDoreplacedent(boolean) doreplacedent}, this will clear the doreplacedent task.
         * Otherwise it will clear the current task.
         *
         * @param clearTask
         * @return
         * @deprecated Use {@link #setPopUpTo(int, boolean)} with the
         * {@link NavDestination#getId() id} of the
         * {@link androidx.navigation.NavController#getGraph() NavController's graph}
         * and set inclusive to true.
         */
        @Deprecated
        @NonNull
        public Builder setClearTask(boolean clearTask) {
            if (clearTask) {
                mLaunchMode |= LAUNCH_CLEAR_TASK;
            } else {
                mLaunchMode &= ~LAUNCH_CLEAR_TASK;
            }
            return this;
        }

        /**
         * Pop up to a given destination before navigating. This pops all non-matching destinations
         * from the back stack until this destination is found.
         *
         * @param destinationId The destination to pop up to, clearing all intervening destinations.
         * @param inclusive true to also pop the given destination from the back stack.
         * @return this Builder
         * @see NavOptions#getPopUpTo
         * @see NavOptions#isPopUpToInclusive
         */
        @NonNull
        public Builder setPopUpTo(@IdRes int destinationId, boolean inclusive) {
            mPopUpTo = destinationId;
            mPopUpToInclusive = inclusive;
            return this;
        }

        /**
         * Sets a custom Animation or Animator resource for the enter animation.
         *
         * <p>Note: Animator resources are not supported for navigating to a new Activity</p>
         * @param enterAnim Custom animation to run
         * @return this Builder
         * @see NavOptions#getEnterAnim()
         */
        @NonNull
        public Builder setEnterAnim(@AnimRes @AnimatorRes int enterAnim) {
            mEnterAnim = enterAnim;
            return this;
        }

        /**
         * Sets a custom Animation or Animator resource for the exit animation.
         *
         * <p>Note: Animator resources are not supported for navigating to a new Activity</p>
         * @param exitAnim Custom animation to run
         * @return this Builder
         * @see NavOptions#getExitAnim()
         */
        @NonNull
        public Builder setExitAnim(@AnimRes @AnimatorRes int exitAnim) {
            mExitAnim = exitAnim;
            return this;
        }

        /**
         * Sets a custom Animation or Animator resource for the enter animation
         * when popping off the back stack.
         *
         * <p>Note: Animator resources are not supported for navigating to a new Activity</p>
         * @param popEnterAnim Custom animation to run
         * @return this Builder
         * @see NavOptions#getPopEnterAnim()
         */
        @NonNull
        public Builder setPopEnterAnim(@AnimRes @AnimatorRes int popEnterAnim) {
            mPopEnterAnim = popEnterAnim;
            return this;
        }

        /**
         * Sets a custom Animation or Animator resource for the exit animation
         * when popping off the back stack.
         *
         * <p>Note: Animator resources are not supported for navigating to a new Activity</p>
         * @param popExitAnim Custom animation to run
         * @return this Builder
         * @see NavOptions#getPopExitAnim()
         */
        @NonNull
        public Builder setPopExitAnim(@AnimRes @AnimatorRes int popExitAnim) {
            mPopExitAnim = popExitAnim;
            return this;
        }

        /**
         * @return a constructed NavOptions
         */
        @NonNull
        public NavOptions build() {
            return new NavOptions(mLaunchMode, mPopUpTo, mPopUpToInclusive, mEnterAnim, mExitAnim, mPopEnterAnim, mPopExitAnim);
        }
    }
}

19 Source : NavOptions.java
with Apache License 2.0
from lulululbj

/**
 * The destination to pop up to before navigating. When set, all non-matching destinations
 * should be popped from the back stack.
 * @return the destinationId to pop up to, clearing all intervening destinations
 * @see Builder#setPopUpTo
 * @see #isPopUpToInclusive
 */
@IdRes
public int getPopUpTo() {
    return mPopUpTo;
}

19 Source : NavGraph.java
with Apache License 2.0
from lulululbj

/**
 * Returns the starting destination for this NavGraph. When navigating to the NavGraph, this
 * destination is the one the user will initially see.
 * @return
 */
@IdRes
public int getStartDestination() {
    return mStartDestId;
}

19 Source : NavDestination.java
with Apache License 2.0
from lulululbj

/**
 * Returns the destination's unique ID. This should be an ID resource generated by
 * the Android resource system.
 *
 * @return this destination's ID
 */
@IdRes
public int getId() {
    return mId;
}

19 Source : NavAction.java
with Apache License 2.0
from lulululbj

/**
 * Navigation actions provide a level of indirection between your navigation code and the
 * underlying destinations. This allows you to define common actions that change their destination
 * or {@link NavOptions} based on the current {@link NavDestination}.
 *
 * <p>The {@link NavOptions} replacedociated with a NavAction are used by default when navigating
 * to this action via {@link NavController#navigate(int)} or
 * {@link NavController#navigate(int, Bundle)}.</p>
 *
 * <p>Actions should be added via {@link NavDestination#putAction(int, int)} or
 * {@link NavDestination#putAction(int, NavAction)}.</p>
 */
public clreplaced NavAction {

    @IdRes
    private final int mDestinationId;

    private NavOptions mNavOptions;

    /**
     * Creates a new NavAction for the given destination.
     *
     * @param destinationId the ID of the destination that should be navigated to when this
     *                      action is used.
     */
    public NavAction(@IdRes int destinationId) {
        this(destinationId, null);
    }

    /**
     * Creates a new NavAction for the given destination.
     *
     * @param destinationId the ID of the destination that should be navigated to when this
     *                      action is used.
     * @param navOptions special options for this action that should be used by default
     */
    public NavAction(@IdRes int destinationId, @Nullable NavOptions navOptions) {
        mDestinationId = destinationId;
        mNavOptions = navOptions;
    }

    /**
     * Gets the ID of the destination that should be navigated to when this action is used
     */
    public int getDestinationId() {
        return mDestinationId;
    }

    /**
     * Sets the NavOptions to be used by default when navigating to this action.
     *
     * @param navOptions special options for this action that should be used by default
     */
    public void setNavOptions(@Nullable NavOptions navOptions) {
        mNavOptions = navOptions;
    }

    /**
     * Gets the NavOptions to be used by default when navigating to this action.
     */
    @Nullable
    public NavOptions getNavOptions() {
        return mNavOptions;
    }
}

19 Source : WebParentLayout.java
with Apache License 2.0
from Justson

/**
 * @author cenxiaozhong
 * @date 2017/12/8
 * @since 3.0.0
 */
public clreplaced WebParentLayout extends FrameLayout implements Provider<AbsAgentWebUIController> {

    private AbsAgentWebUIController mAgentWebUIController = null;

    private static final String TAG = WebParentLayout.clreplaced.getSimpleName();

    @LayoutRes
    private int mErrorLayoutRes;

    @IdRes
    private int mClickId = -1;

    private View mErrorView;

    private WebView mWebView;

    private FrameLayout mErrorLayout = null;

    WebParentLayout(@NonNull Context context) {
        this(context, null);
        LogUtils.i(TAG, "WebParentLayout");
    }

    WebParentLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, -1);
    }

    WebParentLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        if (!(context instanceof Activity)) {
            throw new IllegalArgumentException("WebParentLayout context must be activity or activity sub clreplaced .");
        }
        this.mErrorLayoutRes = R.layout.agentweb_error_page;
    }

    void bindController(AbsAgentWebUIController agentWebUIController) {
        this.mAgentWebUIController = agentWebUIController;
        this.mAgentWebUIController.bindWebParent(this, (Activity) getContext());
    }

    void showPageMainFrameError() {
        View container = this.mErrorLayout;
        if (container != null) {
            container.setVisibility(View.VISIBLE);
        } else {
            createErrorLayout();
            container = this.mErrorLayout;
        }
        View clickView = null;
        if (mClickId != -1 && (clickView = container.findViewById(mClickId)) != null) {
            clickView.setClickable(true);
        } else {
            container.setClickable(true);
        }
    }

    private void createErrorLayout() {
        final FrameLayout mFrameLayout = new FrameLayout(getContext());
        mFrameLayout.setBackgroundColor(Color.WHITE);
        mFrameLayout.setId(R.id.mainframe_error_container_id);
        if (this.mErrorView == null) {
            LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
            LogUtils.i(TAG, "mErrorLayoutRes:" + mErrorLayoutRes);
            mLayoutInflater.inflate(mErrorLayoutRes, mFrameLayout, true);
        } else {
            mFrameLayout.addView(mErrorView);
        }
        ViewStub mViewStub = (ViewStub) this.findViewById(R.id.mainframe_error_viewsub_id);
        final int index = this.indexOfChild(mViewStub);
        this.removeViewInLayout(mViewStub);
        final ViewGroup.LayoutParams layoutParams = getLayoutParams();
        if (layoutParams != null) {
            this.addView(this.mErrorLayout = mFrameLayout, index, layoutParams);
        } else {
            this.addView(this.mErrorLayout = mFrameLayout, index);
        }
        mFrameLayout.setVisibility(View.VISIBLE);
        if (mClickId != -1) {
            final View clickView = mFrameLayout.findViewById(mClickId);
            if (clickView != null) {
                clickView.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        if (getWebView() != null) {
                            clickView.setClickable(false);
                            getWebView().reload();
                        }
                    }
                });
                return;
            } else {
                if (LogUtils.isDebug()) {
                    LogUtils.e(TAG, "ClickView is null , cannot bind accurate view to refresh or reload .");
                }
            }
        }
        mFrameLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (getWebView() != null) {
                    mFrameLayout.setClickable(false);
                    getWebView().reload();
                }
            }
        });
    }

    void hideErrorLayout() {
        View mView = null;
        if ((mView = this.findViewById(R.id.mainframe_error_container_id)) != null) {
            mView.setVisibility(View.GONE);
        }
    }

    void setErrorView(@NonNull View errorView) {
        this.mErrorView = errorView;
    }

    void setErrorLayoutRes(@LayoutRes int resLayout, @IdRes int id) {
        this.mClickId = id;
        if (this.mClickId <= 0) {
            this.mClickId = -1;
        }
        this.mErrorLayoutRes = resLayout;
        if (this.mErrorLayoutRes <= 0) {
            this.mErrorLayoutRes = R.layout.agentweb_error_page;
        }
    }

    @Override
    public AbsAgentWebUIController provide() {
        return this.mAgentWebUIController;
    }

    void bindWebView(WebView view) {
        if (this.mWebView == null) {
            this.mWebView = view;
        }
    }

    WebView getWebView() {
        return this.mWebView;
    }
}

19 Source : BaseDialogConfig.java
with MIT License
from jenly1314

/**
 * @author Jenly <a href="mailto:[email protected]">Jenly</a>
 */
public clreplaced BaseDialogConfig {

    /**
     * 布局ID
     */
    @LayoutRes
    int layoutId;

    /**
     * 标题视图ID
     */
    @IdRes
    int replacedleId = R.id.tvDialogreplacedle;

    /**
     * 内容视图ID
     */
    @IdRes
    int contentId = R.id.tvDialogContent;

    /**
     * 取消视图ID(左边按钮)
     */
    @IdRes
    int cancelId = R.id.btnDialogCancel;

    /**
     * 确定视图ID(右边按钮)
     */
    @IdRes
    int okId = R.id.btnDialogOK;

    /**
     * 按钮中间分割线ID
     */
    @IdRes
    int lineId = R.id.line;

    /**
     * 样式ID
     */
    @StyleRes
    int styleId = R.style.app_dialog;

    /**
     * 标题文本
     */
    CharSequence replacedle;

    /**
     * 内容文本
     */
    CharSequence content;

    /**
     * 取消按钮文本
     */
    CharSequence cancel;

    /**
     * 确定按钮文本
     */
    CharSequence ok;

    /**
     * 是否隐藏取消按钮,如果隐藏取消则底部只显示一个按钮
     */
    boolean isHideCancel;

    /**
     * 是否隐藏标题
     */
    boolean isHidereplacedle;

    View.OnClickListener onClickCancel;

    View.OnClickListener onClickOk;

    public BaseDialogConfig() {
        this(R.layout.app_dialog);
    }

    public BaseDialogConfig(@LayoutRes int layoutId) {
        this.layoutId = layoutId;
    }

    @LayoutRes
    public int getLayoutId() {
        return layoutId;
    }

    /**
     * @param layoutId
     * @return
     * @deprecated 即将废弃,下一个版本可能会移除此方法
     */
    @Deprecated
    public BaseDialogConfig setLayoutId(@IdRes int layoutId) {
        this.layoutId = layoutId;
        return this;
    }

    public int getreplacedleId() {
        return replacedleId;
    }

    public BaseDialogConfig setreplacedleId(@IdRes int replacedleId) {
        this.replacedleId = replacedleId;
        return this;
    }

    public int getStyleId() {
        return styleId;
    }

    public BaseDialogConfig setStyleId(@IdRes int styleId) {
        this.styleId = styleId;
        return this;
    }

    @IdRes
    public int getContentId() {
        return contentId;
    }

    public BaseDialogConfig setContentId(@IdRes int contentId) {
        this.contentId = contentId;
        return this;
    }

    @IdRes
    public int getCancelId() {
        return cancelId;
    }

    public BaseDialogConfig setCancelId(@IdRes int cancelId) {
        this.cancelId = cancelId;
        return this;
    }

    @IdRes
    public int getOkId() {
        return okId;
    }

    public BaseDialogConfig setOkId(@IdRes int okId) {
        this.okId = okId;
        return this;
    }

    @IdRes
    public int getLineId() {
        return lineId;
    }

    public BaseDialogConfig setLineId(@IdRes int lineId) {
        this.lineId = lineId;
        return this;
    }

    public CharSequence getreplacedle() {
        return replacedle;
    }

    public BaseDialogConfig setreplacedle(CharSequence replacedle) {
        this.replacedle = replacedle;
        return this;
    }

    public BaseDialogConfig setreplacedle(@NonNull Context context, @StringRes int resId) {
        this.replacedle = context.getString(resId);
        return this;
    }

    public CharSequence getContent() {
        return content;
    }

    public BaseDialogConfig setContent(CharSequence content) {
        this.content = content;
        return this;
    }

    public CharSequence getCancel() {
        return cancel;
    }

    public BaseDialogConfig setCancel(CharSequence cancel) {
        this.cancel = cancel;
        return this;
    }

    public BaseDialogConfig setCancel(@NonNull Context context, @StringRes int resId) {
        this.cancel = context.getString(resId);
        return this;
    }

    public CharSequence getOk() {
        return ok;
    }

    public BaseDialogConfig setOk(CharSequence ok) {
        this.ok = ok;
        return this;
    }

    public BaseDialogConfig setOk(@NonNull Context context, @StringRes int resId) {
        this.ok = context.getString(resId);
        return this;
    }

    public boolean isHideCancel() {
        return isHideCancel;
    }

    public BaseDialogConfig setHideCancel(boolean hideCancel) {
        isHideCancel = hideCancel;
        return this;
    }

    public boolean isHidereplacedle() {
        return isHidereplacedle;
    }

    public BaseDialogConfig setHidereplacedle(boolean hidereplacedle) {
        isHidereplacedle = hidereplacedle;
        return this;
    }

    public View.OnClickListener getOnClickCancel() {
        return onClickCancel;
    }

    /**
     * 设置“取消”按钮点击监听,不设置默认点击关闭弹框
     * @param onClickCancel
     * @return
     */
    public BaseDialogConfig setOnClickCancel(View.OnClickListener onClickCancel) {
        this.onClickCancel = onClickCancel;
        return this;
    }

    public View.OnClickListener getOnClickOk() {
        return onClickOk;
    }

    /**
     * 设置“确定”按钮点击监听,不设置默认点击关闭弹框
     * @param onClickOk
     * @return
     */
    public BaseDialogConfig setOnClickOk(View.OnClickListener onClickOk) {
        this.onClickOk = onClickOk;
        return this;
    }
}

19 Source : BaseDialogConfig.java
with MIT License
from jenly1314

@IdRes
public int getCancelId() {
    return cancelId;
}

19 Source : BaseDialogConfig.java
with MIT License
from jenly1314

@IdRes
public int getLineId() {
    return lineId;
}

19 Source : BaseDialogConfig.java
with MIT License
from jenly1314

@IdRes
public int getContentId() {
    return contentId;
}

19 Source : BaseDialogConfig.java
with MIT License
from jenly1314

@IdRes
public int getOkId() {
    return okId;
}

19 Source : NestedRadioButton.java
with Apache License 2.0
from jbvincey

/**
 * Created by jean-baptistevincey on 09/01/2018.
 *
 * <p>
 * A radio button is a two-states button that can be either checked or
 * unchecked. When the radio button is unchecked, the user can press or click it
 * to check it. However, contrary to a {@link android.widget.CheckBox}, a radio
 * button cannot be unchecked by the user once checked.
 * </p>
 *
 * <p>
 * Radio buttons are normally used together in a
 * {@link android.widget.RadioGroup}. When several radio buttons live inside
 * a radio group, checking one radio button unchecks all the others.</p>
 * </p>
 *
 * <p>See the <a href="{@docRoot}guide/topics/ui/controls/radiobutton.html">Radio Buttons</a>
 * guide.</p>
 *
 * The difference with RadioButton is that NestedRadioButton allows to have any number of ViewGroup
 * intermediates between your NestedRadioButton and NestedRadioGroup.
 */
public clreplaced NestedRadioButton extends AppCompatRadioButton {

    @IdRes
    private int clickableParentIdRes = View.NO_ID;

    public NestedRadioButton(@NonNull Context context) {
        super(context);
    }

    public NestedRadioButton(@NonNull Context context, @NonNull AttributeSet attrs) {
        super(context, attrs);
        initAttr(context, attrs);
    }

    public NestedRadioButton(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initAttr(context, attrs);
    }

    private void initAttr(@NonNull Context context, @NonNull AttributeSet attrs) {
        // retrieve selected radio button as requested by the user in the
        // XML layout file
        TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.NestedRadioButton);
        clickableParentIdRes = attributes.getResourceId(R.styleable.NestedRadioButton_clickableParent, View.NO_ID);
        attributes.recycle();
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        int id = getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            setId(id);
        }
        attachToParentNestedRadioGroup((View) getParent());
        if (clickableParentIdRes != View.NO_ID) {
            attachClickableParent((View) getParent());
        }
    }

    private void attachClickableParent(View view) {
        if (view != null) {
            if (view.getId() == clickableParentIdRes) {
                view.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        NestedRadioButton.this.setChecked(true);
                    }
                });
            } else if (view.getParent() instanceof View) {
                attachClickableParent((View) view.getParent());
            }
        }
    }

    private void attachToParentNestedRadioGroup(View view) {
        if (view == null) {
            throw new ClreplacedCastException("NestedRadioButton should be under a NestedRadioGroup");
        } else if (view instanceof NestedRadioGroupInterface) {
            ((NestedRadioGroupInterface) view).addNestedRadioButton(this);
        } else if (view.getParent() instanceof View) {
            attachToParentNestedRadioGroup((View) view.getParent());
        } else {
            throw new ClreplacedCastException("NestedRadioButton should be under a NestedRadioGroup");
        }
    }
}

19 Source : NavigationBundle.java
with Apache License 2.0
from harrylefit

/**
 * Created by harryle on 8/20/17.
 */
public clreplaced NavigationBundle {

    private int activeColor = Color.BLACK;

    private int inactiveColor = Color.GRAY;

    private boolean isScrollable;

    private int backgroundColor = Color.WHITE;

    private int textSize;

    private int defaultSelectedPosition = 0;

    private boolean enableRippleEffect = false;

    private int mode = 1;

    private boolean enableTintColor = true;

    private int sizeOfIcon;

    @IdRes
    private int fontFamily;

    private OnNavigationListener onNavigationListener;

    private ViewPager viewPager;

    private boolean hasNotification = false;

    private boolean hidereplacedle = false;

    public ViewPager getViewPager() {
        return viewPager;
    }

    public void setViewPager(ViewPager viewPager) {
        this.viewPager = viewPager;
    }

    public void setActiveColor(int activeColor) {
        this.activeColor = activeColor;
    }

    public void setInactiveColor(int inactiveColor) {
        this.inactiveColor = inactiveColor;
    }

    public void setScrollable(boolean scrollable) {
        isScrollable = scrollable;
    }

    public int getActiveColor() {
        return activeColor;
    }

    public int getInactiveColor() {
        return inactiveColor;
    }

    public boolean isScrollable() {
        return isScrollable;
    }

    public int getBackgroundColor() {
        return backgroundColor;
    }

    public void setBackgroundColor(int backgroundColor) {
        this.backgroundColor = backgroundColor;
    }

    public int getTextSize() {
        return textSize;
    }

    public void setTextSize(int textSize) {
        this.textSize = textSize;
    }

    public void setOnNavigationListener(OnNavigationListener onNavigationListener) {
        this.onNavigationListener = onNavigationListener;
    }

    public boolean isHasNotification() {
        return hasNotification;
    }

    public OnNavigationListener getOnNavigationListener() {
        return onNavigationListener;
    }

    public boolean isEnableRippleEffect() {
        return enableRippleEffect;
    }

    public void setEnableRippleEffect(boolean enableRippleEffect) {
        this.enableRippleEffect = enableRippleEffect;
    }

    public int getDefaultSelectedPosition() {
        return defaultSelectedPosition;
    }

    public void setDefaultSelectedPosition(int defaultSelectedPosition) {
        this.defaultSelectedPosition = defaultSelectedPosition;
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public int getFontFamily() {
        return fontFamily;
    }

    public void setFontFamily(int fontFamily) {
        this.fontFamily = fontFamily;
    }

    public boolean isEnableTintColor() {
        return enableTintColor;
    }

    public void setEnableTintColor(boolean enableTintColor) {
        this.enableTintColor = enableTintColor;
    }

    public void setHasNotification(boolean hasNotification) {
        this.hasNotification = hasNotification;
    }

    public boolean isHidereplacedle() {
        return hidereplacedle;
    }

    public void setHidereplacedle(boolean hidereplacedle) {
        this.hidereplacedle = hidereplacedle;
    }

    public int getSizeOfIcon() {
        return sizeOfIcon;
    }

    public void setSizeOfIcon(int sizeOfIcon) {
        this.sizeOfIcon = sizeOfIcon;
    }
}

19 Source : BaseSingleFragmentActivity.java
with GNU General Public License v3.0
from duyp

@IdRes
protected int getContainerId() {
    // return R.id.container;
    return 0;
}

19 Source : VerticalGateTransition.java
with Apache License 2.0
from Doctoror

/**
 * A {@link Transition} that slides upper view to top and bottom view to bottom
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public clreplaced VerticalGateTransition extends Transition {

    private static final String DUMMY_PROPERTY_NAME = "d";

    @IdRes
    private int mUpperViewId = R.id.appBar;

    @IdRes
    private int mBottomViewId = R.id.recyclerView;

    protected void setUpperViewId(@IdRes final int upperViewId) {
        mUpperViewId = upperViewId;
    }

    protected void setBottomViewId(@IdRes final int bottomViewId) {
        mBottomViewId = bottomViewId;
    }

    @Override
    public void captureStartValues(final TransitionValues transitionValues) {
        // Dummy property must be changed or else createAnimator() won't be called
        transitionValues.values.put(DUMMY_PROPERTY_NAME, "start");
    }

    @Override
    public void captureEndValues(final TransitionValues transitionValues) {
        // Dummy property must be changed or else createAnimator() won't be called
        transitionValues.values.put(DUMMY_PROPERTY_NAME, "end");
    }

    @Override
    public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues, final TransitionValues endValues) {
        final Collection<Animator> animators = new ArrayList<>(2);
        final View upperView = sceneRoot.findViewById(mUpperViewId);
        if (upperView != null) {
            animators.add(ObjectAnimator.ofFloat(upperView, ViewProperties.TRANSLATION_Y, 0, -upperView.getHeight()));
        }
        final View bottomView = sceneRoot.findViewById(mBottomViewId);
        if (bottomView != null) {
            final View bottomViewParent = (View) bottomView.getParent();
            if (bottomView.getHeight() <= bottomViewParent.getHeight()) {
                animators.add(ObjectAnimator.ofFloat(bottomView, ViewProperties.TRANSLATION_Y, 0, bottomViewParent.getHeight() - bottomView.getTop()));
            } else {
                animators.add(ObjectAnimator.ofFloat(bottomView, ViewProperties.TRANSLATION_Y, 0, bottomView.getHeight()));
            }
        }
        final AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        return animatorSet;
    }
}

18 Source : MainActivity.java
with GNU General Public License v3.0
from z-chu

/**
 * Created by Chu on 2016/11/30.
 */
public clreplaced MainActivity extends MvpActivity<MainContract.Presenter> implements MainContract.View, BottomNavigationView.OnNavigationItemSelectedListener, BookcaseFragment.OnBookCaseEditListener {

    static {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    }

    private BottomNavigationView bottomNavigation;

    @IdRes
    private int selectedTabId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.overridePendingTransition(0, 0);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bottomNavigation = (BottomNavigationView) findViewById(R.id.bottom_navigation);
        bottomNavigation.setOnNavigationItemSelectedListener(this);
        getPresenter().start();
        getPresenter().initContentContainer(getSupportFragmentManager(), R.id.content_view);
        if (savedInstanceState != null) {
            savedInstanceState.getInt("selectedTabId", R.id.tab_bookcase);
        } else {
            getPresenter().dispatchTabSelectedTabId(R.id.tab_bookcase);
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("selectedTabId", selectedTabId);
    }

    @NonNull
    @Override
    public MainContract.Presenter createPresenter() {
        return new MainPresenter();
    }

    @Override
    protected boolean isEnableSlideFinish() {
        return false;
    }

    @Override
    protected boolean isCountingPage() {
        return false;
    }

    @Override
    public void switchBookcase(@IdRes int tabId) {
        selectedTabId = tabId;
    }

    @Override
    public void switchExplore(@IdRes int tabId) {
        selectedTabId = tabId;
    }

    @Override
    public void switchMine(@IdRes int tabId) {
        selectedTabId = tabId;
    }

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        return getPresenter().dispatchTabSelectedTabId(item.gereplacedemId());
    }

    @Override
    public ViewGroup getBottomGroup() {
        return bottomNavigation;
    }

    private long exitTime = 0;

    @Override
    public void onBackPressed() {
        if (!BackHandlerHelper.handleBackPress(this)) {
            if ((System.currentTimeMillis() - exitTime) > 2000) {
                ToastUtil.showToast("再按一次退出");
                exitTime = System.currentTimeMillis();
            } else {
                super.onBackPressed();
            }
        }
    }
}

18 Source : MultiSheetView.java
with GNU General Public License v3.0
from timusus

@SuppressLint("DefaultLocale")
@IdRes
public int getSheetPeekViewResId(@Sheet int sheet) {
    switch(sheet) {
        case Sheet.FIRST:
            return R.id.sheet1PeekView;
        case Sheet.SECOND:
            return R.id.sheet2PeekView;
    }
    throw new IllegalStateException(String.format("No peek view resId found for sheet: %d", sheet));
}

18 Source : MultiSheetView.java
with GNU General Public License v3.0
from timusus

@SuppressLint("DefaultLocale")
@IdRes
public int getSheetContainerViewResId(@Sheet int sheet) {
    switch(sheet) {
        case Sheet.FIRST:
            return R.id.sheet1Container;
        case Sheet.SECOND:
            return R.id.sheet2Container;
    }
    throw new IllegalStateException(String.format("No container view resId found for sheet: %d", sheet));
}

18 Source : FragmentSatellite.java
with MIT License
from st235

/**
 * Satellite which works with fragment stack.
 */
public final clreplaced FragmentSatellite implements Satellite {

    @IdRes
    private final int containerId;

    @NonNull
    private final FragmentManager fragmentManager;

    public FragmentSatellite(@IdRes int containerId, @NonNull FragmentManager fragmentManager) {
        this.containerId = containerId;
        this.fragmentManager = fragmentManager;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int getType() {
        return SatelliteTypes.FRAGMENT;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void execute(@NonNull Command command) {
        if (!isApplicable(command))
            throw new CommandNotSupportedException("Fragment group");
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction = ((FragmentCommand) command).apply(containerId, transaction);
        transaction.commit();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isApplicable(@NonNull Command command) {
        return command instanceof FragmentCommand;
    }
}

18 Source : GridPickerView.java
with Apache License 2.0
from philliphsu

/**
 * View to show a 4 x 3 grid of text buttons.
 */
public clreplaced GridPickerView extends GridLayout {

    @IdRes
    private static final int[] TEXTVIEW_IDS = { R.id.nptp_text0, R.id.nptp_text1, R.id.nptp_text2, R.id.nptp_text3, R.id.nptp_text4, R.id.nptp_text5, R.id.nptp_text6, R.id.nptp_text7, R.id.nptp_text8, R.id.nptp_text9, R.id.nptp_text10, R.id.nptp_text11 };

    private final TextView[] TEXTVIEWS = new TextView[12];

    public GridPickerView(Context context) {
        this(context, null);
    }

    public GridPickerView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public GridPickerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setColumnCount(context.getResources().getInteger(R.integer.nptp_gridpicker_column_count));
        inflate(context, R.layout.nptp_gridpicker_text_buttons, this);
        for (int i = 0; i < 12; i++) {
            TEXTVIEWS[i] = (TextView) findViewById(TEXTVIEW_IDS[i]);
        }
    }

    protected final void setOnButtonClickListener(OnClickListener l) {
        for (int i = 0; i < 12; i++) {
            TEXTVIEWS[i].setOnClickListener(l);
        }
    }

    /**
     * @param i     A position from {@code 0 <= i < 12}.
     * @param text  The text to be displayed at position i.
     */
    protected final void setTextForPosition(int i, @Nullable CharSequence text) {
        TEXTVIEWS[i].setText(text);
    }

    /**
     * @param i  A position from {@code 0 <= i < 12}.
     */
    protected final TextView getButton(int i) {
        return TEXTVIEWS[i];
    }
}

18 Source : GridPickerView.java
with Apache License 2.0
from philliphsu

/**
 * View to show a 4 x 3 grid of text buttons.
 */
public clreplaced GridPickerView extends GridLayout {

    @IdRes
    private static final int[] TEXTVIEW_IDS = { R.id.bsp_text0, R.id.bsp_text1, R.id.bsp_text2, R.id.bsp_text3, R.id.bsp_text4, R.id.bsp_text5, R.id.bsp_text6, R.id.bsp_text7, R.id.bsp_text8, R.id.bsp_text9, R.id.bsp_text10, R.id.bsp_text11 };

    private final TextView[] TEXTVIEWS = new TextView[12];

    public GridPickerView(Context context) {
        this(context, null);
    }

    public GridPickerView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public GridPickerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setColumnCount(context.getResources().getInteger(R.integer.bsp_gridpicker_column_count));
        inflate(context, R.layout.bsp_gridpicker_text_buttons, this);
        for (int i = 0; i < 12; i++) {
            TEXTVIEWS[i] = (TextView) findViewById(TEXTVIEW_IDS[i]);
        }
    }

    protected final void setOnButtonClickListener(OnClickListener l) {
        for (int i = 0; i < 12; i++) {
            TEXTVIEWS[i].setOnClickListener(l);
        }
    }

    /**
     * @param i     A position from {@code 0 <= i < 12}.
     * @param text  The text to be displayed at position i.
     */
    protected final void setTextForPosition(int i, @Nullable CharSequence text) {
        TEXTVIEWS[i].setText(text);
    }

    /**
     * @param i  A position from {@code 0 <= i < 12}.
     */
    protected final TextView getButton(int i) {
        return TEXTVIEWS[i];
    }
}

18 Source : SettingsObject.java
with Apache License 2.0
from or-dvir

/**
 * @param <V> the type of value for this object to save (String/Integer/Float...)
 *           NOTE: must be a value which can be saved in {@link android.content.SharedPreferences}
 */
@SuppressWarnings("PointlessBooleanExpression")
public abstract clreplaced SettingsObject<V> implements Serializable {

    private static final int NO_ICON_DONT_ALIGN = -1;

    // ////////////////////////////////////////////////////////
    // mandatory variables									//
    // 
    private final String key;

    // 
    private final String replacedle;

    // 
    private final V defaultValue;

    // 
    @IdRes
    private final int // 
    textViewreplacedleId;

    // 
    @Nullable
    // 
    @IdRes
    private final Integer // 
    textViewSummaryId;

    // 
    @Nullable
    // 
    @IdRes
    private final Integer // 
    imageViewIconId;

    // 
    private final ESettingsTypes type;

    // ////////////////////////////////////////////////////////
    // ////////////////////////////////////////////
    // optional variables						//
    // 
    private String summary;

    // 
    private V value;

    // 
    private boolean useValuereplacedummary;

    // 
    private boolean addDivider;

    // 
    @Nullable
    // 
    @DrawableRes
    private Integer // 
    iconDrawableId;

    // 
    @Nullable
    private Drawable // 
    iconDrawable;

    // ////////////////////////////////////////////
    @IdRes
    private int individualSettingsRootId;

    /**
     * @param key the key for this {@link SettingsObject}
     *            to be saved in the apps' {@link SharedPreferences}
     * @param replacedle the replacedle for this {@link SettingsObject}
     * @param defaultValue the default value of this {@link SettingsObject}
     * @param summary the summary of this {@link SettingsObject}
     * @param textViewreplacedleId the id of the {@link TextView} which is being used
     *                        as the replacedle for this {@link SettingsObject}
     * @param textViewSummaryId the id of the {@link TextView} which is being used
     *                          as the summary for this {@link SettingsObject}
     * @param useValuereplacedummary whether or not the value of this
     *                          {@link SettingsObject} should be displayed
     *                          in the summary
     * @param addDivider whether or not this {@link SettingsObject} should have
     *                   a divider underneath it
     * @param type the type of value this {@link SettingsObject} is saving
     * @param imageViewIconId the id of the {@link ImageView} which is being used
     *                        as this {@link SettingsObject}s' icon
     * @param iconDrawableId  the id of the {@link android.graphics.drawable.Drawable}
     *                        which is being used as the icon
     *                        for this {@link SettingsObject}
     * @param  iconDrawable the {@link android.graphics.drawable.Drawable}
     *                        which is being used as the icon
     *                        for this {@link SettingsObject}
     */
    public SettingsObject(String key, String replacedle, V defaultValue, String summary, @IdRes int textViewreplacedleId, @Nullable @IdRes Integer textViewSummaryId, boolean useValuereplacedummary, boolean addDivider, ESettingsTypes type, @Nullable @IdRes Integer imageViewIconId, @Nullable @DrawableRes Integer iconDrawableId, @Nullable Drawable iconDrawable) {
        this.key = key;
        this.replacedle = replacedle;
        this.defaultValue = defaultValue;
        this.summary = summary;
        this.textViewreplacedleId = textViewreplacedleId;
        this.textViewSummaryId = textViewSummaryId;
        this.useValuereplacedummary = useValuereplacedummary;
        this.addDivider = addDivider;
        this.type = type;
        this.imageViewIconId = imageViewIconId;
        this.iconDrawableId = iconDrawableId;
        this.iconDrawable = iconDrawable;
    }

    /**
     * @return the id of the root view which contains this entire {@link SettingsObject}.
     * (the type of view depends on the {@link SettingsObject}).<br></br>
     * use this method to gain access to individual views inside this {@link SettingsObject}
     * e.g. View root = findViewById(mySettingsObject.getRootId());
     * textViewSummary = root.findViewById(mySettingsObject.getTextViewSummaryId());
     */
    @IdRes
    public int getRootId() {
        return individualSettingsRootId;
    }

    /**
     * @return the id of the drawable which is being used as this {@link SettingsObject}'s
     * icon,<br><br/>
     * or {@link SettingsObject#NO_ICON_DONT_ALIGN} if this {@link SettingsObject}
     * does not have an icon and does NOT need to be aligned with other {@link SettingsObject}s,<br><br/>
     * or null if this {@link SettingsObject} does not have an icon but it DOES
     * need to be aligned with other {@link SettingsObject}s
     */
    @Nullable
    @DrawableRes
    public Integer getIconDrawableId() {
        return iconDrawableId;
    }

    /**
     * @return same as {@link #getIconDrawableId()} but returns {@link Drawable} instead of Id.
     * returns null if this {@link SettingsObject} does not have an icon
     */
    @Nullable
    public Drawable getIconDrawable() {
        return iconDrawable;
    }

    /**
     * @return the id of the {@link ImageView} which is being used as the container
     * for this {@link SettingsObject}s' icon, or null if this {@link SettingsObject}
     * does not have an {@link ImageView}
     */
    @Nullable
    @IdRes
    public Integer getImageViewIconId() {
        return imageViewIconId;
    }

    /**
     * @return the type of value this {@link SettingsObject}
     */
    public ESettingsTypes getType() {
        return type;
    }

    /**
     * @return whether this {@link SettingsObject} has a divider underneath it
     */
    public boolean hasDivider() {
        return addDivider;
    }

    /**
     * @return the key which is being used to save this {@link SettingsObject}s'
     * value to this apps' {@link SharedPreferences}
     */
    public String getKey() {
        return key;
    }

    /**
     * @return the replacedle of this {@link SettingsObject}
     */
    public String getreplacedle() {
        return replacedle;
    }

    /**
     * @return the summary of this {@link SettingsObject}
     */
    public String getSummary() {
        return summary;
    }

    /**
     * @return the current value of this {@link SettingsObject}
     */
    public V getValue() {
        return value;
    }

    /**
     * @return whether or not this {@link SettingsObject} is displaying
     * its' value as the summary.<br></br>
     * if true, the value that will be shown is obtained from {@link SettingsObject#getValueHumanReadable()}
     */
    public boolean useValuereplacedummary() {
        return useValuereplacedummary;
    }

    /**
     * sets the given value to this settings object.
     * NOTE: this only sets the value of this object but does NOT save it in the apps' {@link SharedPreferences}.
     * if in addition you would also like the value to be saved to the apps'
     * settings, use {@link #setValueAndSaveSetting(Context, Object)}
     * @param value
     */
    public void setValue(V value) {
        this.value = value;
    }

    /**
     * convenience method for setting the given value to this {@link SettingsObject}
     * and also saving the value in the apps' settings.<br><br/>
     * VERY IMPORTANT!!! <br><br/>
     * this method does NOT perform validity checks on the given "value" and
     * replacedumes that it is a valid value to be saved as a setting!
     * for example, if this method is called from {@link SeekBarSettingsObject},
     * it is replacedumed that "value" is between {@link SeekBarSettingsObject#getMinValue()}
     * and {@link SeekBarSettingsObject#getMaxValue()}
     * @param context the context to be used to get the app settings
     * @param value the VALID value to be saved in the apps' settings
     * @throws IllegalArgumentException if the given value is of a type which cannot be saved
     *                                  to SharedPreferences
     */
    public void setValueAndSaveSetting(Context context, V value) throws IllegalArgumentException {
        setValue(value);
        Editor editor = EasySettings.retrieveSettingsSharedPrefs(context).edit();
        switch(getType()) {
            case VOID:
                // no actual value to save
                break;
            case BOOLEAN:
                editor.putBoolean(getKey(), (Boolean) value);
                break;
            case FLOAT:
                editor.putFloat(getKey(), (Float) value);
                break;
            case INTEGER:
                editor.putInt(getKey(), (Integer) value);
                break;
            case LONG:
                editor.putLong(getKey(), (Long) value);
                break;
            case STRING:
                editor.putString(getKey(), (String) value);
                break;
            case STRING_SET:
                editor.putStringSet(getKey(), getStringSetToSave((Set<?>) value));
                break;
            default:
                throw new IllegalArgumentException("parameter \"value\" must be of a type that " + "can be saved in SharedPreferences. given type was " + value.getClreplaced().getName());
        }
        editor.apply();
    }

    private Set<String> getStringSetToSave(Set<?> givenSet) {
        Set<String> setToSave = new LinkedHashSet<>(givenSet.size());
        for (Object obj : givenSet) {
            setToSave.add((String) obj);
        }
        return setToSave;
    }

    /**
     * @return the default value of this {@link SettingsObject}
     */
    public V getDefaultValue() {
        return defaultValue;
    }

    /**
     * @return the id of the {@link TextView} which is being used as this {@link SettingsObject}s'
     * replacedle
     */
    @IdRes
    public int getTextViewreplacedleId() {
        return textViewreplacedleId;
    }

    /**
     * @return the if of the {@link TextView} which is being used as this {@link SettingsObject}s'
     * summary, or null if this {@link SettingsObject} does not have a summary
     */
    @Nullable
    @IdRes
    public Integer getTextViewSummaryId() {
        return textViewSummaryId;
    }

    /**
     * @return the id of the layout of this {@link SettingsObject} to be inflated
     */
    @LayoutRes
    public abstract int getLayout();

    /**
     * confirms the validity of existing data and returns a valid value for
     * this {@link SettingsObject}.
     * e.g. imagine you have a {@link SeekBarSettingsObject} with a maximum value of 10, and the user sets
     * it to that value. in the next version of your app, for some reason, you changed the maximum value to be 7 -
     * the previously saved value (10) is no longer valid because it is above the new maximum.
     * @param context to be used if needed
     * @param prefs the shared preferences where the apps' settings are being saved (to be used if needed)
     * @return the value AS IT SHOULD BE SAVED! <br><br/>
     * e.g. for multi-choice list: "value1{DELIMITER}value2{DELIMITER}value3".<br><br/>
     * e.g. for {@link SeekBarSettingsObject}, the previously saved value, or
     * the default value if the previously saved value is no longer valid
     */
    public abstract V checkDataValidity(Context context, SharedPreferences prefs);

    /**
     * @return a human readable form of the value.
     * e.g. for multi-choice list: "value1, value2, value 3"<br><br/>
     * NOTE: if {@link SettingsObject#useValuereplacedummary()} is true,
     * this value will be used for the summary
     */
    public abstract String getValueHumanReadable();

    /**
     * initializes basic views for this {@link SettingsObject}
     * such as the replacedle, summary, and icon.
     * you should override this method and initialize all other views your
     * {@link SettingsObject} contains (e.g. for {@link CheckBoxSettingsObject},
     * initialize the {@link android.widget.CheckBox})
     * @param root the root view containing this entire {@link SettingsObject}
     */
    public void initializeViews(View root) {
        int rootId = View.generateViewId();
        root.setId(rootId);
        individualSettingsRootId = rootId;
        TextView tvreplacedle = root.findViewById(textViewreplacedleId);
        tvreplacedle.setText(getreplacedle());
        if (textViewSummaryId != null) {
            TextView tvSummary = root.findViewById(textViewSummaryId);
            String summary;
            if (useValuereplacedummary()) {
                summary = getValueHumanReadable();
            } else {
                summary = getSummary();
            }
            if (summary != null && summary.isEmpty() == false) {
                tvSummary.setText(summary);
            } else {
                tvSummary.setVisibility(View.GONE);
            }
        }
        if (imageViewIconId != null) {
            ImageView ivIcon = root.findViewById(imageViewIconId);
            if (iconDrawable != null) {
                ivIcon.setImageDrawable(iconDrawable);
            } else // the user specifically set the value to null
            // which means they want the settings object
            // to align as if it has an icon
            if (iconDrawableId == null) {
                ivIcon.setImageDrawable(null);
            } else // the user does NOT want the settings object to align
            if (iconDrawableId.equals(NO_ICON_DONT_ALIGN)) {
                ivIcon.setVisibility(View.GONE);
            } else // the user wants an actual icon
            {
                ivIcon.setImageResource(iconDrawableId);
            }
        }
    }

    // ///////////////////////////////////////////////////////////
    // ///////////////////////////////////////////////////////////
    // ///////////////////////////////////////////////////////////
    // ///////////////////////////////////////////////////////////
    // ///////////////////////////////////////////////////////////
    // ///////////////////////////////////////////////////////////
    public static abstract clreplaced Builder<B extends Builder<B, V>, V> {

        // ////////////////////////////////////////////////
        // mandatory variables							//
        // 
        private String key;

        // 
        private final String replacedle;

        // 
        private final V defaultValue;

        // 
        @IdRes
        private final int // 
        textViewreplacedleId;

        // 
        @Nullable
        // 
        @IdRes
        private final Integer // 
        textViewSummaryId;

        // 
        @Nullable
        // 
        @IdRes
        private final Integer // 
        imageViewIconId;

        // 
        private final ESettingsTypes type;

        // ////////////////////////////////////////////////
        // ////////////////////////////////////////////////////////////////////
        // optional variables												//
        // 
        private String summary;

        // 
        @Nullable
        // 
        @DrawableRes
        private Integer // 
        iconDrawableId = NO_ICON_DONT_ALIGN;

        // 
        private Drawable iconDrawable = null;

        // 
        private boolean useValuereplacedummary = false;

        // 
        private boolean addDivider = false;

        // ////////////////////////////////////////////////////////////////////
        /**
         * @param key the key for this {@link SettingsObject}
         *            to be saved in the apps' {@link SharedPreferences}
         * @param replacedle the replacedle for this {@link SettingsObject}
         * @param defaultValue
         * @param textViewreplacedleId the id of the {@link TextView} which
         *                        is being used as the replacedle for this
         *                 		  {@link SettingsObject}
         * @param textViewSummaryId the id of the {@link TextView} which
         *                        is being used as the summary for this
         *                 		  {@link SettingsObject}
         *                 		    (if no summary is needed, preplaced null)
         * @param type the type of value for this object to save (String/Integer/Float...)
         *           NOTE: must be a value which can be saved in {@link android.content.SharedPreferences}
         * @param imageViewIconId the id of the {@link android.widget.ImageView} that
         *                        is being used as the icon for this {@link SettingsObject}
         *                        (if no icon is needed, preplaced null)
         */
        public Builder(String key, String replacedle, V defaultValue, @IdRes int textViewreplacedleId, @Nullable @IdRes Integer textViewSummaryId, ESettingsTypes type, @Nullable @IdRes Integer imageViewIconId) {
            this.key = key;
            this.replacedle = replacedle;
            this.defaultValue = defaultValue;
            this.textViewreplacedleId = textViewreplacedleId;
            this.textViewSummaryId = textViewSummaryId;
            this.type = type;
            this.imageViewIconId = imageViewIconId;
            verifyType();
        }

        private void verifyType() {
            boolean problem = false;
            switch(type) {
                case VOID:
                    // no actual value to save - no verification needed
                    break;
                case BOOLEAN:
                    if (defaultValue instanceof Boolean == false)
                        problem = true;
                    break;
                case FLOAT:
                    if (defaultValue instanceof Float == false)
                        problem = true;
                    break;
                case INTEGER:
                    if (defaultValue instanceof Integer == false)
                        problem = true;
                    break;
                case LONG:
                    if (defaultValue instanceof Long == false)
                        problem = true;
                    break;
                case STRING:
                    if (defaultValue instanceof String == false)
                        problem = true;
                    break;
                case STRING_SET:
                    if (defaultValue instanceof Set<?>) {
                        checkStringSereplacedems((Set<?>) defaultValue);
                    } else {
                        problem = true;
                    }
                    break;
                default:
                    throw new IllegalArgumentException("SettingsObject with key " + key + " has an invalid type. declared type was " + type + ", valid types are " + Arrays.toString(ESettingsTypes.values()));
            }
            if (problem == true) {
                throw new IllegalArgumentException("SettingsObject with key " + key + " has declared type " + type + ", but actual type was " + defaultValue.getClreplaced().getName());
            }
        }

        private void checkStringSereplacedems(Set<?> set) {
            for (Object obj : set) {
                if (obj instanceof String == false) {
                    throw new IllegalArgumentException("SettingsObject with key " + key + " has declared type STRING_SET" + ", but the given set contains at least one element" + " which is not a String");
                }
            }
        }

        public Drawable getIconDrawable() {
            return iconDrawable;
        }

        @Nullable
        @DrawableRes
        public Integer getIconDrawableId() {
            return iconDrawableId;
        }

        @Nullable
        @IdRes
        public Integer getImageViewIconId() {
            return imageViewIconId;
        }

        public ESettingsTypes getType() {
            return type;
        }

        public String getKey() {
            return key;
        }

        public String getreplacedle() {
            return replacedle;
        }

        public V getDefaultValue() {
            return defaultValue;
        }

        public int getTextViewreplacedleId() {
            return textViewreplacedleId;
        }

        @Nullable
        @IdRes
        public Integer getTextViewSummaryId() {
            return textViewSummaryId;
        }

        public String getSummary() {
            return summary;
        }

        public boolean hasDivider() {
            return addDivider;
        }

        public boolean getUseValuereplacedummary() {
            return useValuereplacedummary;
        }

        /**
         * @param iconId the id of the drawable to be used as an icon for
         *               this {@link SettingsObject}. if you don't want
         *         		 to display an icon, but still want this {@link SettingsObject}
         *         		 to align with the rest of the settings, preplaced null.<br><br/>
         *         		 NOTE: this value overrides {@link #setIconDrawable(Drawable)}
         * @return
         */
        public B setIcon(@Nullable @DrawableRes Integer iconId) {
            this.iconDrawableId = iconId;
            return (B) this;
        }

        /**
         * same as {@link #setIcon(Integer)} but takes a {@link Drawable}
         * instead of drawable Id.<br><br/>
         * NOTE: this value is overridden by {@link #setIcon(Integer)}
         */
        public B setIconDrawable(@Nullable Drawable iconDrawable) {
            this.iconDrawable = iconDrawable;
            return (B) this;
        }

        /**
         * @param summary the text to be dispayed as the summary for this {@link SettingsObject}
         * @return
         */
        public B setSummary(String summary) {
            this.summary = summary;
            return (B) this;
        }

        /**
         * if this method id called, the value of this {@link SettingsObject}
         * will be used as the summary (overriding the value set in {@link SettingsObject.Builder#setSummary(String)})
         * @return
         */
        public B setUseValuereplacedummary() {
            this.useValuereplacedummary = true;
            return (B) this;
        }

        /**
         * if this method is called, a divider will show underneath this {@link SettingsObject}
         * @return
         */
        public B addDivider() {
            this.addDivider = true;
            return (B) this;
        }

        public abstract SettingsObject<V> build();
    }
}

18 Source : SettingsObject.java
with Apache License 2.0
from or-dvir

/**
 * @return the if of the {@link TextView} which is being used as this {@link SettingsObject}s'
 * summary, or null if this {@link SettingsObject} does not have a summary
 */
@Nullable
@IdRes
public Integer getTextViewSummaryId() {
    return textViewSummaryId;
}

18 Source : SettingsObject.java
with Apache License 2.0
from or-dvir

/**
 * @return the id of the {@link ImageView} which is being used as the container
 * for this {@link SettingsObject}s' icon, or null if this {@link SettingsObject}
 * does not have an {@link ImageView}
 */
@Nullable
@IdRes
public Integer getImageViewIconId() {
    return imageViewIconId;
}

18 Source : DrawerPresenter.java
with Apache License 2.0
from Nilhcem

public clreplaced DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter {

    @State
    @StringRes
    int toolbarreplacedle;

    @State
    @IdRes
    int selectedItemId;

    public DrawerPresenter(DrawerMvp.View view) {
        super(view);
    }

    @Override
    public void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        if (savedInstanceState == null) {
            onNavigationItemSelected(R.id.drawer_nav_schedule);
        }
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        view.updateToolbarreplacedle(toolbarreplacedle);
    }

    @Override
    public void onNavigationItemSelected(@IdRes int itemId) {
        if (itemId != selectedItemId) {
            switch(itemId) {
                case R.id.drawer_nav_schedule:
                    view.showFragment(new SchedulePagerFragmentBuilder(false).build());
                    toolbarreplacedle = R.string.drawer_nav_schedule;
                    break;
                case R.id.drawer_nav_agenda:
                    view.showFragment(new SchedulePagerFragmentBuilder(true).build());
                    toolbarreplacedle = R.string.drawer_nav_agenda;
                    break;
                case R.id.drawer_nav_speakers:
                    view.showFragment(new SpeakersListFragment());
                    toolbarreplacedle = R.string.drawer_nav_speakers;
                    break;
                case R.id.drawer_nav_venue:
                    view.showFragment(new VenueFragment());
                    toolbarreplacedle = R.string.drawer_nav_venue;
                    break;
                case R.id.drawer_nav_settings:
                    view.showFragment(new SettingsFragment());
                    toolbarreplacedle = R.string.drawer_nav_settings;
                    break;
                default:
                    throw new IllegalArgumentException();
            }
            view.hideTabLayout();
            view.updateToolbarreplacedle(toolbarreplacedle);
            selectedItemId = itemId;
        }
        view.closeNavigationDrawer();
    }

    @Override
    public boolean onBackPressed() {
        if (view.isNavigationDrawerOpen()) {
            view.closeNavigationDrawer();
            return true;
        } else if (toolbarreplacedle != R.string.drawer_nav_schedule) {
            int firsreplacedem = R.id.drawer_nav_schedule;
            onNavigationItemSelected(firsreplacedem);
            view.selectDrawerMenuItem(firsreplacedem);
            return true;
        }
        return false;
    }
}

18 Source : NavActionTest.java
with Apache License 2.0
from lulululbj

@RunWith(JUnit4.clreplaced)
@SmallTest
public clreplaced NavActionTest {

    @IdRes
    private static final int DESTINATION_ID = 1;

    @Test
    public void createAction() {
        NavAction action = new NavAction(DESTINATION_ID);
        replacedertThat(action.getDestinationId(), is(DESTINATION_ID));
    }

    @Test
    public void createActionWithNullNavOptions() {
        NavAction action = new NavAction(DESTINATION_ID, null);
        replacedertThat(action.getDestinationId(), is(DESTINATION_ID));
        replacedertThat(action.getNavOptions(), nullValue());
    }

    @Test
    public void setNavOptions() {
        NavAction action = new NavAction(DESTINATION_ID);
        NavOptions navOptions = new NavOptions.Builder().build();
        action.setNavOptions(navOptions);
        replacedertThat(action.getNavOptions(), is(navOptions));
    }
}

18 Source : ContextViewBlock.java
with Apache License 2.0
from iflove

/**
 * Created by lazy on 2017/4/23.
 */
abstract clreplaced ContextViewBlock implements ActivityLifeCycle {

    protected final String TAG = this.getClreplaced().getCanonicalName();

    protected final Activity mActivity;

    protected final Context mContext;

    View mBlockingView;

    @IdRes
    int mBlockingViewId = View.NO_ID;

    // Not yet created.
    static final int INITIALIZING = 0;

    // The activity has finished its creation.
    static final int CREATED = 1;

    // Created.
    static final int CREATED_VIEW = 2;

    // Created and started, not resumed.
    static final int STARTED = 3;

    // Created started and resumed.
    static final int RESUMED = 4;

    // Fully created, not started.
    static final int STOPPED = 5;

    // Created started and resumed.
    static final int PAUSE = 6;

    // Created started and resumed.
    static final int STOP = 7;

    // Created started and resumed.
    static final int DESTROY = 8;

    int mState = INITIALIZING;

    protected ContextViewBlock(Context context) {
        Preconditions.checkNotNull(context);
        this.mContext = context;
        this.mActivity = (Activity) this.mContext;
    }

    protected ContextViewBlock(View blockingView) {
        Preconditions.checkNotNull(blockingView);
        this.mBlockingView = blockingView;
        mBlockingViewId = blockingView.getId();
        this.mContext = blockingView.getContext();
        this.mActivity = (Activity) this.mContext;
        onAttachToActivity(mActivity);
    }

    protected ContextViewBlock(@NonNull Context context, @LayoutRes final int layoutResId) {
        this(context, layoutResId, null, false);
    }

    protected ContextViewBlock(@NonNull Context context, @LayoutRes final int layoutResId, @Nullable ViewGroup root, boolean attachToRoot) {
        this(LayoutInflater.from(context).inflate(layoutResId, root, attachToRoot));
    }

    protected ContextViewBlock(@NonNull Activity activity, @IdRes final int resId) {
        this(activity.findViewById(resId));
    }

    protected abstract void onAttachToActivity(@NonNull Activity activity);

    protected abstract void onDetachToActivity(@NonNull Activity activity);

    protected abstract void onFinishInflateView();

    public int getId() {
        return mBlockingViewId;
    }

    public Resources getResources() {
        return mActivity.getResources();
    }

    public Application getApplication() {
        return mActivity.getApplication();
    }

    public Intent getIntent() {
        return mActivity.getIntent();
    }

    public void setIntent(Intent newIntent) {
        mActivity.setIntent(newIntent);
    }

    public Activity getActivity() {
        return mActivity;
    }

    public Context getContext() {
        return mContext;
    }

    public replacedetManager getreplacedets() {
        return mContext.getreplacedets();
    }

    public Looper getMainLooper() {
        return mContext.getMainLooper();
    }

    public void startActivity(Intent intent) {
        mActivity.startActivity(intent);
    }

    protected void startActivity(Clreplaced<? extends Activity> clazz) {
        Intent intent = new Intent();
        intent.setClreplaced(getContext(), clazz);
        mActivity.startActivity(intent);
    }

    public void finishActivity() {
        mActivity.finish();
    }

    public View getBlockingView() {
        return mBlockingView;
    }

    protected <T> T castBlockingView() {
        // noinspection unchecked
        return (T) mBlockingView;
    }

    public abstract UIKitIntent getUIKitIntent();

    public abstract void setUIKitIntent(UIKitIntent mUiKitIntent);

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        moveToState(CREATED);
    }

    @Override
    public void onCreateView() {
        moveToState(CREATED_VIEW);
        onFinishInflateView();
    }

    @Override
    public void onNewIntent(Intent intent) {
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
    }

    @Override
    public void onStart() {
        moveToState(STARTED);
    }

    @Override
    public void onResume() {
        moveToState(RESUMED);
    }

    @Override
    public void onPause() {
        moveToState(PAUSE);
    }

    @Override
    public void onStop() {
        moveToState(STOP);
    }

    @Override
    public void onRestart() {
        moveToState(STARTED);
    }

    @Override
    public void onDestroy() {
        moveToState(DESTROY);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    }

    @Override
    public void onBackPressed() {
    }

    public int getState() {
        return mState;
    }

    void moveToState(int newState) {
        this.mState = newState;
    }
}

18 Source : ThemeToButtonIdMapper.java
with Apache License 2.0
from Doctoror

@IdRes
int themeToButtonId(@NonNull final Theme theme) {
    switch(theme) {
        case DAY:
            return R.id.radioDay;
        case NIGHT:
            return R.id.radioNight;
        case DAYNIGHT:
            return R.id.radioDayNight;
        default:
            throw new IllegalArgumentException("Unexpected theme: " + theme);
    }
}

See More Examples