use of mpicbg.trakem2.util.Pair in project android-topeka by googlesamples.
the class TransitionHelper method createSafeTransitionParticipants.
/**
* Create the transition participants required during a activity transition while
* avoiding glitches with the system UI.
*
* @param activity The activity used as start for the transition.
* @param includeStatusBar If false, the status bar will not be added as the transition
* participant.
* @return All transition participants.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) {
// Avoid system UI glitches as described here:
// https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb
View decor = activity.getWindow().getDecorView();
View statusBar = null;
if (includeStatusBar) {
statusBar = decor.findViewById(android.R.id.statusBarBackground);
}
View navBar = decor.findViewById(android.R.id.navigationBarBackground);
// Create pair of transition participants.
List<Pair> participants = new ArrayList<>(3);
addNonNullViewToTransitionParticipants(statusBar, participants);
addNonNullViewToTransitionParticipants(navBar, participants);
// only add transition participants if there's at least one none-null element
if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) {
participants.addAll(Arrays.asList(otherParticipants));
}
//noinspection unchecked
return participants.toArray(new Pair[participants.size()]);
}
use of mpicbg.trakem2.util.Pair in project native-navigation by airbnb.
the class AutoSharedElementCallback method mapBestPartialMatches.
private void mapBestPartialMatches(List<String> names, Map<String, View> sharedElements) {
List<Pair<View, String>> allTransitionViews = new ArrayList<>();
ViewUtils.findTransitionViews(getDecorView(), allTransitionViews);
List<View> partialMatches = new ArrayList<>();
for (String name : names) {
if (sharedElements.containsKey(name)) {
// Exact match
continue;
}
TransitionName tn = TransitionName.parse(name);
findAllPartialMatches(tn, allTransitionViews, partialMatches);
if (!partialMatches.isEmpty()) {
View mostVisibleView = ViewUtils.getMostVisibleView(partialMatches);
sharedElements.put(name, mostVisibleView);
}
}
if (delegate != null) {
delegate.onPostMapSharedElements(names, sharedElements);
}
}
use of mpicbg.trakem2.util.Pair in project DataX by alibaba.
the class OtsWriterSlaveProxy method write.
public void write(RecordReceiver recordReceiver, TaskPluginCollector collector) throws Exception {
LOG.info("Writer slave started.");
WriterConfig writerConfig = new WriterConfig();
writerConfig.setConcurrency(conf.getConcurrencyWrite());
writerConfig.setMaxBatchRowsCount(conf.getBatchWriteCount());
writerConfig.setMaxBatchSize(conf.getRestrictConf().getRequestTotalSizeLimition());
writerConfig.setBufferSize(conf.getBufferSize());
writerConfig.setMaxAttrColumnSize(conf.getRestrictConf().getAttributeColumnSize());
writerConfig.setMaxColumnsCount(conf.getRestrictConf().getMaxColumnsCount());
writerConfig.setMaxPKColumnSize(conf.getRestrictConf().getPrimaryKeyColumnSize());
otsWriter = new DefaultOTSWriter(otsAsync, conf.getTableName(), writerConfig, new WriterCallback(collector), Executors.newFixedThreadPool(3));
int expectColumnCount = conf.getPrimaryKeyColumn().size() + conf.getAttributeColumn().size();
Record record;
while ((record = recordReceiver.getFromReader()) != null) {
LOG.debug("Record Raw: {}", record.toString());
int columnCount = record.getColumnNumber();
if (columnCount != expectColumnCount) {
// 如果Column的个数和预期的个数不一致时,认为是系统故障或者用户配置Column错误,异常退出
throw new IllegalArgumentException(String.format(OTSErrorMessage.RECORD_AND_COLUMN_SIZE_ERROR, columnCount, expectColumnCount));
}
// 类型转换
try {
RowPrimaryKey primaryKey = Common.getPKFromRecord(conf.getPrimaryKeyColumn(), record);
List<Pair<String, ColumnValue>> attributes = Common.getAttrFromRecord(conf.getPrimaryKeyColumn().size(), conf.getAttributeColumn(), record);
RowChange rowChange = Common.columnValuesToRowChange(conf.getTableName(), conf.getOperation(), primaryKey, attributes);
WithRecord withRecord = (WithRecord) rowChange;
withRecord.setRecord(record);
otsWriter.addRowChange(rowChange);
} catch (IllegalArgumentException e) {
LOG.warn("Found dirty data.", e);
collector.collectDirtyRecord(record, e.getMessage());
} catch (ClientException e) {
LOG.warn("Found dirty data.", e);
collector.collectDirtyRecord(record, e.getMessage());
}
}
otsWriter.close();
LOG.info("Writer slave finished.");
}
use of mpicbg.trakem2.util.Pair in project DataX by alibaba.
the class Common method getAttrFromRecord.
public static List<Pair<String, ColumnValue>> getAttrFromRecord(int pkCount, List<OTSAttrColumn> attrColumns, Record r) {
List<Pair<String, ColumnValue>> attr = new ArrayList<Pair<String, ColumnValue>>(r.getColumnNumber());
for (int i = 0; i < attrColumns.size(); i++) {
Column col = r.getColumn(i + pkCount);
OTSAttrColumn expect = attrColumns.get(i);
if (col.getRawData() == null) {
attr.add(new Pair<String, ColumnValue>(expect.getName(), null));
continue;
}
ColumnValue cv = ColumnConversion.columnToColumnValue(col, expect);
attr.add(new Pair<String, ColumnValue>(expect.getName(), cv));
}
return attr;
}
use of mpicbg.trakem2.util.Pair in project android by owncloud.
the class FileDataStorageManager method getAvailableOfflineFilesFromEveryAccount.
/**
* Get a collection with all the files set by the user as available offline, from all the accounts
* in the device.
*
* This is the only method working with a NULL account in {@link #mAccount}. Not something to do often.
*
* @return List with all the files set by the user as available offline.
*/
public List<Pair<OCFile, String>> getAvailableOfflineFilesFromEveryAccount() {
List<Pair<OCFile, String>> result = new ArrayList<>();
Cursor cursorOnKeptInSync = null;
try {
// query for any favorite file in any OC account
cursorOnKeptInSync = getContentResolver().query(ProviderTableMeta.CONTENT_URI, null, ProviderTableMeta.FILE_KEEP_IN_SYNC + " = ?", new String[] { String.valueOf(OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE.getValue()) }, // do NOT get also AVAILABLE_OFFLINE_PARENT: only those SET BY THE USER (files or folders)
null);
if (cursorOnKeptInSync != null && cursorOnKeptInSync.moveToFirst()) {
OCFile file;
String accountName;
do {
file = createFileInstance(cursorOnKeptInSync);
accountName = cursorOnKeptInSync.getString(cursorOnKeptInSync.getColumnIndex(ProviderTableMeta.FILE_ACCOUNT_OWNER));
result.add(new Pair<>(file, accountName));
} while (cursorOnKeptInSync.moveToNext());
}
} catch (Exception e) {
Log_OC.e(TAG, "Exception retrieving all the available offline files", e);
} finally {
if (cursorOnKeptInSync != null) {
cursorOnKeptInSync.close();
}
}
return result;
}
Aggregations