Esempio n. 1
0
  private static void SendHeadImageQueryMsg(String _imageID, int _style, boolean _isWeiboOrIM)
      throws Exception {

    if (sm_mainApp.m_dontDownloadWeiboHeadImage) {
      return;
    }

    if (!recvMain.isSDCardSupport() || !sm_mainApp.isSDCardAvailable(false)) {
      return;
    }

    int sign = _isWeiboOrIM ? msg_head.msgWeiboHeadImage : msg_head.msgChatHeadImage;

    ByteArrayOutputStream t_os = new ByteArrayOutputStream();
    t_os.write(sign);
    t_os.write(_style);

    if (_isWeiboOrIM) {
      if (_style == fetchWeibo.QQ_WEIBO_STYLE) {
        sendReceive.WriteString(t_os, _imageID);
      } else {
        sendReceive.WriteLong(t_os, Long.parseLong(_imageID));
      }
    } else {
      sendReceive.WriteString(t_os, _imageID);
    }

    // whether large image
    sendReceive.WriteBoolean(t_os, fsm_headImageWidth == fetchWeibo.fsm_headImageSize_l);

    sm_mainApp.m_connectDeamon.addSendingData(sign, t_os.toByteArray(), true);
  }
Esempio n. 2
0
  private static boolean LoadWeiboImage(WeiboHeadImage _image) {

    String t_imageFilename = null;

    try {

      if (!sm_mainApp.isSDCardAvailable(false)) {
        return true;
      }

      if (fsm_largeHeadImage) {
        if (_image.m_isWeiboOrIM) {
          t_imageFilename =
              sm_mainApp.GetWeiboHeadImageDir(_image.m_weiboStyle) + _image.m_userID + "_l.png";
        } else {
          t_imageFilename =
              sm_mainApp.GetIMHeadImageDir(_image.m_weiboStyle) + _image.m_userID + "_l.png";
        }

      } else {
        if (_image.m_isWeiboOrIM) {
          t_imageFilename =
              sm_mainApp.GetWeiboHeadImageDir(_image.m_weiboStyle) + _image.m_userID + ".png";
        } else {
          t_imageFilename =
              sm_mainApp.GetIMHeadImageDir(_image.m_weiboStyle) + _image.m_userID + ".png";
        }
      }

      FileConnection t_fc = (FileConnection) Connector.open(t_imageFilename, Connector.READ_WRITE);
      try {
        if (t_fc.exists()) {
          InputStream t_fileIn = t_fc.openInputStream();
          try {

            byte[] t_data = new byte[(int) t_fc.fileSize()];
            sendReceive.ForceReadByte(t_fileIn, t_data, t_data.length);

            _image.m_headImage =
                EncodedImage.createEncodedImage(t_data, 0, t_data.length).getBitmap();
            _image.m_dataHash = t_data.length;

          } finally {
            t_fileIn.close();
            t_fileIn = null;
          }

          return true;
        }

      } finally {
        t_fc.close();
        t_fc = null;
      }
    } catch (Exception e) {
      debugOutput("LWI:" + t_imageFilename);
      exceptionOutput("LWI1", e);
    }

    return false;
  }