类io.reactivex.annotations.Nullable源码实例Demo

下面列出了怎么用io.reactivex.annotations.Nullable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: V2EX   文件: DialogUtil.java
public static AlertDialog getProgress(Context context,
                                      String title,
                                      @Nullable DialogListener<Boolean> dialogListener){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, getTheme(context));
    builder.setTitle(title);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, 80);
    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setLayoutParams(layoutParams);
    frameLayout.setPadding(0,50, 0, 50);
    ProgressBar progressBar = new ProgressBar(context);
    progressBar.setLayoutParams(layoutParams);
    frameLayout.addView(progressBar);
    builder.setView(frameLayout);
    builder.setCancelable(false);
    if (dialogListener != null) builder.setNegativeButton("取 消", (dialog, which) -> {
        dialogListener.onResult(false);
        dialog.dismiss();
    });
    return builder.create();
}
 
源代码2 项目: RxJava2Debug   文件: StackTraceUtils.java
/**
 * Extract StackTrace and filter to show an app-specific entry at its top
 *
 * @param exception RxJavaAssemblyException to be parsed
 * @return StackTrace, filtered so a app-specific line is at the top of it
 */
@NonNull
static StackTraceElement[] parseStackTrace(@NonNull RxJavaAssemblyException exception, @Nullable String[] basePackages) {
    String[] lines = exception.stacktrace()
            .split(NEW_LINE_REGEX);

    List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>();
    boolean filterIn = false;
    for (String line : lines) {
        filterIn = filterIn
                || basePackages == null
                || basePackages.length == 0
                || startsWithAny(line, basePackages);
        if (filterIn) {
            StackTraceElement element = parseStackTraceLine(line);
            if (element != null) {
                stackTrace.add(element);
            }
        }
    }

    return stackTrace.toArray(new StackTraceElement[0]);
}
 
源代码3 项目: AndroidGodEye   文件: ViewBgUtil.java
@Nullable
private static Bitmap drawableToBitmap(Drawable drawable) {
    try {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        // We ask for the bounds if they have been set as they would be most
        // correct, then we check we are  > 0
        final int width = !drawable.getBounds().isEmpty() ?
                drawable.getBounds().width() : drawable.getIntrinsicWidth();

        final int height = !drawable.getBounds().isEmpty() ?
                drawable.getBounds().height() : drawable.getIntrinsicHeight();

        // Now we check we are > 0
        final Bitmap bitmap = Bitmap.createBitmap(width, height,
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, width, height);
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        return null;
    }
}
 
源代码4 项目: onetwo   文件: FormHttpMessageConverter.java
@Override
public boolean canRead(Class<?> clazz, @Nullable MediaType mediaType) {
	if (!MultiValueMap.class.isAssignableFrom(clazz)) {
		return false;
	}
	if (mediaType == null) {
		return true;
	}
	for (MediaType supportedMediaType : getSupportedMediaTypes()) {
		// We can't read multipart....
		if (!supportedMediaType.equals(MediaType.MULTIPART_FORM_DATA) && supportedMediaType.includes(mediaType)) {
			return true;
		}
	}
	return false;
}
 
源代码5 项目: onetwo   文件: FormHttpMessageConverter.java
private void writeForm(MultiValueMap<String, String> formData, @Nullable MediaType contentType,
		HttpOutputMessage outputMessage) throws IOException {

	contentType = getMediaType(contentType);
	outputMessage.getHeaders().setContentType(contentType);

	Charset charset = contentType.getCharset();
	Assert.notNull(charset, "No charset"); // should never occur

	final byte[] bytes = serializeForm(formData, charset).getBytes(charset);
	outputMessage.getHeaders().setContentLength(bytes.length);

	if (outputMessage instanceof StreamingHttpOutputMessage) {
		StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) outputMessage;
		streamingOutputMessage.setBody(outputStream -> StreamUtils.copy(bytes, outputStream));
	}
	else {
		StreamUtils.copy(bytes, outputMessage.getBody());
	}
}
 
