androidx.annotation.UiThread Java Examples
The following examples show how to use
androidx.annotation.UiThread.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowWidget.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
@UiThread @Nullable public GeckoResult<boolean[]> getVisited(@NonNull GeckoSession geckoSession, @NonNull String[] urls) { if (mSession.isPrivateMode()) { return GeckoResult.fromValue(new boolean[]{}); } GeckoResult<boolean[]> result = new GeckoResult<>(); SessionStore.get().getHistoryStore().getVisited(Arrays.asList(urls)).thenAcceptAsync(list -> { final boolean[] primitives = new boolean[list.size()]; int index = 0; for (Boolean object : list) { primitives[index++] = object; } result.complete(primitives); }, mUIThreadExecutor).exceptionally(throwable -> { Log.d(LOGTAG, "Error getting history: " + throwable.getLocalizedMessage()); throwable.printStackTrace(); return null; }); return result; }
Example #2
Source File: CardsAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
@NonNull @UiThread public List<BaseCard> findAndRemoveFaceUpCards() { List<BaseCard> faceUp = new ArrayList<>(); for (int i = 0; i < cards.size(); i++) { CardsGroup group = cards.get(i); if (!group.isUnknwon()) { faceUp.addAll(group); cards.remove(i); notifyItemRemoved(i); break; } } return faceUp; }
Example #3
Source File: IdentityUtil.java From bcm-android with GNU General Public License v3.0 | 6 votes |
@UiThread public static ListenableFuture<IdentityRecord> getRemoteIdentityKey(final Context context, final Recipient recipient) { final SettableFuture<IdentityRecord> future = new SettableFuture<>(); Observable.create(new ObservableOnSubscribe<IdentityRecord>() { @Override public void subscribe(ObservableEmitter<IdentityRecord> emitter) throws Exception { emitter.onNext(Repository.getIdentityRepo(recipient.getAddress().context()).getIdentityRecord(recipient.getAddress().serialize())); emitter.onComplete(); } }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> future.set(result), throwable -> future.set(null)); return future; }
Example #4
Source File: HttpClient.java From Aria2App with GNU General Public License v3.0 | 6 votes |
@UiThread private HttpClient(@NonNull MultiProfile.UserProfile profile, @NonNull OnConnect connectionListener, boolean close) throws GeneralSecurityException, IOException, NetUtils.InvalidUrlException { this(profile); executorService.submit(() -> { try (Socket socket = new Socket()) { final long initializedAt = System.currentTimeMillis(); socket.connect(new InetSocketAddress(profile.serverAddr, profile.serverPort), (int) TimeUnit.SECONDS.toMillis(Prefs.getInt(PK.A2_NETWORK_TIMEOUT))); handler.post(() -> { if (connectionListener.onConnected(HttpClient.this)) connectionListener.onPingTested(HttpClient.this, System.currentTimeMillis() - initializedAt); }); if (close) close(); } catch (IOException ex) { handler.post(() -> connectionListener.onFailedConnecting(profile, ex)); close(); } }); }
Example #5
Source File: SpiderQueen.java From MHViewer with Apache License 2.0 | 6 votes |
@UiThread public static SpiderQueen obtainSpiderQueen(@NonNull Context context, @NonNull GalleryInfo galleryInfo, @Mode int mode) { OSUtils.checkMainLoop(); SpiderQueen queen = sQueenMap.get(galleryInfo.getCid()); if (queen == null) { EhApplication application = (EhApplication) context.getApplicationContext(); queen = new SpiderQueen(application, galleryInfo); sQueenMap.put(galleryInfo.getCid(), queen); // Set mode queen.setMode(mode); queen.start(); } else { // Set mode queen.setMode(mode); } return queen; }
Example #6
Source File: TutorialManager.java From CommonUtils with Apache License 2.0 | 5 votes |
@UiThread private void show(@NonNull Activity activity, @NonNull final BaseTutorial tutorial) { tutorial.newSequence(activity); if (listener.buildSequence(tutorial)) { isShowingTutorial = true; activity.runOnUiThread(() -> tutorial.show(TutorialManager.this)); } }
Example #7
Source File: GleanMetricsService.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
@UiThread public static void voiceInputEvent() { Url.INSTANCE.getQueryType().get("voice_query").add(); // Record search engines. String searchEngine = getDefaultSearchEngineIdentifierForTelemetry(); Searches.INSTANCE.getCounts().get(searchEngine).add(); }
Example #8
Source File: GleanMetricsService.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
@UiThread public static void urlBarEvent(boolean aIsUrl) { if (aIsUrl) { Url.INSTANCE.getQueryType().get("type_link").add(); } else { Url.INSTANCE.getQueryType().get("type_query").add(); // Record search engines. String searchEngine = getDefaultSearchEngineIdentifierForTelemetry(); Searches.INSTANCE.getCounts().get(searchEngine).add(); } }
Example #9
Source File: TelemetryWrapper.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
@UiThread public static void urlBarEvent(boolean aIsUrl) { if (aIsUrl) { TelemetryWrapper.browseEvent(); } else { TelemetryWrapper.searchEnterEvent(); } }
Example #10
Source File: TelemetryWrapper.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
@UiThread public static void start() { // Call Telemetry.scheduleUpload() early. // See https://github.com/MozillaReality/FirefoxReality/issues/1353 TelemetryHolder.get() .queuePing(TelemetryCorePingBuilder.TYPE) .queuePing(TelemetryMobileEventPingBuilder.TYPE) .scheduleUpload(); TelemetryHolder.get().recordSessionStart(); TelemetryEvent.create(Category.ACTION, Method.FOREGROUND, Object.APP).queue(); }
Example #11
Source File: SurfaceViewImplementation.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
/** * Sets the completer and the size. The completer will only be set if the current size of * the Surface matches the target size. */ @UiThread void setSurfaceRequest(@NonNull SurfaceRequest surfaceRequest) { cancelPreviousRequest(); mSurfaceRequest = surfaceRequest; Size targetSize = surfaceRequest.getResolution(); mTargetSize = targetSize; if (!tryToComplete()) { // The current size is incorrect. Wait for it to change. Log.d(TAG, "Wait for new Surface creation."); mSurfaceView.getHolder().setFixedSize(targetSize.getWidth(), targetSize.getHeight()); } }
Example #12
Source File: TutorialManager.java From CommonUtils with Apache License 2.0 | 5 votes |
@UiThread public void tryShowingTutorials(final Activity activity) { if (isShowingTutorial || !DialogUtils.isContextValid(activity)) return; for (BaseTutorial tutorial : tutorials) { if (shouldShowFor(tutorial) && listener.canShow(tutorial)) { show(activity, tutorial); return; } } }
Example #13
Source File: SensitiveGameData.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@UiThread void update(@NonNull GameInfo info, @Nullable GameCards cards, @Nullable GameLayout layout) { update(info.game); List<GameInfo.Player> oldPlayers = new ArrayList<>(players); synchronized (players) { players.clear(); players.addAll(info.players); } if (layout != null) { layout.setup(this); if (cards != null) { layout.setHand(cards.hand); layout.setBlackCard(cards.blackCard); layout.setTable(cards.whiteCards, cards.blackCard); } } synchronized (spectators) { for (String spectator : spectators) { if (spectator.equals(me)) listener.playerIsSpectator(); } } synchronized (players) { for (GameInfo.Player player : players) playerChange(player, oldPlayers); } if (playersInterface != null) playersInterface.dispatchUpdate(DiffUtil.calculateDiff(new PlayersDiff(oldPlayers, players), false)); }
Example #14
Source File: MenuItemsAdapter.java From CommonUtils with Apache License 2.0 | 5 votes |
@UiThread void setActiveItem(E which) { int pos = indexOf(which); for (int i = 0; i < getItemCount(); i++) { BaseDrawerItem item = items.get(i); boolean active = i == pos; if (item.active != active) { item.active = active; notifyItemChanged(pos); } } }
Example #15
Source File: SurfaceViewImplementation.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@UiThread private void cancelPreviousRequest() { if (mSurfaceRequest != null) { Log.d(TAG, "Request canceled: " + mSurfaceRequest); mSurfaceRequest.willNotProvideSurface(); mSurfaceRequest = null; } mTargetSize = null; }
Example #16
Source File: ExemptAppPresenter.java From igniter with GNU General Public License v3.0 | 5 votes |
@UiThread private void displayAppList(List<AppInfo> appInfoList) { if (mWorkInAllowMode) { mView.showAllowAppList(appInfoList); } else { mView.showBlockAppList(appInfoList); } }
Example #17
Source File: SensitiveGameData.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@UiThread void playerChange(@NonNull GameInfo.Player player) { playerChange(player, players); for (int i = 0; i < players.size(); i++) { if (players.get(i).name.equals(player.name)) { synchronized (players) { players.set(i, player); } if (playersInterface != null) playersInterface.notifyItemChanged(i); return; } } }
Example #18
Source File: Session.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
@UiThread @Nullable public GeckoResult<boolean[]> getVisited(@NonNull GeckoSession aSession, @NonNull String[] urls) { if (mState.mSession == aSession) { if (mHistoryDelegate != null) { return mHistoryDelegate.getVisited(aSession, urls); } else { final GeckoResult<boolean[]> response = new GeckoResult<>(); mQueuedCalls.add(() -> { if (mHistoryDelegate != null) { try { requireNonNull(mHistoryDelegate.getVisited(aSession, urls)).then(aBoolean -> { response.complete(aBoolean); return null; }).exceptionally(throwable -> { Log.d(LOGTAG, "Null GeckoResult from getVisited"); return null; }); } catch (NullPointerException e) { e.printStackTrace(); } } }); return response; } } return GeckoResult.fromValue(new boolean[]{}); }
Example #19
Source File: WebSocketClient.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread private WebSocketClient(@NonNull MultiProfile.UserProfile profile, boolean close) throws GeneralSecurityException, NetUtils.InvalidUrlException, IOException { super(profile); webSocket = new WeakReference<>(client.newWebSocket(NetUtils.createWebsocketRequest(profile), new Listener())); initializedAt = System.currentTimeMillis(); closeAfterTest = close; }
Example #20
Source File: CardsAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@UiThread public void setCardGroups(List<CardsGroup> cards, @Nullable BaseCard blackCard) { if (blackCard != null) { for (CardsGroup group : cards) { if (group.isUnknwon()) { for (int i = 1; i < blackCard.numPick(); i++) group.add(Card.newBlankCard()); } } } this.cards.clear(); this.cards.addAll(cards); notifyDataSetChanged(); }
Example #21
Source File: CardsAdapter.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@UiThread public void removeCard(@NonNull BaseCard card) { for (int i = cards.size() - 1; i >= 0; i--) { CardsGroup group = cards.get(i); if (group.contains(card)) { cards.remove(i); notifyItemRemoved(i); break; } } }
Example #22
Source File: HttpClient.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread private HttpClient(@NonNull MultiProfile.UserProfile profile) throws GeneralSecurityException, IOException, NetUtils.InvalidUrlException { super(profile); ErrorHandler.get().unlock(); this.executorService = Executors.newCachedThreadPool(); this.url = NetUtils.createHttpURL(profile); }
Example #23
Source File: FilesAdapter.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread public void update(@NonNull DownloadWithUpdate download, @NonNull AriaFiles files) { AriaDirectory dir = AriaDirectory.createRoot(download, files); if (currentDir == null) { changeDir(dir); } else { AriaDirectory currentDirUpdated = dir.findDirectory(currentDir.path); if (currentDirUpdated == null) changeDir(dir); else updateDir(currentDirUpdated); } }
Example #24
Source File: NetTester.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread private void publishResult(MultiProfile.UserProfile profile, MultiProfile.TestStatus status) { if (profileListener != null) { profileListener.statusUpdated(profile.getParent().id, status); return; } switch (status.status) { case OFFLINE: publishMessage("Host is offline, check your connection parameters", Level.ERROR); break; case ERROR: publishMessage("Failed establishing a connection", Level.ERROR); break; case ONLINE: publishMessage("Host is online, connection parameters are configured correctly", Level.SUCCESS); break; default: case UNKNOWN: break; } if (status.ex != null) { if (status.ex.getMessage() == null) { Throwable cause = status.ex.getCause(); if (cause != null && cause.getMessage() != null) publishMessage(cause.getMessage(), Level.ERROR); } else { publishMessage(status.ex.getMessage(), Level.ERROR); } } }
Example #25
Source File: SensitiveGameData.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
@UiThread void resetToIdleAndHost() { synchronized (players) { for (GameInfo.Player player : players) { if (player.name.equals(host)) player.status = GameInfo.PlayerStatus.HOST; else player.status = GameInfo.PlayerStatus.IDLE; } } playersInterface.clearPool(); playersInterface.notifyDataSetChanged(); }
Example #26
Source File: StreamsChannel.java From streams_channel with Apache License 2.0 | 5 votes |
@Override @UiThread public void endOfStream() { if (hasEnded.getAndSet(true) || streams.get(id).sink != this) { return; } StreamsChannel.this.messenger.send(name, null); }
Example #27
Source File: DirectDownloadsAdapter.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread public void remove(Download download) { int index = indexOf(download); if (index != -1) { downloads.remove(index); notifyItemRemoved(index); } }
Example #28
Source File: StreamsChannel.java From streams_channel with Apache License 2.0 | 5 votes |
@Override @UiThread public void success(Object event) { if (hasEnded.get() || streams.get(id).sink != this) { return; } StreamsChannel.this.messenger.send(name, codec.encodeSuccessEnvelope(event)); }
Example #29
Source File: DirectDownloadsAdapter.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread public void updateProgress(@NotNull Download download, long eta, long speed) { int index = indexOf(download); if (index != -1) { FetchDownloadWrapper wrapper = downloads.get(index); wrapper.set(download); notifyItemChanged(index, wrapper.progress(eta, speed)); } }
Example #30
Source File: FetchHelper.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@UiThread public static void updateDownloadCount(@NonNull Context context, @NonNull FetchDownloadCountListener listener) { try { FetchHelper.get(context).updateDownloadCountInternal(listener); } catch (InitializationException ex) { listener.onFetchDownloadCount(0); } }