Esempio n. 1
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;
   }
 }
Esempio n. 2
0
 protected void initData() {
   super.initData();
   setContentView(R.layout.aty_download);
   btnBack = (ImageButton) findViewById(R.id.btnBack);
   btnBack.setOnClickListener(this);
   lvDownloads = (ListView) findViewById(R.id.lvDownloads);
   refreshData();
   GlobalResTypes.getInstance().setCallBackType4(callbackResDownload);
 }
Esempio n. 3
0
 protected void refreshData() {
   // 检测type2s 数据是否已加载
   EntityResType2 t2 = null;
   List<EntityResType2> unfinishedType2s = new ArrayList<EntityResType2>();
   for (String key : GlobalResTypes.ALL_TYPE2S_MAP.keySet()) {
     t2 = GlobalResTypes.ALL_TYPE2S_MAP.get(key);
     if (!t2.isFinished()) unfinishedType2s.add(t2);
   }
   if (unfinishedType2s.size() > 0) {
     allDownloadType2Size = unfinishedType2s.size();
     showLoading(getString(R.string.loaddingTip2));
     GlobalResTypes.getInstance().setCallBackType2(callbackResDownload2);
     for (EntityResType2 entityResType2 : unfinishedType2s) {
       GlobalResTypes.getInstance().startDownload(entityResType2);
     }
     return;
   }
   String userLessonType1 = GlobalRes.getInstance().getBeans().getDefaultLessonId();
   EntityResType1 type1 = null;
   for (String key : GlobalResTypes.ALL_TYPE1S_MAP.keySet()) {
     type1 = GlobalResTypes.ALL_TYPE1S_MAP.get(key);
     if (type1.isBase() && !type1.getId().equals(userLessonType1)) {
       continue;
     }
     entitys.add(type1);
     for (EntityResType2 type2 : type1.getType2s()) {
       entitys.add(type2);
       for (EntityResType4 type4 : type2.getType4s()) {
         entitys.add(type4);
       }
     }
   }
   try {
     mAdapter = new AdapterSimpleTree(lvDownloads, this, entitys, 1);
     mAdapter.setOnTreeNodeClickListener(this);
     mAdapter.setCallback(this);
   } catch (Exception e) {
     e.printStackTrace();
   }
   lvDownloads.setAdapter(mAdapter);
 }
Esempio n. 4
0
 private void refreshCurrentView(LessonData data, ViewHolder holder, int position) {
   if (position == 0) {
     holder.img.setVisibility(View.INVISIBLE);
     if (firstSize == 2) {
       ViewUtils.setLinearMargins(
           holder.llImgsContainer, marginBig, LinearLayout.LayoutParams.MATCH_PARENT, 0, 0, 0, 0);
     } else {
       ViewUtils.setLinearMargins(
           holder.llImgsContainer,
           ((AppInfo.getScreenWidth() - imgWidth) >> 1) - marginBig,
           LinearLayout.LayoutParams.MATCH_PARENT,
           0,
           0,
           0,
           0);
     }
     return;
   }
   if (position == getCount() - 1) {
     holder.img.setVisibility(View.INVISIBLE);
     ViewUtils.setLinearMargins(
         holder.llImgsContainer,
         ((AppInfo.getScreenWidth() - imgWidth) >> 1),
         LinearLayout.LayoutParams.MATCH_PARENT,
         0,
         0,
         0,
         0);
     return;
   }
   ViewUtils.setLinearMargins(
       holder.llImgsContainer,
       LinearLayout.LayoutParams.WRAP_CONTENT,
       LinearLayout.LayoutParams.MATCH_PARENT,
       0,
       0,
       0,
       0);
   holder.img.setVisibility(View.VISIBLE);
   if (null == data) {
     return;
   }
   ////    	//60 60 100 45
   ////    	int h = AppInfo.getScreenHeight() -
   // DensityUtils.dip2px(holder.llImgsContainer.getContext(), 60 + 60 + 100 + 45);
   String path = data.getAnswer().getLocalImgPath();
   holder.img.clear();
   holder.img.setWrong();
   GlobalResTypes.getInstance().displayLessonBitmapNoCache(path, holder.img);
 }
Esempio n. 5
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   GlobalResTypes.getInstance().clearCallbackType2();
   GlobalResTypes.getInstance().clearCallbackType4();
 }