Skip to content

Instantly share code, notes, and snippets.

Avatar

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.
${DISPLAY}
-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 {
BrowseTree(mediaSource)
}
@kgilmer
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/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 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
holder.playbackState.setImageResource(mediaItem.playbackRes)
Glide.with(holder.albumArt)
- .load(mediaItem.albumArtUri)
- .into(holder.albumArt)
@kgilmer
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, JsonCatalog::class.java)
@kgilmer
kgilmer / ReadNetwork.java
Created Aug 22, 2018
uamp read network in Java
View ReadNetwork.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);
}
View JsonSource.kt
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)
View RemoteJsonSource.java
public class RemoteJSONSource implements MusicProviderSource {
private static final String TAG = LogHelper.makeLogTag(RemoteJSONSource.class);
protected static final String CATALOG_URL =
"http://storage.googleapis.com/automotive-media/music.json";
private static final String JSON_MUSIC = "music";
private static final String JSON_TITLE = "title";
private static final String JSON_ALBUM = "album";
@kgilmer
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?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Since UAMP is a music player, the volume controls should adjust the music volume while
// in the app.
volumeControlStream = AudioManager.STREAM_MUSIC
@kgilmer
kgilmer / MusicPlayerActivity.java
Created Aug 22, 2018
uamp-java Main Activity
View MusicPlayerActivity.java
public class MusicPlayerActivity extends BaseActivity
implements MediaBrowserFragment.MediaFragmentListener {
private static final String TAG = LogHelper.makeLogTag(MusicPlayerActivity.class);
private static final String SAVED_MEDIA_ID="com.example.android.uamp.MEDIA_ID";
private static final String FRAGMENT_TAG = "uamp_list_container";
public static final String EXTRA_START_FULLSCREEN =
"com.example.android.uamp.EXTRA_START_FULLSCREEN";