示例#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);
  }
示例#2
0
  private static Bitmap getDefaultHeadImage() throws Exception {

    if (sm_defaultHeadImage == null) {

      if (sm_mainApp == null && UiApplication.getUiApplication() instanceof recvMain) {
        sm_mainApp = (recvMain) UiApplication.getUiApplication();
      }

      byte[] bytes =
          IOUtilities.streamToBytes(
              sm_mainApp
                  .getClass()
                  .getResourceAsStream(
                      fsm_largeHeadImage ? "/defaultHeadImage_l.png" : "/defaultHeadImage.png"));
      sm_defaultHeadImage = EncodedImage.createEncodedImage(bytes, 0, bytes.length).getBitmap();
      sm_defaultHeadImageHashCode = bytes.length;
    }

    return sm_defaultHeadImage;
  }
示例#3
0
 // ! debug information output
 private static void debugOutput(String _debug) {
   if (sm_mainApp != null) {
     sm_mainApp.SetErrorString(_debug);
   }
 }
示例#4
0
 // ! exception output
 private static void exceptionOutput(String _tag, Exception e) {
   if (sm_mainApp != null) {
     sm_mainApp.SetErrorString(_tag, e);
   }
 }
示例#5
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;
  }