Пример #1
0
 public static DownloadImgContextMgr getInstance()
 {
     if (gDownImgContextMgr == null)
     {
         gDownImgContextMgr = new DownloadImgContextMgr();
     }
     return(gDownImgContextMgr);
 }
Пример #2
0
 public static void onImageDownContextDispatcher(object sender, EventArgs e)
 {
     DownloadImgContextMgr.getInstance().clearnFinishedContext();
     if (DownloadImgContextMgr.getInstance().countRunningContext() < MAX_RUNNING)
     {
         DownloadImgContext context = DownloadImgContextMgr.getInstance().getFirstContextNeedHandle();
         if (context == null)
         {
             if (DownloadImgContextMgr.getInstance().countRunningContext() == 0)
             {
                 mTimerObject.stop();
                 //mTimerObject.Stop();
                 //mTimerObject.Close();
                 //mTimerObject.Dispose();
                 mTimerObject = null;
             }
         }
         else
         {
             Log.i("DownloadImgService", "new  imagedown task  startup, msgid = " + context.mImgInfo.nMsgSvrID);
             context.startScene();
         }
     }
 }
Пример #3
0
        public static int doScene(int imgMsgSvrId, ChatMsg item, string toTalker, int compressType = 0)
        {
            // ChatMsg item = StorageMgr.chatMsg.getBySvrID(toTalker, imgMsgSvrId);
            if (item == null)
            {
                Log.e("DownloadImgService", "Not found chat msg by srvidimg " + imgMsgSvrId);
                return(-1);
            }
            if (string.IsNullOrEmpty(item.strClientMsgId))
            {
                item.strClientMsgId = MD5Core.GetHashString(toTalker + imgMsgSvrId + Util.getNowMilliseconds());
                //StorageMgr.chatMsg.modifyMsg(item);
            }
            //MsgTrans trans = StorageMgr.msgImg.getByMsgSvrID(imgMsgSvrId);
            //bool flag = false;
            //if (trans == null)
            //{
            //    trans = new MsgTrans();
            //    flag = true;
            //}
            MsgTrans trans = new MsgTrans();

            trans.nMsgSvrID       = imgMsgSvrId;
            trans.nMsgLocalID     = item.nMsgLocalID;
            trans.strThumbnail    = item.strThumbnail;
            trans.strFromUserName = toTalker;
            trans.strToUserName   = AccountMgr.getCurAccount().strUsrName;
            trans.nTransType      = 2;
            DownloadImgContext context = DownloadImgContextMgr.getInstance().getContextBySvrid(imgMsgSvrId);

            if (context != null)
            {
                if ((context.mCompressType != 0) || (compressType != 1))
                {
                    Log.e("DownloadImgService", "imgMsgSvrId: " + imgMsgSvrId + "has been in Queue");
                    return(-1);
                }
                DownloadImgContextMgr.getInstance().remove(context);
            }
            DownloadImgContext context2 = new DownloadImgContext {
                mImgInfo      = trans,
                mCompressType = compressType,
                mChatMsg      = item,
                beginTime     = (long)Util.getNowMilliseconds()
            };
            CImgMsgContext context3 = parseImageContent(item.strTalker, item.strMsg);

            if (context3 == null)
            {
                Log.e("DownloadImgService", "Parse image msg xml failed: " + item.strContent);
                return(-1);
            }
            context2.mImgMsgContent = context3;
            if (compressType == 1)
            {
                context2.mImgInfo.nTotalDataLen = context3.hdlength;
            }
            else
            {
                context2.mImgInfo.nTotalDataLen = context3.length;
            }
            //if (!context2.intLocalDataFile(trans))
            //{
            //    Log.e("DownloadImgService", "intLocalDataFile failed! ");
            //    return -1;
            //}
            context2.mStatus = 0;
            DownloadImgContextMgr.getInstance().putToHead(context2);
            checkReadyContextDispatcher();
            context2.updateChatMsg();
            //  if (flag)
            // {
            // StorageMgr.msgTrans.add(context2.mImgInfo);
            // }
            return(1);
        }