예제 #1
0
 public void setViewCount() {
   viewCount = 1;
   final int N = children.size();
   for (int i = 0; i < N; i++) {
     ViewNode child = children.get(i);
     child.setViewCount();
     viewCount += child.viewCount;
   }
 }
예제 #2
0
 public void setProfileRatings() {
   final int N = children.size();
   if (N > 1) {
     double totalMeasure = 0;
     double totalLayout = 0;
     double totalDraw = 0;
     for (int i = 0; i < N; i++) {
       ViewNode child = children.get(i);
       totalMeasure += child.measureTime;
       totalLayout += child.layoutTime;
       totalDraw += child.drawTime;
     }
     for (int i = 0; i < N; i++) {
       ViewNode child = children.get(i);
       if (child.measureTime / totalMeasure >= RED_THRESHOLD) {
         child.measureRating = ProfileRating.RED;
       } else if (child.measureTime / totalMeasure >= YELLOW_THRESHOLD) {
         child.measureRating = ProfileRating.YELLOW;
       } else {
         child.measureRating = ProfileRating.GREEN;
       }
       if (child.layoutTime / totalLayout >= RED_THRESHOLD) {
         child.layoutRating = ProfileRating.RED;
       } else if (child.layoutTime / totalLayout >= YELLOW_THRESHOLD) {
         child.layoutRating = ProfileRating.YELLOW;
       } else {
         child.layoutRating = ProfileRating.GREEN;
       }
       if (child.drawTime / totalDraw >= RED_THRESHOLD) {
         child.drawRating = ProfileRating.RED;
       } else if (child.drawTime / totalDraw >= YELLOW_THRESHOLD) {
         child.drawRating = ProfileRating.YELLOW;
       } else {
         child.drawRating = ProfileRating.GREEN;
       }
     }
   }
   for (int i = 0; i < N; i++) {
     children.get(i).setProfileRatings();
   }
 }