Search in sources :

Example 31 with WorkerThread

use of android.support.annotation.WorkerThread in project Shuttle by timusus.

the class FileBrowser method getInitialDir.

@WorkerThread
public File getInitialDir() {
    ThreadUtils.ensureNotOnMainThread();
    File dir;
    String[] files;
    String settingsDir = SettingsManager.getInstance().getFolderBrowserInitialDir();
    if (settingsDir != null) {
        File file = new File(settingsDir);
        if (file.exists()) {
            return file;
        }
    }
    dir = new File("/");
    files = dir.list((dir1, filename) -> dir1.isDirectory() && filename.toLowerCase().contains("storage"));
    if (files != null && files.length > 0) {
        dir = new File(dir + "/" + files[0]);
        // If there's an extsdcard path in our base dir, let's navigate to that. External SD cards are cool.
        files = dir.list((dir1, filename) -> dir1.isDirectory() && filename.toLowerCase().contains("extsdcard"));
        if (files != null && files.length > 0) {
            dir = new File(dir + "/" + files[0]);
        } else {
            // If we have external storage, use that as our initial dir
            if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                dir = Environment.getExternalStorageDirectory();
            }
        }
    } else {
        // If we have external storage, use that as our initial dir
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            dir = Environment.getExternalStorageDirectory();
        }
    }
    // Whether or not there was an sdcard, let's see if there's a 'music' dir for us to navigate to
    if (dir != null) {
        files = dir.list((dir1, filename) -> dir1.isDirectory() && filename.toLowerCase().contains("music"));
    }
    if (files != null && files.length > 0) {
        dir = new File(dir + "/" + files[0]);
    }
    return dir;
}
Also used : R(com.simplecity.amp_library.R) TagInfo(com.simplecity.amp_library.model.TagInfo) Environment(android.os.Environment) FolderObject(com.simplecity.amp_library.model.FolderObject) TextUtils(android.text.TextUtils) WorkerThread(android.support.annotation.WorkerThread) File(java.io.File) ArrayList(java.util.ArrayList) List(java.util.List) FileObject(com.simplecity.amp_library.model.FileObject) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Comparator(java.util.Comparator) Collections(java.util.Collections) FileType(com.simplecity.amp_library.interfaces.FileType) File(java.io.File) WorkerThread(android.support.annotation.WorkerThread)

Example 32 with WorkerThread

use of android.support.annotation.WorkerThread in project mobile-center-sdk-android by Microsoft.

the class Analytics method queuePage.

/**
 * Enqueue page log now.
 */
@WorkerThread
private void queuePage(String name, Map<String, String> properties) {
    PageLog pageLog = new PageLog();
    pageLog.setName(name);
    pageLog.setProperties(properties);
    mChannel.enqueue(pageLog, ANALYTICS_GROUP);
}
Also used : PageLog(com.microsoft.appcenter.analytics.ingestion.models.PageLog) WorkerThread(android.support.annotation.WorkerThread)

Example 33 with WorkerThread

use of android.support.annotation.WorkerThread in project mobile-center-sdk-android by Microsoft.

the class AppCenter method queueCustomProperties.

/**
 * Send custom properties.
 * Unit test requires top level methods when PowerMock.whenNew.
 *
 * @param properties properties to send.
 */
@WorkerThread
private void queueCustomProperties(@NonNull Map<String, Object> properties) {
    CustomPropertiesLog customPropertiesLog = new CustomPropertiesLog();
    customPropertiesLog.setProperties(properties);
    mChannel.enqueue(customPropertiesLog, CORE_GROUP);
}
Also used : CustomPropertiesLog(com.microsoft.appcenter.ingestion.models.CustomPropertiesLog) WorkerThread(android.support.annotation.WorkerThread)

Example 34 with WorkerThread

use of android.support.annotation.WorkerThread in project k-9 by k9mail.

the class AttachmentResolver method createFromPart.

@WorkerThread
public static AttachmentResolver createFromPart(Part part) {
    AttachmentInfoExtractor attachmentInfoExtractor = AttachmentInfoExtractor.getInstance();
    Map<String, Uri> contentIdToAttachmentUriMap = buildCidToAttachmentUriMap(attachmentInfoExtractor, part);
    return new AttachmentResolver(contentIdToAttachmentUriMap);
}
Also used : AttachmentInfoExtractor(com.fsck.k9.message.extractors.AttachmentInfoExtractor) Uri(android.net.Uri) WorkerThread(android.support.annotation.WorkerThread)

Example 35 with WorkerThread

use of android.support.annotation.WorkerThread in project k-9 by k9mail.

the class AttachmentInfoExtractor method extractAttachmentInfo.

@WorkerThread
public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException {
    Uri uri;
    long size;
    boolean isContentAvailable;
    if (part instanceof LocalPart) {
        LocalPart localPart = (LocalPart) part;
        String accountUuid = localPart.getAccountUuid();
        long messagePartId = localPart.getId();
        size = localPart.getSize();
        isContentAvailable = part.getBody() != null;
        uri = AttachmentProvider.getAttachmentUri(accountUuid, messagePartId);
    } else if (part instanceof LocalMessage) {
        LocalMessage localMessage = (LocalMessage) part;
        String accountUuid = localMessage.getAccount().getUuid();
        long messagePartId = localMessage.getMessagePartId();
        size = localMessage.getSize();
        isContentAvailable = part.getBody() != null;
        uri = AttachmentProvider.getAttachmentUri(accountUuid, messagePartId);
    } else {
        Body body = part.getBody();
        if (body instanceof DeferredFileBody) {
            DeferredFileBody decryptedTempFileBody = (DeferredFileBody) body;
            size = decryptedTempFileBody.getSize();
            uri = getDecryptedFileProviderUri(decryptedTempFileBody, part.getMimeType());
            isContentAvailable = true;
        } else {
            throw new IllegalArgumentException("Unsupported part type provided");
        }
    }
    return extractAttachmentInfo(part, uri, size, isContentAvailable);
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) LocalPart(com.fsck.k9.mailstore.LocalPart) Uri(android.net.Uri) Body(com.fsck.k9.mail.Body) DeferredFileBody(com.fsck.k9.mailstore.DeferredFileBody) DeferredFileBody(com.fsck.k9.mailstore.DeferredFileBody) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

WorkerThread (android.support.annotation.WorkerThread)58 NonNull (android.support.annotation.NonNull)21 Cursor (android.database.Cursor)17 StorIOException (com.pushtorefresh.storio.StorIOException)15 File (java.io.File)13 ArrayList (java.util.ArrayList)13 Uri (android.net.Uri)8 ContentValues (android.content.ContentValues)6 Nullable (android.support.annotation.Nullable)6 StorIOSQLite (com.pushtorefresh.storio.sqlite.StorIOSQLite)6 HashMap (java.util.HashMap)6 HistoryItem (acr.browser.lightning.database.HistoryItem)5 IOException (java.io.IOException)5 FileInputStream (java.io.FileInputStream)4 Intent (android.content.Intent)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 InputStream (java.io.InputStream)3 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)3 List (java.util.List)3 ContentUris (android.content.ContentUris)2