本文整理汇总了Java中android.annotation.SuppressLint类的典型用法代码示例。如果您正苦于以下问题:Java SuppressLint类的具体用法?Java SuppressLint怎么用?Java SuppressLint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuppressLint类属于android.annotation包,在下文中一共展示了SuppressLint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import android.annotation.SuppressLint; //导入依赖的package包/类
@Override
public Date deserialize(JsonElement element, Type type, JsonDeserializationContext context)
throws JsonParseException {
String date = element.getAsString();
@SuppressLint("SimpleDateFormat")
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
return formatter.parse(date);
} catch (ParseException e) {
Log.e(TAG, "Date parsing failed");
Log.exception(e);
return new Date();
}
}
示例2: convertActivityToTranslucent
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint({"NewApi"})
public void convertActivityToTranslucent() {
try {
Class<?> translucentConversionListenerClazz = null;
for (Class<?> clazz : Activity.class.getDeclaredClasses()) {
if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
translucentConversionListenerClazz = clazz;
}
}
Method method;
if (VERSION.SDK_INT > 19) {
method = Activity.class.getDeclaredMethod("convertToTranslucent", new
Class[]{translucentConversionListenerClazz, ActivityOptions.class});
method.setAccessible(true);
method.invoke(this.mActivity, new Object[]{null, null});
return;
}
method = Activity.class.getDeclaredMethod("convertToTranslucent", new
Class[]{translucentConversionListenerClazz});
method.setAccessible(true);
method.invoke(this.mActivity, new Object[]{null});
} catch (Throwable th) {
}
}
示例3: onRename
import android.annotation.SuppressLint; //导入依赖的package包/类
@Override
public void onRename(Device device) {
@SuppressLint("InflateParams")
EditText edit = (EditText) LayoutInflater.from(this).inflate(R.layout.layout_edit_name, null);
new AlertDialog.Builder(this)
.setTitle(R.string.change_name)
.setView(edit)
.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss())
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
if (edit.getText().toString().trim().length() > 0) {
device.setName(edit.getText().toString().trim());
updateDeviceSubject.onNext(device);
}
dialog.dismiss();
})
.show();
}
示例4: testGetInvalidJobId
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint("ApplySharedPref")
@Test
public void testGetInvalidJobId() throws Exception {
final Job test = createTestJob();
final String json = gson.toJson(test);
final String key = SimpleUploadDataStore.jobIdKey(test.id());
final Set<String> keys = new HashSet<>();
keys.add(key);
final SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putStringSet(SimpleUploadDataStore.KEY_JOB_IDS, keys);
editor.putString(key, json);
editor.commit();
final TestSubscriber<Job> ts = TestSubscriber.create();
dataStore.get("bad_id").subscribe(ts);
ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts.assertNoErrors();
ts.assertValueCount(1);
ts.assertValue(Job.INVALID_JOB);
}
示例5: onInitializeAccessibilityNodeInfo
import android.annotation.SuppressLint; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@SuppressLint("Override")
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(AbsHListView.class.getName());
if (isEnabled()) {
if (getFirstVisiblePosition() > 0) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
}
if (getLastVisiblePosition() < getCount() - 1) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
}
}
}
示例6: getView
import android.annotation.SuppressLint; //导入依赖的package包/类
/**
* Main mathod used to display view in list
*/
@SuppressLint("InflateParams")
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder viewHolder = null;
LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ContactBean tb = data.get(position);
if(convertView == null){
viewHolder = new ViewHolder();
convertView = inflate.inflate(R.layout.add_prefix_member_list_item, null);
viewHolder.txtName = (TextView)convertView.findViewById(R.id.txtContactName);
viewHolder.spCountry = (MaterialSpinner)convertView.findViewById(R.id.spCountry);
viewHolder.txtName.setTypeface(ManagerTypeface.getTypeface(context, R.string.typeface_roboto_regular));
convertView.setTag(viewHolder);
convertView.setTag(R.id.txtContactName, viewHolder.txtName);
}else{
viewHolder = (ViewHolder)convertView.getTag();
}
viewHolder.txtName.setTypeface(fontBauhus);
viewHolder.txtName.setText(tb.getName());
return convertView;
}
示例7: onStart
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint("MissingPermission")
@Override
public void onStart() {
Application application = (Application) getTargetContext().getApplicationContext();
String simpleName = UnlockDeviceAndroidJUnitRunner.class.getSimpleName();
// Unlock the device so that the tests can input keystrokes.
((KeyguardManager) application.getSystemService(KEYGUARD_SERVICE))
.newKeyguardLock(simpleName)
.disableKeyguard();
// Wake up the screen.
PowerManager powerManager = ((PowerManager) application.getSystemService(POWER_SERVICE));
mWakeLock = powerManager.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP |
ON_AFTER_RELEASE, simpleName);
mWakeLock.acquire();
super.onStart();
}
示例8: onTouchEvent
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
boolean hasSingleTap = mSingleTapConfirmedHandler.hasMessages(MSG_CHECK_DOUBLE_TAP_TIMEOUT);
Log.w(TAG, "onTouchEvent hasSingleTap: " + hasSingleTap);
if (!hasSingleTap) {
mDownMillis = SystemClock.uptimeMillis();
} else {
Log.w(TAG, "onTouchEvent disallow onSpanClick mSingleTapConfirmedHandler because of DOUBLE TAP");
disallowOnSpanClickInterrupt();
}
break;
}
boolean ret = super.onTouchEvent(event);
if (mNeedForceEventToParent) {
return mTouchSpanHit;
}
return ret;
}
示例9: onBind
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint( "SetTextI18n" )
public void onBind( BeerProductItem item ){
setBeerImage( item.getImage() );
tvBeerName.setText( item.getName() );
tvBeerPercent.setText( item.getAlcohol() );
tvBeerVolume.setText( item.getVolume() );
tvBeerPrice.setText( StringUtils.getCommaPriceWithBaht( getContext(), item.getPrice() ) );
if( item.isAdded() ){
btnAdded.setVisibility( View.VISIBLE );
btnAddToCart.setVisibility( View.GONE );
}else{
btnAdded.setVisibility( View.GONE );
btnAddToCart.setVisibility( View.VISIBLE );
}
}
示例10: getSDCardAvailaleSize
import android.annotation.SuppressLint; //导入依赖的package包/类
/**
* 获取磁盘可用空间.
*/
@SuppressWarnings("deprecation")
@SuppressLint({"NewApi", "ObsoleteSdkInt"})
public static long getSDCardAvailaleSize() {
File path = getRootPath();
StatFs stat = new StatFs(path.getPath());
long blockSize, availableBlocks;
if (Build.VERSION.SDK_INT >= 18) {
blockSize = stat.getBlockSizeLong();
availableBlocks = stat.getAvailableBlocksLong();
} else {
blockSize = stat.getBlockSize();
availableBlocks = stat.getAvailableBlocks();
}
return availableBlocks * blockSize;
}
示例11: stopBackgroundThread
import android.annotation.SuppressLint; //导入依赖的package包/类
/**
* Stops the background thread and its {@link Handler}.
*/
@SuppressLint("LongLogTag")
@DebugLog
private void stopBackgroundThread() {
backgroundThread.quitSafely();
inferenceThread.quitSafely();
try {
backgroundThread.join();
backgroundThread = null;
backgroundHandler = null;
inferenceThread.join();
inferenceThread = null;
inferenceThread = null;
} catch (final InterruptedException e) {
Log.e(TAG, "error" ,e );
}
}
示例12: fileExt
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint("DefaultLocale")
private String fileExt(String url) {
if (url.indexOf("?") > -1) {
url = url.substring(0, url.indexOf("?"));
}
if (url.lastIndexOf(".") == -1) {
return null;
} else {
String ext = url.substring(url.lastIndexOf("."));
if (ext.indexOf("%") > -1) {
ext = ext.substring(0, ext.indexOf("%"));
}
if (ext.indexOf("/") > -1) {
ext = ext.substring(0, ext.indexOf("/"));
}
return ext.toLowerCase();
}
}
示例13: init
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint("NewApi")
private void init(Context context, AttributeSet attributeSet) {
mVisible = true;
mColorNormal = getColor(R.color.material_blue_500);
mColorPressed = darkenColor(mColorNormal);
mColorRipple = lightenColor(mColorNormal);
mColorDisabled = getColor(android.R.color.darker_gray);
mType = TYPE_NORMAL;
mShadow = true;
mScrollThreshold = getResources().getDimensionPixelOffset(R.dimen.fab_scroll_threshold);
mShadowSize = getDimension(R.dimen.fab_shadow_size);
if (hasLollipopApi()) {
StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(context,
R.animator.fab_press_elevation);
setStateListAnimator(stateListAnimator);
}
if (attributeSet != null) {
initAttributes(context, attributeSet);
}
updateBackground();
}
示例14: autoFocusAgainLater
import android.annotation.SuppressLint; //导入依赖的package包/类
@SuppressLint("NewApi")
private synchronized void autoFocusAgainLater() {
if (!stopped && outstandingTask == null) {
AutoFocusTask newTask = new AutoFocusTask();
try {
// Unnecessary, our app's min sdk is higher than 11.
// if (Build.VERSION.SDK_INT >= 11) {
// newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// } else {
//
// }
newTask.execute();
outstandingTask = newTask;
} catch (RejectedExecutionException ree) {
Log.w(TAG, "Could not request auto focus", ree);
}
}
}
示例15: injectDeferredObject
import android.annotation.SuppressLint; //导入依赖的package包/类
/**
* Inject an object (script or style) into the InAppBrowser AmazonWebView.
*
* This is a helper method for the inject{Script|Style}{Code|File} API calls, which
* provides a consistent method for injecting JavaScript code into the document.
*
* If a wrapper string is supplied, then the source string will be JSON-encoded (adding
* quotes) and wrapped using string formatting. (The wrapper string should have a single
* '%s' marker)
*
* @param source The source object (filename or script/style text) to inject into
* the document.
* @param jsWrapper A JavaScript string to wrap the source string in, so that the object
* is properly injected, or null if the source string is JavaScript text
* which should be executed directly.
*/
private void injectDeferredObject(String source, String jsWrapper) {
final String scriptToInject;
if (jsWrapper != null) {
org.json.JSONArray jsonEsc = new org.json.JSONArray();
jsonEsc.put(source);
String jsonRepr = jsonEsc.toString();
String jsonSourceString = jsonRepr.substring(1, jsonRepr.length()-1);
scriptToInject = String.format(jsWrapper, jsonSourceString);
} else {
scriptToInject = source;
}
final String finalScriptToInject = scriptToInject;
this.cordova.getActivity().runOnUiThread(new Runnable() {
@SuppressLint("NewApi")
@Override
public void run() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
// This action will have the side-effect of blurring the currently focused element
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
} /*else {
inAppWebView.evaluateJavascript(finalScriptToInject, null);
}*/
}
});
}