Beispiel #1
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);
 }
Beispiel #2
0
  public AdapterBoss(Context context, List<List<LessonFragment>> datas) {
    super();
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    margin = DensityUtils.dip2px(context, 10);
    //        imgWidth = (int) ((AppInfo.getScreenWidth() - margin * 4) / 2.5);
    imgWidth = (int) ((AppInfo.getScreenWidth() - margin * 6) / 2.5);
    imgBigWidth = (int) (imgWidth * 1.5);
    //        marginBig = (int) (margin + (imgWidth * 0.5 / 6));
    marginBig = (int) (margin + (imgWidth * 0.5 / 6));
    //        marginBig = margin;

    // 一张图片距离
    distance1 = (int) (imgWidth + marginBig * 2);
    // 一半图片距离
    distance2 = distance1 / 2;
    int step = 1;
    int pageNo = 0;
    int prevSize = 0;
    int currSize = 0;
    int distance = 0;
    this.datas.add(null);
    for (List<LessonFragment> list : datas) {
      stepMap.put(pageNo, -1);
      for (LessonFragment lessonFragment : list) {
        this.datas.addAll(lessonFragment.getDatas());
        currSize = lessonFragment.getDatas().size();

        if (stepMap.get(pageNo) == -1) {
          stepMap.put(pageNo, step);
          pageMap.put(step, pageNo);
        }

        // 第一次进来
        if (firstSize == 0) {
          firstSize = currSize;
        }
        if (prevSize == 0) {
          if (currSize == 1) {
            distanceMap.put(step++, distance);
          } else {
            distanceMap.put(step++, distance);
            distanceMap.put(step++, distance);
          }
        } else if (prevSize == 1) {
          if (currSize == 1) {
            distance += distance1;
            distanceMap.put(step++, distance);
          } else {
            distance += distance1 + distance2;
            distanceMap.put(step++, distance);
            distanceMap.put(step++, distance);
          }
        } else {
          if (currSize == 1) {
            distance += distance1 * 2 - distance2;
            distanceMap.put(step++, distance);
          } else {
            distance += distance1 * 2;
            distanceMap.put(step++, distance);
            distanceMap.put(step++, distance);
          }
        }
        prevSize = currSize;
      }
      ++pageNo;
    }
    this.datas.add(null);
  }