android.view.View

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

79116 Examples 7

19 Source : VideoListFragment.java
with MIT License
from zzh12138

@Override
public void onVideoPlay(int position) {
    LinearLayoutManager manager = (LinearLayoutManager) mRecycler.getLayoutManager();
    int first = manager.findFirstVisibleItemPosition();
    if (position == 0 && !mRecycler.canScrollVertically(-1)) {
        return;
    }
    View view = mRecycler.getChildAt(position - first);
    mRecycler.smoothScrollBy(0, view.getTop() - Util.dip2px(getContext(), 40));
}

19 Source : ReBoundLayout.java
with MIT License
from zzh12138

public void seInnerView(View innerView) {
    this.innerView = innerView;
}

19 Source : DragZoomLayout.java
with MIT License
from zzh12138

public void setInnerView(View innerView) {
    this.innerView = innerView;
}

19 Source : JZUtils.java
with MIT License
from zzh12138

public static void onScrollPlayVideo(AbsListView absListView, int firstVisiblePosition, int lastVisiblePosition) {
    for (int i = firstVisiblePosition; i <= lastVisiblePosition; i++) {
        View ad = absListView.getChildAt(i - firstVisiblePosition);
        View view = ad.findViewById(R.id.player);
        if (view != null && view instanceof JZVideoPlayerStandard) {
            JZVideoPlayerStandard player = (JZVideoPlayerStandard) view;
            Log.d(TAG, "onScrollStateChanged: " + JZUtils.getViewVisiblePercent(player));
            if (JZMediaManager.instance().positionInList != i && getViewVisiblePercent(player) == 1f) {
                player.startButton.performClick();
                break;
            }
        }
    }
}

19 Source : JZUtils.java
with MIT License
from zzh12138

public static void onScrollPlayVideo(RecyclerView recyclerView, int firstVisiblePosition, int lastVisiblePosition) {
    if (JZMediaManager.isWiFi) {
        for (int i = 0; i <= lastVisiblePosition - firstVisiblePosition; i++) {
            View child = recyclerView.getChildAt(i);
            View view = child.findViewById(R.id.player);
            if (view != null && view instanceof JZVideoPlayerStandard) {
                JZVideoPlayerStandard player = (JZVideoPlayerStandard) view;
                if (getViewVisiblePercent(player) == 1f) {
                    if (JZMediaManager.instance().positionInList != i + firstVisiblePosition) {
                        player.startButton.performClick();
                    }
                    break;
                }
            }
        }
    }
}

19 Source : MainActivity.java
with MIT License
from zzh12138

private void closeVideoListFragment() {
    isShowVideo = false;
    final NewsBean bean = mList.get(clickPosition);
    if (videoListFragment.isPlayingFirst()) {
        videoListFragment.removeVideoList();
        JZMediaManager.instance().positionInList = clickPosition;
        int first = mLayoutManager.findFirstVisibleItemPosition();
        View v = recycler.getChildAt(clickPosition - first);
        if (v != null) {
            final PlayerContainer container = v.findViewById(R.id.adapter_video_container);
            if (!isAttach) {
                container.removeAllViews();
            }
            recycler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    JZVideoPlayerManager.getCurrentJzvd().attachToContainer(container);
                    JZVideoPlayerStandard p = (JZVideoPlayerStandard) JZVideoPlayerManager.getCurrentJzvd();
                    p.showAnimationView();
                    p.positionInList = clickPosition;
                    p.setVideoList(false);
                    p.setVideoActivity(false);
                    p.setVideoTime(bean.getDuration()).setOnVideoPlayerContainerClickListener(new JZVideoPlayerStandard.OnVideoPlayerContainerClickListener() {

                        @Override
                        public void videoPlayerContainerClick() {
                            int[] location = new int[2];
                            container.getLocationOnScreen(location);
                            ViewAttr attr = new ViewAttr();
                            attr.setX(location[0]);
                            attr.setY(location[1]);
                            attr.setWidth(container.getWidth());
                            attr.setHeight(container.getHeight());
                            onreplacedleClick(clickPosition, attr);
                        }
                    });
                    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                    transaction.remove(videoListFragment);
                    transaction.commitAllowingStateLoss();
                }
            }, 800);
        }
    } else {
        JZVideoPlayer.releaseAllVideos();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.remove(videoListFragment);
        transaction.commitAllowingStateLoss();
        if (isAttach) {
            int first = mLayoutManager.findFirstVisibleItemPosition();
            View v = recycler.getChildAt(clickPosition - first);
            if (v != null) {
                final PlayerContainer container = v.findViewById(R.id.adapter_video_container);
                container.removeAllViews();
                JZVideoPlayerStandard p = new JZVideoPlayerStandard(MainActivity.this);
                Glide.with(MainActivity.this).load(bean.getImageUrl()).into(p.coverImageView);
                p.positionInList = clickPosition;
                p.setUp(bean.getVideoUrl(), JZVideoPlayer.SCREEN_WINDOW_NORMAL, bean.getreplacedle());
                p.setVideoTime(bean.getDuration()).setOnVideoPlayerContainerClickListener(new JZVideoPlayerStandard.OnVideoPlayerContainerClickListener() {

                    @Override
                    public void videoPlayerContainerClick() {
                        int[] location = new int[2];
                        container.getLocationOnScreen(location);
                        ViewAttr attr = new ViewAttr();
                        attr.setX(location[0]);
                        attr.setY(location[1]);
                        attr.setWidth(container.getWidth());
                        attr.setHeight(container.getHeight());
                        onreplacedleClick(clickPosition, attr);
                    }
                });
                container.addView(p);
            }
        }
    }
