Search in sources :

Example 1 with EmojiFragment

use of com.codez.collar.fragment.EmojiFragment in project Collar by CodeZsx.

the class PostActivity method initView.

@Override
public void initView() {
    EventBusUtils.register(this);
    isRepost = getIntent().getBooleanExtra(INTENT_REPOST, false);
    if (isRepost) {
        setToolbarTitle(mBinding.toolbar, "转发微博");
        mRetweetedStatus = (StatusBean) getIntent().getSerializableExtra(StatusBean.INTENT_SERIALIZABLE);
        initRetweeted();
    } else {
        setToolbarTitle(mBinding.toolbar, "发布微博");
    }
    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);
            }
            mBinding.tvStatusLength.setText((STATUS_MAX_LENGTH - s.length()) + "");
        }

        @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) {
            L.e(emoji.getContent());
            mBinding.etContent.setText(EmojiUtil.transEmoji(mBinding.etContent.getText().toString() + emoji.getContent(), PostActivity.this));
            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.post(new Runnable() {

                    @Override
                    public void run() {
                        mBinding.rlAdditional.setVisibility(View.GONE);
                        mBinding.ivEmoj.setSelected(false);
                    }
                });
            } else if (rect.bottom - oldRectBottom > 0) {
            // 界面扩展即软键盘正在关闭
            }
            oldRectBottom = rect.bottom;
        }
    });
    mBinding.ivAlbum.setOnClickListener(this);
    mBinding.ivEmoj.setOnClickListener(this);
    mBinding.ivAt.setOnClickListener(this);
    mBinding.ivTopic.setOnClickListener(this);
    mBinding.ivCommit.setOnClickListener(this);
    mBinding.tvAddress.setOnClickListener(this);
}
Also used : Rect(android.graphics.Rect) EmojiFragment(com.codez.collar.fragment.EmojiFragment) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Emoji(com.codez.collar.ui.emoji.Emoji) View(android.view.View)

Example 2 with EmojiFragment

use of com.codez.collar.fragment.EmojiFragment 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)

Aggregations

Rect (android.graphics.Rect)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 View (android.view.View)2 EmojiFragment (com.codez.collar.fragment.EmojiFragment)2 Emoji (com.codez.collar.ui.emoji.Emoji)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 DirectMsgConversationAdapter (com.codez.collar.adapter.DirectMsgConversationAdapter)1