/** * This method is always called whenever the typing status change is received from the subscribed userId or Group * Be careful to instantiate your views here. */ public void createView() { Contact contact = new AppContactService(getContext()).getContactById(typerUserId); removeAllViews(); if (typingText == null) { typingText = new TextView(getContext()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); typingText.setLayoutParams(params); typingText.setTextSize(14); typingText.setTextColor(getContext().getResources().getColor(R.color.apploizc_black_color)); } addView(typingText); if (isTyping) { typingText.setText((contact != null ? contact.getDisplayName() : "") + " is Typing..."); } else { typingText.setText((contact != null ? contact.getDisplayName() : "") + " is not Typing..."); } }
@Override public void onReceive(Context context, Intent intent) { typerUserId = intent.getStringExtra("userId"); String typing = intent.getStringExtra("isTyping"); isTyping = "1".equals(typing); createView(); } }
public void unSubscribe(Channel channel, Contact contact) { Applozic.unSubscribeToTyping(getContext(), channel, contact); if (mReceiver != null) { LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(mReceiver); mReceiver = null; } }
@Override protected void onPause() { Applozic.disconnectPublish(this); typingIndicator.unSubscribe(null, new AppContactService(this).getContactById("reytum6")); super.onPause(); }
@Override protected void onResume() { Applozic.connectPublish(this); typingIndicator.subscribe(null, new AppContactService(this).getContactById("reytum6")); super.onResume(); }
public void subscribe(Channel channel, Contact contact) { Applozic.subscribeToTyping(getContext(), channel, contact); if (mReceiver == null) { mReceiver = new ALTypingReceiver(); } LocalBroadcastManager.getInstance(getContext()).registerReceiver(mReceiver, new IntentFilter(BroadcastService.INTENT_ACTIONS.UPDATE_TYPING_STATUS.toString())); }