public void onCreate() { super.onCreate(); isAlive = true; Bridge.init(getApplicationContext()); if (Prefs.isLeftAligned(getApplicationContext())) { this.rootView = (RelativeLayout) LayoutInflater.from(this) .inflate(C0901R.layout.intercomsdk_chathead_layout_left_aligned, null); } else { this.rootView = (RelativeLayout) LayoutInflater.from(this) .inflate(C0901R.layout.intercomsdk_chathead_layout_right_aligned, null); } this.conversations = PreviewStateHolder.getInstance().getUnreadConversations(); this.unreadCount = this.conversations.size(); this.currentlyDisplayedConversation = new Conversation(); this.mBound = false; this.windowManager = (WindowManager) getSystemService("window"); this.params = new LayoutParams(-2, -2, 2002, 520, -3); setUpBoundaries(); this.windowManager.addView(this.rootView, this.params); initializeChathead(); Bridge.getBus().register(this); Bridge.getBus().register(PreviewStateHolder.getInstance()); Bridge.getPoller().startPreviewPolling(); Logger.INTERNAL("notificationAvatar", "on create"); }
public int onStartCommand(Intent intent, int flags, int startId) { Logger.INTERNAL("notificationAvatar", "on start command"); if (intent != null) { PreviewStateHolder stateHolder = PreviewStateHolder.getInstance(); stateHolder.setPreviewVisiblity( intent.getIntExtra(PREVIEW_VISIBILITY, stateHolder.getPreviewVisibility())); } checkConversations(); return 2; }
public void onDestroy() { Logger.INTERNAL("notificationAvatar", "on destroy"); if (this.rootView != null) { this.windowManager.removeView(this.rootView); } Bridge.getBus().unregister(this); Bridge.getBus().unregister(PreviewStateHolder.getInstance()); Bridge.getPoller().endPolling(); unregisterReceiver(this.mBroadcastReceiver); isAlive = false; super.onDestroy(); }
private void checkConversations() { if (PreviewStateHolder.getInstance().getPreviewVisibility() != 0) { hideChathead(); } else if (this.conversations.isEmpty()) { hideChathead(); } else { Conversation conversation = (Conversation) this.conversations.get(0); String messageStyle = conversation.getLastPart().getMessageStyle(); if (Part.ANNOUNCEMENT_MESSAGE_STYLE.equals(messageStyle) || Part.SMALL_ANNOUNCEMENT_MESSAGE_STYLE.equals(messageStyle)) { Intent intent = new Intent(this, MainActivity.class); intent.putExtra(Constants.CREATE_CONVERSATION, conversation); intent.addFlags(268435456); startActivity(intent); } else if (Part.CHAT_MESSAGE_STYLE.equals(messageStyle)) { updateChatHeadUI(conversation); } } }