Skip to content

Instantly share code, notes, and snippets.


Ken Gilmer kgilmer

View GitHub Profile
View gist:23e63b621656456e440271de5205422a
./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.
-h,-help This help message.
View MusicService.kt
* 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 {
kgilmer / uamp-artist-java.diff
Created Aug 23, 2018
Add artist to uamp java
View uamp-artist-java.diff
diff --git a/mobile/src/main/java/com/example/android/uamp/model/ b/mobile/src/main/java/com/example/android/uamp/model/
index 3370c6a..86c6777 100644
--- a/mobile/src/main/java/com/example/android/uamp/model/
+++ b/mobile/src/main/java/com/example/android/uamp/model/
@@ -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 / uamp-artist-kotlin.diff
Created Aug 23, 2018
Add artist to kotlin version of uamp
View uamp-artist-kotlin.diff
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
- .load(mediaItem.albumArtUri)
- .into(holder.albumArt)
kgilmer / ReadNetwork.kt
Created Aug 22, 2018
uamp read network Kotlin
View ReadNetwork.kt
val catalogConn = URL(catalogUri.toString())
val reader = BufferedReader(InputStreamReader(catalogConn.openStream()))
val musicCat = gson.fromJson<JsonCatalog>(reader,
kgilmer /
Created Aug 22, 2018
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) {
View JsonSource.kt
class JsonSource(context: Context, source: Uri) : AbstractMusicSource() {
private var catalog: List<MediaMetadataCompat> = emptyList()
init {
UpdateCatalogTask(Glide.with(context)) { mediaItems ->
catalog = mediaItems
public class RemoteJSONSource implements MusicProviderSource {
private static final String TAG = LogHelper.makeLogTag(RemoteJSONSource.class);
protected static final String CATALOG_URL =
private static final String JSON_MUSIC = "music";
private static final String JSON_TITLE = "title";
private static final String JSON_ALBUM = "album";
kgilmer / MainActivity.kt
Created Aug 22, 2018
uamp Kotlin Version
View MainActivity.kt
class MainActivity : AppCompatActivity() {
private lateinit var viewModel: MainActivityViewModel
override fun onCreate(savedInstanceState: Bundle?) {
// Since UAMP is a music player, the volume controls should adjust the music volume while
// in the app.
volumeControlStream = AudioManager.STREAM_MUSIC
kgilmer /
Created Aug 22, 2018
uamp-java Main Activity
public class MusicPlayerActivity extends BaseActivity
implements MediaBrowserFragment.MediaFragmentListener {
private static final String TAG = LogHelper.makeLogTag(MusicPlayerActivity.class);
private static final String SAVED_MEDIA_ID="";
private static final String FRAGMENT_TAG = "uamp_list_container";
public static final String EXTRA_START_FULLSCREEN =