use of android.support.annotation.WorkerThread in project mobile-center-sdk-android by Microsoft.
the class AppCenter method finishConfiguration.
@WorkerThread
private void finishConfiguration() {
/* Load some global constants. */
Constants.loadFromContext(mApplication);
/* If parameters are valid, init context related resources. */
StorageHelper.initialize(mApplication);
/* Initialize session storage. */
SessionContext.getInstance();
/* Get enabled state. */
boolean enabled = isInstanceEnabled();
/* Init uncaught exception handler. */
mUncaughtExceptionHandler = new UncaughtExceptionHandler();
if (enabled) {
mUncaughtExceptionHandler.register();
}
/* Init channel. */
mLogSerializer = new DefaultLogSerializer();
mLogSerializer.addLogFactory(StartServiceLog.TYPE, new StartServiceLogFactory());
mLogSerializer.addLogFactory(CustomPropertiesLog.TYPE, new CustomPropertiesLogFactory());
mChannel = new DefaultChannel(mApplication, mAppSecret, mLogSerializer, mHandler);
mChannel.setEnabled(enabled);
mChannel.addGroup(CORE_GROUP, DEFAULT_TRIGGER_COUNT, DEFAULT_TRIGGER_INTERVAL, DEFAULT_TRIGGER_MAX_PARALLEL_REQUESTS, null);
if (mLogUrl != null) {
mChannel.setLogUrl(mLogUrl);
}
if (!enabled) {
NetworkStateHelper.getSharedInstance(mApplication).close();
}
AppCenterLog.debug(LOG_TAG, "App Center storage initialized.");
}
use of android.support.annotation.WorkerThread in project mobile-center-sdk-android by Microsoft.
the class AppCenter method sendStartServiceLog.
/**
* Queue start service log.
*
* @param serviceNames the services to send.
*/
@WorkerThread
private void sendStartServiceLog(List<String> serviceNames) {
if (isInstanceEnabled()) {
StartServiceLog startServiceLog = new StartServiceLog();
startServiceLog.setServices(serviceNames);
mChannel.enqueue(startServiceLog, CORE_GROUP);
} else {
if (mStartedServicesNamesToLog == null) {
mStartedServicesNamesToLog = new ArrayList<>();
}
mStartedServicesNamesToLog.addAll(serviceNames);
}
}
use of android.support.annotation.WorkerThread in project Shuttle by timusus.
the class ArtworkUtils method getAllFolderArtwork.
/**
* Searches the parent directory of the passed in path for [cover/album/artwork].[png/jpg/jpeg]
* using regex and returns a {@link List<File>} representing the artwork
*/
@WorkerThread
public static List<File> getAllFolderArtwork(@Nullable final String path) {
List<File> fileArray = new ArrayList<>();
if (path != null) {
File[] files;
File parent = new File(path).getParentFile();
if (parent.exists() && parent.isDirectory()) {
final Pattern pattern = Pattern.compile("(folder|cover|album).*\\.(jpg|jpeg|png)", Pattern.CASE_INSENSITIVE);
files = parent.listFiles(file1 -> pattern.matcher(file1.getName()).matches());
if (files.length != 0) {
for (File file : files) {
if (file.exists()) {
fileArray.add(file);
}
}
}
}
}
return fileArray;
}
use of android.support.annotation.WorkerThread in project ViewAnimator by florent37.
the class SvgPathParser method parsePath.
/**
* This is where the hard-to-parse paths are handled.
* Uppercase rules are absolute positions, lowercase are relative.
* Types of path rules:
* <p/>
* <ol>
* <li>M/m - (x y)+ - Move to (without drawing)
* <li>Z/z - (no params) - Close path (back to starting point)
* <li>L/l - (x y)+ - Line to
* <li>H/h - x+ - Horizontal ine to
* <li>V/v - y+ - Vertical line to
* <li>C/c - (x1 y1 x2 y2 x y)+ - Cubic bezier to
* <li>S/s - (x2 y2 x y)+ - Smooth cubic bezier to (shorthand that assumes the x2, y2 from previous C/S is the x1, y1 of this bezier)
* <li>Q/q - (x1 y1 x y)+ - Quadratic bezier to
* <li>T/t - (x y)+ - Smooth quadratic bezier to (assumes previous control point is "reflection" of last one w.r.t. to current point)
* </ol>
* <p/>
* Numbers are separate by whitespace, comma or nothing at all (!) if they are self-delimiting, (ie. begin with a - sign)
*
* @param dAttributeOfPath the d attribute of <path> from the XML
*/
@WorkerThread
public static Path parsePath(String dAttributeOfPath) throws Exception {
int n = dAttributeOfPath.length();
ParserHelper helper = new ParserHelper(dAttributeOfPath, 0);
helper.skipWhitespace();
Path path = new Path();
float lastX = 0;
float lastY = 0;
float lastX1 = 0;
float lastY1 = 0;
float subPathStartX = 0;
float subPathStartY = 0;
char prevCmd = 0;
while (helper.getPosition() < n) {
char cmd = dAttributeOfPath.charAt(helper.getPosition());
switch(cmd) {
case '-':
case '+':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (prevCmd == 'm' || prevCmd == 'M') {
cmd = (char) (((int) prevCmd) - 1);
break;
} else if (prevCmd == 'c' || prevCmd == 'C') {
cmd = prevCmd;
break;
} else if (prevCmd == 'l' || prevCmd == 'L') {
cmd = prevCmd;
break;
}
default:
{
helper.advance();
prevCmd = cmd;
}
}
boolean wasCurve = false;
switch(cmd) {
case 'M':
case 'm':
{
float x = helper.nextFloat();
float y = helper.nextFloat();
Log.d(null, String.format("move to: [%s,%s]", x, y));
if (cmd == 'm') {
subPathStartX += x;
subPathStartY += y;
path.rMoveTo(x, y);
lastX += x;
lastY += y;
} else {
subPathStartX = x;
subPathStartY = y;
path.moveTo(x, y);
lastX = x;
lastY = y;
}
break;
}
case 'Z':
case 'z':
{
Log.d(null, String.format("close, move to: [%s,%s]", subPathStartX, subPathStartY));
path.close();
path.moveTo(subPathStartX, subPathStartY);
lastX = subPathStartX;
lastY = subPathStartY;
lastX1 = subPathStartX;
lastY1 = subPathStartY;
wasCurve = true;
break;
}
case 'L':
case 'l':
{
float x = helper.nextFloat();
float y = helper.nextFloat();
Log.d(null, String.format("line to: [%s,%s]", x, y));
if (cmd == 'l') {
path.rLineTo(x, y);
lastX += x;
lastY += y;
} else {
path.lineTo(x, y);
lastX = x;
lastY = y;
}
break;
}
case 'H':
case 'h':
{
float x = helper.nextFloat();
Log.d(null, String.format("horizontal line to: [%s]", x));
if (cmd == 'h') {
path.rLineTo(x, 0);
lastX += x;
} else {
path.lineTo(x, lastY);
lastX = x;
}
break;
}
case 'V':
case 'v':
{
float y = helper.nextFloat();
Log.d(null, String.format("vertical line to: [%s]", y));
if (cmd == 'v') {
path.rLineTo(0, y);
lastY += y;
} else {
path.lineTo(lastX, y);
lastY = y;
}
break;
}
case 'C':
case 'c':
{
wasCurve = true;
float x1 = helper.nextFloat();
float y1 = helper.nextFloat();
float x2 = helper.nextFloat();
float y2 = helper.nextFloat();
float x = helper.nextFloat();
float y = helper.nextFloat();
Log.d(null, String.format("cubic to: [%s,%s][%s,%s][%s,%s]", x1, y1, x2, y2, x, y));
if (cmd == 'c') {
x1 += lastX;
x2 += lastX;
x += lastX;
y1 += lastY;
y2 += lastY;
y += lastY;
}
path.cubicTo(x1, y1, x2, y2, x, y);
lastX1 = x2;
lastY1 = y2;
lastX = x;
lastY = y;
break;
}
case 'S':
case 's':
{
wasCurve = true;
float x2 = helper.nextFloat();
float y2 = helper.nextFloat();
float x = helper.nextFloat();
float y = helper.nextFloat();
Log.d(null, String.format("cubic to: [%s,%s][%s,%s]", x2, y2, x, y));
if (cmd == 's') {
x2 += lastX;
x += lastX;
y2 += lastY;
y += lastY;
}
float x1 = 2 * lastX - lastX1;
float y1 = 2 * lastY - lastY1;
path.cubicTo(x1, y1, x2, y2, x, y);
lastX1 = x2;
lastY1 = y2;
lastX = x;
lastY = y;
break;
}
case 'A':
case 'a':
{
float rx = helper.nextFloat();
float ry = helper.nextFloat();
float theta = helper.nextFloat();
int largeArc = (int) helper.nextFloat();
int sweepArc = (int) helper.nextFloat();
float x = helper.nextFloat();
float y = helper.nextFloat();
Log.d(null, String.format("arc to: [%s,%s][%s][%s,%s][%s,%s]", rx, ry, theta, largeArc, sweepArc, x, y));
drawArc(path, lastX, lastY, x, y, rx, ry, theta, largeArc, sweepArc);
lastX = x;
lastY = y;
break;
}
}
if (!wasCurve) {
lastX1 = lastX;
lastY1 = lastY;
}
helper.skipWhitespace();
}
return path;
}
Aggregations