Skip to content

Instantly share code, notes, and snippets.

View kgilmer's full-sized avatar

Ken Gilmer kgilmer

View GitHub Profile
rootProject.name = "example-codegen"
include("codegen", "codegen-test")
using Gtk;
// Creates a dialog style window with a static text block, dynamic list, and static button bar.
// Changes to the list cause the dialog to update its bounds accourding to the items.
public class Example : Window
{
public Example()
{
this.title = "ListBox";
this.set_default_size(200, 20);
using Gtk;
const int KEY_CODE_ESCAPE = 65307;
const int KEY_CODE_ENTER = 65293;
/**
* This example demonstrates how to create a simple GTK dialog that operates independently from the window manager.
*
* The program collects input from the user. If the user presses enter, the entered text is returned to the caller.
* If the user presses escape, the program ends.
./rofi usage:
./rofi [-options ...]
Command line only options:
-no-config Do not load configuration, use default values.
-v,-version Print the version number and exit.
-dmenu Start in dmenu mode.
-display [string] X server to contact.
${DISPLAY}
-h,-help This help message.
/**
* This must be `by lazy` because the source won't initially be ready.
* See [MusicService.onLoadChildren] to see where it's accessed (and first
* constructed).
*/
private val browseTree: BrowseTree by lazy {
BrowseTree(mediaSource)
}
@kgilmer
kgilmer / uamp-artist-java.diff
Created August 23, 2018 23:23
Add artist to uamp java
diff --git a/mobile/src/main/java/com/example/android/uamp/model/MusicProvider.java b/mobile/src/main/java/com/example/android/uamp/model/MusicProvider.java
index 3370c6a..86c6777 100644
--- a/mobile/src/main/java/com/example/android/uamp/model/MusicProvider.java
+++ b/mobile/src/main/java/com/example/android/uamp/model/MusicProvider.java
@@ -53,6 +51,7 @@ public class MusicProvider {
// Categorized caches for music track data:
private ConcurrentMap<String, List<MediaMetadataCompat>> mMusicListByGenre;
+ private ConcurrentMap<String, List<MediaMetadataCompat>> mMusicListByArtist;
private final ConcurrentMap<String, MutableMediaMetadata> mMusicListById;
@kgilmer
kgilmer / uamp-artist-kotlin.diff
Created August 23, 2018 23:17
Add artist to kotlin version of uamp
diff --git a/app/src/main/java/com/example/android/uamp/MediaItemAdapter.kt b/app/src/main/java/com/example/android/uamp/MediaItemAdapter.kt
index d220374..a855a81 100644
--- a/app/src/main/java/com/example/android/uamp/MediaItemAdapter.kt
+++ b/app/src/main/java/com/example/android/uamp/MediaItemAdapter.kt
@@ -71,11 +71,10 @@ class MediaItemAdapter(private val itemClickedListener: (MediaItemData) -> Unit
holder.playbackState.setImageResource(mediaItem.playbackRes)
Glide.with(holder.albumArt)
- .load(mediaItem.albumArtUri)
- .into(holder.albumArt)
@kgilmer
kgilmer / ReadNetwork.kt
Created August 22, 2018 00:54
uamp read network Kotlin
val catalogConn = URL(catalogUri.toString())
val reader = BufferedReader(InputStreamReader(catalogConn.openStream()))
val musicCat = gson.fromJson<JsonCatalog>(reader, JsonCatalog::class.java)
@kgilmer
kgilmer / ReadNetwork.java
Created August 22, 2018 00:52
uamp read network in Java
BufferedReader reader = null;
try {
URLConnection urlConnection = new URL(urlString).openConnection();
reader = new BufferedReader(new InputStreamReader(
urlConnection.getInputStream(), "iso-8859-1"));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
class JsonSource(context: Context, source: Uri) : AbstractMusicSource() {
private var catalog: List<MediaMetadataCompat> = emptyList()
init {
state = STATE_INITIALIZING
UpdateCatalogTask(Glide.with(context)) { mediaItems ->
catalog = mediaItems
state = STATE_INITIALIZED
}.execute(source)