Java Code Examples for android.support.annotation.RequiresApi

The following are top voted examples for showing how to use android.support.annotation.RequiresApi. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RelativeRadioGroup   File: RelativeRadioGroup.java   View source code 8 votes vote down vote up
/**
 * {@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);
    }
}
 
Example 2
Project: FilterLibrary   File: PhotoFilter.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: Cable-Android   File: AttachmentRegionDecoder.java   View source code 6 votes vote down vote up
@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());
}
 
Example 4
Project: VBrowser-Android   File: DownloadForegroundService.java   View source code 6 votes vote down vote up
@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;
}
 
Example 5
Project: ImHome   File: AlarmUtils.java   View source code 6 votes vote down vote up
@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()));
}
 
Example 6
Project: Lunary-Ethereum-Wallet   File: AppLockActivity.java   View source code 6 votes vote down vote up
@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();
    }
}
 
Example 7
Project: CollegeDoc   File: PdfView.java   View source code 6 votes vote down vote up
@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();
    }
}
 
Example 8
Project: silly-android   File: Coloring.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 9
Project: betterHotels   File: TripListActivity.java   View source code 6 votes vote down vote up
@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);
        }
    });
}
 
Example 10
Project: AutoInputAuthCode   File: AuthCode.java   View source code 6 votes vote down vote up
@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();
}
 
Example 11
Project: Cable-Android   File: AttachmentRegionDecoder.java   View source code 6 votes vote down vote up
@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;
  }
}
 
Example 12
Project: FilterLibrary   File: PhotoFilter.java   View source code 6 votes vote down vote up
@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;
}
 
Example 13
Project: FilterLibrary   File: PhotoFilter.java   View source code 6 votes vote down vote up
@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;
}
 
Example 14
Project: betterHotels   File: GalleryActivity.java   View source code 6 votes vote down vote up
@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();
        }
    });
}
 
Example 15
Project: Amazing   File: ScreenRecordActivity.java   View source code 6 votes vote down vote up
@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();
}
 
Example 16
Project: GitHub   File: ImageFormatKeyframesFragment.java   View source code 6 votes vote down vote up
@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);
    }
  });
}
 
Example 17
Project: LikeWechatPhotoViewer   File: MainActivity.java   View source code 6 votes vote down vote up
@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;
}
 
Example 18
Project: Floo   File: ContainerActivity.java   View source code 5 votes vote down vote up
@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();
}
 
Example 19
Project: neatle   File: Device.java   View source code 5 votes vote down vote up
@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);
}
 
Example 20
Project: Spyglass   File: WithDefaultToInDimension.java   View source code 5 votes vote down vote up
@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);
}
 
Example 21
Project: rtmp-rtsp-stream-client-java   File: VideoEncoder.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 22
Project: Spyglass   File: WithDefaultToInteger.java   View source code 5 votes vote down vote up
@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);
}
 
Example 23
Project: Spyglass   File: WithDefaultToNull.java   View source code 5 votes vote down vote up
@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);
}
 
Example 24
Project: RxNetwork   File: RxNetworkInfo.java   View source code 5 votes vote down vote up
@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;
}
 
Example 25
Project: https-github.com-hyb1996-NoRootScriptDroid   File: Images.java   View source code 5 votes vote down vote up
@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;
}
 
Example 26
Project: antea   File: AnteaService.java   View source code 5 votes vote down vote up
@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);
}
 
Example 27
Project: Spyglass   File: WithUseString.java   View source code 5 votes vote down vote up
@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);
}
 
Example 28
Project: Phoenix-for-VK   File: AppNotificationChannels.java   View source code 5 votes vote down vote up
@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;
}
 
Example 29
Project: Spyglass   File: WithDefaultToMmDimensionResource.java   View source code 5 votes vote down vote up
@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);
}
 
Example 30
Project: LocaleChanger   File: SystemLocaleRetriever.java   View source code 5 votes vote down vote up
@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;
}
 
Example 31
Project: Auto.js   File: AutoJs.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void request() {
    Activity activity = mAppUtils.getCurrentActivity();
    if (activity instanceof OnActivityResultDelegate.DelegateHost) {
        ScreenCaptureRequester requester = new ActivityScreenCaptureRequester(
                ((OnActivityResultDelegate.DelegateHost) activity).getOnActivityResultDelegateMediator(), activity);
        requester.setOnActivityResultCallback(mCallback);
        requester.request();
    } else {
        ScreenCaptureRequestActivity.request(mContext, mCallback);
    }
}
 
Example 32
Project: TubiPlayer   File: WebviewActivity.java   View source code 5 votes vote down vote up
@RequiresApi(Build.VERSION_CODES.KITKAT)
private void initVpaidWebview(WebView view, Handler handler) {
    tubiVPAID = new TubiVPAID(view, handler,null);

    tubiVPAID.init(null);

    webView.setVisibility(View.VISIBLE);
    webView.bringToFront();
    webView.invalidate();

    webView.addJavascriptInterface(tubiVPAID, "TubiNativeJSInterface");
    webView.loadUrl(VPAID_URL);

}
 
Example 33
Project: Camera-Roll-Android-App   File: AlbumActivity.java   View source code 5 votes vote down vote up
@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
    if (sharedElementReturnPosition != -1 && album != null &&
            sharedElementReturnPosition < album.getAlbumItems().size()) {
        String newTransitionName = album.getAlbumItems().get(sharedElementReturnPosition).getPath();
        View layout = recyclerView.findViewWithTag(newTransitionName);
        View newSharedElement = layout != null ? layout.findViewById(R.id.image) : null;
        if (newSharedElement != null) {
            names.clear();
            names.add(newTransitionName);
            sharedElements.clear();
            sharedElements.put(newTransitionName, newSharedElement);
        }
        sharedElementReturnPosition = -1;
    } else {
        View navigationBar = findViewById(android.R.id.navigationBarBackground);
        View statusBar = findViewById(android.R.id.statusBarBackground);
        if (navigationBar != null) {
            names.add(navigationBar.getTransitionName());
            sharedElements.put(navigationBar.getTransitionName(), navigationBar);
        }
        if (statusBar != null) {
            names.add(statusBar.getTransitionName());
            sharedElements.put(statusBar.getTransitionName(), statusBar);
        }
    }
}
 
Example 34
Project: Bigbang   File: TotleSwitchTile.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onClick() {
    Log.d(LOG_TAG, "onClick state = " + Integer.toString(getQsTile().getState()));
    Icon icon;
    String title;
    if (toggleState == STATE_ON) {
        toggleState = STATE_OFF;
        title = getResources().getString(R.string.notify_total_switch_off);
        icon =  Icon.createWithResource(getApplicationContext(), R.drawable.notify_off);
        getQsTile().setState(Tile.STATE_INACTIVE);// 更改成非活跃状态
    } else {
        toggleState = STATE_ON;
        title = getResources().getString(R.string.notify_total_switch_on);
        icon = Icon.createWithResource(getApplicationContext(), R.drawable.notify_on);
        getQsTile().setState(Tile.STATE_ACTIVE);//更改成活跃状态
    }
    getQsTile().setIcon(icon);//设置图标
    getQsTile().setLabel(title);
    getQsTile().updateTile();//更新Tile

    Intent intent = new Intent();
    intent.setClass(this, TotalSwitchActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityAndCollapse(intent);

}
 
Example 35
Project: MySelfDemo   File: MyView2.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void drawRoundRect(Canvas canvas) {
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.BLACK);
    paint.setAntiAlias(true);
    canvas.drawRoundRect(100, 100, 500, 300, 150, 50, paint); //参数的意思是: left top right bottom 的坐标   rx 是圆角的横向的左标  ry是圆角的纵向坐标
}
 
Example 36
Project: Spyglass   File: WithDefaultToFractionUsingParentFractionAndBaseMultiplier.java   View source code 5 votes vote down vote up
@TargetApi(21)
@RequiresApi(21)
public WithDefaultToFractionUsingParentFractionAndBaseMultiplier(
		final Context context,
		final AttributeSet attrs,
		final int defStyleAttr,
		final int defStyleRes) {

	super(context, attrs, defStyleAttr, defStyleRes);
	init(attrs, defStyleAttr, defStyleRes);
}
 
Example 37
Project: GitHub   File: StatusBarUtil.java   View source code 5 votes vote down vote up
/** android 6.0设置字体颜色 */
    @RequiresApi(Build.VERSION_CODES.M)
    private static void darkModeForM(Window window, boolean dark) {
//        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//        window.setStatusBarColor(Color.TRANSPARENT);

        int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
        if (dark) {
            systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        window.getDecorView().setSystemUiVisibility(systemUiVisibility);
    }
 
Example 38
Project: GitHub   File: CustomPopWindow.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public CustomPopWindow showAsDropDown(View anchor, int xOff, int yOff, int gravity){
    if(mPopupWindow!=null){
        mPopupWindow.showAsDropDown(anchor,xOff,yOff,gravity);
    }
    return this;
}
 
Example 39
Project: PrivacyStreams   File: AccessibilityUtils.java   View source code 5 votes vote down vote up
/**
 *
 * @param root
 * @param appName
 * @return
 */

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getBrowserCurrentUrl(AccessibilityNodeInfo root, String appName){
    try{
        AccessibilityNodeInfo bar = root.findAccessibilityNodeInfosByViewId(getUrlResourceId(appName)).get(0);
        if(bar!=null){
            return bar.getText().toString();
        }
    }
    catch (Exception exception){
        return null;
    }
    return null;
}
 
Example 40
Project: GroupingMessages   File: MainActivity.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.M)
private boolean addPermission(List<String> permissionsList, String permission) {
    if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
        permissionsList.add(permission);
        // Check for Rationale Option
        if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permission))
            return false;
    }
    return true;
}