blob: d5bde090709476c6c4a7013e15c25f5f6bf53fb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package com.xtremelabs.robolectric.shadows;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;
import java.util.HashMap;
import java.util.Map;
@Implements(LayerDrawable.class)
public class ShadowLayerDrawable extends ShadowDrawable {
@RealObject
protected LayerDrawable realLayerDrawable;
protected Drawable[] drawables;
private Map<Integer, Integer> indexForId = new HashMap<Integer, Integer>();
public void __constructor__(Drawable[] drawables) {
this.drawables = drawables;
}
@Implementation
public int getNumberOfLayers() {
return drawables.length;
}
@Implementation
public Drawable getDrawable( int idx ) {
Drawable d = null;
if( idx < drawables.length && idx >= 0 ) {
d = drawables[ idx ];
}
return d;
}
@Implementation
public boolean setDrawableByLayerId(int id, Drawable drawable) {
if (!indexForId.containsKey(id)) {
return false;
}
drawables[indexForId.get(id)] = drawable;
return true;
}
@Implementation
public void setId(int index, int id) {
indexForId.put(id, index);
}
}
|