// clickPosition = -1;
// isAttach = false;
}

19 Source : VideoListFragment.java
with MIT License
from zzh12138

@Override
public void scrollToPosition(int position) {
    if (mRecycler != null && !isShowComment && position >= 0 && position < mList.size()) {
        int first = mLayoutManager.findFirstVisibleItemPosition();
        View view = mRecycler.getChildAt(position - first);
        if (view != null) {
            if (position == mList.size() - 2) {
                // 最后一个
                JZVideoPlayerStandard player = view.findViewById(R.id.player);
                showMask(player);
            } else {
                int scrollY = view.getTop();
                scrollY -= DensityUtil.dipTopx(getContext(), 50);
                if (position > JZMediaManager.instance().positionInList) {
                    // 点击下一个
                    if (scrollY < 0) {
                        scrollY = 0;
                    }
                }
                mRecycler.smoothScrollBy(0, scrollY);
                if (scrollY == 0) {
                    JZVideoPlayerStandard player = view.findViewById(R.id.player);
                    showMask(player);
                }
            }
        }
    }
}

19 Source : IndicatorHeaderView.java
with Apache License 2.0
from zyyoona7

/**
 * Created by zyyoona7 on 2017/6/9.
 * iOS邮件应用HeaderView
 */
public clreplaced IndicatorHeaderView extends FrameLayout implements IHeaderView {

    private static final String TAG = "IndicatorHeaderView";

    private View mRootView = null;

    private IndicatorLoadingView mLoadingView;

    public IndicatorHeaderView(@NonNull Context context) {
        this(context, null);
    }

    public IndicatorHeaderView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        mRootView = LayoutInflater.from(context).inflate(R.layout.header_indicator, this);
        mLoadingView = (IndicatorLoadingView) findViewById(R.id.ilv_header);
    }

    /**
     * 设置颜色
     *
     * @param color
     */
    public void setColor(int color) {
        mLoadingView.setColor(color);
    }

    @Override
    public View getView() {
        return this;
    }

    @Override
    public void onPullingDown(float fraction, float maxHeadHeight, float headHeight) {
        if (fraction <= 1) {
            mLoadingView.setCurrentProgress(Math.round(fraction * mLoadingView.getMaxProgress()));
        } else {
            if (mLoadingView.getCurrentProgress() < mLoadingView.getMaxProgress()) {
                mLoadingView.setCurrentProgress(mLoadingView.getMaxProgress());
            }
        }
    }

    @Override
    public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) {
        if (fraction < 1) {
            mLoadingView.setCurrentProgress(Math.round(fraction * mLoadingView.getMaxProgress()));
        }
    }

    @Override
    public void startAnim(float maxHeadHeight, float headHeight) {
        mLoadingView.startAnim();
    }

    @Override
    public void onFinish(OnAnimEndListener animEndListener) {
        animEndListener.onAnimEnd();
    }

    @Override
    public void reset() {
        mLoadingView.stopAnim();
        mLoadingView.resetColorOrder();
    }
}

19 Source : CardActivity.java
with Apache License 2.0
from zyyoona7

public void change(View view) {
    if (mGroupSize == 3) {
        mGroupSize = 9;
    } else {
        mGroupSize = 3;
    }
    init();
}

19 Source : CardActivity.java
with Apache License 2.0
from zyyoona7

public void add(View view) {
    mCount += 10;
    mAdapter.notifyDataSetChanged();
}

19 Source : HorizontalCarouselLayout.java
with Apache License 2.0
from zyyoona7

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int count = getChildCount();
    int specWidthSize = View.MeasureSpec.getSize(widthMeasureSpec);
    int specHeightSize = View.MeasureSpec.getSize(heightMeasureSpec);
    this.mWidthCenter = (specWidthSize / 2);
    this.mHeightCenter = (specHeightSize / 2);
    this.mChildrenWidth = ((int) (specWidthSize * this.mChildSizeRatio));
    this.mChildrenHeight = ((int) (specHeightSize * this.mChildSizeRatio));
    this.mChildrenWidthMiddle = (this.mChildrenWidth / 2);
    this.mChildrenHeightMiddle = (this.mChildrenHeight / 2);
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        measureChild(child, this.mChildrenWidth, this.mChildrenHeight);
    }
    setMeasuredDimension(specWidthSize, specHeightSize);
}

