summaryrefslogtreecommitdiff
path: root/app/src/test/java/android/content/Intent.java
blob: 92211558e95642cf31eb49bae31eb9302ffa6b73 (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
55
56
57
58
59
60
61
package android.content;

import android.os.Bundle;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Intent {
    final String[] action = new String[1];
    final Map<String, Object> fakeExtras = new HashMap<>();
    final List<String> categories = new ArrayList<>();

    public Intent setAction(String action) {
        this.action[0] = action;
        return this;
    }

    public String getAction() {
        return action[0];
    }

    public Intent putExtra(String key, Bundle bundle) {
        fakeExtras.put(key, bundle);
        return this;
    }

    public Bundle getBundleExtra(String key) {
        Object o = fakeExtras.get(key);
        if (o != null) {
            return (Bundle) o;
        }
        return null;
    }

    public Intent putExtra(String key, Parcelable extra) {
        fakeExtras.put(key, extra);
        return this;
    }

    public Parcelable getParcelableExtra(String key) {
        Object o = fakeExtras.get(key);
        if (o != null) {
            return (Parcelable) o;
        }
        return null;
    }

    public Intent addCategory(String key) {
        categories.add(key);
        return this;
    }

    public Set<String> getCategories() {
        return new HashSet<>(categories);
    }
}