コード例 #1
0
ファイル: AIMAccount.java プロジェクト: morpeh/Dolca-HD
    public void applyInfoToFriendFromBuddyInfo(final Friend friend, BuddyInfo info) {
      friend.setIsAvailable(true);
      long status = info.getIcqStatus();
      if ((status & FullUserInfo.ICQSTATUS_AWAY) == 1) {
        friend.setStatus(Friend.Status.AWAY);
      } else if (((status & FullUserInfo.ICQSTATUS_DND) == 1)) {
        friend.setStatus(Friend.Status.DND);
      } else if ((status & FullUserInfo.ICQSTATUS_OCCUPIED) == 1) {
        friend.setStatus(Friend.Status.DND);
      } else if ((status & FullUserInfo.ICQSTATUS_NA) == 1) {
        friend.setStatus(Friend.Status.NA);
      } else if ((status & FullUserInfo.ICQSTATUS_DEFAULT) == 1) {
        friend.setStatus(Friend.Status.AVAILABLE);
      } else if ((status & FullUserInfo.ICQSTATUS_FFC) == 1) {
        friend.setStatus(Friend.Status.AVAILABLE);
      }

      friend.setStatusMessage(info.getStatusMessage());
      //			Screenname buddy = new Screenname(friend.getUserName());
      //			connection.getInfoService().requestDirectoryInfo(buddy);
      //			connection.getInfoService().requestUserProfile(buddy);

      //			 int requestId = nextSeqId();
      long buddyUIN = Long.parseLong(friend.getUserName());
      long ownerUIN = Long.parseLong(getUserName());
      MetaShortInfoRequest req = new MetaShortInfoRequest(ownerUIN, 2, buddyUIN);

      //	         ShortInfoResponseRetriever responseRetriever = new ShortInfoResponseRetriever();
      connection
          .getInfoService()
          .getOscarConnection()
          .sendSnacRequest(
              req,
              new SnacRequestAdapter() {
                public void handleResponse(SnacResponseEvent e) {
                  SnacCommand snac = e.getSnacCommand();
                  if (snac instanceof MetaShortInfoCmd) {
                    MetaShortInfoCmd infoSnac = (MetaShortInfoCmd) snac;
                    String nick = infoSnac.getNickname();
                    String firstName = infoSnac.getFirstName();
                    String lastName = infoSnac.getLastName();
                    String fullname = firstName + " " + lastName;
                    if (fullname.length() < 2) fullname = nick;
                    friend.setName(fullname);
                  }
                }
              });

      //	         synchronized(responseRetriever)
      //	         {
      //	             try{
      //	                 responseRetriever.wait(30000);
      //	             }
      //	             catch (InterruptedException ex)
      //	             {
      //	             }
      //	         }

    }
コード例 #2
0
ファイル: ImageUtils.java プロジェクト: shliujing/root-tools
 public static String getImageAbsolutePath(Context context, Uri imageUri) {
   if (context == null || imageUri == null) {
     return null;
   }
   if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT
       && DocumentsContract.isDocumentUri(context, imageUri)) {
     if (isExternalStorageDocument(imageUri)) {
       String docId = DocumentsContract.getDocumentId(imageUri);
       String[] split = docId.split(":");
       String type = split[0];
       if ("primary".equalsIgnoreCase(type)) {
         return Environment.getExternalStorageDirectory() + "/" + split[1];
       }
     } else if (isDownloadsDocument(imageUri)) {
       String id = DocumentsContract.getDocumentId(imageUri);
       Uri contentUri =
           ContentUris.withAppendedId(
               Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
       return getDataColumn(context, contentUri, null, null);
     } else if (isMediaDocument(imageUri)) {
       String docId = DocumentsContract.getDocumentId(imageUri);
       String[] split = docId.split(":");
       String type = split[0];
       Uri contentUri = null;
       if ("image".equals(type)) {
         contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
       } else if ("video".equals(type)) {
         contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
       } else if ("audio".equals(type)) {
         contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
       }
       String selection = MediaStore.Images.Media._ID + "=?";
       String[] selectionArgs = new String[] {split[1]};
       return getDataColumn(context, contentUri, selection, selectionArgs);
     }
   } else if ("content".equalsIgnoreCase(imageUri.getScheme())) {
     if (isGooglePhotosUri(imageUri)) return imageUri.getLastPathSegment();
     return getDataColumn(context, imageUri, null, null);
   } else if ("file".equalsIgnoreCase(imageUri.getScheme())) {
     return imageUri.getPath();
   }
   return null;
 }
コード例 #3
0
ファイル: Godot.java プロジェクト: gokudomatic/godot
  @Override
  public void onDownloadProgress(DownloadProgressInfo progress) {
    mAverageSpeed.setText(
        getString(
            com.godot.game.R.string.kilobytes_per_second,
            Helpers.getSpeedString(progress.mCurrentSpeed)));
    mTimeRemaining.setText(
        getString(
            com.godot.game.R.string.time_remaining,
            Helpers.getTimeRemaining(progress.mTimeRemaining)));

    progress.mOverallTotal = progress.mOverallTotal;
    mPB.setMax((int) (progress.mOverallTotal >> 8));
    mPB.setProgress((int) (progress.mOverallProgress >> 8));
    mProgressPercent.setText(
        Long.toString(progress.mOverallProgress * 100 / progress.mOverallTotal) + "%");
    mProgressFraction.setText(
        Helpers.getDownloadProgressString(progress.mOverallProgress, progress.mOverallTotal));
  }