19 Source : Collector.java
with Apache License 2.0
from zyyoona7

protected void collect(View v) {
    this.mOldViews.add(v);
}

19 Source : EasyRecyclerViewAdapter.java
with GNU General Public License v3.0
from zyl409214686

public void setHeaderView(View headerView) {
    mHeaderView = headerView;
    notifyItemInserted(0);
}

19 Source : EasyRecyclerViewAdapter.java
with GNU General Public License v3.0
from zyl409214686

public void setFooterView(View footerView) {
    mFooterView = footerView;
    // notifyItemInserted(getFooterPosition());
    notifyDataSetChanged();
}

19 Source : MainActivity.java
with Apache License 2.0
from zybieku

public void button(View view) {
    Intent intent1 = new Intent(MainActivity.this, CaptureActivity.clreplaced);
    startActivityForResult(intent1, QR_CODE);
}

19 Source : SplashActivity.java
with Apache License 2.0
from zybieku

// proxy方式
public void clickProxy(View view) {
    startActivity(new Intent(this, ProxyModeActivity.clreplaced));
}

19 Source : SplashActivity.java
with Apache License 2.0
from zybieku

// 继承方式
public void clickExtend(View view) {
    startActivity(new Intent(this, MainActivity.clreplaced));
}

19 Source : SplashActivity.java
with Apache License 2.0
from zybieku

public void clickProxyFragment(View view) {
    startActivity(new Intent(this, ProxyModeFragmentActivity.clreplaced));
}

19 Source : ProxyModeActivity.java
with Apache License 2.0
from zybieku

/**
 * 非侵入式控制
 * @author jiiiiiin
 */
public clreplaced ProxyModeActivity extends AppCompatActivity {

    private static final String TAG = "ProxyModeActivity";

    private View mBtnCode;

    private ActivityKeyBoardProxy mActivityKeyBoardProxy;

    public static void start(Activity activity) {
        activity.startActivity(new Intent(activity, ProxyModeActivity.clreplaced));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ui_activity_host_login);
        mBtnCode = findViewById(R.id.btn_code);
        try {
            mActivityKeyBoardProxy = new ActivityKeyBoardProxyBuild().withActivity(this).withHideSoftByEditViewIds(new int[] { R.id.et_phone, R.id.et_check_code, R.id.et_city_code }).withFilterViewByIds(new View[] { mBtnCode }).withOnHideInputForceListener(new ActivityKeyBoardProxy.OnHideInputForceListener() {

                @Override
                public void onHideInputForce(MotionEvent motionEvent) {
                    Log.d(TAG, "隐藏了系统键盘");
                }
            }).build();
        } catch (Exception e) {
            e.printStackTrace();
            Log.e(TAG, e.getMessage());
        }
    }

    @Override
    public boolean dispatchTouchEvent(final MotionEvent ev) {
        if (mActivityKeyBoardProxy != null) {
            mActivityKeyBoardProxy.onDispatchTouchEvent(ev);
        }
        return super.dispatchTouchEvent(ev);
    }
}

19 Source : ActivityKeyBoardProxyBuild.java
with Apache License 2.0
from zybieku

/**
 * @author jiiiiiin
 * @version 1.0
 */
public clreplaced ActivityKeyBoardProxyBuild {

    private Activity mActivity = null;

    private int[] mHideSoftByEditViewIds = null;

    private View[] mFilterViewByIds = null;

    private boolean _initialized = false;

    private ActivityKeyBoardProxy mActivityKeyBoardProxy = null;

    private ActivityKeyBoardProxy.OnHideInputForceListener mOnHideInputForceListener = null;

    public ActivityKeyBoardProxyBuild withActivity(@NonNull Activity activity) {
        this.mActivity = activity;
        return this;
    }

    public ActivityKeyBoardProxyBuild withHideSoftByEditViewIds(@NonNull int[] hideSoftByEditViewIds) {
        this.mHideSoftByEditViewIds = hideSoftByEditViewIds;
        return this;
    }

    public ActivityKeyBoardProxyBuild withFilterViewByIds(@NonNull View[] filterViewByIds) {
        this.mFilterViewByIds = filterViewByIds;
        return this;
    }

    public ActivityKeyBoardProxyBuild withOnHideInputForceListener(@NonNull ActivityKeyBoardProxy.OnHideInputForceListener onHideInputForceListener) {
        this.mOnHideInputForceListener = onHideInputForceListener;
        return this;
    }

    public final ActivityKeyBoardProxy build() throws Exception {
        if (ActivityUtil.activityIsLiving(mActivity)) {
            if (!_initialized) {
                mActivityKeyBoardProxy = ActivityKeyBoardProxy.newInstance(mActivity, mHideSoftByEditViewIds, mFilterViewByIds, mOnHideInputForceListener);
                _initialized = true;
            }
            return mActivityKeyBoardProxy;
        } else {
            throw new Exception("Activity is not living err");
        }
    }
}

