Search in sources :

Example 66 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project Collar by CodeZsx.

the class DirectMsgActivity method initView.

@Override
public void initView() {
    EventBusUtils.register(this);
    // 获取intent传递过来的uid,screen_name
    mUid = getIntent().getStringExtra(INTENT_UID);
    mScreenName = getIntent().getStringExtra(INTENT_SCREEN_NAME);
    setToolbarTitle(mBinding.toolbar, mScreenName);
    mAdapter = new DirectMsgConversationAdapter(this);
    mAdapter.setUid(AccessTokenKeeper.getInstance().getUid());
    mBinding.recyclerView.setAdapter(mAdapter);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true);
    mBinding.recyclerView.setLayoutManager(linearLayoutManager);
    // 设置edittext
    mBinding.etContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if ("".equals(s.toString())) {
                mBinding.ivCommit.setSelected(false);
            } else {
                mBinding.ivCommit.setSelected(true);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    // 设置表情界面
    EmojiFragment emojiFragment = new EmojiFragment();
    getSupportFragmentManager().beginTransaction().add(R.id.rl_additional, emojiFragment).show(emojiFragment).commit();
    emojiFragment.addOnEmojiClickListener(new EmojiFragment.OnEmojiClickListener() {

        @Override
        public void onEmojiDelete() {
            L.e("delete");
        }

        @Override
        public void onEmojiClick(Emoji emoji) {
            // TODO:增加表情转化功能
            // mBinding.etContent.setText(EmojiUtil.transEmoji(mBinding.etContent.getText().toString() + emoji.getContent(), DirectMsgActivity.this));
            mBinding.etContent.setText(mBinding.etContent.getText().toString() + emoji.getContent());
            mBinding.etContent.setSelection(mBinding.etContent.getText().length());
        }
    });
    // 当软键盘呼出时,关闭表情界面
    getWindow().getDecorView().addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        int oldRectBottom = 0;

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            // 获取View可见区域的bottom
            Rect rect = new Rect();
            getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
            // 界面收缩即软键盘正在打开
            if (rect.bottom - oldRectBottom < 0) {
                mBinding.rlAdditional.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        mBinding.rlAdditional.setVisibility(View.GONE);
                        mBinding.ivEmoj.setSelected(false);
                    }
                }, 10);
            } else if (rect.bottom - oldRectBottom > 0) {
            // 界面扩展即软键盘正在关闭
            }
            oldRectBottom = rect.bottom;
        }
    });
    mBinding.ivCommit.setOnClickListener(this);
    mBinding.ivEmoj.setOnClickListener(this);
    // mBinding.getRoot().addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
    // @Override
    // public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
    // //获取View可见区域的bottom
    // Rect rect = new Rect();
    // getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    // if(bottom!=0 && oldBottom!=0 && bottom - rect.bottom <= 0){
    // L.e("keboard close");
    // }else {
    // mBinding.rlAdditional.setVisibility(View.GONE);
    // mBinding.ivEmoj.setSelected(false);
    // L.e("keyboard open");
    // }
    // }
    // });
    loadData();
}
Also used : Rect(android.graphics.Rect) EmojiFragment(com.codez.collar.fragment.EmojiFragment) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) DirectMsgConversationAdapter(com.codez.collar.adapter.DirectMsgConversationAdapter) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Emoji(com.codez.collar.ui.emoji.Emoji)

Example 67 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project BaseRecyclerViewAdapter by donghan0912.

the class BaseViewHolder method setVisibility.

/**
 * @param id the id of view
 * @param visibility the value should be View.GONE, View.INVISIBLE or View.VISIBLE
 * @return ViewHolder
 */
public BaseViewHolder setVisibility(@IdRes int id, int visibility) {
    View view = findViewById(id);
    if (visibility != View.GONE && visibility != View.INVISIBLE && visibility != View.VISIBLE) {
        throw new IllegalStateException("the visibility value not right");
    }
    view.setVisibility(visibility);
    return this;
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 68 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project GomoTest by suReZj.

the class MyDecoration method drawHorizontalLine.

// 画横线, 这里的parent其实是显示在屏幕显示的这部分
public void drawHorizontalLine(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        // 获得child的布局信息
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    // Log.d("wnw", left + " " + top + " "+right+"   "+bottom+" "+i);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 69 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project gh4a by slapperwan.

the class DividerItemDecoration method onDraw.

@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
        return;
    }
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount - 1; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int top = child.getBottom() + params.bottomMargin;
        int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 70 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project LearnApp by YouCii.

the class RecyclerItemDecoration method drawHorizontal.

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

View (android.view.View)315 RecyclerView (android.support.v7.widget.RecyclerView)294 Paint (android.graphics.Paint)47 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)29 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 ViewGroup (android.view.ViewGroup)15 Intent (android.content.Intent)13 Rect (android.graphics.Rect)12 Preference (android.support.v7.preference.Preference)12 GridLayoutManager (android.support.v7.widget.GridLayoutManager)11 SuppressLint (android.annotation.SuppressLint)10 AlertDialog (android.support.v7.app.AlertDialog)10 Bundle (android.os.Bundle)9 Bitmap (android.graphics.Bitmap)8 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)8 Button (android.widget.Button)8 PreferenceScreen (android.support.v7.preference.PreferenceScreen)7 ArrayList (java.util.ArrayList)7 Animator (android.animation.Animator)6