Search in sources :

Example 6 with MainThread

use of androidx.annotation.MainThread in project android-beacon-library by AltBeacon.

the class BeaconService method onCreate.

@MainThread
@Override
public void onCreate() {
    this.startForegroundIfConfigured();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        bluetoothCrashResolver = new BluetoothCrashResolver(this);
        bluetoothCrashResolver.start();
    }
    mScanHelper = new ScanHelper(this);
    if (mScanHelper.getCycledScanner() == null) {
        mScanHelper.createCycledLeScanner(false, bluetoothCrashResolver);
    }
    mScanHelper.setMonitoringStatus(MonitoringStatus.getInstanceForApplication(this));
    mScanHelper.setRangedRegionState(new HashMap<Region, RangeState>());
    mScanHelper.setBeaconParsers(new HashSet<BeaconParser>());
    mScanHelper.setExtraDataBeaconTracker(new ExtraDataBeaconTracker());
    BeaconManager beaconManager = BeaconManager.getInstanceForApplication(getApplicationContext());
    beaconManager.setScannerInSameProcess(true);
    if (beaconManager.isMainProcess()) {
        LogManager.i(TAG, "beaconService version %s is starting up on the main process", BuildConfig.VERSION_NAME);
        // if we are on the main process, we use local broadcast notifications to deliver results.
        ensureNotificationProcessorSetup();
    } else {
        LogManager.i(TAG, "beaconService version %s is starting up on a separate process", BuildConfig.VERSION_NAME);
        ProcessUtils processUtils = new ProcessUtils(this);
        LogManager.i(TAG, "beaconService PID is " + processUtils.getPid() + " with process name " + processUtils.getProcessName());
    }
    String longScanForcingEnabled = getManifestMetadataValue("longScanForcingEnabled");
    if (longScanForcingEnabled != null && longScanForcingEnabled.equals("true")) {
        LogManager.i(TAG, "longScanForcingEnabled to keep scans going on Android N for > 30 minutes");
        if (mScanHelper.getCycledScanner() != null) {
            mScanHelper.getCycledScanner().setLongScanForcingEnabled(true);
        }
    }
    mScanHelper.reloadParsers();
    DistanceCalculator defaultDistanceCalculator = new ModelSpecificDistanceCalculator(this, BeaconManager.getDistanceModelUpdateUrl());
    Beacon.setDistanceCalculator(defaultDistanceCalculator);
    // Look for simulated scan data
    try {
        Class klass = Class.forName("org.altbeacon.beacon.SimulatedScanData");
        java.lang.reflect.Field f = klass.getField("beacons");
        mScanHelper.setSimulatedScanData((List<Beacon>) f.get(null));
    } catch (ClassNotFoundException e) {
        LogManager.d(TAG, "No org.altbeacon.beacon.SimulatedScanData class exists.");
    } catch (Exception e) {
        LogManager.e(e, TAG, "Cannot get simulated Scan data.  Make sure your org.altbeacon.beacon.SimulatedScanData class defines a field with the signature 'public static List<Beacon> beacons'");
    }
}
Also used : DistanceCalculator(org.altbeacon.beacon.distance.DistanceCalculator) ModelSpecificDistanceCalculator(org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator) BluetoothCrashResolver(org.altbeacon.bluetooth.BluetoothCrashResolver) ProcessUtils(org.altbeacon.beacon.utils.ProcessUtils) BeaconParser(org.altbeacon.beacon.BeaconParser) BeaconManager(org.altbeacon.beacon.BeaconManager) Beacon(org.altbeacon.beacon.Beacon) Region(org.altbeacon.beacon.Region) ModelSpecificDistanceCalculator(org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator) MainThread(androidx.annotation.MainThread)

Example 7 with MainThread

use of androidx.annotation.MainThread in project SeriesGuide by UweTrottmann.

the class TaskManager method tryBackupTask.

/**
 * If no {@link AddShowTask} or {@link JsonExportTask} created by this {@link
 * com.battlelancer.seriesguide.util.TaskManager} is running a
 * {@link JsonExportTask} is scheduled in silent mode.
 */
@MainThread
public synchronized boolean tryBackupTask(Context context) {
    if (!isAddTaskRunning() && (backupTask == null || backupTask.isCompleted())) {
        JsonExportTask exportTask = new JsonExportTask(context, null, false, true, null);
        backupTask = exportTask.launch();
        return true;
    }
    return false;
}
Also used : JsonExportTask(com.battlelancer.seriesguide.dataliberation.JsonExportTask) MainThread(androidx.annotation.MainThread)

Example 8 with MainThread

use of androidx.annotation.MainThread in project vlc-android by videolan.

