本文整理匯總了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};
}