Example #1
0
 public void connectionClosedOnError(Exception e) {
   Log.e("ConListener", "connectionClosedOnError");
   if (!service.isAuthenticated()) Notify.offlineNotify(context, "Connection closed");
   if (!isStarted) {
     isStarted = true;
     context.sendBroadcast(new Intent(Constants.UPDATE));
     Log.e("ConListener", "Trying to connect");
     new Thread() {
       public void run() {
         while (!service.isAuthenticated(account)) {
           service.reconnect(account);
           try {
             Thread.sleep(30000);
           } catch (Exception ignored) {
           }
         }
         isStarted = false;
       }
     }.start();
   }
 }
Example #2
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.offline:
       if (prefs.getBoolean("hideOffline", false)) service.setPreference("hideOffline", false);
       else service.setPreference("hideOffline", true);
       updateMenu();
       updateList();
       break;
     case R.id.status:
       RosterDialogs.changeStatusDialog(this, null, null);
       break;
     case android.R.id.home:
       RosterDialogs.changeStatusDialog(this, null, null);
       break;
     case R.id.add:
       RosterDialogs.addDialog(this, null);
       break;
     case R.id.search:
       menu.removeItem(R.id.chats);
       item.expandActionView();
       break;
     case R.id.bookmarks:
       Intent bIntent = new Intent(this, Bookmarks.class);
       startActivity(bIntent);
       break;
     case R.id.chats:
       ChangeChatDialog.show(this);
       break;
     case R.id.accounts:
       Intent aIntent = new Intent(this, Accounts.class);
       startActivity(aIntent);
       break;
     case R.id.prefs:
       startActivityForResult(new Intent(this, Preferences.class), ACTIVITY_PREFERENCES);
       break;
     case R.id.disco:
       startActivity(new Intent(this, ServiceDiscovery.class));
       break;
     case R.id.notes:
       startActivity(new Intent(this, NotesActivity.class));
       break;
     case R.id.xml:
       startActivity(new Intent(this, XMLConsole.class));
       break;
     case R.id.notify:
       if (prefs.getBoolean("soundDisabled", false)) service.setPreference("soundDisabled", false);
       else service.setPreference("soundDisabled", true);
       updateMenu();
       break;
     case R.id.exit:
       if (prefs.getBoolean("DeleteHistory", false)) {
         getContentResolver().delete(JTalkProvider.CONTENT_URI, null, null);
       }
       Notify.cancelAll(this);
       stopService(new Intent(this, JTalkService.class));
       finish();
       System.exit(0);
       break;
     default:
       return false;
   }
   return true;
 }