소스 검색

Invalidates the Android view cache after each shot.

Steve Kellock 9 년 전
부모
커밋
2a42744e73
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5
    3
      android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java

+ 5
- 3
android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java 파일 보기

94
         if (w <= 0 || h <= 0) {
94
         if (w <= 0 || h <= 0) {
95
             throw new RuntimeException("Impossible to snapshot the view: view is invalid");
95
             throw new RuntimeException("Impossible to snapshot the view: view is invalid");
96
         }
96
         }
97
+        if (!view.isDrawingCacheEnabled())
98
+          view.setDrawingCacheEnabled(true);
99
+
97
         Bitmap bitmap = view.getDrawingCache();
100
         Bitmap bitmap = view.getDrawingCache();
98
-        if (bitmap == null)
99
-            view.setDrawingCacheEnabled(true);
100
-        bitmap = view.getDrawingCache();
101
+
101
         if (width != null && height != null && (width != w || height != h)) {
102
         if (width != null && height != null && (width != w || height != h)) {
102
             bitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
103
             bitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
103
         }
104
         }
105
             throw new RuntimeException("Impossible to snapshot the view");
106
             throw new RuntimeException("Impossible to snapshot the view");
106
         }
107
         }
107
         bitmap.compress(format, (int)(100.0 * quality), os);
108
         bitmap.compress(format, (int)(100.0 * quality), os);
109
+        view.setDrawingCacheEnabled(false);
108
     }
110
     }
109
 }
111
 }