19 Source : ActivityKeyBoardProxyBuild.java
with Apache License 2.0
from zybieku

public ActivityKeyBoardProxyBuild withFilterViewByIds(@NonNull View[] filterViewByIds) {
    this.mFilterViewByIds = filterViewByIds;
    return this;
}

19 Source : ActivityKeyBoardProxy.java
with Apache License 2.0
from zybieku

/**
 * @author jiiiiiin
 * @version 1.0
 */
public clreplaced ActivityKeyBoardProxy {

    private final Activity mActivity;

    private final int[] mHideSoftByEditViewIds;

    private final View[] mFilterViewByIds;

    private final OnHideInputForceListener mOnHideInputForceListener;

    private ActivityKeyBoardProxy(@NonNull Activity activity, @NonNull int[] hideSoftByEditViewIds, View[] filterViewByIds, OnHideInputForceListener onHideInputForceListener) {
        this.mActivity = activity;
        this.mHideSoftByEditViewIds = hideSoftByEditViewIds;
        this.mFilterViewByIds = filterViewByIds;
        this.mOnHideInputForceListener = onHideInputForceListener;
    }

    public static ActivityKeyBoardProxy newInstance(@NonNull Activity activity, @NonNull int[] hideSoftByEditViewIds, View[] filterViewByIds, OnHideInputForceListener onHideInputForceListener) {
        if (filterViewByIds == null) {
            filterViewByIds = new View[] {};
        }
        return new ActivityKeyBoardProxy(activity, hideSoftByEditViewIds, filterViewByIds, onHideInputForceListener);
    }

    public interface OnHideInputForceListener {

        /**
         * 调用了隐藏系统键盘的功能
         *
         * @param motionEvent
         */
        void onHideInputForce(MotionEvent motionEvent);
    }

    public void onDispatchTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
            if (isTouchView(mFilterViewByIds, motionEvent) || mHideSoftByEditViewIds.length == 0) {
                return;
            }
            View v = mActivity.getCurrentFocus();
            if (isFocusEditText(v, mHideSoftByEditViewIds)) {
                if (isTouchView(mHideSoftByEditViewIds, motionEvent)) {
                    return;
                }
                // 隐藏键盘
                KeyBoardUtils.hideInputForce(mActivity);
                clearViewFocus(v, mHideSoftByEditViewIds);
                if (mOnHideInputForceListener != null) {
                    mOnHideInputForceListener.onHideInputForce(motionEvent);
                }
            }
        }
    }

    // region软键盘的处理
    /**
     * 清除editText的焦点
     *
     * @param v   焦点所在View
     * @param ids 输入框
     */
    public void clearViewFocus(View v, int... ids) {
        if (null != v && null != ids && ids.length > 0) {
            for (int id : ids) {
                if (v.getId() == id) {
                    v.clearFocus();
                    break;
                }
            }
        }
    }

    /**
     * 隐藏键盘
     *
     * @param v   焦点所在View
     * @param ids 输入框
     * @return true代表焦点在edit上
     */
    private boolean isFocusEditText(View v, int... ids) {
        if (v instanceof EditText) {
            EditText tmp_et = (EditText) v;
            for (int id : ids) {
                if (tmp_et.getId() == id) {
                    return true;
                }
            }
        }
        return false;
    }

    // 是否触摸在指定view上面,对某个控件过滤
    public boolean isTouchView(View[] views, MotionEvent motionEvent) {
        if (views == null || views.length == 0) {
            return false;
        }
        int[] location = new int[2];
        for (View view : views) {
            view.getLocationOnScreen(location);
            int x = location[0];
            int y = location[1];
            if (motionEvent.getX() > x && motionEvent.getX() < (x + view.getWidth()) && motionEvent.getY() > y && motionEvent.getY() < (y + view.getHeight())) {
                return true;
            }
        }
        return false;
    }

    // 是否触摸在指定view上面,对某个控件过滤
    private boolean isTouchView(int[] ids, MotionEvent motionEvent) {
        int[] location = new int[2];
        for (int id : ids) {
            View view = mActivity.findViewById(id);
            if (view == null) {
                continue;
            }
            view.getLocationOnScreen(location);
            int x = location[0];
            int y = location[1];
            if (motionEvent.getX() > x && motionEvent.getX() < (x + view.getWidth()) && motionEvent.getY() > y && motionEvent.getY() < (y + view.getHeight())) {
                return true;
            }
        }
        return false;
    }
    // endregion
}

19 Source : ActivityKeyBoardProxy.java
with Apache License 2.0
from zybieku