the class MediaBrowser method browse.

/**
 * Browse to the specified uri.
 *
 * @param uri
 * @param flags see {@link MediaBrowser.Flag}
 */
@MainThread
public void browse(Uri uri, int flags) {
    final IMedia media = mFactory.getFromUri(mILibVlc, uri);
    browse(media, flags);
    media.release();
}
Also used : IMedia(org.videolan.libvlc.interfaces.IMedia) MainThread(androidx.annotation.MainThread)

Example 9 with MainThread

use of androidx.annotation.MainThread in project Signal-Android by signalapp.

the class SearchToolbar method hide.

@MainThread
private void hide() {
    if (getVisibility() == View.VISIBLE) {
        if (listener != null)
            listener.onSearchClosed();
        if (Build.VERSION.SDK_INT >= 21) {
            Animator animator = ViewAnimationUtils.createCircularReveal(this, (int) x, (int) y, getWidth(), 0);
            animator.setDuration(400);
            animator.addListener(new AnimationCompleteListener() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    setVisibility(View.INVISIBLE);
                }
            });
            animator.start();
        } else {
            setVisibility(View.INVISIBLE);
        }
    }
}
Also used : Animator(android.animation.Animator) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener) MainThread(androidx.annotation.MainThread)

Example 10 with MainThread

use of androidx.annotation.MainThread in project nextcloud-notes by stefan-niedermann.

the class NotesRepository method getCategoryOrder.

/**
 * Gets the sorting method of a {@link NavigationCategory}, the category can be normal
 * {@link CategoryOptions} or one of {@link ENavigationCategoryType}.
 * If the category no normal {@link CategoryOptions}, sorting method will be got from
 * {@link SharedPreferences}.
 * <p>
 * The sorting method of the category can be used to decide to use which sorting method to show
 * the notes for each categories.
 *
 * @param selectedCategory The category
 * @return The sorting method in CategorySortingMethod enum format
 */
@NonNull
@MainThread
public LiveData<CategorySortingMethod> getCategoryOrder(@NonNull NavigationCategory selectedCategory) {
    final var sp = PreferenceManager.getDefaultSharedPreferences(context);
    String prefKey;
    switch(selectedCategory.getType()) {
        // TODO make this account specific
        case RECENT:
            {
                prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.label_all_notes);
                break;
            }
        case FAVORITES:
            {
                prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.label_favorites);
                break;
            }
        case UNCATEGORIZED:
            {
                prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.action_uncategorized);
                break;
            }
        case DEFAULT_CATEGORY:
        default:
            {
                final String category = selectedCategory.getCategory();
                if (category != null) {
                    return db.getCategoryOptionsDao().getCategoryOrder(selectedCategory.getAccountId(), category);
                } else {
                    Log.e(TAG, "Cannot read " + CategorySortingMethod.class.getSimpleName() + " for " + ENavigationCategoryType.DEFAULT_CATEGORY + ".");
                    return new MutableLiveData<>(CategorySortingMethod.SORT_MODIFIED_DESC);
                }
            }
    }
    return map(new SharedPreferenceIntLiveData(sp, prefKey, CategorySortingMethod.SORT_MODIFIED_DESC.getId()), CategorySortingMethod::findById);
}
Also used : CategorySortingMethod(it.niedermann.owncloud.notes.shared.model.CategorySortingMethod) SharedPreferenceIntLiveData(it.niedermann.android.sharedpreferences.SharedPreferenceIntLiveData) MainThread(androidx.annotation.MainThread) NonNull(androidx.annotation.NonNull)

Aggregations

MainThread (androidx.annotation.MainThread)27 Animator (android.animation.Animator)4 NonNull (androidx.annotation.NonNull)3 IMedia (org.videolan.libvlc.interfaces.IMedia)3 Uri (android.net.Uri)2 ArrayMap (android.util.ArrayMap)2 AlphaAnimation (android.view.animation.AlphaAnimation)2 Animation (android.view.animation.Animation)2 AnimationSet (android.view.animation.AnimationSet)2 OvershootInterpolator (android.view.animation.OvershootInterpolator)2 TranslateAnimation (android.view.animation.TranslateAnimation)2 TextView (android.widget.TextView)2 RequiresApi (androidx.annotation.RequiresApi)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 DefaultLifecycleObserver (androidx.lifecycle.DefaultLifecycleObserver)2 LifecycleOwner (androidx.lifecycle.LifecycleOwner)2 ProcessLifecycleOwner (androidx.lifecycle.ProcessLifecycleOwner)2 MediaItem (com.google.android.exoplayer2.MediaItem)2 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)2 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)2