本文整理汇总了Java中android.support.annotation.WorkerThread类的典型用法代码示例。如果您正苦于以下问题:Java WorkerThread类的具体用法?Java WorkerThread怎么用?Java WorkerThread使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorkerThread类属于android.support.annotation包,在下文中一共展示了WorkerThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runProgram
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
private void runProgram(Context context, JavaProjectFolder projectFile, int action, Intent intent) throws Exception {
InputStream in = mConsoleEditText.getInputStream();
File tempDir = getDir("dex", MODE_PRIVATE);
switch (action) {
case CompileHelper.Action.RUN: {
CompileHelper.compileAndRun(context, in, tempDir, projectFile);
break;
}
case CompileHelper.Action.RUN_DEX: {
File dex = (File) intent.getSerializableExtra(CompileManager.DEX_FILE);
if (dex != null) {
String mainClass = projectFile.getMainClass().getName();
CompileHelper.executeDex(context, in, dex, tempDir, mainClass);
}
break;
}
}
}
示例2: delete
import android.support.annotation.WorkerThread; //导入依赖的package包/类
/**
* Delete rows from the specified {@code table} and notify any subscribed queries. This method
* will not trigger a notification if no rows were deleted.
*
* @see SQLiteDatabase#delete(String, String, String[])
*/
@WorkerThread
public int delete(@NonNull String table, @Nullable String whereClause,
@Nullable String... whereArgs) {
SQLiteDatabase db = getWritableDatabase();
if (logging) {
log("DELETE\n table: %s\n whereClause: %s\n whereArgs: %s", table, whereClause,
Arrays.toString(whereArgs));
}
int rows = db.delete(table, whereClause, whereArgs);
if (logging) log("DELETE affected %s %s", rows, rows != 1 ? "rows" : "row");
if (rows > 0) {
// Only send a table trigger if rows were affected.
sendTableTrigger(Collections.singleton(table));
}
return rows;
}
示例3: surfaceChanged
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@UiThread
public void surfaceChanged(final SurfaceHolder holder, int format, int width, int height) {
runOnNativeThread(new Runnable() {
@WorkerThread
@Override
public void run() {
m_surfaceHolder = holder;
if (m_surfaceHolder != null) {
Surface surface = m_surfaceHolder.getSurface();
if (surface.isValid()) {
nativeSetSurface(m_jniApiRunnerPtr, surface);
}
}
}
});
}
示例4: onPointerUp
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@UiThread
public void onPointerUp(final int primaryActionIndex, final int primaryActionIdentifier, final int pointerCount, final float[] x, final float y[], final int[] pointerIdentity, final int[] pointerIndex) {
runOnNativeThread(new Runnable() {
@WorkerThread
@Override
public void run() {
nativeProcessPointerUp(m_jniApiRunnerPtr, primaryActionIndex, primaryActionIdentifier, pointerCount, x, y, pointerIdentity, pointerIndex);
}
});
if (m_eeGeoMap == null) {
Log.d("eegeo-android-sdk", "skipping input event -- map not ready");
return;
}
if (x.length > 0) { // TODO: remove this and promote to native ITouchController
Point mouseUpPoint = new Point((int) x[0], (int) y[0]);
double distSquared = Math.pow(mouseUpPoint.x - m_mouseDownPoint.x, 2) + Math.pow(mouseUpPoint.y - m_mouseDownPoint.y, 2);
if (distSquared < 25) {
m_eeGeoMap.onTapped(mouseUpPoint);
}
}
}
示例5: writeToFile
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
private void writeToFile() {
if (mFiles.canWrite(mLogFile)) {
List<LogMessage> list;
synchronized (mLock) {
list = new LinkedList<>(mCacheQueue);
mCacheQueue.clear();
}
mFiles.writeToFile(list, mLogFile);
if (mSetting.debuggable()) {
mWriteCount ++;
}
}
}
示例6: jniOnIndoorEntered
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
private void jniOnIndoorEntered() {
final IndoorMap indoorMap = IndoorsApiJniCalls.getIndoorMapData(m_eegeoMapApiPtr);
final int currentIndoorFloor = IndoorsApiJniCalls.getCurrentFloorIndex(m_eegeoMapApiPtr);
m_uiRunner.runOnUiThread(new Runnable() {
@UiThread
@Override
public void run() {
m_indoorMap = indoorMap;
m_currentIndoorFloor = currentIndoorFloor;
for (OnIndoorEnteredListener listener : m_onIndoorEnteredListeners) {
listener.onIndoorEntered();
}
}
});
}
示例7: notifyTagsLoaded
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
public void notifyTagsLoaded()
{
m_uiRunner.runOnUiThread(new Runnable() {
@Override
public void run() {
m_hasLoadedTags = true;
m_loadInProgress = false;
if(m_listener != null)
{
m_listener.onTagsLoadCompleted();
}
m_listener = null;
}
});
}
示例8: create
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
public int create(PolygonOptions polygonOptions, Polygon.AllowHandleAccess allowHandleAccess) throws InvalidParameterException {
if (allowHandleAccess == null)
throw new NullPointerException("Null access token. Method is intended for internal use by Polygon");
if (polygonOptions.getPoints().size() < 2)
throw new InvalidParameterException("PolygonOptions points must contain at least two elements");
List<LatLng> exteriorPoints = polygonOptions.getPoints();
List<List<LatLng>> holes = polygonOptions.getHoles();
final int[] ringVertexCounts = buildRingVertexCounts(exteriorPoints, holes);
final double[] allPointsDoubleArray = buildPointsArray(exteriorPoints, holes, ringVertexCounts);
return nativeCreatePolygon(
m_jniEegeoMapApiPtr,
polygonOptions.getIndoorMapId(),
polygonOptions.getIndoorFloorId(),
polygonOptions.getElevation(),
polygonOptions.getElevationMode().ordinal(),
allPointsDoubleArray,
ringVertexCounts,
polygonOptions.getFillColor()
);
}
示例9: setProgramViewCount
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
static void setProgramViewCount(Context context, long programId, int numberOfViews) {
Uri programUri = TvContractCompat.buildPreviewProgramUri(programId);
try (Cursor cursor = context.getContentResolver().query(programUri, null, null, null,
null)) {
if (!cursor.moveToFirst()) {
return;
}
PreviewProgram existingProgram = PreviewProgram.fromCursor(cursor);
PreviewProgram.Builder builder = new PreviewProgram.Builder(existingProgram)
.setInteractionCount(numberOfViews)
.setInteractionType(TvContractCompat.PreviewProgramColumns
.INTERACTION_TYPE_VIEWS);
int rowsUpdated = context.getContentResolver().update(
TvContractCompat.buildPreviewProgramUri(programId),
builder.build().toContentValues(), null, null);
if (rowsUpdated != 1) {
Log.e(TAG, "Update program failed");
}
}
}
示例10: getAllMedia
import android.support.annotation.WorkerThread; //导入依赖的package包/类
/**
* Get all the multimedia files, including videos and pictures.
*/
@WorkerThread
public ArrayList<AlbumFolder> getAllMedia() {
Map<String, AlbumFolder> albumFolderMap = new HashMap<>();
AlbumFolder allFileFolder = new AlbumFolder();
allFileFolder.setChecked(true);
allFileFolder.setName(mContext.getString(R.string.album_all_images_videos));
scanImageFile(albumFolderMap, allFileFolder);
scanVideoFile(albumFolderMap, allFileFolder);
ArrayList<AlbumFolder> albumFolders = new ArrayList<>();
Collections.sort(allFileFolder.getAlbumFiles());
albumFolders.add(allFileFolder);
for (Map.Entry<String, AlbumFolder> folderEntry : albumFolderMap.entrySet()) {
AlbumFolder albumFolder = folderEntry.getValue();
Collections.sort(albumFolder.getAlbumFiles());
albumFolders.add(albumFolder);
}
return albumFolders;
}
示例11: getVariable
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
T getVariable(String variableName)
throws ParticleCloudException, IOException, VariableDoesNotExistException {
if (!device.deviceState.variables.containsKey(variableName)) {
throw new VariableDoesNotExistException(variableName);
}
R reply;
try {
reply = callApi(variableName);
} catch (RetrofitError e) {
throw new ParticleCloudException(e);
}
if (!reply.coreInfo.connected) {
// FIXME: we should be doing this "connected" check on _any_ reply that comes back
// with a "coreInfo" block.
device.cloud.onDeviceNotConnected(device.deviceState);
throw new IOException("Device is not connected.");
} else {
return reply.result;
}
}
示例12: fetchBuildingInformation
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
private void fetchBuildingInformation(int nativeHandle)
{
final BuildingHighlight buildingHighlight = m_nativeHandleToBuildingHighlight.get(nativeHandle);
if (buildingHighlight == null)
throw new NullPointerException("BuildingHighlight object not found for nativeHandle");
final BuildingInformation buildingInformation = nativeGetBuildingInformation(m_jniEegeoMapApiPtr, nativeHandle);
if (buildingInformation != null) {
m_uiRunner.runOnUiThread(new Runnable() {
@UiThread
@Override
public void run() {
buildingHighlight.setBuildingInformation(buildingInformation);
}
});
}
}
示例13: extractAttachmentInfoForView
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
public List<AttachmentViewInfo> extractAttachmentInfoForView(List<Part> attachmentParts)
throws MessagingException {
List<AttachmentViewInfo> attachments = new ArrayList<>();
for (Part part : attachmentParts) {
AttachmentViewInfo attachmentViewInfo = extractAttachmentInfo(part);
attachments.add(attachmentViewInfo);
}
return attachments;
}
示例14: updateElevation
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@UiThread
private void updateElevation() {
final double elevation = m_elevation;
submit(new Runnable() {
@WorkerThread
public void run() {
m_bluesphereApi.setElevation(BlueSphere.m_allowHandleAccess, elevation);
}
});
}
示例15: extractMessageForView
import android.support.annotation.WorkerThread; //导入依赖的package包/类
@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations cryptoAnnotations)
throws MessagingException {
ArrayList<Part> extraParts = new ArrayList<>();
Part cryptoContentPart = MessageCryptoStructureDetector.findPrimaryEncryptedOrSignedPart(message, extraParts);
if (cryptoContentPart == null) {
if (cryptoAnnotations != null && !cryptoAnnotations.isEmpty()) {
Timber.e("Got crypto message cryptoContentAnnotations but no crypto root part!");
}
return extractSimpleMessageForView(message, message);
}
boolean isOpenPgpEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) &&
MessageCryptoStructureDetector.isMultipartEncryptedOpenPgpProtocol(cryptoContentPart)) ||
MessageCryptoStructureDetector.isPartPgpInlineEncrypted(cryptoContentPart);
boolean isSMimeEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) &&
MessageCryptoStructureDetector.isMultipartEncryptedSMimeProtocol(cryptoContentPart));
if ((!QMail.isOpenPgpProviderConfigured() && isOpenPgpEncrypted) || (!QMail.isSMimeProviderConfigured() && isSMimeEncrypted)) {
CryptoResultAnnotation noProviderAnnotation = CryptoResultAnnotation.createErrorAnnotation(
CryptoError.SMIME_ENCRYPTED_NO_PROVIDER, null);
return MessageViewInfo.createWithErrorState(message, false)
.withCryptoData(noProviderAnnotation, null, null, null);
}
CryptoResultAnnotation cryptoContentPartAnnotation =
cryptoAnnotations != null ? cryptoAnnotations.get(cryptoContentPart) : null;
if (cryptoContentPartAnnotation != null) {
return extractCryptoMessageForView(message, extraParts, cryptoContentPart, cryptoContentPartAnnotation);
}
return extractSimpleMessageForView(message, message);
}