summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/feed/FeedImage.java
blob: c588f5e719e0a95c51c2f5cd4388a8527cf887a4 (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
package de.danoeh.antennapod.feed;

import android.net.Uri;

import de.danoeh.antennapod.asynctask.PicassoImageResource;

import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;



public class FeedImage extends FeedFile implements PicassoImageResource {
	public static final int FEEDFILETYPE_FEEDIMAGE = 1;

	protected String title;
	protected FeedComponent owner;

	public FeedImage(String download_url, String title) {
		super(null, download_url, false);
		this.download_url = download_url;
		this.title = title;
	}

	public FeedImage(long id, String title, String file_url,
			String download_url, boolean downloaded) {
		super(file_url, download_url, downloaded);
		this.id = id;
		this.title = title;
	}

	@Override
	public String getHumanReadableIdentifier() {
		if (owner != null && owner.getHumanReadableIdentifier() != null) {
			return owner.getHumanReadableIdentifier();
		} else {
			return download_url;
		}
	}

	@Override
	public int getTypeAsInt() {
		return FEEDFILETYPE_FEEDIMAGE;
	}

	public FeedImage() {
		super();
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public FeedComponent getOwner() {
		return owner;
	}

	public void setOwner(FeedComponent owner) {
		this.owner = owner;
	}

    @Override
    public Uri getImageUri() {
        if (file_url != null && downloaded) {
            return Uri.fromFile(new File(file_url));
        } else {
            return null;
        }
    }
}