private void hideChathead() {
   Logger.INTERNAL("notificationAvatar", "hiding notificationAvatar");
   this.rootView.setVisibility(8);
   this.notificationAvatar.setVisibility(8);
   this.shadow.setVisibility(8);
   this.indicatorLayout.setVisibility(8);
 }
 public void onRebind(Intent intent) {
   Logger.INTERNAL("notificationAvatar", "on rebind");
   this.mBound = true;
   hideChathead();
   Bridge.getPoller().startInboxPolling();
   super.onRebind(intent);
 }
 public boolean onUnbind(Intent intent) {
   Logger.INTERNAL("notificationAvatar", "on unbind");
   this.mBound = false;
   getUnreadConversations();
   Bridge.getPoller().startPreviewPolling();
   return true;
 }
 public IBinder onBind(Intent intent) {
   Logger.INTERNAL("notificationAvatar", "on bind");
   this.mBound = true;
   hideChathead();
   Bridge.getPoller().startInboxPolling();
   return null;
 }
 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");
 }
 private void showChathead() {
   if (!this.mBound) {
     Logger.INTERNAL("notificationAvatar", "showing notificationAvatar");
     this.rootView.setVisibility(0);
     this.notificationAvatar.setVisibility(0);
     this.shadow.setVisibility(0);
     this.indicatorLayout.setVisibility(0);
   }
 }
 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();
 }