Search in sources :

Example 1 with Emoji

use of com.codez.collar.ui.emoji.Emoji 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 Emoji

use of com.codez.collar.ui.emoji.Emoji 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 3 with Emoji

use of com.codez.collar.ui.emoji.Emoji in project Collar by CodeZsx.

the class EmojiFragment method getPagerView.

// 获取表情图页的view
private View getPagerView(int position, final ArrayList<Emoji> list) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.item_emoji_pager, null);
    GridView gridView = (GridView) layout.findViewById(R.id.gridView);
    // 初始化当前position的页面表情图list
    final List<Emoji> pagerList = new ArrayList<>();
    pagerList.addAll(list.subList(position * (COLUMNS * ROWS - 1), (COLUMNS * ROWS - 1) * (position + 1) > list.size() ? list.size() : (COLUMNS * ROWS - 1) * (position + 1)));
    // 添加末尾的删除图标,中间有空余,则需添加对应数量的null
    if (pagerList.size() < (COLUMNS * ROWS - 1)) {
        for (int i = pagerList.size(); i < (COLUMNS * ROWS - 1); i++) {
            pagerList.add(null);
        }
    }
    Emoji deleteEmoji = new Emoji();
    deleteEmoji.setResourceId(R.drawable.ic_emoji_delete);
    pagerList.add(deleteEmoji);
    EmojiAdapter mEmojiAdapter = new EmojiAdapter(getContext(), pagerList);
    gridView.setAdapter(mEmojiAdapter);
    gridView.setNumColumns(COLUMNS);
    // 表情点击事件
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == COLUMNS * ROWS - 1) {
                if (listener != null) {
                    listener.onEmojiDelete();
                }
                return;
            }
            if (listener != null) {
                listener.onEmojiClick(pagerList.get(position));
            }
        // TODO:添加到最近list中
        }
    });
    return gridView;
}
Also used : ArrayList(java.util.ArrayList) IndicatorView(com.codez.collar.ui.IndicatorView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) LayoutInflater(android.view.LayoutInflater) Emoji(com.codez.collar.ui.emoji.Emoji) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView)

Aggregations

View (android.view.View)3 Emoji (com.codez.collar.ui.emoji.Emoji)3 Rect (android.graphics.Rect)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 EmojiFragment (com.codez.collar.fragment.EmojiFragment)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 LayoutInflater (android.view.LayoutInflater)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 DirectMsgConversationAdapter (com.codez.collar.adapter.DirectMsgConversationAdapter)1 IndicatorView (com.codez.collar.ui.IndicatorView)1 ArrayList (java.util.ArrayList)1