xxedms.zip

  • WnFGm9
    了解作者
  • cubesuit
    开发工具
  • 5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2018-10-30 00:12
    上传日期
利用相应的信息技术以及互联网技术来协调企业与顾客间在销售、营销和服务上的交互
xxedms.zip
  • LongTextConvert.java
    642B
  • AccountsPresentComponent.java
    607B
  • StatusCommentsPresentModule.java
    979B
  • ChatFragment.java
    17.2KB
  • ChatManagerPresent.java
    136B
内容介绍
package com.caij.emore.ui.fragment; import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.util.ArrayMap; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import com.caij.emore.Key; import com.caij.emore.R; import com.caij.emore.account.Token; import com.caij.emore.account.UserPrefs; import com.caij.emore.bean.Emotion; import com.caij.emore.bean.ImageInfo; import com.caij.emore.bean.wrap.DirectMessageWrap; import com.caij.emore.di.ManagerAndApiComponent; import com.caij.emore.di.present.component.DaggerChatPresentComponent; import com.caij.emore.di.present.module.ChatPresentModule; import com.caij.emore.database.bean.DirectMessage; import com.caij.emore.event.EventTag; import com.caij.emore.present.ChatPresent; import com.caij.emore.present.imp.ChatPresentImp; import com.caij.emore.ui.activity.BaseActivity; import com.caij.emore.ui.activity.UserInfoActivity; import com.caij.emore.ui.adapter.MessageAdapter; import com.caij.emore.ui.adapter.delegate.MessageDelegateProvider; import com.caij.emore.ui.view.DirectMessageView; import com.caij.emore.ui.activity.ImagePrewActivity; import com.caij.lib.util.DialogUtil; import com.caij.lib.util.DrawableUtil; import com.caij.emore.utils.weibo.NavigationUtil; import com.caij.lib.util.SystemUtil; import com.caij.emore.utils.rxbus.RxBus; import com.caij.lib.widget.recyclerview.HeaderAndFooterRecyclerViewAdapter; import com.caij.lib.widget.recyclerview.OnItemPartViewClickListener; import com.caij.lib.widget.recyclerview.XRecyclerView; import com.caij.lib.widget.recyclerview.LoadMoreView; import com.caij.rvadapter.RecyclerViewOnItemClickListener; import com.caij.rvadapter.RecyclerViewOnItemLongClickListener; import java.util.ArrayList; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import rx.Observable; import rx.functions.Action1; import static android.support.v7.widget.RecyclerView.*; /** * Created by Caij on 2016/7/10. */ public class ChatFragment extends BaseFragment<ChatPresent> implements BaseActivity.OnActivityBackPressedListener, DirectMessageView, TextWatcher, RecyclerViewOnItemClickListener, OnItemPartViewClickListener, RecyclerViewOnItemLongClickListener, OnTouchListener { @BindView(R.id.recycler_view) RecyclerView mRecyclerView; @BindView(R.id.iv_emotion) ImageView ivEmotion; @BindView(R.id.iv_add) ImageView ivAdd; @BindView(R.id.tv_send) TextView tvSend; @BindView(R.id.fl_emotion) FrameLayout flEmotion; @BindView(R.id.et_content) EditText etContent; private MessageAdapter mMessageAdapter; private LoadMoreView mLoadMoreView; private LinearLayoutManager mLinearLayoutManager; private HeaderAndFooterRecyclerViewAdapter headerAndFooterRecyclerViewAdapter; private Observable<Emotion> mEmotionObservable; private Observable<Object> mEmotionDeleteObservable; private long recipientId; public static ChatFragment newInstance(long uid) { Bundle args = new Bundle(); args.putLong(Key.ID, uid); ChatFragment fragment = new ChatFragment(); fragment.setArguments(args); return fragment; } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_chat, container, false); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setHasOptionsMenu(true); initView(); initIconImage(); getChildFragmentManager().beginTransaction(). replace(R.id.fl_emotion, new EmotionFragment()).commit(); mEmotionObservable = RxBus.get().register(EventTag.ON_EMOTION_CLICK); mEmotionDeleteObservable = RxBus.get().register(EventTag.ON_EMOTION_DELETE_CLICK); mEmotionObservable.subscribe(new Action1<Emotion>() { @Override public void call(Emotion emotion) { onEmotionClick(emotion); } }); mEmotionDeleteObservable.subscribe(new Action1<Object>() { @Override public void call(Object o) { onEmotionDeleteClick(); } }); mMessageAdapter.registerAdapterDataObserver(mPresent.getAdapterDataObserver()); } private void initView() { mLinearLayoutManager = new LinearLayoutManager(getActivity()); mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mLinearLayoutManager.setStackFromEnd(true); mRecyclerView.setLayoutManager(mLinearLayoutManager); mMessageAdapter = new MessageAdapter(getActivity(), this); mMessageAdapter.setOnItemClickListener(this); headerAndFooterRecyclerViewAdapter = new HeaderAndFooterRecyclerViewAdapter(mMessageAdapter); mLoadMoreView = new LoadMoreView(getActivity()); mLoadMoreView.setState(XRecyclerView.STATE_EMPTY); headerAndFooterRecyclerViewAdapter.addHeaderView(mLoadMoreView); mMessageAdapter.setOnItemLongClickListener(this); etContent.addTextChangedListener(this); mRecyclerView.setAdapter(headerAndFooterRecyclerViewAdapter); etContent.setOnTouchListener(this); mRecyclerView.addOnScrollListener(new ScrollListener()); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_chat, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId() == R.id.block) { mPresent.blockUser(recipientId); return true; } return super.onOptionsItemSelected(item); } @Override public void onStart() { super.onStart(); mPresent.onStart(); } @Override public void onStop() { super.onStop(); mPresent.onStop(); } private void hideBottom() { SystemUtil.hideKeyBoard(getActivity()); showEmotionView(false); } protected void onEmotionDeleteClick() { KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); etContent.dispatchKeyEvent(event); } protected void onEmotionClick(Emotion emotion) { Editable editAble = etContent.getEditableText(); int start = etContent.getSelectionStart(); editAble.insert(start, emotion.key); } private void loadMore() { mPresent.loadMore(); } private void initIconImage() { Drawable emotionDrawable = DrawableUtil.createSelectDrawable(getActivity(), R.mipmap.compose_emoticonbutton_background, R.color.icon_normal_color, R.color.colorPrimary); ivEmotion.setImageDrawable(emotionDrawable); Drawable addDrawable = DrawableUtil.createSelectDrawable(getActivity(), R.mipmap.navigationbar_subsribe_manage, R.color.icon_normal_color, R.color.colorPrimary
评论
    相关推荐