• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.robolectric.shadows;
2 
3 import static android.os.Build.VERSION_CODES.KITKAT_WATCH;
4 import static android.os.Build.VERSION_CODES.LOLLIPOP;
5 
6 import android.graphics.Bitmap;
7 import android.graphics.Canvas;
8 import android.graphics.Picture;
9 import org.robolectric.annotation.Implementation;
10 import org.robolectric.annotation.Implements;
11 
12 @Implements(Picture.class)
13 public class ShadowPicture {
14 
15   private int width;
16   private int height;
17 
18   @Implementation
__constructor__()19   protected void __constructor__() {}
20 
21   @Implementation(minSdk = LOLLIPOP)
__constructor__(long nativePicture)22   protected void __constructor__(long nativePicture) {}
23 
24   @Implementation(maxSdk = KITKAT_WATCH)
__constructor__(int nativePicture, boolean fromStream)25   protected void __constructor__(int nativePicture, boolean fromStream) {}
26 
27   @Implementation
__constructor__(Picture src)28   protected void __constructor__(Picture src) {
29     width = src.getWidth();
30     height = src.getHeight();
31   }
32 
33   @Implementation
getWidth()34   protected int getWidth() {
35     return width;
36   }
37 
38   @Implementation
getHeight()39   protected int getHeight() {
40     return height;
41   }
42 
43   @Implementation
beginRecording(int width, int height)44   protected Canvas beginRecording(int width, int height) {
45     this.width = width;
46     this.height = height;
47     return new Canvas(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888));
48   }
49 }
50