コード例 #1
0
 private void createShortcut(AbstractContact abstractContact) {
   Intent intent = new Intent();
   intent.putExtra(
       Intent.EXTRA_SHORTCUT_INTENT,
       ChatViewer.createShortCutIntent(
           this, abstractContact.getAccount(), abstractContact.getUser()));
   intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, abstractContact.getName());
   Bitmap bitmap;
   if (MUCManager.getInstance().hasRoom(abstractContact.getAccount(), abstractContact.getUser())) {
     bitmap = AvatarManager.getInstance().getRoomBitmap(abstractContact.getUser());
   } else {
     bitmap = AvatarManager.getInstance().getUserBitmap(abstractContact.getUser());
   }
   intent.putExtra(
       Intent.EXTRA_SHORTCUT_ICON, AvatarManager.getInstance().createShortcutBitmap(bitmap));
   setResult(RESULT_OK, intent);
 }
コード例 #2
0
 @Override
 public void onContactClick(AbstractContact abstractContact) {
   if (action == null) {
     startActivity(
         ChatViewer.createSpecificChatIntent(
             this, abstractContact.getAccount(), abstractContact.getUser()));
     return;
   }
   switch (action) {
     case ACTION_ROOM_INVITE:
       {
         action = null;
         Intent intent = getIntent();
         String account = getRoomInviteAccount(intent);
         String user = getRoomInviteUser(intent);
         if (account != null && user != null) {
           try {
             MUCManager.getInstance().invite(account, user, abstractContact.getUser());
           } catch (NetworkException e) {
             Application.getInstance().onError(e);
           }
         }
         finish();
         break;
       }
     case Intent.ACTION_SEND:
       action = null;
       startActivity(
           ChatViewer.createSendIntent(
               this, abstractContact.getAccount(), abstractContact.getUser(), sendText));
       finish();
       break;
     case Intent.ACTION_CREATE_SHORTCUT:
       {
         createShortcut(abstractContact);
         finish();
         break;
       }
     default:
       startActivity(
           ChatViewer.createSpecificChatIntent(
               this, abstractContact.getAccount(), abstractContact.getUser()));
       break;
   }
 }