_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q155600
ApiErrorExtractor.getErrorMessage
train
public String getErrorMessage(IOException e) { // Prefer to use message from GJRE. GoogleJsonResponseException gjre = getJsonResponseExceptionOrNull(e); if (gjre != null && gjre.getDetails() != null) { return gjre.getDetails().getMessage(); } return e.getMessage(); }
java
{ "resource": "" }
q155601
ApiErrorExtractor.getErrorInfo
train
protected ErrorInfo getErrorInfo(IOException e) { GoogleJsonError gjre = getDetails(e); if (gjre != null) { return getErrorInfo(gjre); } return null; }
java
{ "resource": "" }
q155602
ApiErrorExtractor.getDetails
train
protected GoogleJsonError getDetails(IOException e) { if (e instanceof GoogleJsonResponseException) { return ((GoogleJsonResponseException) e).getDetails(); } return null; }
java
{ "resource": "" }
q155603
ApiErrorExtractor.getErrorInfo
train
protected ErrorInfo getErrorInfo(GoogleJsonError details) { if (details == null) { return null; } List<ErrorInfo> errors = details.getErrors(); return errors.isEmpty() ? null : errors.get(0); }
java
{ "resource": "" }
q155604
EntriesCredentialConfiguration.getConfigurationInto
train
public void getConfigurationInto(Entries configuration) { for (String prefix : prefixes) { configuration.setBoolean(prefix + ENABLE_SERVICE_ACCOUNTS_SUFFIX, isServiceAccountEnabled()); if (getServiceAccountEmail() != null) { configuration.set(prefix + SERVICE_ACCOUNT_EMAIL_SUFFIX, getServiceAcco...
java
{ "resource": "" }
q155605
EntriesCredentialConfiguration.setConfiguration
train
public void setConfiguration(Entries entries) { for (String prefix : prefixes) { Optional<Boolean> enableServiceAccounts = maybeGetBoolean(entries, prefix + ENABLE_SERVICE_ACCOUNTS_SUFFIX); if (enableServiceAccounts.isPresent()) { setEnableServiceAccounts(enableServiceAccounts.get());...
java
{ "resource": "" }
q155606
ObjectWriteConditions.apply
train
public void apply(Insert objectToInsert) { if (hasContentGenerationMatch()) { objectToInsert.setIfGenerationMatch(getContentGenerationMatch()); } if (hasMetaGenerationMatch()) { objectToInsert.setIfMetagenerationMatch(getMetaGenerationMatch()); } }
java
{ "resource": "" }
q155607
GoogleHadoopSyncableOutputStream.getNextTemporaryPath
train
private URI getNextTemporaryPath() { Path basePath = ghfs.getHadoopPath(finalGcsPath); Path baseDir = basePath.getParent(); Path tempPath = new Path( baseDir, String.format("%s%s.%d.%s", TEMPFILE_PREFIX, basePath.getName(), curComponentIndex, UUID.randomUUID().toString())); r...
java
{ "resource": "" }
q155608
DefaultHttpLogFormatter.prepare
train
@API(status = EXPERIMENTAL) public List<String> prepare(final Precorrelation precorrelation, final HttpRequest request) throws IOException { final String requestLine = String.format("%s %s %s", request.getMethod(), request.getRequestUri(), request.getProtocolVersion()); return prepar...
java
{ "resource": "" }
q155609
DefaultHttpLogFormatter.format
train
@API(status = EXPERIMENTAL) public String format(final List<String> lines) { return String.join("\n", lines); }
java
{ "resource": "" }
q155610
Strman.appendArray
train
public static String appendArray(final String value, final String[] appends) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (appends == null || appends.length == 0) { return value; } StringJoiner joiner = new StringJoiner(""); for (String appen...
java
{ "resource": "" }
q155611
Strman.between
train
public static String[] between(final String value, final String start, final String end) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(start, NULL_STRING_PREDICATE, () -> "'start' should be not null."); validate(end, NULL_STRING_PREDICATE, () -> "'end' should be no...
java
{ "resource": "" }
q155612
Strman.chars
train
public static String[] chars(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.split(""); }
java
{ "resource": "" }
q155613
Strman.collapseWhitespace
train
public static String collapseWhitespace(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.trim().replaceAll("\\s\\s+", " "); }
java
{ "resource": "" }
q155614
Strman.contains
train
public static boolean contains(final String value, final String needle, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (caseSensitive) { return value.contains(needle); } return value.toLowerCase().contains(needle.toLowerCas...
java
{ "resource": "" }
q155615
Strman.containsAll
train
public static boolean containsAll(final String value, final String[] needles) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return Arrays.stream(needles).allMatch(needle -> contains(value, needle, false)); }
java
{ "resource": "" }
q155616
Strman.containsAny
train
public static boolean containsAny(final String value, final String[] needles, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return Arrays.stream(needles).anyMatch(needle -> contains(value, needle, caseSensitive)); }
java
{ "resource": "" }
q155617
Strman.ensureLeft
train
public static String ensureLeft(final String value, final String prefix) { return ensureLeft(value, prefix, true); }
java
{ "resource": "" }
q155618
Strman.ensureLeft
train
public static String ensureLeft(final String value, final String prefix, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (caseSensitive) { return value.startsWith(prefix) ? value : prefix + value; } String _value = value.toL...
java
{ "resource": "" }
q155619
Strman.base64Decode
train
public static String base64Decode(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return new String(Base64.getDecoder().decode(value), StandardCharsets.UTF_8); }
java
{ "resource": "" }
q155620
Strman.base64Encode
train
public static String base64Encode(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8)); }
java
{ "resource": "" }
q155621
Strman.ensureRight
train
public static String ensureRight(final String value, final String suffix) { return ensureRight(value, suffix, true); }
java
{ "resource": "" }
q155622
Strman.ensureRight
train
public static String ensureRight(final String value, final String suffix, boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return endsWith(value, suffix, caseSensitive) ? value : append(value, suffix); }
java
{ "resource": "" }
q155623
Strman.first
train
public static Optional<String> first(final String value, final int n) { return Optional.ofNullable(value).filter(v -> !v.isEmpty()).map(v -> v.substring(0, n)); }
java
{ "resource": "" }
q155624
Strman.format
train
public static String format(final String value, String... params) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); Pattern p = Pattern.compile("\\{(\\w+)}"); Matcher m = p.matcher(value); String result = value; while (m.find()) { int paramNumber = I...
java
{ "resource": "" }
q155625
Strman.insert
train
public static String insert(final String value, final String substr, final int index) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(substr, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (index > value.length()) { return value; } r...
java
{ "resource": "" }
q155626
Strman.isUpperCase
train
public static boolean isUpperCase(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); for (int i = 0; i < value.length(); i++) { if (Character.isLowerCase(value.charAt(i))) { return false; } } return true; }
java
{ "resource": "" }
q155627
Strman.last
train
public static String last(final String value, int n) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (n > value.length()) { return value; } return value.substring(value.length() - n); }
java
{ "resource": "" }
q155628
Strman.leftPad
train
public static String leftPad(final String value, final String pad, final int length) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(pad, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (value.length() > length) { return value; } retu...
java
{ "resource": "" }
q155629
Strman.lastIndexOf
train
public static int lastIndexOf(final String value, final String needle) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return lastIndexOf(value, needle, value.length(), true); }
java
{ "resource": "" }
q155630
Strman.lastIndexOf
train
public static int lastIndexOf(final String value, final String needle, final int offset, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(needle, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (caseS...
java
{ "resource": "" }
q155631
Strman.leftTrim
train
public static String leftTrim(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.replaceAll("^\\s+", ""); }
java
{ "resource": "" }
q155632
Strman.prependArray
train
public static String prependArray(final String value, final String[] prepends) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (prepends == null || prepends.length == 0) { return value; } StringJoiner joiner = new StringJoiner(""); for (String p...
java
{ "resource": "" }
q155633
Strman.removeEmptyStrings
train
public static String[] removeEmptyStrings(String[] strings) { if (Objects.isNull(strings)) { throw new IllegalArgumentException("Input array should not be null"); } return Arrays.stream(strings).filter(str -> str != null && !str.trim().isEmpty()).toArray(String[]::new); }
java
{ "resource": "" }
q155634
Strman.removeLeft
train
public static String removeLeft(final String value, final String prefix) { return removeLeft(value, prefix, true); }
java
{ "resource": "" }
q155635
Strman.removeLeft
train
public static String removeLeft(final String value, final String prefix, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(prefix, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (caseSensitive) { return value.startsWith(pr...
java
{ "resource": "" }
q155636
Strman.removeNonWords
train
public static String removeNonWords(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.replaceAll("[^\\w]+", ""); }
java
{ "resource": "" }
q155637
Strman.removeRight
train
public static String removeRight(final String value, final String suffix) { return removeRight(value, suffix, true); }
java
{ "resource": "" }
q155638
Strman.removeRight
train
public static String removeRight(final String value, final String suffix, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(suffix, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return endsWith(value, suffix, caseSensitive) ? value ...
java
{ "resource": "" }
q155639
Strman.removeSpaces
train
public static String removeSpaces(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.replaceAll("\\s", ""); }
java
{ "resource": "" }
q155640
Strman.repeat
train
public static String repeat(final String value, final int multiplier) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return Stream.generate(() -> value).limit(multiplier).collect(joining()); }
java
{ "resource": "" }
q155641
Strman.replace
train
public static String replace(final String value, final String search, final String newValue, final boolean caseSensitive) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); validate(search, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (ca...
java
{ "resource": "" }
q155642
Strman.reverse
train
public static String reverse(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return new StringBuilder(value).reverse().toString(); }
java
{ "resource": "" }
q155643
Strman.rightTrim
train
public static String rightTrim(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.replaceAll("\\s+$", ""); }
java
{ "resource": "" }
q155644
Strman.safeTruncate
train
public static String safeTruncate(final String value, final int length, final String filler) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (length == 0) { return ""; } if (length >= value.length()) { return value; } String...
java
{ "resource": "" }
q155645
Strman.split
train
public static String[] split(final String value, final String regex) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.split(regex); }
java
{ "resource": "" }
q155646
Strman.words
train
public static String[] words(final String value, final String delimiter) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.split(delimiter); }
java
{ "resource": "" }
q155647
Strman.truncate
train
public static String truncate(final String value, final int length, final String filler) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); if (length == 0) { return ""; } if (length >= value.length()) { return value; } return appe...
java
{ "resource": "" }
q155648
Strman.htmlDecode
train
public static String htmlDecode(final String encodedHtml) { validate(encodedHtml, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); String[] entities = encodedHtml.split("&\\W+;"); return Arrays.stream(entities).map(e -> HtmlEntities.decodedEntities.get(e)).collect(joining()); }
java
{ "resource": "" }
q155649
Strman.htmlEncode
train
public static String htmlEncode(final String html) { validate(html, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return html.chars().mapToObj(c -> "\\u" + String.format("%04x", c).toUpperCase()) .map(HtmlEntities.encodedEntities::get).collect(joining()); }
java
{ "resource": "" }
q155650
Strman.shuffle
train
public static String shuffle(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); String[] chars = chars(value); Random random = new Random(); for (int i = 0; i < chars.length; i++) { int r = random.nextInt(chars.length); String ...
java
{ "resource": "" }
q155651
Strman.slice
train
public static String slice(final String value, int begin, int end) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); return value.substring(begin, end); }
java
{ "resource": "" }
q155652
Strman.slugify
train
public static String slugify(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); String transliterated = transliterate(collapseWhitespace(value.trim().toLowerCase())); return Arrays.stream(words(transliterated.replace("&", "-and-"), "\\W+")).collect(joining("-...
java
{ "resource": "" }
q155653
Strman.transliterate
train
public static String transliterate(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); String result = value; Set<Map.Entry<String, List<String>>> entries = Ascii.ascii.entrySet(); for (Map.Entry<String, List<String>> entry : entries) { for...
java
{ "resource": "" }
q155654
Strman.surround
train
public static String surround(final String value, final String prefix, final String suffix) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); String _prefix = Optional.ofNullable(prefix).orElse(""); return append(_prefix, value, Optional.ofNullable(suffix).orElse(_prefix)); ...
java
{ "resource": "" }
q155655
Strman.toCamelCase
train
public static String toCamelCase(final String value) { if (value == null || value.length() == 0) { return ""; } String str = toStudlyCase(value); return str.substring(0, 1).toLowerCase() + str.substring(1); }
java
{ "resource": "" }
q155656
Strman.toStudlyCase
train
public static String toStudlyCase(final String value) { validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER); String[] words = collapseWhitespace(value.trim()).split("\\s*(_|-|\\s)\\s*"); return Arrays.stream(words).filter(w -> !w.trim().isEmpty()).map(Strman::upperFirst).collect(joi...
java
{ "resource": "" }
q155657
Strman.tail
train
public static Optional<String> tail(final String value) { return Optional.ofNullable(value).filter(v -> !v.isEmpty()).map(v -> last(v, v.length() - 1)); }
java
{ "resource": "" }
q155658
Strman.join
train
public static String join(final String[] strings, final String separator) throws IllegalArgumentException { if (strings == null) { throw new IllegalArgumentException("Input array 'strings' can't be null"); } if (separator == null) { throw new IllegalArgumentException("sep...
java
{ "resource": "" }
q155659
Strman.capitalize
train
public static String capitalize(final String input) throws IllegalArgumentException { if (input == null) { throw new IllegalArgumentException("input can't be null"); } if (input.length() == 0) { return ""; } return head(input).map(String::toUpperCase).map(...
java
{ "resource": "" }
q155660
Strman.isEnclosedBetween
train
public static boolean isEnclosedBetween(final String input, final String leftEncloser, String rightEncloser) { if (input == null) { throw new IllegalArgumentException("input can't be null"); } if (leftEncloser == null) { throw new IllegalArgumentException("leftEncloser ca...
java
{ "resource": "" }
q155661
Strman.upperFirst
train
public static String upperFirst(String input) { if (input == null) { throw new IllegalArgumentException("input can't be null"); } return head(input).map(String::toUpperCase).map(h -> tail(input).map(t -> h + t).orElse(h)).get(); }
java
{ "resource": "" }
q155662
Strman.trimStart
train
public static Optional<String> trimStart(final String input) { return Optional.ofNullable(input).filter(v -> !v.isEmpty()).map(Strman::leftTrim); }
java
{ "resource": "" }
q155663
Strman.trimStart
train
public static Optional<String> trimStart(final String input, String... chars) { return Optional.ofNullable(input).filter(v -> !v.isEmpty()).map(v -> { String pattern = String.format("^[%s]+", join(chars, "\\")); return v.replaceAll(pattern, ""); }); }
java
{ "resource": "" }
q155664
Strman.trimEnd
train
public static Optional<String> trimEnd(final String input) { return Optional.ofNullable(input).filter(v -> !v.isEmpty()).map(Strman::rightTrim); }
java
{ "resource": "" }
q155665
Strman.charsCount
train
public static Map<Character, Long> charsCount(String input) { if (isNullOrEmpty(input)) { return Collections.emptyMap(); } return input.chars().mapToObj(c -> (char) c).collect(groupingBy(identity(), counting())); }
java
{ "resource": "" }
q155666
Strman.underscored
train
public static String underscored(final String input) { if (input == null || input.length() == 0) { return ""; } return input.trim().replaceAll("([a-z\\d])([A-Z]+)", "$1_$2").replaceAll("[-\\s]+", "_").toLowerCase(); }
java
{ "resource": "" }
q155667
Strman.zip
train
public static List<String> zip(String... inputs) { if (inputs.length == 0) { return Collections.emptyList(); } OptionalInt min = Arrays.stream(inputs).mapToInt(str -> str == null ? 0 : str.length()).min(); if (!min.isPresent()) { return Collections.emptyList(); ...
java
{ "resource": "" }
q155668
Strman.humanize
train
public static String humanize(final String input) { if (input == null || input.length() == 0) { return ""; } return upperFirst(underscored(input).replaceAll("_", " ")); }
java
{ "resource": "" }
q155669
Strman.swapCase
train
public static String swapCase(String input) { if (input == null || input.length() == 0) { return ""; } StringBuilder resultBuilder = new StringBuilder(); for (char ch : input.toCharArray()) { if (Character.isUpperCase(ch)) { resultBuilder.append(Ch...
java
{ "resource": "" }
q155670
Strman.formatNumber
train
public static String formatNumber(long number) { String stringRepresentation = Long.toString(number); StringBuilder sb = new StringBuilder(); int bound = stringRepresentation.length() - 1; String delimiter = ","; int counter = 0; for (int i = bound; i >= 0; i--) { ...
java
{ "resource": "" }
q155671
TouchEffectDrawable.setPadding
train
public void setPadding(int left, int top, int right, int bottom) { if ((left | top | right | bottom) == 0) { mState.mPadding = null; } else { if (mState.mPadding == null) { mState.mPadding = new Rect(); } mState.mPadding.set(left, top, righ...
java
{ "resource": "" }
q155672
AbsSeekBar.setThumbColor
train
public void setThumbColor(int startColor, int endColor) { mSeekBarDrawable.setThumbColor(ColorStateList.valueOf(startColor)); if (mIndicator != null) mIndicator.setColors(startColor, endColor); }
java
{ "resource": "" }
q155673
UiCompat.setHotspotBounds
train
public static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //We don't want the full size rect, Lollipop ripple would be too big int size = (right - left) / 8; drawable.setHots...
java
{ "resource": "" }
q155674
UiCompat.setTextDirection
train
public static void setTextDirection(TextView textView, int textDirection) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { UiCompatNotCrash.setTextDirection(textView, textDirection); } }
java
{ "resource": "" }
q155675
EditText.checkShowTitle
train
private void checkShowTitle(Editable s, boolean skipChange) { // in this we can check width if (isShowTitle() && getWidth() > 0) { boolean have = s != null && s.length() > 0; if (have != isHaveText || (have && skipChange)) { isHaveText = have; anim...
java
{ "resource": "" }
q155676
CommandService.onDestroy
train
@Override public void onDestroy() { CommandServiceImpl impl = mImpl; if (impl != null) { mImpl = null; impl.destroy(); } super.onDestroy(); // Kill process android.os.Process.killProcess(android.os.Process.myPid()); }
java
{ "resource": "" }
q155677
ActionSyncTask.run
train
@Override public void run() { if (!mDone) { synchronized (this) { if (!mDone) { call(); mDone = true; try { this.notifyAll(); } catch (Exception ignored) { ...
java
{ "resource": "" }
q155678
ActionSyncTask.waitRun
train
void waitRun(long waitMillis, int waitNanos, boolean cancelOnTimeOut) { if (!mDone) { synchronized (this) { if (!mDone) { try { this.wait(waitMillis, waitNanos); } catch (InterruptedException ignored) { ...
java
{ "resource": "" }
q155679
Blur.checkSource
train
private static Bitmap checkSource(Bitmap original, int radius) { if (radius < 0 || radius > 256) { throw new RuntimeException("Blur bitmap radius must >= 1 and <=256."); } // First we should check the original if (original == null) { throw new NullPointerExceptio...
java
{ "resource": "" }
q155680
Blur.onStackBlur
train
public static Bitmap onStackBlur(Bitmap original, int radius) { Bitmap bitmap = checkSource(original, radius); // Return this none blur if (radius == 1) { return bitmap; } //Jni BitMap Blur nativeStackBlurBitmap(bitmap, radius); return (bitmap); ...
java
{ "resource": "" }
q155681
Blur.onStackBlurPixels
train
public static int[] onStackBlurPixels(int[] pix, int w, int h, int radius) { if (radius < 0 || radius > 256) { throw new RuntimeException("Blur bitmap radius must >= 1 and <=256."); } if (pix == null) { throw new RuntimeException("Blur bitmap pix isn't null."); }...
java
{ "resource": "" }
q155682
Ui.dipToPx
train
public static float dipToPx(Resources resources, float dp) { DisplayMetrics metrics = resources.getDisplayMetrics(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, metrics); }
java
{ "resource": "" }
q155683
Ui.modulateColorAlpha
train
public static int modulateColorAlpha(int color, int alpha) { int colorAlpha = color >>> 24; int scale = alpha + (alpha >> 7); int newAlpha = colorAlpha * scale >> 8; int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = color & 0xFF; return newAlpha <...
java
{ "resource": "" }
q155684
Ui.changeColorAlpha
train
public static int changeColorAlpha(int color, int alpha) { int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = color & 0xFF; return alpha << 24 | r << 16 | g << 8 | b; }
java
{ "resource": "" }
q155685
Ui.isTrueFromAttribute
train
public static boolean isTrueFromAttribute(AttributeSet attrs, String attribute, boolean defaultValue) { return attrs.getAttributeBooleanValue(Ui.androidStyleNameSpace, attribute, defaultValue); }
java
{ "resource": "" }
q155686
Ui.getBackgroundColor
train
public static int getBackgroundColor(Context context, AttributeSet attrs) { int color = Color.TRANSPARENT; if (isHaveAttribute(attrs, "background")) { int styleId = attrs.getStyleAttribute(); int[] attributesArray = new int[]{android.R.attr.background}; try { ...
java
{ "resource": "" }
q155687
Ui.getColorsFromArrayRes
train
public static int[] getColorsFromArrayRes(Resources resources, int resId) { try { @SuppressLint("Recycle") TypedArray array = resources.obtainTypedArray(resId); if (array.length() > 0) { final int len = array.length(); final int[] colors = new ...
java
{ "resource": "" }
q155688
Ui.isHaveAttribute
train
public static boolean isHaveAttribute(AttributeSet attrs, String attribute) { return attrs.getAttributeValue(Ui.androidStyleNameSpace, attribute) != null; }
java
{ "resource": "" }
q155689
Effect.setPaintAlpha
train
protected int setPaintAlpha(Paint paint, int alpha) { final int prevAlpha = paint.getAlpha(); paint.setAlpha(Ui.modulateAlpha(prevAlpha, alpha)); return prevAlpha; }
java
{ "resource": "" }
q155690
Reflector.with
train
public static Reflector with(String name, ClassLoader classLoader) throws ReflectException { return with(getClassForName(name, classLoader)); }
java
{ "resource": "" }
q155691
Reflector.set
train
public Reflector set(String name, Object value) throws ReflectException { try { Field field = field0(name); field.setAccessible(true); field.set(obj, unwrap(value)); return this; } catch (Exception e) { throw new ReflectException(e); } ...
java
{ "resource": "" }
q155692
Reflector.get
train
@SuppressWarnings("RedundantTypeArguments") public <T> T get(String name) throws ReflectException { return field(name).<T>get(); }
java
{ "resource": "" }
q155693
Reflector.create
train
public Reflector create(Object... args) throws ReflectException { Class<?>[] types = getTypes(args); try { Constructor<?> constructor = type().getDeclaredConstructor(types); return with(constructor, args); } catch (NoSuchMethodException e) { for (Constructor<...
java
{ "resource": "" }
q155694
Reflector.toLowerCaseFirstOne
train
@SuppressLint("DefaultLocale") private static String toLowerCaseFirstOne(String string) { int length = string.length(); if (length == 0 || Character.isLowerCase(string.charAt(0))) { return string; } else if (length == 1) { return string.toLowerCase(); } else ...
java
{ "resource": "" }
q155695
Reflector.getClasses
train
public static <T> Class<?>[] getClasses(Type[] types) { if (types == null) return null; if (types.length == 0) return new Class<?>[0]; Class<?>[] classes = new Class[types.length]; // Resolve types by chasing down type variables. for (int i = 0; i < types...
java
{ "resource": "" }
q155696
HandlerPoster.handleMessage
train
@Override public void handleMessage(Message msg) { if (msg.what == ASYNC) { mAsyncDispatcher.dispatch(); } else if (msg.what == SYNC) { mSyncDispatcher.dispatch(); } else super.handleMessage(msg); }
java
{ "resource": "" }
q155697
Loading.setBackgroundColorRes
train
public void setBackgroundColorRes(int colorRes) { ColorStateList colorStateList = UiCompat.getColorStateList(getResources(), colorRes); if (colorStateList == null) setBackgroundColor(0); else setBackgroundColor(colorStateList.getDefaultColor()); }
java
{ "resource": "" }
q155698
Loading.setLoadingDrawable
train
protected void setLoadingDrawable(LoadingDrawable drawable) { if (drawable == null) { throw new NullPointerException("LoadingDrawable is null, You can only set the STYLE_CIRCLE and STYLE_LINE parameters."); } else { drawable.setCallback(this); mLoadingDrawable = drawa...
java
{ "resource": "" }
q155699
TextView.setBorder
train
public void setBorder(int flag, int size, int color) { if (mBorder != flag || mBorderSize != size || mBorderColor != color) { mBorder = flag; mBorderSize = size; mBorderColor = color; if (flag <= 0) { mBorderDrawable = null; } else { ...
java
{ "resource": "" }