use of mpicbg.trakem2.util.Pair in project animate by hitherejoe.
the class SharedTransitionsActivity method startToolbarTransition.
@OnClick(R.id.text_shared_toolbar)
public void startToolbarTransition() {
Intent intent = new Intent(SharedTransitionsActivity.this, SharedTransitionToolbarActivity.class);
Pair squareParticipant = new Pair<>(mRelativeView, ViewCompat.getTransitionName(mRelativeView));
Pair toolbarParticipants = new Pair<>(mToolbarView, ViewCompat.getTransitionName(mToolbarView));
ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(SharedTransitionsActivity.this, squareParticipant, toolbarParticipants);
ActivityCompat.startActivity(SharedTransitionsActivity.this, intent, transitionActivityOptions.toBundle());
}
use of mpicbg.trakem2.util.Pair in project hadoop by apache.
the class LogsCLI method getContainerLogFiles.
private List<Pair<PerContainerLogFileInfo, String>> getContainerLogFiles(Configuration conf, String containerIdStr, String nodeHttpAddress) throws IOException {
List<Pair<PerContainerLogFileInfo, String>> logFileInfos = new ArrayList<>();
Client webServiceClient = Client.create();
try {
WebResource webResource = webServiceClient.resource(WebAppUtils.getHttpSchemePrefix(conf) + nodeHttpAddress);
ClientResponse response = webResource.path("ws").path("v1").path("node").path("containers").path(containerIdStr).path("logs").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
if (response.getStatusInfo().getStatusCode() == ClientResponse.Status.OK.getStatusCode()) {
try {
JSONArray array = new JSONArray();
JSONObject json = response.getEntity(JSONObject.class);
Object logsInfoObj = json.get("containerLogsInfo");
if (logsInfoObj instanceof JSONObject) {
array.put((JSONObject) logsInfoObj);
} else if (logsInfoObj instanceof JSONArray) {
JSONArray logsArray = (JSONArray) logsInfoObj;
for (int i = 0; i < logsArray.length(); i++) {
array.put(logsArray.getJSONObject(i));
}
}
for (int i = 0; i < array.length(); i++) {
JSONObject log = array.getJSONObject(i);
String aggregateType = log.has("logAggregationType") ? log.getString("logAggregationType") : "N/A";
Object ob = log.get("containerLogInfo");
if (ob instanceof JSONArray) {
JSONArray obArray = (JSONArray) ob;
for (int j = 0; j < obArray.length(); j++) {
logFileInfos.add(new Pair<PerContainerLogFileInfo, String>(generatePerContainerLogFileInfoFromJSON(obArray.getJSONObject(j)), aggregateType));
}
} else if (ob instanceof JSONObject) {
logFileInfos.add(new Pair<PerContainerLogFileInfo, String>(generatePerContainerLogFileInfoFromJSON((JSONObject) ob), aggregateType));
}
}
} catch (Exception e) {
System.err.println("Unable to parse json from webservice. Error:");
System.err.println(e.getMessage());
throw new IOException(e);
}
}
} catch (ClientHandlerException | UniformInterfaceException ex) {
System.err.println("Unable to fetch log files list");
throw new IOException(ex);
}
return logFileInfos;
}
use of mpicbg.trakem2.util.Pair in project realm-rxjava-example by kboyarshinov.
the class MainActivity method requestWithZip.
private void requestWithZip() {
if (compositeSubscription == null) {
return;
}
Observable<Issue> issues = dataService.issues();
Subscription subscription = Observable.zip(issues.take(10), issues.takeLast(10), new Func2<Issue, Issue, Pair<Issue, Issue>>() {
@Override
public Pair<Issue, Issue> call(Issue issue, Issue issue2) {
return new Pair<>(issue, issue2);
}
}).toList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Pair<Issue, Issue>>>() {
@Override
public void call(List<Pair<Issue, Issue>> pairs) {
Log.d(TAG, "List of issue pairs " + pairs.size());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
Log.e(TAG, "Error requesting issue pairs", throwable);
}
});
compositeSubscription.add(subscription);
}
use of mpicbg.trakem2.util.Pair in project Rocket.Chat.Android by RocketChat.
the class MessageOptionsDialogFragment method setUpDialog.
private void setUpDialog(final BottomSheetDialog bottomSheetDialog, String messageId) {
RocketChatCache cache = new RocketChatCache(bottomSheetDialog.getContext());
String hostname = cache.getSelectedServerHostname();
EditMessageInteractor editMessageInteractor = getEditMessageInteractor(hostname);
MessageRepository messageRepository = new RealmMessageRepository(hostname);
Disposable disposable = messageRepository.getById(messageId).flatMap(it -> {
if (!it.isPresent()) {
return Single.just(Pair.<Message, Boolean>create(null, false));
}
Message message = it.get();
return Single.zip(Single.just(message), editMessageInteractor.isAllowed(message), Pair::create);
}).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(pair -> {
if (pair.second) {
bottomSheetDialog.findViewById(R.id.message_options_info).setVisibility(View.GONE);
View editView = bottomSheetDialog.findViewById(R.id.message_options_edit_action);
editView.setVisibility(View.VISIBLE);
editView.setOnClickListener(view -> internalListener.onEdit(pair.first));
} else {
((TextView) bottomSheetDialog.findViewById(R.id.message_options_info)).setText(R.string.message_options_no_permissions_info);
}
}, throwable -> {
((TextView) bottomSheetDialog.findViewById(R.id.message_options_info)).setText(R.string.message_options_no_message_info);
Logger.report(throwable);
});
compositeDisposable.add(disposable);
}
use of mpicbg.trakem2.util.Pair in project Douya by DreaminginCodeZH.
the class TransitionUtils method makeActivityOptionsBundle.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Bundle makeActivityOptionsBundle(Activity activity, View... sharedViews) {
if (!shouldEnableTransition()) {
return null;
}
ArrayList<Pair<View, String>> sharedElementList = new ArrayList<>();
for (View sharedView : sharedViews) {
sharedElementList.add(Pair.create(sharedView, sharedView.getTransitionName()));
}
View appbar = activity.findViewById(R.id.appBarWrapper);
if (appbar != null) {
sharedElementList.add(Pair.create(appbar, appbar.getTransitionName()));
}
//noinspection unchecked
Pair<View, String>[] sharedElements = sharedElementList.toArray(new Pair[sharedElementList.size()]);
//noinspection unchecked
return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements).toBundle();
}
Aggregations