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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations