java类android.support.annotation.RequiresApi的实例源码

RelativeRadioGroup.java 文件源码 项目:RelativeRadioGroup 阅读 47 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
    if (parent == RelativeRadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
PhotoFilter.java 文件源码 项目:FilterLibrary 阅读 35 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap seven(Context context, Bitmap bitmap){
    renderScript=RenderScript.create(context);
    outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
    inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
    outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
    final  ScriptIntrinsicColorMatrix colorMatrix7 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
    colorMatrix7.setColorMatrix(new android.renderscript.Matrix4f(new float[]
            {
                    1.22994596833595f, 0.0209523774645382f, 0.383244054685119f, 0f,
                    0.450138899443543f, 1.18737418804171f, -0.106933249401007f, 0f
                    - 0.340084867779496f, 0.131673434493755f, 1.06368919471589f, 0f,
                    0f, 0f, 0f,
                    11.91f, 11.91f, 11.91f, 0f}));
    colorMatrix7.forEach(inputAllocation, outputAllocation);
    outputAllocation.copyTo(outBitmap);
    return outBitmap;
}
AttachmentRegionDecoder.java 文件源码 项目:Cable-Android 阅读 40 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Point init(Context context, Uri uri) throws Exception {
  Log.w(TAG, "Init!");
  if (!PartAuthority.isLocalUri(uri)) {
    passthrough = new SkiaImageRegionDecoder();
    return passthrough.init(context, uri);
  }

  MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

  if (masterSecret == null) {
    throw new IllegalStateException("No master secret available...");
  }

  InputStream inputStream = PartAuthority.getAttachmentStream(context, masterSecret, uri);

  this.bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);
  inputStream.close();

  return new Point(bitmapRegionDecoder.getWidth(), bitmapRegionDecoder.getHeight());
}
DownloadForegroundService.java 文件源码 项目:VBrowser-Android 阅读 48 收藏 0 点赞 0 评论 0
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(){
    String channelId = "VBrowserNotification";
    String channelName = "前台下载通知";
    NotificationChannel chan = new NotificationChannel(channelId,
            channelName, NotificationManager.IMPORTANCE_HIGH);
    chan.setLightColor(Color.BLUE);
    chan.setImportance(NotificationManager.IMPORTANCE_NONE);
    chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
    NotificationManager service = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    service.createNotificationChannel(chan);
    return channelId;
}
AlarmUtils.java 文件源码 项目:ImHome 阅读 38 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.N)
public static void setAlarm(Context context,int hour, int minute, int second) {
    Calendar calendar = Calendar.getInstance();
    Calendar rightNow = Calendar.getInstance();
    calendar.set(Calendar.HOUR, hour);
    int timeOffset = hour - calendar.get(Calendar.HOUR);
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR, hour - timeOffset);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.SECOND, second);

    Intent intent = new Intent(context, AlarmReceiver.class);
    pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
    alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    //set the alarm repeat one day
    alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
            calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
    Log.i("setting", String.valueOf(calendar.getTime()));
    Log.i("actual", String.valueOf(rightNow.getTime()));
}
AppLockActivity.java 文件源码 项目:Lunary-Ethereum-Wallet 阅读 46 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.M)
public void setupFingerprintStuff() {
    fingerprintManager = (FingerprintManager) this.getSystemService(Context.FINGERPRINT_SERVICE);
    fingerprintHelper = new FingerprintHelper(this);
    try {
        generateKey();

        if (cipherInit()) {
            cryptoObject = new FingerprintManager.CryptoObject(cipher);
            fingerprintHelper.startAuth(fingerprintManager, cryptoObject);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
PdfView.java 文件源码 项目:CollegeDoc 阅读 46 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //PDF
    if (resultCode == RESULT_OK) {
        if (requestCode == SELECT_PDF) {

            Uri selectedUri_PDF = data.getData();
            InputStream inputstream;
            try {
                inputstream = getContentResolver().openInputStream(selectedUri_PDF);
                pdfview.fromStream(inputstream).load();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                Toast.makeText(PdfView.this, "unable to open", Toast.LENGTH_SHORT).show();
            }
        }
    }
    else
    {
        startActivity(new Intent(PdfView.this,Subjects.class));
        finish();
    }
}
Coloring.java 文件源码 项目:silly-android 阅读 43 收藏 0 点赞 0 评论 0
/**
 * Creates a new {@link RippleDrawable} introduced in Lollipop.
 *
 * @param normalColor  Color for the idle/normal state
 * @param rippleColor  Color for the ripple effect
 * @param bounds       Clipping bounds for the ripple state. Set to {@code null} to get a borderless ripple
 * @param cornerRadius Set to round the corners on rectangular drawables, 0 to disable
 * @return A fully colored RippleDrawable, new instance each time
 */
@NonNull
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static RippleDrawable createRippleDrawable(@ColorInt final int normalColor, @ColorInt final int rippleColor, @Nullable final Rect bounds,
                                                  @IntRange(from = 0) final int cornerRadius) {
    Drawable maskDrawable = null;
    if (bounds != null) {
        // clip color is white
        maskDrawable = createColoredDrawable(Color.WHITE, bounds);
        if (maskDrawable instanceof GradientDrawable) {
            ((GradientDrawable) maskDrawable).setCornerRadius(cornerRadius);
        }
        maskDrawable.setBounds(bounds);
    }

    Drawable normalStateDrawable = null;
    // transparent has no idle state
    if (normalColor != Color.TRANSPARENT) {
        normalStateDrawable = createColoredDrawable(normalColor, bounds);
        if (normalStateDrawable instanceof GradientDrawable) {
            ((GradientDrawable) normalStateDrawable).setCornerRadius(cornerRadius);
        }
    }

    return new RippleDrawable(ColorStateList.valueOf(rippleColor), normalStateDrawable, maskDrawable);
}
TripListActivity.java 文件源码 项目:betterHotels 阅读 37 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_trips_list);
    initializeToolbar();

    ivHero1 = (ImageView) findViewById(R.id.iv_hero_1);
    trip1Layout = (ViewGroup) findViewById(R.id.trip_1_layout);
    trip1Layout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Pair<View, String> p1 = Pair.create((View) ivHero1, ivHero1.getTransitionName());
            ActivityOptionsCompat options = ActivityOptionsCompat.
                    makeSceneTransitionAnimation((TripListActivity.this), p1);
            Bundle bundle = options.toBundle();
            Intent i = new Intent(TripListActivity.this, TripDetailActivity.class);
            startActivity(i, bundle);
        }
    });
}
AuthCode.java 文件源码 项目:AutoInputAuthCode 阅读 41 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    TextView mAuthCode = mTextViewRef.get();
    if (mAuthCode == null) {
        return;
    }
    if (!mAuthCode.getText().toString().isEmpty()) return;

    switch (msg.what) {
        case ReadSmsService.OBSERVER_SMS_CODE_MSG:
            mAuthCode.setText((String) msg.obj);
            break;
        case ReadSmsService.RECEIVER_SMS_CODE_MSG:
            mAuthCode.setText((String) msg.obj);
            break;
        default:
            break;
    }
    recycle();
}
AttachmentRegionDecoder.java 文件源码 项目:Cable-Android 阅读 49 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Bitmap decodeRegion(Rect rect, int sampleSize) {
  Log.w(TAG, "Decode region: " + rect);

  if (passthrough != null) {
    return passthrough.decodeRegion(rect, sampleSize);
  }

  synchronized(this) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize      = sampleSize;
    options.inPreferredConfig = Bitmap.Config.RGB_565;

    Bitmap bitmap = bitmapRegionDecoder.decodeRegion(rect, options);

    if (bitmap == null) {
      throw new RuntimeException("Skia image decoder returned null bitmap - image format may not be supported");
    }

    return bitmap;
  }
}
PhotoFilter.java 文件源码 项目:FilterLibrary 阅读 40 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap fifteen(Context context, Bitmap bitmap){
    renderScript=RenderScript.create(context);
    outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
    inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
    outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
    final ScriptIntrinsicColorMatrix colorMatrix13 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
    colorMatrix13.setColorMatrix(new android.renderscript.Matrix4f(new float[]
            {

                    2.10279132254252f,  -0.298212630531356f,       0.42128146417712f,   0f,
                    0.222897572029231f,     1.68701190285368f,     -0.883421304780577f,   0f,
                    -0.765688894571747f,   0.171200727677677f,    2.02213984060346f,     0f,
                    0                          ,  0                 ,0                ,1f


            }));
    colorMatrix13.forEach(inputAllocation, outputAllocation);
    outputAllocation.copyTo(outBitmap);
    return outBitmap;
}
PhotoFilter.java 文件源码 项目:FilterLibrary 阅读 34 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap twelve(Context context, Bitmap bitmap){
    renderScript=RenderScript.create(context);
    outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
    inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
    outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
    final ScriptIntrinsicColorMatrix colorMatrix12 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
    colorMatrix12.setColorMatrix(new android.renderscript.Matrix4f(new float[]
            {
                    .309f, .409f, .309f, 0f,
                    .609f, .309f, .409f, 0f,
                    0.42f, .42f, .2f, 0f,
                    0f, 0f, 0f, 1f


            }));
    colorMatrix12.forEach(inputAllocation, outputAllocation);
    outputAllocation.copyTo(outBitmap);
    return outBitmap;
}
GalleryActivity.java 文件源码 项目:betterHotels 阅读 52 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    parentLayout = (LinearLayout) findViewById(R.id.parent_view);
    ivHeroImage = (ImageView) findViewById(R.id.iv_image_gallery);
    ivClose = (ImageView) findViewById(R.id.iv_close);
    imageResource = getIntent().getIntExtra("image", R.drawable.img_city_1);
    ivHeroImage.setImageResource(imageResource);

    ivClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });
}
ScreenRecordActivity.java 文件源码 项目:Amazing 阅读 36 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode != REQUEST_CODE) {
        return;
    }
    if (manager == null) {
        return;
    }
    mediaProjection = manager.getMediaProjection(resultCode, data);
    if (mediaProjection == null) {
        return;
    }
    onStartRecord();
}
ImageFormatKeyframesFragment.java 文件源码 项目:GitHub 阅读 36 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void initAnimation(View view) {
  mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
  mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setOldController(mSimpleDraweeView.getController())
      .setUri(URI_KEYFRAMES_ANIMATION)
      .setAutoPlayAnimations(true)
      .build();
  mSimpleDraweeView.setController(controller);

  final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background);
  switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      mSimpleDraweeView.getHierarchy().setBackgroundImage(isChecked
          ? new CheckerBoardDrawable(getResources())
          : null);
    }
  });
}
MainActivity.java 文件源码 项目:LikeWechatPhotoViewer 阅读 49 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public View instantiateItem(ViewGroup container, int position) {
    PhotoView photoView = new PhotoView(container.getContext());
    photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
        @Override
        public void onViewTap(View view, float x, float y) {
            playZoomOutAnim();
        }
    });
    PicInfo picInfo = picUrls.get(position);
    sceneHelp.showExpandedView(photoView, picInfo);
    container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return photoView;
}
ContainerActivity.java 文件源码 项目:Floo 阅读 35 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void setResultAndBackToPage2(View view) {
    Floo.stack(this)
        .target(Urls.indexUrl("https://chunchun.io/page2"))
        .result("https://play.google.com/store/apps/details?id=com.drakeet.purewriter")
        .start();
}
Device.java 文件源码 项目:neatle 阅读 46 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
    BluetoothGattCallback target;
    synchronized (lock) {
        target = currentCallback;
    }
    target.onMtuChanged(gatt, mtu, status);
}
WithDefaultToInDimension.java 文件源码 项目:Spyglass 阅读 43 收藏 0 点赞 0 评论 0
@TargetApi(21)
@RequiresApi(21)
public WithDefaultToInDimension(
        final Context context,
        final AttributeSet attrs,
        final int defStyleAttr,
        final int defStyleRes) {

    super(context, attrs, defStyleAttr, defStyleRes);
    init(attrs, defStyleAttr, defStyleRes);
}
VideoEncoder.java 文件源码 项目:rtmp-rtsp-stream-client-java 阅读 40 收藏 0 点赞 0 评论 0
/**
 * choose the video encoder by mime. API 21+
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private MediaCodecInfo chooseVideoEncoderAPI21(String mime) {
  MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
  MediaCodecInfo[] mediaCodecInfos = mediaCodecList.getCodecInfos();
  for (MediaCodecInfo mci : mediaCodecInfos) {
    if (!mci.isEncoder()) {
      continue;
    }
    String[] types = mci.getSupportedTypes();
    for (String type : types) {
      if (type.equalsIgnoreCase(mime)) {
        Log.i(TAG, String.format("videoEncoder %s type supported: %s", mci.getName(), type));
        MediaCodecInfo.CodecCapabilities codecCapabilities = mci.getCapabilitiesForType(mime);
        for (int color : codecCapabilities.colorFormats) {
          Log.i(TAG, "Color supported: " + color);
          //check if encoder support any yuv420 color
          if (color == FormatVideoEncoder.YUV420PLANAR.getFormatCodec()
              || color == FormatVideoEncoder.YUV420SEMIPLANAR.getFormatCodec()
              || color == FormatVideoEncoder.YUV420PACKEDPLANAR.getFormatCodec()) {
            return mci;
          }
        }
      }
    }
  }
  return null;
}
WithDefaultToInteger.java 文件源码 项目:Spyglass 阅读 38 收藏 0 点赞 0 评论 0
@TargetApi(21)
@RequiresApi(21)
public WithDefaultToInteger(
        final Context context,
        final AttributeSet attrs,
        final int defStyleAttr,
        final int defStyleRes) {

    super(context, attrs, defStyleAttr, defStyleRes);
    init(attrs, defStyleAttr, defStyleRes);
}
WithDefaultToNull.java 文件源码 项目:Spyglass 阅读 30 收藏 0 点赞 0 评论 0
@TargetApi(21)
@RequiresApi(21)
public WithDefaultToNull(
        final Context context,
        final AttributeSet attrs,
        final int defStyleAttr,
        final int defStyleRes) {

    super(context, attrs, defStyleAttr, defStyleRes);
    init(attrs, defStyleAttr, defStyleRes);
}
RxNetworkInfo.java 文件源码 项目:RxNetwork 阅读 45 收藏 0 点赞 0 评论 0
@RequiresApi(LOLLIPOP)
@Nullable
static NetworkCapabilities getCapabilities(@NonNull Network network,
    @NonNull ConnectivityManager connectivityManager) {

  NetworkCapabilities networkCapabilities = null;

  try {
    networkCapabilities = connectivityManager.getNetworkCapabilities(network);
  } catch (Exception exc) {
    logger.log(WARNING,
        "Could not retrieve network capabilities from provided network: " + exc.getMessage());
  }

  return networkCapabilities;
}
Images.java 文件源码 项目:https-github.com-hyb1996-NoRootScriptDroid 阅读 41 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean captureScreen(String path) {
    mScriptRuntime.requiresApi(21);
    Image image = mScreenCapturer.capture();
    if (image != null) {
        saveImage(image, path);
        image.close();
        return true;
    }
    return false;
}
AnteaService.java 文件源码 项目:antea 阅读 42 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onServiceConnected() {
    super.onServiceConnected();
    AccessibilityServiceInfo info = this.getServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED | AccessibilityEvent.TYPE_VIEW_LONG_CLICKED;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    this.setServiceInfo(info);

    clipboardManager.addPrimaryClipChangedListener(this);
}
WithUseString.java 文件源码 项目:Spyglass 阅读 37 收藏 0 点赞 0 评论 0
@RequiresApi(21)
@TargetApi(21)
public WithUseString(
        final Context context,
        final AttributeSet attrs,
        final int defStyleAttr,
        final int defStyleRes) {

    super(context, attrs, defStyleAttr, defStyleRes);
    init(attrs, defStyleAttr, defStyleRes);
}
AppNotificationChannels.java 文件源码 项目:Phoenix-for-VK 阅读 36 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getGroupInvitesChannel(Context context){
    String channelName = context.getString(R.string.group_invites_channel);
    NotificationChannel channel = new NotificationChannel(GROUP_INVITES_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
    channel.enableLights(true);
    channel.enableVibration(true);
    return channel;
}
WithDefaultToMmDimensionResource.java 文件源码 项目:Spyglass 阅读 61 收藏 0 点赞 0 评论 0
@TargetApi(21)
@RequiresApi(21)
public WithDefaultToMmDimensionResource(
        final Context context,
        final AttributeSet attrs,
        final int defStyleAttr,
        final int defStyleRes) {

    super(context, attrs, defStyleAttr, defStyleRes);
    init(attrs, defStyleAttr, defStyleRes);
}
SystemLocaleRetriever.java 文件源码 项目:LocaleChanger 阅读 51 收藏 0 点赞 0 评论 0
@RequiresApi(api = Build.VERSION_CODES.N)
private static List<Locale> mapToListOfLocales(LocaleList localeList) {
    List<Locale> locales = new ArrayList<>();
    for (int i = 0; i < localeList.size(); i++) {
        locales.add(localeList.get(i));
    }
    return locales;
}


问题


面经


文章

微信
公众号

扫码关注公众号