aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/xtremelabs/robolectric/shadows/ShadowTypedArray.java
blob: 74054be260b4d9df5701fbc6f28c6e5f3e42d2b0 (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
52
53
54
package com.xtremelabs.robolectric.shadows;

import android.content.res.Resources;
import android.content.res.TypedArray;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings({"UnusedDeclaration"})
@Implements(TypedArray.class)
public class ShadowTypedArray implements UsesResources {
    private Resources resources;
    private List<Object> values = new ArrayList<Object>();

    public void injectResources(Resources resources) {
        this.resources = resources;
    }

    @Implementation
    public Resources getResources() {
        return resources;
    }

    public void add(Object attributeValue) {
        values.add(attributeValue);
    }

    @Implementation
    public java.lang.String getString(int index) {
        return (String) values.get(index);
    }

    @Implementation
    public int getInt(int index, int defValue) {
        return defValue;
    }

    @Implementation
    public int getInteger(int index, int defValue) {
        return defValue;
    }

    @Implementation
    public int getResourceId(int index, int defValue) {
        return defValue;
    }

    @Implementation
    public float getDimension(int index, float defValue) {
        return defValue;
    }
}