Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MimeTypeUtil.java « util « deck « nextcloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 04694a05857ceb707af84ad12736e0983c034135 (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
package it.niedermann.nextcloud.deck.util;

import androidx.annotation.Nullable;

import java.util.Locale;

public class MimeTypeUtil {

    public static final String IMAGE_JPEG = "image/jpeg";
    public static final String TEXT_PLAIN = "text/plain";
    public static final String TEXT_VCARD = "text/vcard";
    public static final String APPLICATION_PDF = "application/pdf";

    public static boolean isImage(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("image/") &&
                !mimeType.toLowerCase(Locale.ROOT).contains("djvu");
    }

    public static boolean isVideo(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("video/");
    }

    public static boolean isAudio(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("audio/");
    }

    public static boolean isText(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("text/");
    }

    public static boolean isTextPlain(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith(TEXT_PLAIN);
    }

    public static boolean isContact(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith(TEXT_VCARD);
    }

    public static boolean isPdf(@Nullable String mimeType) {
        return mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith(APPLICATION_PDF);
    }
}