Exemplo n.º 1
0
 @Override
 public void stopHandler(String id, long progress, long max) {
   Node node = mAdapter.getAllNodeMap().get(id);
   node.setProgress(progress);
   node.setMax(max);
   node.setStatus(INode.STATUS_STOP);
 }
Exemplo n.º 2
0
 @Override
 public void startHandler(String id, long max) {
   Node node = mAdapter.getAllNodeMap().get(id);
   node.setMax(max);
   node.setStatus(INode.STATUS_START);
   setViewData(node);
 }
Exemplo n.º 3
0
 @Override
 public void errorHandler(String id) {
   Node node = mAdapter.getAllNodeMap().get(id);
   node.setProgress(0L);
   node.setProgress(1L);
   node.setStatus(INode.STATUS_NORMAL);
   setViewData(node);
 }
Exemplo n.º 4
0
 @Override
 public void progressHandler(String id, long progress, long max) {
   Node node = mAdapter.getAllNodeMap().get(id);
   if (node.getStatus() != INode.STATUS_START) {
     return;
   }
   node.setStatus(INode.STATUS_START);
   node.setProgress(progress);
   node.setMax(max);
   setViewData(node);
 }
Exemplo n.º 5
0
 /**
  * ************************************************************************************************************************
  */
 private void setViewData(Node node) {
   AdapterSimpleTree.ViewHolder v = mAdapter.getViewMap().get(node.getId());
   if (null == v) return;
   Long p = 100L;
   if (node.getStatus() != INode.STATUS_FINISH) {
     p = node.getProgress() * 100 / node.getMax();
   }
   v.pbTreeNode.setProgress(p.intValue());
   v.pbTreeNode.setMax(100);
   AdapterSimpleTree.refreshStatus(v.txtBtn, node.getStatus());
 }
Exemplo n.º 6
0
 @Override
 public void waitingHanler(String id) {
   Node node = mAdapter.getAllNodeMap().get(id);
   node.setStatus(INode.STATUS_WAIT);
   setViewData(node);
 }
Exemplo n.º 7
0
 @Override
 public void finishedHandler(String id) {
   Node node = mAdapter.getAllNodeMap().get(id);
   node.setStatus(INode.STATUS_FINISH);
   setViewData(node);
 }
Exemplo n.º 8
0
 private void refreshDownloadName(Node node) {
   AdapterSimpleTree.ViewHolder v = mAdapter.getViewMap().get(node.getId() + "_dl");
   node.setName(node.isClickedDownloadAll() ? "全部暂停" : "全部下载");
   if (null == v) return;
   v.txtTreeNodeLable.setText(node.getName());
 }
Exemplo n.º 9
0
 @Override
 public void clickHanlder(Node node) {
   if (!node.isLeaf()) {
     return;
   }
 }
Exemplo n.º 10
0
 @Override
 public void onClick(Node node, int position) {
   if (!node.isLeaf()) {
     return;
   }
   if (node.isDownloadAll()) {
     EntityResType2 type2 = GlobalResTypes.ALL_TYPE2S_MAP.get(node.getParent().getId());
     List<EntityResType4> entitys = type2.getType4s();
     if (null != entitys) {
       if (node.isClickedDownloadAll()) {
         node.setClickedDownloadAll(false);
         refreshDownloadName(node);
         for (EntityResType4 entity : entitys) {
           node = mAdapter.getAllNodeMap().get(entity.getId());
           if (node.getStatus() == INode.STATUS_START
               || node.getStatus() == INode.STATUS_WAIT
               || node.getStatus() == INode.STATUS_CONNECTING) {
             node.setStatus(INode.STATUS_STOP);
             entity.setStatus(INode.STATUS_STOP);
             setViewData(node);
           }
         }
         GlobalResTypes.getInstance().stopAllQueueDownload();
         return;
       }
       node.setClickedDownloadAll(true);
       refreshDownloadName(node);
       for (EntityResType4 entity : entitys) {
         node = mAdapter.getAllNodeMap().get(entity.getId());
         if (node.getStatus() == INode.STATUS_NORMAL || node.getStatus() == INode.STATUS_STOP) {
           entity.setStatus(INode.STATUS_CONNECTING);
           node.setStatus(INode.STATUS_CONNECTING);
           setViewData(node);
           GlobalResTypes.getInstance().startDownload(node.getId());
         }
       }
     }
     return;
   }
   switch (node.getStatus()) {
     case INode.STATUS_NORMAL:
     case INode.STATUS_STOP:
       node.setStatus(INode.STATUS_CONNECTING);
       setViewData(node);
       GlobalResTypes.getInstance().startDownload(node.getId());
       break;
     case INode.STATUS_START:
       node.setStatus(INode.STATUS_STOP);
       setViewData(node);
       GlobalResTypes.getInstance().stopDownload(node.getId());
       break;
   }
 }