Ejemplo n.º 1
0
    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)
      //	             {
      //	             }
      //	         }

    }
Ejemplo n.º 2
0
 private ContentValues tranValues(Transaction trans) {
   ContentValues newValue = new ContentValues();
   newValue.put("acct_id", trans.acct.ID);
   newValue.put("trans_id", trans.transID);
   newValue.put("serv_trans_id", trans.servTransID);
   newValue.put("type", trans.type);
   newValue.put("amt", trans.amt);
   newValue.put(
       "post_date", trans.postDate == null ? null : Long.toString(trans.postDate.getTime()));
   newValue.put(
       "init_date", trans.initDate == null ? null : Long.toString(trans.initDate.getTime()));
   newValue.put(
       "avail_date", trans.availDate == null ? null : Long.toString(trans.availDate.getTime()));
   return newValue;
 }
Ejemplo n.º 3
0
 public Account getAccountFromCursor(Cursor cur) {
   Account acct = new Account();
   acct.ID = cur.getInt(0);
   acct.serviceId = cur.getInt(1);
   acct.name = cur.getString(2);
   String iAge = cur.getString(3);
   acct.lastUpdate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   acct.curBalAmt = cur.getDouble(4);
   iAge = cur.getString(5);
   acct.curBalDate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   acct.availBalAmt = cur.getDouble(6);
   iAge = cur.getString(7);
   acct.availBalDate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   iAge = cur.getString(8);
   acct.lastTrans = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   return acct;
 }
Ejemplo n.º 4
0
  @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));
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
      String sdStatus = Environment.getExternalStorageState();
      if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
        Log.i("TestFile", "SD card is not avaiable/writeable right now.");
        return;
      }
      String name =
          new DateFormat().format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";
      Toast.makeText(this, name, Toast.LENGTH_LONG).show();
      Bundle bundle = data.getExtras();
      Bitmap bitmap = (Bitmap) bundle.get("data"); // 获取相机返回的数据,并转换为Bitmap图片格式

      FileOutputStream b = null;
      File file = new File("/sdcard/myImage/");
      if (!file.exists()) file.mkdirs(); // 创建文件夹

      String fileName = "/sdcard/myImage/" + name;
      File photofile = new File(fileName);
      if (!photofile.exists()) {
        try {
          photofile.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      try {
        b = new FileOutputStream(photofile);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, b); // 把数据写入文件
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          b.flush();
          b.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      // 动态的改变gridview中的一个Item的内容
      bitmapList.set(currentIndex, bitmap);
      myGalleryAdapter.notifyDataSetChanged();
      updatePhoto(
          Long.valueOf(phoneNumberToId.get(phoneNumber.get(currentIndex))), bitmapToBytes(bitmap));
      //            ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bitmap);//
      // 将图片显示在ImageView里
      Intent intent = new Intent(ContactActivity.this, ContactActivity.class);
      this.startActivity(intent);
      this.finish();
    }
  }
Ejemplo n.º 6
0
  private ContentValues acctValues(Account acct) {
    ContentValues newValue = new ContentValues();

    if (acct.service != null) {
      if (acct.service.ID != 0) newValue.put("service_id", acct.service.ID);
    } else {
      if (acct.serviceId != 0) newValue.put("service_id", acct.serviceId);
    }
    newValue.put("name", acct.name);
    newValue.put(
        "last_update", acct.lastUpdate == null ? null : Long.toString(acct.lastUpdate.getTime()));
    newValue.put("curbal_amt", acct.curBalAmt);
    newValue.put(
        "curbal_date", acct.curBalDate == null ? null : Long.toString(acct.curBalDate.getTime()));
    newValue.put("availbal_amt", acct.availBalAmt);
    newValue.put(
        "availbal_date",
        acct.availBalDate == null ? null : Long.toString(acct.availBalDate.getTime()));
    newValue.put(
        "last_trans", acct.lastTrans == null ? null : Long.toString(acct.lastTrans.getTime()));
    return newValue;
  }
  private void updatePhoto(Long rawContactId, byte[] photo) {

    ContentValues values = new ContentValues();
    values.put(ContactsContract.Contacts.Photo.PHOTO, photo);

    String selection =
        ContactsContract.RawContacts.Data.RAW_CONTACT_ID
            + "=? and "
            + ContactsContract.RawContacts.Data.MIMETYPE
            + "=?";
    String[] selectionArgs =
        new String[] {
          Long.toString(rawContactId), ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE
        };

    getContentResolver()
        .update(ContactsContract.Data.CONTENT_URI, values, selection, selectionArgs);
  }