源代码6 项目: a   文件: DownloadBookBean.java
@Override
public boolean equals(@Nullable Object obj) {
    if (obj instanceof DownloadBookBean) {
        return TextUtils.equals(((DownloadBookBean) obj).getNoteUrl(), this.noteUrl);
    }
    return super.equals(obj);
}
 
源代码7 项目: MyBookshelf   文件: DownloadBookBean.java
@Override
public boolean equals(@Nullable Object obj) {
    if (obj instanceof DownloadBookBean) {
        return TextUtils.equals(((DownloadBookBean) obj).getNoteUrl(), this.noteUrl);
    }
    return super.equals(obj);
}
 
源代码8 项目: MaoWanAndoidClient   文件: BaseObserver.java
@Override
public void onNext(@Nullable ResponseBody<T> t) {
    if(t.getErrorCode()!=0){
       onFailure(new Exception(t.getErrorMsg()), t.getErrorMsg());
    }else {
       onSuccess(t.getData());
    }
}
 
源代码9 项目: HaoReader   文件: ObjectsCompat.java
public static boolean isNull(@Nullable Object object) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Objects.isNull(object);
    } else {
        return object == null;
    }
}
 
源代码10 项目: HaoReader   文件: ObjectsCompat.java
public static boolean nonNull(@Nullable Object object) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Objects.nonNull(object);
    } else {
        return object != null;
    }
}
 
源代码11 项目: HaoReader   文件: ObjectsCompat.java
public static boolean equals(@Nullable Object a, @Nullable Object b) {
    if (Build.VERSION.SDK_INT >= 19) {
        return Objects.equals(a, b);
    } else {
        return (a == b) || (a != null && a.equals(b));
    }
}
 
源代码12 项目: HaoReader   文件: ObjectsCompat.java
public static int hash(@Nullable Object... values) {
    if (Build.VERSION.SDK_INT >= 19) {
        return Objects.hash(values);
    } else {
        return Arrays.hashCode(values);
    }
}
 
源代码13 项目: HaoReader   文件: DownloadBookBean.java
@Override
public boolean equals(@Nullable Object obj) {
    if (obj instanceof DownloadBookBean) {
        return TextUtils.equals(((DownloadBookBean) obj).getNoteUrl(), this.noteUrl);
    }
    return super.equals(obj);
}
 
源代码14 项目: RxJava2Debug   文件: StackTraceUtils.java
/**
 * Parse string containing a <i>single line</i> of a StackTrace
 *
 * @param stackTraceLine string containing single line of a StackTrace
 * @return parsed StackTraceElement
 */
@Nullable
private static StackTraceElement parseStackTraceLine(@NonNull String stackTraceLine) {
    StackTraceElement retVal = null;

    Matcher matcher = STACK_TRACE_ELEMENT_PATTERN.matcher(stackTraceLine);
    if (matcher.matches()) {
        String clazz = matcher.group(1);
        String method = matcher.group(2);
        String filename = matcher.group(3);
        int line = Integer.valueOf(matcher.group(4));
        retVal = new StackTraceElement(clazz, method, filename, line);
    }
    return retVal;
}
 
源代码15 项目: Alarmio   文件: SoundData.java
/**
 * Construct a new instance of SoundData from an identifier string which was
 * (hopefully) created by [toString](#tostring).
 *
 * @param string            A non-null identifier string.
 * @return                  A recreated SoundData instance.
 */
@Nullable
public static SoundData fromString(String string) {
    if (string.contains(SEPARATOR)) {
        String[] data = string.split(SEPARATOR);
        if (data.length == 3
                && data[0].length() > 0 && data[1].length() > 0 && data[2].length() > 0)
            return new SoundData(data[0], data[1], data[2]);
    }

    return null;
}
 
源代码16 项目: RxCommand   文件: RxCommand.java
/**
 * If the receiver is enabled, this method will:
 * <p>
 * 1. Invoke the `func` given at the time of creation.
 * 2. Multicast the returned observable.
 * 3. Send the multicasted observable on {@link #executionObservables()}.
 * 4. Subscribe (connect) to the original observable on the main thread.
 *
 * @param input The input value to pass to the receiver's `func`. This may be null.
 * @return the multicasted observable, after subscription. If the receiver is not
 * enabled, returns a observable that will send an error.
 */
