summaryrefslogtreecommitdiffstats
path: root/src/org/cyanogenmod/launcher/cards/SimpleMessageCard.java
blob: 97665db337a8c69d03d0d0949e8fb51befbbaba4 (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
package org.cyanogenmod.launcher.cards;

import android.content.Context;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.android.launcher3.R;
import it.gmariotti.cardslib.library.internal.Card;

/**
 * A custom card that will show a title and message only.
 * Swipe is also enabled by default.
 */
public class SimpleMessageCard extends CmCard {
    private String mBody;

    public SimpleMessageCard(Context context) {
        this(context, R.layout.simple_message_card_inner_content);
    }

    public SimpleMessageCard(final Context context, int innerLayout) {
        super(context, innerLayout);
        setSwipeable(true);
    }

    @Override
    public void onUndoSwipe(Card card, boolean timedOut) {
        // TODO implement undo handling
    }

    public void setBody(String body) {
        mBody = body;
    }

    public String getBody() {
        return mBody;
    }

    @Override
    public void setupInnerViewElements(ViewGroup parent, View view) {
        TextView title = (TextView)view.findViewById(R.id.simple_message_card_title);
        TextView body = (TextView)view.findViewById(R.id.simple_message_card_text);

        if (!TextUtils.isEmpty(getTitle())) {
            title.setText(getTitle());
        }
        if (!TextUtils.isEmpty(getBody())) {
            body.setText(getBody());
        }
    }
}