public static ActivityKeyBoardProxy newInstance(@NonNull Activity activity, @NonNull int[] hideSoftByEditViewIds, View[] filterViewByIds, OnHideInputForceListener onHideInputForceListener) {
    if (filterViewByIds == null) {
        filterViewByIds = new View[] {};
    }
    return new ActivityKeyBoardProxy(activity, hideSoftByEditViewIds, filterViewByIds, onHideInputForceListener);
}

19 Source : ActivityKeyBoardProxy.java
with Apache License 2.0
from zybieku

/**
 * 隐藏键盘
 *
 * @param v   焦点所在View
 * @param ids 输入框
 * @return true代表焦点在edit上
 */
private boolean isFocusEditText(View v, int... ids) {
    if (v instanceof EditText) {
        EditText tmp_et = (EditText) v;
        for (int id : ids) {
            if (tmp_et.getId() == id) {
                return true;
            }
        }
    }
    return false;
}

19 Source : MainActivity.java
with Apache License 2.0
from zybieku

/**
 * 方式一
 * 继承BaseActivity
 */
public clreplaced MainActivity extends BaseActivity {

    private EditText mPhone;

    private View mBtnCode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ui_activity_host_login);
        mPhone = (EditText) findViewById(R.id.et_phone);
        mBtnCode = findViewById(R.id.btn_code);
    }

    @Override
    public View[] filterViewByIds() {
        View[] views = { mBtnCode };
        return views;
    }

    @Override
    public int[] hideSoftByEditViewIds() {
        int[] ids = { R.id.et_phone, R.id.et_check_code, R.id.et_city_code };
        return ids;
    }
}

19 Source : BaseActivity.java
with Apache License 2.0
from zybieku

/**
 * 隐藏键盘
 *
 * @param v   焦点所在View
 * @param ids 输入框
 * @return true代表焦点在edit上
 */
public boolean isFocusEditText(View v, int... ids) {
    if (v instanceof EditText) {
        EditText tmp_et = (EditText) v;
        for (int id : ids) {
            if (tmp_et.getId() == id) {
                return true;
            }
        }
    }
    return false;
}

19 Source : CartFragment.java
with Apache License 2.0
from zxuu

@OnClick(R.id.btn_del)
public void delCart(View view) {
    mAdapter.delCart();
}

19 Source : CreateOrderActivity.java
with Apache License 2.0
from zxuu

@OnClick(R.id.btn_createOrder)
public void createNewOrder(View view) {
    postNewOrder();
}

19 Source : CustomPopupWindow.java
with Apache License 2.0
from Zweihui

/**
 * ================================================
 * 因为继承于 {@link PopupWindow} ,所以它本身就是一个 {@link PopupWindow}
 * 因此如果此类里封装的功能并不能满足您的需求(不想过多封装 UI 的东西,这里只提供思想,觉得不满足需求可以自己仿照着封装)
 * 您可以直接调用 {@link PopupWindow} 的 Api 满足需求
 *
 * @see <a href="https://github.com/JessYanCoding/MVPArms/wiki#3.7">CustomPopupWindow wiki 官方文档</a>
 * Created by JessYan on 4/22/2016
 * <a href="mailto:[email protected]">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * ================================================
 */