@MainThread
public final Observable<T> execute(@Nullable Object input) {
    boolean enabled = mImmediateEnabled.blockingFirst();
    if (!enabled) {
        return Observable.error(new IllegalStateException("The command is disabled and cannot be executed"));
    }
    try {
        Observable<T> observable = mFunc.apply(input);
        if (observable == null) {
            throw new RuntimeException(String.format("null Observable returned from observable func for value %s", input));
        }

        // This means that `executing` and `enabled` will send updated values before
        // the observable actually starts performing work.
        final ConnectableObservable<T> connection = observable
                .subscribeOn(AndroidSchedulers.mainThread())
                .replay();

        mAddedExecutionObservableSubject.onNext(connection);
        connection.connect();
        return connection;
    } catch (Exception e) {
        e.printStackTrace();
        return Observable.error(e);
    }
}
 
源代码17 项目: RxPermission   文件: MockRxPermission.java
@Nullable Permission get(@NonNull final String name) {
  for (final Permission permission : permissions) {
    if (permission.name().equals(name)) {
      return permission;
    }
  }

  return null;
}
 
源代码18 项目: rxfirebase   文件: RxValue.java
/**
 * @param emitter
 * @param function
 * @return
 */
@NonNull
@CheckReturnValue
public static Transaction.Handler transaction(
        @NonNull final SingleEmitter<DataSnapshot> emitter,
        @NonNull final Function<MutableData, Transaction.Result> function) {
    return new Transaction.Handler() {
        @Override
        public Transaction.Result doTransaction(MutableData mutableData) {
            try {
                return function.apply(mutableData);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void onComplete(@Nullable DatabaseError databaseError,
                               boolean committed,
                               @NonNull DataSnapshot dataSnapshot) {
            if (!emitter.isDisposed()) {
                if (null == databaseError) {
                    emitter.onSuccess(dataSnapshot);
                } else {
                    emitter.onError(databaseError.toException());
                }
            }
        }
    };
}
 
源代码19 项目: rxfirebase   文件: RxDatabaseReference.java
/**
 * @param emitter
 * @param function
 * @return
 */
@NonNull
@CheckReturnValue
public static Transaction.Handler transaction(
        @NonNull final SingleEmitter<DataSnapshot> emitter,
        @NonNull final Function<MutableData, Transaction.Result> function) {
    return new Transaction.Handler() {
        @Override
        public Transaction.Result doTransaction(MutableData mutableData) {
            try {
                return function.apply(mutableData);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void onComplete(@Nullable DatabaseError databaseError,
                               boolean committed,
                               @NonNull DataSnapshot dataSnapshot) {
            if (!emitter.isDisposed()) {
                if (null == databaseError) {
                    emitter.onSuccess(dataSnapshot);
                } else {
                    emitter.onError(databaseError.toException());
                }
            }
        }
    };
}
 
源代码20 项目: rxfirebase   文件: RxFirebaseStorage.java
/**
 * @see StorageReference#putFile(Uri, StorageMetadata, Uri)
 */
@CheckReturnValue
@NonNull
public static Single<UploadTask.TaskSnapshot> putFile(
        @NonNull final StorageReference ref,
        @NonNull final Uri uri,
        @Nullable final StorageMetadata storageMetadata,
        @Nullable final Uri existingUploadUri) {
    return RxTask.single(new Callable<Task<UploadTask.TaskSnapshot>>() {
        @Override
        public Task<UploadTask.TaskSnapshot> call() throws Exception {
            return ref.putFile(uri, storageMetadata, existingUploadUri);
        }
    });
}
 
源代码21 项目: onetwo   文件: FormHttpMessageConverter.java
@Override
public boolean canWrite(Class<?> clazz, @Nullable MediaType mediaType) {
	if (!MultiValueMap.class.isAssignableFrom(clazz)) {
		return false;
	}
	if (mediaType == null || MediaType.ALL.equals(mediaType)) {
		return true;
	}
	for (MediaType supportedMediaType : getSupportedMediaTypes()) {
		if (supportedMediaType.isCompatibleWith(mediaType)) {
			return true;
		}
	}
	return false;
}
 
源代码22 项目: onetwo   文件: FormHttpMessageConverter.java
@Override
@SuppressWarnings("unchecked")
public void write(MultiValueMap<String, ?> map, @Nullable MediaType contentType, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	if (!isMultipart(map, contentType)) {
		writeForm((MultiValueMap<String, String>) map, contentType, outputMessage);
	}
	else {
		writeMultipart((MultiValueMap<String, Object>) map, outputMessage);
	}
}
 
源代码23 项目: onetwo   文件: FormHttpMessageConverter.java
private boolean isMultipart(MultiValueMap<String, ?> map, @Nullable MediaType contentType) {
	if (contentType != null) {
		return MediaType.MULTIPART_FORM_DATA.includes(contentType);
	}
	for (String name : map.keySet()) {
		for (Object value : map.get(name)) {
			if (value != null && !(value instanceof String)) {
				return true;
			}
		}
	}
	return false;
}
 
源代码24 项目: onetwo   文件: FormHttpMessageConverter.java
private MediaType getMediaType(@Nullable MediaType mediaType) {
	if (mediaType == null) {
		return DEFAULT_FORM_DATA_MEDIA_TYPE;
	}
	else if (mediaType.getCharset() == null) {
		return new MediaType(mediaType, this.charset);
	}
	else {
		return mediaType;
	}
}
 
源代码25 项目: onetwo   文件: FormHttpMessageConverter.java
/**
 * Return the filename of the given multipart part. This value will be used for the
 * {@code Content-Disposition} header.
 * <p>The default implementation returns {@link Resource#getFilename()} if the part is a
 * {@code Resource}, and {@code null} in other cases. Can be overridden in subclasses.
 * @param part the part to determine the file name for
 * @return the filename, or {@code null} if not known
 */
@Nullable
protected String getFilename(Object part) {
	if (part instanceof Resource) {
		Resource resource = (Resource) part;
		String filename = resource.getFilename();
		if (filename != null && this.multipartCharset != null) {
			filename = MimeDelegate.encode(filename, this.multipartCharset.name());
		}
		return filename;
	}
	else {
		return null;
	}
}
 
源代码26 项目: RxDownloader   文件: RxDownloader.java
private DownloadManager.Request createRequest(@NonNull String url,
                                              @NonNull String filename,
                                              @Nullable String destinationPath,
                                              @NonNull String mimeType,
                                              boolean inPublicDir,
                                              boolean showCompletedNotification) {

    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    request.setDescription(filename);
    request.setMimeType(mimeType);

    if (destinationPath == null) {
        destinationPath = Environment.DIRECTORY_DOWNLOADS;
    }

    File destinationFolder = inPublicDir
            ? Environment.getExternalStoragePublicDirectory(destinationPath)
            : new File(context.getFilesDir(), destinationPath);

    createFolderIfNeeded(destinationFolder);
    removeDuplicateFileIfExist(destinationFolder, filename);

    if (inPublicDir) {
        request.setDestinationInExternalPublicDir(destinationPath, filename);
    } else {
        request.setDestinationInExternalFilesDir(context, destinationPath, filename);
    }

    request.setNotificationVisibility(showCompletedNotification
            ? DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED
            : DownloadManager.Request.VISIBILITY_VISIBLE);

    return request;
}
 
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    setTitle(R.string.filter_keywords);
    setHasOptionsMenu(false);
    mFilterKeywordsManager = FilterKeywordsManagerImpl.getInstance();
    super.onCreate(savedInstanceState);
}
 
源代码28 项目: Hands-Chopping   文件: BaseConverterFactory.java
@Nullable
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
    return responseConverter();
}
 
源代码29 项目: Hands-Chopping   文件: BaseConverterFactory.java
@Nullable
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
    return super.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit);
}
 
源代码30 项目: HaoReader   文件: ObjectsCompat.java
public static int hashCode(@Nullable Object o) {
    return o != null ? o.hashCode() : 0;
}
 
 类所在包
 类方法
 同包方法