當前位置: 首頁>>代碼示例>>Java>>正文


Java WorkerThread類代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:21,代碼來源:ExecuteActivity.java

示例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;
}
 
開發者ID:jiechic,項目名稱:sqlbrite-sqlcipher,代碼行數:26,代碼來源:BriteDatabase.java

示例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);
                }
            }
        }
    });
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:17,代碼來源:EegeoNativeMapView.java

示例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);
        }
    }
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:22,代碼來源:EegeoNativeMapView.java

示例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 ++;
        }
    }
}
 
開發者ID:kaedea,項目名稱:b-log,代碼行數:17,代碼來源:LogFileImpl.java

示例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();
            }
        }
    });
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:17,代碼來源:EegeoMap.java

示例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;
        }
    });
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:17,代碼來源:TagApi.java

示例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()
    );
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:26,代碼來源:PolygonApi.java

示例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");
        }
    }
}
 
開發者ID:googlesamples,項目名稱:leanback-homescreen-channels,代碼行數:22,代碼來源:SampleTvProvider.java

示例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;
}
 
開發者ID:WeiXinqiao,項目名稱:Recognize-it,代碼行數:25,代碼來源:MediaReader.java

示例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;
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:25,代碼來源:ParticleDevice.java

示例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);
            }
        });
    }
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:20,代碼來源:BuildingsApi.java

示例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;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:13,代碼來源:AttachmentInfoExtractor.java

示例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);
        }
    });
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:12,代碼來源:BlueSphere.java

示例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);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:35,代碼來源:MessageViewInfoExtractor.java


注:本文中的android.support.annotation.WorkerThread類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。