public clreplaced CustomPopupWindow extends PopupWindow {

    private View mContentView;

    private View mParentView;

    private CustomPopupWindowListener mListener;

    private boolean isOutsideTouch;

    private boolean isFocus;

    private Drawable mBackgroundDrawable;

    private int mAnimationStyle;

    private boolean isWrap;

    private CustomPopupWindow(Builder builder) {
        this.mContentView = builder.contentView;
        this.mParentView = builder.parentView;
        this.mListener = builder.listener;
        this.isOutsideTouch = builder.isOutsideTouch;
        this.isFocus = builder.isFocus;
        this.mBackgroundDrawable = builder.backgroundDrawable;
        this.mAnimationStyle = builder.animationStyle;
        this.isWrap = builder.isWrap;
        initLayout();
    }

    public static Builder builder() {
        return new Builder();
    }

    private void initLayout() {
        mListener.initPopupView(mContentView);
        setWidth(isWrap ? LayoutParams.WRAP_CONTENT : LayoutParams.MATCH_PARENT);
        setHeight(isWrap ? LayoutParams.WRAP_CONTENT : LayoutParams.MATCH_PARENT);
        setFocusable(isFocus);
        setOutsideTouchable(isOutsideTouch);
        setBackgroundDrawable(mBackgroundDrawable);
        if (// 如果设置了动画则使用动画
        mAnimationStyle != -1)
            setAnimationStyle(mAnimationStyle);
        setContentView(mContentView);
    }

    /**
     * 获得用于展示popup内容的view
     *
     * @return
     */
    public View getContentView() {
        return mContentView;
    }

    /**
     * 用于填充contentView,必须传ContextThemeWrapper(比如activity)不然popupwindow要报错
     * @param context
     * @param layoutId
     * @return
     */
    public static View inflateView(ContextThemeWrapper context, int layoutId) {
        return LayoutInflater.from(context).inflate(layoutId, null);
    }

    public void show() {
        // 默认显示到中间
        if (mParentView == null) {
            showAtLocation(mContentView, Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0);
        } else {
            showAtLocation(mParentView, Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0);
        }
    }

    public static final clreplaced Builder {

        private View contentView;

        private View parentView;

        private CustomPopupWindowListener listener;

        // 默认为true
        private boolean isOutsideTouch = true;

        // 默认为true
        private boolean isFocus = true;

        // 默认为透明
        private Drawable backgroundDrawable = new ColorDrawable(0x00000000);

        private int animationStyle = -1;

        private boolean isWrap;

        private Builder() {
        }

        public Builder contentView(View contentView) {
            this.contentView = contentView;
            return this;
        }

        public Builder parentView(View parentView) {
            this.parentView = parentView;
            return this;
        }

        public Builder isWrap(boolean isWrap) {
            this.isWrap = isWrap;
            return this;
        }

        public Builder customListener(CustomPopupWindowListener listener) {
            this.listener = listener;
            return this;
        }

        public Builder isOutsideTouch(boolean isOutsideTouch) {
            this.isOutsideTouch = isOutsideTouch;
            return this;
        }

        public Builder isFocus(boolean isFocus) {
            this.isFocus = isFocus;
            return this;
        }

        public Builder backgroundDrawable(Drawable backgroundDrawable) {
            this.backgroundDrawable = backgroundDrawable;
            return this;
        }

        public Builder animationStyle(int animationStyle) {
            this.animationStyle = animationStyle;
            return this;
        }

        public CustomPopupWindow build() {
            if (contentView == null)
                throw new IllegalStateException("ContentView is required");
            if (listener == null)
                throw new IllegalStateException("CustomPopupWindowListener is required");
            return new CustomPopupWindow(this);
        }
    }

    public interface CustomPopupWindowListener {

        public void initPopupView(View contentView);
    }
}

19 Source : DeviceUtils.java
with Apache License 2.0
from Zweihui

public static void showSoftKeyboard(Context context, View view) {
    ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_FORCED);
}

19 Source : DeviceUtils.java
with Apache License 2.0
from Zweihui

/**
 * 隐藏软键盘
 *
 * @param context
 * @param view
 */
public static void hideSoftKeyboard(Context context, View view) {
    if (view == null)
        return;
    InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive())
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

19 Source : DeviceUtils.java
with Apache License 2.0
from Zweihui

public static void toogleSoftKeyboard(Context context, View view) {
    ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}

19 Source : SwipeBackLayout.java
with Apache License 2.0
from Zweihui

/**
 * Set up contentView which will be moved by user gesture
 *
 * @param view
 */
private void setContentView(View view) {
    mContentView = view;
}

19 Source : MarginAdapterHelper.java
with Apache License 2.0
from Zweihui

public void onBindViewHolder(View itemView, final int position, int itemCount) {
    int padding = UiUtils.dip2px(itemView.getContext(), mPagePadding);
    itemView.setPadding(padding, 0, padding, 0);
    int leftMarin = position == 0 ? padding + UiUtils.dip2px(itemView.getContext(), mShowLeftCardWidth) : 0;
    int rightMarin = position == itemCount - 1 ? padding + UiUtils.dip2px(itemView.getContext(), mShowLeftCardWidth) : 0;
    setViewMargin(itemView, leftMarin, 0, rightMarin, 0);
}

19 Source : FollowButton.java
with Apache License 2.0
from Zweihui

private void init() {
    View layout = inflate(mContext, R.layout.view_followbutton, this);
    mBtnFollow = (Button) layout.findViewById(R.id.btn_follow);
    mProgressBar = (MaterialProgressBar) layout.findViewById(R.id.loading);
    mProgressBar.bringToFront();
}

19 Source : TitleBehaviorAnim.java
with Apache License 2.0
from Zweihui

/**
 * Created by Administrator on 2017/9/15 0015.
 */
