summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/feed/FeedPreferences.java
blob: 29bc5ef0cca0ce09721a4f008c25e9dbfa89b8a9 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package de.danoeh.antennapod.feed;

import android.content.Context;
import de.danoeh.antennapod.storage.DBWriter;
import org.apache.commons.lang3.StringUtils;

/**
 * Contains preferences for a single feed.
 */
public class FeedPreferences {

    private long feedID;
    private boolean autoDownload;
    private String username;
    private String password;

    public FeedPreferences(long feedID, boolean autoDownload, String username, String password) {
        this.feedID = feedID;
        this.autoDownload = autoDownload;
        this.username = username;
        this.password = password;
    }


    /**
     * Compare another FeedPreferences with this one. The feedID and autoDownload attribute are excluded from the
     * comparison.
     *
     * @return True if the two objects are different.
     */
    public boolean compareWithOther(FeedPreferences other) {
        if (other == null)
            return true;
        if (!StringUtils.equals(username, other.username)) {
            return true;
        }
        if (!StringUtils.equals(password, other.password)) {
            return true;
        }
        return false;
    }

    /**
     * Update this FeedPreferences object from another one. The feedID and autoDownload attributes are excluded
     * from the update.
     */
    public void updateFromOther(FeedPreferences other) {
        if (other == null)
            return;
        this.username = other.username;
        this.password = other.password;
    }

    public long getFeedID() {
        return feedID;
    }

    public void setFeedID(long feedID) {
        this.feedID = feedID;
    }

    public boolean getAutoDownload() {
        return autoDownload;
    }

    public void setAutoDownload(boolean autoDownload) {
        this.autoDownload = autoDownload;
    }

    public void save(Context context) {
        DBWriter.setFeedPreferences(context, this);
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}