use of android.support.annotation.RequiresApi in project PainlessMusicPlayer by Doctoror.
the class PlaybackNotificationFactoryImpl method createChannel.
@RequiresApi(Build.VERSION_CODES.O)
private static NotificationChannel createChannel(@NonNull final Context context) {
final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.Now_Playing), NotificationManager.IMPORTANCE_DEFAULT);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
channel.setShowBadge(true);
channel.enableVibration(false);
channel.setSound(null, null);
return channel;
}
use of android.support.annotation.RequiresApi in project UniPool by divya21raj.
the class SentRequestsTEA method onBindViewHolder.
// Replace the contents of a view (invoked by the layout manager)
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onBindViewHolder(MyHolder holder, int position) {
TripEntry tripEntry = list.get(position);
UtilityMethods.fillTripEntryHolder(holder, tripEntry);
holder.cardArrow.setOnClickListener(v -> {
if (holder.tripEntryExpand.isExpanded()) {
holder.tripEntryExpand.collapse();
holder.cardArrow.setImageResource(R.drawable.ic_arrow_left_24px);
} else {
holder.tripEntryExpand.expand();
holder.cardArrow.setImageResource(R.drawable.ic_arrow_drop_down_circle_24px);
}
});
holder.requestButton.setVisibility(View.INVISIBLE);
}
use of android.support.annotation.RequiresApi in project yoo_home_Android by culturer.
the class LoginActivity method initEvent.
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void initEvent() {
mEtMobile.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (!TextUtils.isEmpty(s) && mIvCleanPhone.getVisibility() == View.GONE) {
mIvCleanPhone.setVisibility(View.VISIBLE);
} else if (TextUtils.isEmpty(s)) {
mIvCleanPhone.setVisibility(View.GONE);
}
}
});
mEtPassword.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (!TextUtils.isEmpty(s) && mCleanPassword.getVisibility() == View.GONE) {
mCleanPassword.setVisibility(View.VISIBLE);
} else if (TextUtils.isEmpty(s)) {
mCleanPassword.setVisibility(View.GONE);
}
if (s.toString().isEmpty())
return;
if (!s.toString().matches("[A-Za-z0-9]+")) {
String temp = s.toString();
Toast.makeText(LoginActivity.this, "请输入数字或字母", Toast.LENGTH_SHORT).show();
s.delete(temp.length() - 1, temp.length());
mEtPassword.setSelection(s.length());
}
}
});
/**
* 禁止键盘弹起的时候可以滚动
*/
mScrollView.setOnTouchListener((v, event) -> true);
mScrollView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
/* old是改变前的左上右下坐标点值,没有old的是改变后的左上右下坐标点值
现在认为只要控件将Activity向上推的高度超过了1/3屏幕高,就认为软键盘弹起*/
if (oldBottom != 0 && bottom != 0 && (oldBottom - bottom > keyHeight)) {
Log.e("wenzhihao", "up------>" + (oldBottom - bottom));
int dist = mContent.getBottom() - bottom;
if (dist > 0) {
ObjectAnimator mAnimatorTranslateY = ObjectAnimator.ofFloat(mContent, "translationY", 0.0f, -dist);
mAnimatorTranslateY.setDuration(300);
mAnimatorTranslateY.setInterpolator(new LinearInterpolator());
mAnimatorTranslateY.start();
RxAnimationTool.zoomIn(mLogo, 0.6f, dist);
}
mService.setVisibility(View.INVISIBLE);
} else if (oldBottom != 0 && bottom != 0 && (bottom - oldBottom > keyHeight)) {
Log.e("wenzhihao", "down------>" + (bottom - oldBottom));
if ((mContent.getBottom() - oldBottom) > 0) {
ObjectAnimator mAnimatorTranslateY = ObjectAnimator.ofFloat(mContent, "translationY", mContent.getTranslationY(), 0);
mAnimatorTranslateY.setDuration(300);
mAnimatorTranslateY.setInterpolator(new LinearInterpolator());
mAnimatorTranslateY.start();
// 键盘收回后,logo恢复原来大小,位置同样回到初始位置
RxAnimationTool.zoomOut(mLogo, 0.6f);
}
mService.setVisibility(View.VISIBLE);
}
});
mBtnLogin.setOnClickListener(v -> {
RxKeyboardTool.hideSoftInput(LoginActivity.this);
tel = mEtMobile.getText().toString();
password = MD5Util.encrypt(mEtPassword.getText().toString().trim());
presenter.login(tel, password);
});
}
use of android.support.annotation.RequiresApi in project xDrip-plus by jamorham.
the class BackgroundScanReceiver method onReceive.
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
android.util.Log.d("BackgroundScanReceiver", "GOT SCAN INTENT!! " + action);
if (action != null && action.equals(ACTION_NAME)) {
String caller = intent.getStringExtra(CALLING_CLASS);
if (caller == null)
caller = this.getClass().getSimpleName();
// TODO by class name?
final BackgroundScanner backgroundScanner = RxBleProvider.getSingleton().getBackgroundScanner();
try {
final List<ScanResult> scanResults = backgroundScanner.onScanResultReceived(intent);
final String matchedMac = scanResults.get(0).getBleDevice().getMacAddress();
final String matchedName = scanResults.get(0).getBleDevice().getName();
final boolean calledBack = processCallbacks(caller, matchedMac, matchedName, SCAN_FOUND_CALLBACK);
UserError.Log.d(caller, "Scan results received: " + matchedMac + " " + scanResults);
if (!calledBack) {
try {
// bit of an ugly fix to system wide persistent nature of background scans and lack of proper support for one hit over various android devices
backgroundScanner.stopBackgroundBleScan(// must match original
PendingIntent.getBroadcast(// must match original
xdrip.getAppContext(), // must match original
142, intent, PendingIntent.FLAG_UPDATE_CURRENT));
} catch (Exception e) {
//
}
}
} catch (NullPointerException | BleScanException exception) {
UserError.Log.e(caller, "Failed to scan devices" + exception);
}
}
// ignore invalid actions
}
use of android.support.annotation.RequiresApi in project muzei by romannurik.
the class GalleryArtSource method addAllImagesFromTree.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private int addAllImagesFromTree(final List<Uri> allImages, final Uri treeUri, final String parentDocumentId) {
final Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(treeUri, parentDocumentId);
Cursor children = getContentResolver().query(childrenUri, new String[] { DocumentsContract.Document.COLUMN_DOCUMENT_ID, DocumentsContract.Document.COLUMN_MIME_TYPE }, null, null, null);
if (children == null) {
return 0;
}
int numImagesAdded = 0;
while (children.moveToNext()) {
String documentId = children.getString(children.getColumnIndex(DocumentsContract.Document.COLUMN_DOCUMENT_ID));
String mimeType = children.getString(children.getColumnIndex(DocumentsContract.Document.COLUMN_MIME_TYPE));
if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) {
// Recursively explore all directories
numImagesAdded += addAllImagesFromTree(allImages, treeUri, documentId);
} else if (mimeType != null && mimeType.startsWith("image/")) {
// Add images to the list
if (allImages != null) {
allImages.add(DocumentsContract.buildDocumentUriUsingTree(treeUri, documentId));
}
numImagesAdded++;
}
}
children.close();
return numImagesAdded;
}
Aggregations