public clreplaced replacedleBehaviorAnim extends CommonAnim {

    private View mHeadView;

    private View mTargetChild;

    public replacedleBehaviorAnim(View headView) {
        mHeadView = headView;
        mTargetChild = headView.findViewById(R.id.toolbar);
    }

    @Override
    public void show() {
        ValueAnimator animator;
        if (mTargetChild != null) {
            animator = ValueAnimator.ofFloat(mHeadView.getY(), 0);
            animator.setDuration(getDuration());
            animator.setInterpolator(getInterpolator());
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    mHeadView.setY((Float) valueAnimator.getAnimatedValue());
                }
            });
        } else {
            animator = ValueAnimator.ofFloat(mHeadView.getY(), 0);
            animator.setDuration(getDuration());
            animator.setInterpolator(getInterpolator());
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    mHeadView.setY((Float) valueAnimator.getAnimatedValue());
                }
            });
        }
        animator.start();
    }

    @Override
    public void hide() {
        ValueAnimator animator;
        if (mTargetChild != null) {
            animator = ValueAnimator.ofFloat(mHeadView.getY(), -mTargetChild.getHeight());
            animator.setDuration(getDuration());
            animator.setInterpolator(getInterpolator());
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    mHeadView.setY((Float) valueAnimator.getAnimatedValue());
                }
            });
        } else {
            animator = ValueAnimator.ofFloat(mHeadView.getY(), -mHeadView.getHeight());
            animator.setDuration(getDuration());
            animator.setInterpolator(getInterpolator());
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    mHeadView.setY((Float) valueAnimator.getAnimatedValue());
                }
            });
        }
        animator.start();
    }
}

19 Source : BottomBehaviorAnim.java
with Apache License 2.0
from Zweihui

/**
 * Created by Administrator on 2017/9/15 0015.
 */
public clreplaced BottomBehaviorAnim extends CommonAnim {

    private View mBottomView;

    private float mOriginalY;

    public BottomBehaviorAnim(View bottomView) {
        mBottomView = bottomView;
        mOriginalY = mBottomView.getY();
    }

    @Override
    public void show() {
        ValueAnimator animator = ValueAnimator.ofFloat(mBottomView.getY(), mOriginalY);
        animator.setDuration(getDuration());
        animator.setInterpolator(getInterpolator());
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                mBottomView.setY((Float) valueAnimator.getAnimatedValue());
            }
        });
        animator.start();
    }

    @Override
    public void hide() {
        ValueAnimator animator = ValueAnimator.ofFloat(mBottomView.getY(), mOriginalY + mBottomView.getHeight());
        animator.setDuration(getDuration());
        animator.setInterpolator(getInterpolator());
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                mBottomView.setY((Float) valueAnimator.getAnimatedValue());
            }
        });
        animator.start();
    }
}

19 Source : CacheFragment.java
with Apache License 2.0
from Zweihui

public void initPopupWindow(View view, int position) {
    PopupWindow popupWindow = new PopupWindow(getActivity());
    popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setContentView(LayoutInflater.from(getActivity()).inflate(R.layout.pop_cache, null));
    popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
    popupWindow.setOutsideTouchable(false);
    popupWindow.setFocusable(true);
    popupWindow.getContentView().findViewById(R.id.tv_delete).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PermissionUtil.externalStorage(new PermissionUtil.RequestPermission() {

                @Override
                public void onRequestPermissionSuccess() {
                    deleteVideoCache(data.get(position), position);
                }

                @Override
                public void onRequestPermissionFailure(List<String> permissions) {
                    UiUtils.snackbarText("Request permissons failure");
                }

                @Override
                public void onRequestPermissionFailureWithAskNeverAgain(List<String> permissions) {
                    UiUtils.snackbarText("Request permissons failure");
                }
            }, mRxPermissions, mAppComponent.rxErrorHandler());
            popupWindow.dismiss();
        }
    });
    popupWindow.showAsDropDown(view, 0, -view.getHeight());
}

19 Source : CacheFragment.java
with Apache License 2.0
from Zweihui

private void gotoDetail(View view, int position) {
    VideoListInfo.Video video = new VideoListInfo.Video();
    video.setData(data.get(position).getVideo());
    TRouter.go(Constants.VIDEO, new DataExtra(Constants.VIDEO_INFO, video).build(), view);
}

19 Source : AuthorIndexFragment.java
with Apache License 2.0
from Zweihui

@SingleClick
private void gotoPlaylist(View view, int position) {
    TRouter.go(Constants.VIDEOLIST, new DataExtra(Constants.COMMON_ID, adapter.getData().get(position).getData().getHeader().getId()).add(Constants.COMMON_TYPE, adapter.getData().get(position).getData().getHeader().getreplacedle()).build(), view.findViewById(R.id.iv_bg));
}

19 Source : AuthorIndexFragment.java
with Apache License 2.0
from Zweihui

@SingleClick
private void gotoAuthorDetail(View view, int position) {
    TRouter.go(Constants.AUTHORDETAIL, new DataExtra(Constants.AUTHOR_ID, data.get(position).getData().getHeader().getId()).build());
}

19 Source : AuthorIndexFragment.java
with Apache License 2.0
from Zweihui

@SingleClick
private void gotoPopular(View view, int position) {
    TRouter.go(Constants.VIDEOLIST, new DataExtra(Constants.COMMON_ID, id).add(Constants.COMMON_TYPE, "popular").build(), view.findViewById(R.id.iv_bg));
}

19 Source : RegistActivity.java
with Apache License 2.0
from Zweihui

