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 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"; |
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
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 |
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 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"; |
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
Language | Command | Output | |
---|---|---|---|
Java | time uamp-java/gradlew -b uamp-java/mobile/build.gradle clean assemble | real 0m29.688s user 0m2.677s | |
Kotlin | time uamp-java/gradlew -b uamp-kotlin/app/build.gradle clean assemble | real 0m27.798s user 0m2.332s |
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
Metric | Java | Kotlin | Difference | Notes | |
---|---|---|---|---|---|
Source Files | 52 | 20 | 32 fewer files | Using find and grepping on file extension | |
Lines of Code | 3719 | 1084 | 2635 fewer LoC | Using https://github.com/arturbosch/lloc | |
Class Count | 63 | 29 | 34 fewer classes | using find/grep |
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
package org.uamp.server | |
import com.sun.net.httpserver.HttpExchange | |
import com.sun.net.httpserver.HttpServer | |
import java.io.File | |
import java.net.InetSocketAddress | |
import java.net.URI | |
fun main(args: Array<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
... | |
/** | |
* Utility class to get a list of MusicTrack's based on a server-side JSON | |
* configuration. | |
*/ | |
public class RemoteJSONSource implements MusicProviderSource { | |
private static final String TAG = LogHelper.makeLogTag(RemoteJSONSource.class); |
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
import com.sun.net.httpserver.HttpExchange | |
import com.sun.net.httpserver.HttpServer | |
import java.io.File | |
import java.net.InetSocketAddress | |
import java.net.URI | |
fun main(args: Array<String>) { | |
val port = args[0].toIntOrNull() ?: 8080 | |
val basePath = File(args.getOrElse(1, { System.getProperty("user.dir")!! })) |
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
fun fetchFileOrNull(exchange: HttpExchange, basePath: File): File? = | |
when (validRequest(exchange)) { | |
true -> { | |
localFileFromRequestUri(basePath, exchange.requestURI).let { requestedFile -> | |
if (requestedFile.isFile) requestedFile else null | |
} | |
} | |
false -> null | |
} |
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
fun fetchFileOrNull(exchange: HttpExchange, basePath: File): File? = | |
when (validRequest(exchange)) { | |
true -> { | |
val resource = localFileFromRequestUri(basePath, exchange.requestURI) | |
print("Seeking ${resource.absolutePath}...") | |
if (resource.isFile) resource else null | |
} | |
false -> null |