diff --git a/.gitignore b/.gitignore index 6a548f3..a24d51b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ proguard/ *.ipr *.iws .idea/ + +# Gradle files +build/ +.gradle/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..3663dbe --- /dev/null +++ b/build.gradle @@ -0,0 +1,46 @@ +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:0.7.0' + } +} + +apply plugin: 'android' + +dependencies { + compile fileTree('libs/') + compile 'com.android.support:appcompat-v7:18.0.+' + compile 'com.android.support:mediarouter-v7:18.0.+' +} + +android { + compileSdkVersion 19 + buildToolsVersion "19.0.1" + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + + // Move the tests to tests/java, tests/res, etc... + instrumentTest.setRoot('tests') + + // Move the build types to build-types/ + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... + // This moves them out of them default location under src//... which would + // conflict with src/ being used by the main source set. + // Adding new build types or product flavors should be accompanied + // by a similar customization. + debug.setRoot('build-types/debug') + release.setRoot('build-types/release') + } +} diff --git a/lint.xml b/lint.xml new file mode 100644 index 0000000..d463a26 --- /dev/null +++ b/lint.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index e6c9295..6cf9423 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -119,7 +119,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements public void onServiceConnected(ComponentName className, IBinder service) { mMediaRouterPlayService = (MediaRouterPlayServiceBinder) service; mMediaRouterPlayService.getService().setRouterFragment(RouteFragment.this); - mPlaylistAdapter.addAll(mMediaRouterPlayService.getService().getPlaylist()); + mPlaylistAdapter.add(mMediaRouterPlayService.getService().getPlaylist()); receiveIsPlaying(mMediaRouterPlayService.getService().getCurrentTrack()); applyColors(); } @@ -154,7 +154,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements super.onActivityCreated(savedInstanceState); mRouteAdapter = new RouteAdapter(getActivity()); - mRouteAdapter.addAll(MediaRouter.getInstance(getActivity()).getRoutes()); + mRouteAdapter.add(MediaRouter.getInstance(getActivity()).getRoutes()); mRouteAdapter.remove(MediaRouter.getInstance(getActivity()).getDefaultRoute()); mPlaylistAdapter = new FileArrayAdapter(getActivity()); @@ -483,7 +483,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements */ public void play(List playlist, int start) { mPlaylistAdapter.clear(); - mPlaylistAdapter.addAll(playlist); + mPlaylistAdapter.add(playlist); mMediaRouterPlayService.getService().setPlaylist(playlist); if (mSelectedRoute != null) diff --git a/src/com/github/nutomic/controldlna/utility/RouteAdapter.java b/src/com/github/nutomic/controldlna/utility/RouteAdapter.java index 6e6b4ee..e9455a0 100644 --- a/src/com/github/nutomic/controldlna/utility/RouteAdapter.java +++ b/src/com/github/nutomic/controldlna/utility/RouteAdapter.java @@ -1,5 +1,7 @@ package com.github.nutomic.controldlna.utility; +import java.util.List; + import android.content.Context; import android.support.v7.media.MediaRouter.RouteInfo; import android.view.LayoutInflater; @@ -33,4 +35,12 @@ public class RouteAdapter extends ArrayAdapter { return convertView; } + /** + * Replacement for addAll, which is not implemented on lower API levels. + */ + public void add(List routes) { + for (RouteInfo r : routes) + add(r); + } + }