This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void hideKeyboard(Context context, View view) { | |
getInputMethodManager(context).hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} | |
public static void showKeyboard(Context context, View view) { | |
getInputMethodManager(context).showSoftInput(view, 0); | |
} | |
public static InputMethodManager getInputMethodManager(Context context) { | |
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<String> getHeavyList() { | |
List<String> list = new ArrayList<>(); | |
list.add("First string"); | |
list.add("Second string"); | |
list.add("Third string"); | |
return list; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Do 1 heavy operation, when successful, fire 2 more heavy operations sequentially that use the first operation's data | |
*/ | |
private List<String> getHeavyList() { | |
List<String> list = new ArrayList<>(); | |
list.add("First string"); | |
list.add("Second string"); | |
list.add("Third string"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final String gifUrl = "http://i.imgur.com/LU208u2.gif"; | |
final RequestOptions requestOptions = new RequestOptions() | |
.fitCenter(this); | |
Glide.with(LoginActivity.this).asBitmap().load(gifUrl).apply(requestOptions).into(imageViewPreview); | |
final View.OnClickListener onClickListener = new OnClickListener() { | |
@Override | |
public void onClick(View v) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.onPropertyCommitted = function (args) { | |
if (args.propertyName == "height") { | |
var ageEntityProperty = dataForm.getPropertyByName("age"); | |
if (ageEntityProperty) { | |
if (args.entityProperty.originalValue == 2) { | |
ageEntityProperty.hidden = true; | |
} else { | |
ageEntityProperty.hidden = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
if (dy > 0) { | |
if (!recyclerView.canScrollVertically(1)) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings("deprecation") | |
public static Spanned fromHtml(String source) { | |
if (source == null) { | |
return null; | |
} | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final ExoPlayer exoPlayer; | |
public PlayerExoPlayer(ExoPlayer exoPlayer) { | |
this.exoPlayer = exoPlayer; | |
} | |
public void prepareMp3(Context context, Uri uri) { | |
DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter(); | |
String userAgent = System.getProperty("http.agent"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Took forever because of crappy tutorials, for example https://developer.android.com/guide/topics/media-apps/audio-app/building-a-mediabrowserservice.html | |
// Key information was in COMMENTS in MediaButtonReceiver.java | |
// The key is to have a receiver with filter android.intent.action.MEDIA_BUTTON AND in the service | |
// register pending intent to the button in notification | |
builder.addAction(new NotificationCompat.Action( | |
R.drawable.ic_skip_next_black_24dp, getString(R.string.skip_next), | |
MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_SKIP_TO_NEXT))); | |
// manifest changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<File> getExternalDirectoryRoots(Context context) { | |
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null); | |
List<File> externalDirectories = new ArrayList<>(); | |
Set<String> stringSet = new HashSet<>(); | |
for (File file : externalFilesDirs) { | |
String[] split = file.getAbsolutePath().split("/"); | |
if (split.length > 1) { |
OlderNewer