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