@OnClick({ R.id.rl_select_district, R.id.btn_reget_code, R.id.btn_verification })
public void onViewClicked(View view) {
    switch(view.getId()) {
        case R.id.rl_select_district:
            showSelectDistrictDialog();
            break;
        case R.id.btn_reget_code:
            requestPermission(false);
            break;
        case R.id.btn_verification:
            UiUtils.hidesoftInput(this, mToolbar);
            btnNextPressed();
            break;
    }
}

19 Source : MainActivity.java
with Apache License 2.0
from Zweihui

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.im_face:
        case R.id.tv_name:
            gotoLogin();
            break;
    }
}

19 Source : HistoryActivity.java
with Apache License 2.0
from Zweihui

public void initPopupWindow(View view, int position) {
    PopupWindow popupWindow = new PopupWindow(HistoryActivity.this);
    popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setContentView(LayoutInflater.from(HistoryActivity.this).inflate(R.layout.pop_history, null));
    popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
    popupWindow.setOutsideTouchable(false);
    popupWindow.setFocusable(true);
    popupWindow.getContentView().findViewById(R.id.tv_delete).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            deleteVideoHistory(data.get(position), position);
            popupWindow.dismiss();
        }
    });
    popupWindow.getContentView().findViewById(R.id.tv_share).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String share = data.get(position).getShareInfo();
            if (share != null) {
                gotoShare(share);
            }
            popupWindow.dismiss();
        }
    });
    popupWindow.showAsDropDown(view, 0, -view.getHeight());
}

19 Source : HistoryActivity.java
with Apache License 2.0
from Zweihui

@SingleClick
private void gotoDetail(View view, int position) {
    VideoListInfo.Video videoInfo = new VideoListInfo.Video();
    videoInfo.setData(data.get(position).getVideo());
    TRouter.go(Constants.VIDEO, new DataExtra(Constants.VIDEO_INFO, videoInfo).build(), view.findViewById(R.id.iv_bg));
}

19 Source : HeaderPositionCalculator.java
with Apache License 2.0
from zuoweitan

/**
 * Determines if a view should have a sticky header.
 * The view has a sticky header if:
 * 1. It is the first element in the recycler view
 * 2. It has a valid ID replacedociated to its position
 *
 * @param itemView given by the RecyclerView
 * @param orientation of the Recyclerview
 * @param position of the list item in question
 * @return True if the view should have a sticky header
 */
public boolean hreplacedtickyHeader(View itemView, int orientation, int position) {
    int offset, margin;
    mDimensionCalculator.initMargins(mTempRect1, itemView);
    if (orientation == LinearLayout.VERTICAL) {
        offset = itemView.getTop();
        margin = mTempRect1.top;
    } else {
        offset = itemView.getLeft();
        margin = mTempRect1.left;
    }
    return offset <= margin && mAdapter.getHeaderId(position) >= 0;
}

19 Source : ListItemData.java
with Apache License 2.0
from zuoweitan

/**
 * @author Wayne
 */
public clreplaced LisreplacedemData {

    private Integer mIndexInAdapter;

    private View mView;

    private Lisreplacedem mLisreplacedem;

    private boolean mIsVisibleItemChanged;

    public int getIndex() {
        return mIndexInAdapter;
    }

    public View getView() {
        return mView;
    }

    public Lisreplacedem getLisreplacedem() {
        return mLisreplacedem;
    }

    public LisreplacedemData fillWithData(int indexInAdapter, View view, Lisreplacedem item) {
        mIndexInAdapter = indexInAdapter;
        mView = view;
        mLisreplacedem = item;
        return this;
    }

    public boolean isAvailable() {
        return mIndexInAdapter != null && mView != null && mLisreplacedem != null;
    }

    public void setVisibleItemChanged(boolean isDataChanged) {
        mIsVisibleItemChanged = isDataChanged;
    }

    public boolean isVisibleItemChanged() {
        return mIsVisibleItemChanged;
    }

    @Override
    public String toString() {
        return "LisreplacedemData{" + "mIndexInAdapter=" + mIndexInAdapter + ", mView=" + mView + ", mLisreplacedem=" + mLisreplacedem + ", mIsVisibleItemChanged=" + mIsVisibleItemChanged + '}';
    }

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

    @Override
    public int hashCode() {
        int result = mIndexInAdapter != null ? mIndexInAdapter.hashCode() : 0;
        result = 31 * result + (mView != null ? mView.hashCode() : 0);
        return result;
    }
}

19 Source : ListItemData.java
with Apache License 2.0
from zuoweitan

public LisreplacedemData fillWithData(int indexInAdapter, View view, Lisreplacedem item) {
    mIndexInAdapter = indexInAdapter;
    mView = view;
    mLisreplacedem = item;
    return this;
}

19 Source : Utils.java
with Apache License 2.0
from zuoweitan

public static void showInputMethod(final View view, long delayMillis) {
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            showSoftInput(view.getContext(), view);
        }
    }, delayMillis);
}

See More Examples