本文整理汇总了Java中android.support.annotation.Size类的典型用法代码示例。如果您正苦于以下问题:Java Size类的具体用法?Java Size怎么用?Java Size使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Size类属于android.support.annotation包,在下文中一共展示了Size类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnWidths
import android.support.annotation.Size; //导入依赖的package包/类
/**
* 根据比例计算,获取每列的实际宽度。
* 三级联动默认每列宽度为屏幕宽度的三分之一,两级联动默认每列宽度为屏幕宽度的一半。
*/
@Size(3)
protected int[] getColumnWidths(boolean onlyTwoColumn) {
LogUtils.verbose(this, String.format(java.util.Locale.CHINA, "column weight is: %f-%f-%f"
, firstColumnWeight, secondColumnWeight, thirdColumnWeight));
int[] widths = new int[3];
// fixed: 17-1-7 Equality tests should not be made with floating point values.
if ((int) firstColumnWeight == 0 && (int) secondColumnWeight == 0
&& (int) thirdColumnWeight == 0) {
if (onlyTwoColumn) {
widths[0] = screenWidthPixels / 2;
widths[1] = widths[0];
widths[2] = 0;
} else {
widths[0] = screenWidthPixels / 3;
widths[1] = widths[0];
widths[2] = widths[0];
}
} else {
widths[0] = (int) (screenWidthPixels * firstColumnWeight);
widths[1] = (int) (screenWidthPixels * secondColumnWeight);
widths[2] = (int) (screenWidthPixels * thirdColumnWeight);
}
return widths;
}
示例2: getMixImagesBitmap
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Constructing a bitmap that contains the given bitmaps(max is three).
*
* For given two bitmaps the result will be a half and half bitmap.
*
* For given three the result will be a half of the first bitmap and the second
* half will be shared equally by the two others.
*
* @param bitmaps Array of bitmaps to use for the final image.
* @param width width of the final image, A positive number.
* @param height height of the final image, A positive number.
*
* @return A Bitmap containing the given images.
* */
@Nullable public static Bitmap getMixImagesBitmap(@Size(min = 1) int width,@Size(min = 1) int height, @NonNull Bitmap...bitmaps){
if (height == 0 || width == 0) return null;
if (bitmaps.length == 0) return null;
Bitmap finalImage = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(finalImage);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
if (bitmaps.length == 2){
canvas.drawBitmap(ThumbnailUtils.extractThumbnail(bitmaps[0], width/2, height), 0, 0, paint);
canvas.drawBitmap(ThumbnailUtils.extractThumbnail(bitmaps[1], width/2, height), width/2, 0, paint);
}
else{
canvas.drawBitmap(ThumbnailUtils.extractThumbnail(bitmaps[0], width/2, height), 0, 0, paint);
canvas.drawBitmap(ThumbnailUtils.extractThumbnail(bitmaps[1], width/2, height/2), width/2, 0, paint);
canvas.drawBitmap(ThumbnailUtils.extractThumbnail(bitmaps[2], width/2, height/2), width/2, height/2, paint);
}
return finalImage;
}
示例3: CondomContext
import android.support.annotation.Size; //导入依赖的package包/类
private CondomContext(final CondomCore condom, final @Nullable Context app_context, final @Nullable @Size(max=16) String tag) {
super(condom.mBase);
final Context base = condom.mBase;
mCondom = condom;
mApplicationContext = app_context != null ? app_context : this;
mBaseContext = new Lazy<Context>() { @Override protected Context create() {
return new PseudoContextImpl(CondomContext.this);
}};
mPackageManager = new Lazy<PackageManager>() { @Override protected PackageManager create() {
return new CondomPackageManager(base.getPackageManager());
}};
mContentResolver = new Lazy<ContentResolver>() { @Override protected ContentResolver create() {
return new CondomContentResolver(base, base.getContentResolver());
}};
final List<CondomKit> kits = condom.mKits;
if (kits != null && ! kits.isEmpty()) {
mKitManager = new KitManager();
for (final CondomKit kit : kits)
kit.onRegister(mKitManager);
} else mKitManager = null;
TAG = CondomCore.buildLogTag("Condom", "Condom.", tag);
}
示例4: hasPermissions
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Check if the calling context has a set of permissions.
*
* @param context The calling context
* @param permissions One or more permission.
* @return True if all permissions are already granted, false if at least one permission is not
* yet granted.
* @see android.Manifest.permission
*/
public static boolean hasPermissions(@NonNull Context context,
@NonNull @Size(min = 1) String... permissions) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}
final AppOpsManager appOpsManager = context.getSystemService(AppOpsManager.class);
final String packageName = context.getPackageName();
for (String permission : permissions) {
if (ContextCompat.checkSelfPermission(context, permission)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
String op = AppOpsManager.permissionToOp(permission);
if (!TextUtils.isEmpty(op) && appOpsManager != null
&& appOpsManager.noteProxyOp(op, packageName) != AppOpsManager.MODE_ALLOWED) {
return false;
}
}
return true;
}
示例5: requestPermissions
import android.support.annotation.Size; //导入依赖的package包/类
private static void requestPermissions(@NonNull BasePermissionInvoker invoker,
@IntRange(from = 0) int requestCode,
@Size(min = 1) @NonNull String[]... permissionSets) {
final List<String> permissionList = new ArrayList<>();
for (String[] permissionSet : permissionSets) {
permissionList.addAll(Arrays.asList(permissionSet));
}
final String[] permissions = permissionList.toArray(new String[permissionList.size()]);
if (hasPermissions(invoker.getContext(), permissions)) {
notifyAlreadyHasPermissions(invoker, requestCode, permissions);
return;
}
if (invoker.shouldShowRequestPermissionRationale(permissions)) {
if (invokeShowRationaleMethod(false, invoker, requestCode, permissions)) {
return;
}
}
invoker.executeRequestPermissions(requestCode, permissions);
}
示例6: showDefaultRationaleDialog
import android.support.annotation.Size; //导入依赖的package包/类
public static void showDefaultRationaleDialog(
@NonNull Context context, @NonNull final PermissionRequestExecutor executor,
@IntRange(from = 0) final int code,
@NonNull @Size(min = 1) final String... permissions) {
new AlertDialog.Builder(context)
.setTitle(R.string.hey_permission_request_title)
.setMessage(R.string.hey_permission_request_message)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
executor.executeRequestPermissions(code, permissions);
}
})
.setCancelable(false)
.show();
}
示例7: getTouchLocationOnScreen
import android.support.annotation.Size; //导入依赖的package包/类
@Override
public void getTouchLocationOnScreen(MotionEvent event, @Size(2) int[] locationOut) {
int pointerId = event.getPointerId(event.getActionIndex());
int pointerIdx = event.findPointerIndex(pointerId);
float offsetX = event.getX(pointerIdx);
float offsetY = event.getY(pointerIdx);
// Get local screen coordinates.
getLocationOnScreen(locationOut);
// add the scaled offset.
if (mWorkspaceView != null) {
float scale = mWorkspaceView.getScaleX();
offsetX = offsetX * scale;
offsetY = offsetY * scale;
}
locationOut[0] += (int) offsetX;
locationOut[1] += (int) offsetY;
}
示例8: isBeyondSlopThreshold
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Checks whether {@code actionMove} is beyond the allowed slop (i.e., unintended) drag motion
* distance.
*
* @param actionMove The {@link MotionEvent#ACTION_MOVE} event.
* @return True if the motion is beyond the allowed slop threshold
*/
private boolean isBeyondSlopThreshold(MotionEvent actionMove) {
BlockView touchedView = mPendingDrag.getTouchedBlockView();
// Not dragging yet - compute distance from Down event and start dragging if far enough.
@Size(2) int[] touchDownLocation = mTempScreenCoord1;
mPendingDrag.getTouchDownScreen(touchDownLocation);
@Size(2) int[] curScreenLocation = mTempScreenCoord2;
touchedView.getTouchLocationOnScreen(actionMove, curScreenLocation);
final int deltaX = touchDownLocation[0] - curScreenLocation[0];
final int deltaY = touchDownLocation[1] - curScreenLocation[1];
// Dragged far enough to start a drag?
return (deltaX * deltaX + deltaY * deltaY > mTouchSlopSquared);
}
示例9: IE_JwtToken
import android.support.annotation.Size; //导入依赖的package包/类
IE_JwtToken(@org.intellij.lang.annotations.Pattern(TOKEN_VALIDATOR_MATCHER) @Size(min = 5) @NonNull String pEncodedToken) throws IllegalArgumentException {
super();
this._EncodedToken = pEncodedToken;
if(! this._EncodedToken.matches(TOKEN_VALIDATOR_MATCHER)) {
throw new IllegalArgumentException(String.format("Wrong token format. Token: %s does not match the regex %s", pEncodedToken, TOKEN_VALIDATOR_MATCHER));
}
JSONObject payloadJSON = null;
try {
Matcher matcher = TOKEN_PAYLOAD_MATCHER.matcher(pEncodedToken);
if (matcher.find()) {
payloadJSON = new JSONObject(
new String(Base64.decode(matcher.group(1), Base64.DEFAULT), "UTF-8"));
}
} catch (Exception ignored) { }
if(payloadJSON != null) {
long tmpUserID = payloadJSON.optLong("id", -1L);
this._UserID = tmpUserID == -1L ? null : tmpUserID;
//noinspection WrongConstant
this._UserType = payloadJSON.optInt("type", USER_TYPE__ANONYMOUS);
} else {
this._UserID = null;
this._UserType = USER_TYPE__ANONYMOUS;
}
}
示例10: in
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Create an expression to check this column against several values.
* <p>
* SQL: this IN (values...)
*
* @param values The values to test against this column
* @return Expression
*/
@NonNull
@CheckResult
public final Expr in(@NonNull @Size(min = 1) long... values) {
final int length = values.length;
if (length == 0) {
throw new SQLException("Empty IN clause values");
}
final String[] args = new String[length];
final StringBuilder sb = new StringBuilder(6 + (length << 1));
sb.append(" IN (");
for (int i = 0; i < length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append('?');
args[i] = Long.toString(values[i]);
}
sb.append(')');
return new ExprN(this, sb.toString(), args);
}
示例11: notIn
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Create an expression to check this column against several values.
* <p>
* SQL: this NOT IN (values...)
*
* @param values The values to test against this column
* @return Expression
*/
@NonNull
@CheckResult
public final Expr notIn(@NonNull @Size(min = 1) long... values) {
final int length = values.length;
if (length == 0) {
throw new SQLException("Empty IN clause values");
}
final String[] args = new String[length];
final StringBuilder sb = new StringBuilder(10 + (length << 1));
sb.append(" NOT IN (");
for (int i = 0; i < length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append('?');
args[i] = Long.toString(values[i]);
}
sb.append(')');
return new ExprN(this, sb.toString(), args);
}
示例12: using
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Create join "USING" clause.
* <p>
* Each of the columns specified must exist in the datasets to both the left and right
* of the join-operator. For each pair of columns, the expression "lhs.X = rhs.X"
* is evaluated for each row of the cartesian product as a boolean expression.
* Only rows for which all such expressions evaluates to true are included from the
* result set. When comparing values as a result of a USING clause, the normal rules
* for handling affinities, collation sequences and NULL values in comparisons apply.
* The column from the dataset on the left-hand side of the join-operator is considered
* to be on the left-hand side of the comparison operator (=) for the purposes of
* collation sequence and affinity precedence.
* <p>
* For each pair of columns identified by a USING clause, the column from the
* right-hand dataset is omitted from the joined dataset. This is the only difference
* between a USING clause and its equivalent ON constraint.
*
* @param columns
* Columns to use in the USING clause
* @return Join clause
*/
@NonNull
@CheckResult
public final JoinClause using(@NonNull @Size(min = 1) final Column... columns) {
final int colLen = columns.length;
final StringBuilder sb = new StringBuilder(8 + colLen * 12);
sb.append("USING (");
for (int i = 0; i < colLen; i++) {
if (i > 0) {
sb.append(',');
}
sb.append(columns[i].name);
}
sb.append(')');
return new JoinClause(this, "", sb.toString()) {
@Override
boolean containsColumn(@NonNull Column<?, ?, ?, ?, ?> column) {
for (int i = 0; i < colLen; i++) {
if (columns[i].equals(column)) {
return true;
}
}
return false;
}
};
}
示例13: in
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Create an expression to check this column against several values.
* <p>
* SQL: this IN (values...)
*
* @param values The values to test against this column
* @return Expression
*/
@NonNull
@CheckResult
public final Expr in(@NonNull @Size(min = 1) Collection<T> values) {
final int length = values.size();
if (length == 0) {
throw new SQLException("Empty IN clause values");
}
final String[] args = new String[length];
final StringBuilder sb = new StringBuilder(6 + (length << 1));
sb.append(" IN (");
final Iterator<T> iterator = values.iterator();
for (int i = 0; i < length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append('?');
args[i] = toSqlArg(iterator.next());
}
sb.append(')');
return new ExprN(this, sb.toString(), args);
}
示例14: notIn
import android.support.annotation.Size; //导入依赖的package包/类
/**
* Create an expression to check this column against several values.
* <p>
* SQL: this NOT IN (values...)
*
* @param values The values to test against this column
* @return Expression
*/
@NonNull
@CheckResult
public final Expr notIn(@NonNull @Size(min = 1) Collection<T> values) {
final int length = values.size();
if (length == 0) {
throw new SQLException("Empty IN clause values");
}
final String[] args = new String[length];
final StringBuilder sb = new StringBuilder(10 + (length << 1));
sb.append(" NOT IN (");
final Iterator<T> iterator = values.iterator();
for (int i = 0; i < length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append('?');
args[i] = toSqlArg(iterator.next());
}
sb.append(')');
return new ExprN(this, sb.toString(), args);
}
示例15: getDimensions
import android.support.annotation.Size; //导入依赖的package包/类
@Size(value = 2)
private int[] getDimensions(int orientation, float videoWidth, float videoHeight) {
final float aspectRatio = videoWidth / videoHeight;
int width;
int height;
if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|| orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
width = getMeasuredWidth();
height = (int) ((float) width / aspectRatio);
if (height > getMeasuredHeight()) {
height = getMeasuredHeight();
width = (int) ((float) height * aspectRatio);
}
} else {
height = getMeasuredHeight();
width = (int) ((float) height * aspectRatio);
if (width > getMeasuredWidth()) {
width = getMeasuredWidth();
height = (int) ((float) width / aspectRatio);
}
}
return new int[] {width, height};
}