Changed packet structure, added missing license text to files.
This commit is contained in:
parent
c236173a45
commit
3207eb3e5b
16 changed files with 261 additions and 136 deletions
|
@ -34,7 +34,7 @@
|
|||
|
||||
<service android:name="org.teleal.cling.android.AndroidUpnpServiceImpl" />
|
||||
|
||||
<service android:name="com.github.nutomic.controldlna.service.PlayService" />
|
||||
<service android:name="com.github.nutomic.controldlna.upnp.PlayService" />
|
||||
|
||||
</application>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<com.github.nutomic.controldlna.RemoteImageView
|
||||
<com.github.nutomic.controldlna.utility.RemoteImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="?android:attr/listPreferredItemHeight"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package com.github.nutomic.controldlna;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Handles background task of loading a bitmap by URI.
|
||||
*
|
||||
* @author Felix Ableitner
|
||||
*
|
||||
*/
|
||||
public class LoadImageTask extends AsyncTask<URI, Void, Bitmap> {
|
||||
|
||||
private static final String TAG = "LoadImageTask";
|
||||
|
||||
@Override
|
||||
protected Bitmap doInBackground(URI... uri) {
|
||||
if (uri[0] == null)
|
||||
return null;
|
||||
|
||||
Bitmap bm = null;
|
||||
try {
|
||||
URLConnection conn = new URL(uri[0].toString())
|
||||
.openConnection();
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
bm = BitmapFactory.decodeStream(bis);
|
||||
bis.close();
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Failed to load artwork image", e);
|
||||
}
|
||||
return bm;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package com.github.nutomic.controldlna;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.github.nutomic.controldlna.LoadImageTask;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* ImageView that can directly load from a UPNP URI.
|
||||
*
|
||||
* @author Felix Ableitner
|
||||
*
|
||||
*/
|
||||
public class RemoteImageView extends ImageView {
|
||||
|
||||
/**
|
||||
* Assigns the icon as image drawable when it is loaded.
|
||||
*
|
||||
* @author Felix
|
||||
*
|
||||
*/
|
||||
private class AssignImageTask extends LoadImageTask {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bm) {
|
||||
if (bm != null)
|
||||
setImageBitmap(bm);
|
||||
else
|
||||
setImageDrawable(null);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public RemoteImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RemoteImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RemoteImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URI where the image should be loaded from, loads and assigns it.
|
||||
*/
|
||||
public void setImageUri(URI uri) {
|
||||
setImageDrawable(null);
|
||||
new AssignImageTask().execute(uri);
|
||||
}
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ import android.view.KeyEvent;
|
|||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.github.nutomic.controldlna.R;
|
||||
import com.github.nutomic.controldlna.UpnpPlayer;
|
||||
import com.github.nutomic.controldlna.upnp.UpnpPlayer;
|
||||
|
||||
/**
|
||||
* Main activity, with tabs for media servers and media renderers.
|
||||
|
|
|
@ -27,7 +27,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
package com.github.nutomic.controldlna.gui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.teleal.cling.controlpoint.SubscriptionCallback;
|
||||
|
@ -43,7 +42,6 @@ import org.teleal.cling.support.avtransport.lastchange.AVTransportLastChangePars
|
|||
import org.teleal.cling.support.avtransport.lastchange.AVTransportVariable;
|
||||
import org.teleal.cling.support.lastchange.LastChange;
|
||||
import org.teleal.cling.support.model.PositionInfo;
|
||||
import org.teleal.cling.support.model.item.Item;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -65,11 +63,11 @@ import android.widget.ListView;
|
|||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
|
||||
import com.github.nutomic.controldlna.DeviceArrayAdapter;
|
||||
import com.github.nutomic.controldlna.FileArrayAdapter;
|
||||
import com.github.nutomic.controldlna.R;
|
||||
import com.github.nutomic.controldlna.UpnpPlayer;
|
||||
import com.github.nutomic.controldlna.gui.MainActivity.OnBackPressedListener;
|
||||
import com.github.nutomic.controldlna.upnp.UpnpPlayer;
|
||||
import com.github.nutomic.controldlna.utility.DeviceArrayAdapter;
|
||||
import com.github.nutomic.controldlna.utility.FileArrayAdapter;
|
||||
|
||||
/**
|
||||
* Shows a list of media servers, allowing to select one for playback.
|
||||
|
@ -179,15 +177,6 @@ public class RendererFragment extends Fragment implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new playlist.
|
||||
*/
|
||||
public void setPlaylist(List<Item> playlist, int start) {
|
||||
mPlaylistAdapter.clear();
|
||||
mPlaylistAdapter.add(playlist);
|
||||
getPlayer().getPlayService().setPlaylist(playlist, start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a media renderer.
|
||||
*/
|
||||
|
@ -266,10 +255,12 @@ public class RendererFragment extends Fragment implements
|
|||
AVTransportVariable.TransportState.class)
|
||||
.getValue()) {
|
||||
case PLAYING:
|
||||
mPlaying = true;
|
||||
mPlayPause.setImageResource(R.drawable.ic_media_pause);
|
||||
mPlayPause.setContentDescription(getResources().
|
||||
getString(R.string.pause));
|
||||
mPlaying = true;
|
||||
mPlaylistAdapter.clear();
|
||||
mPlaylistAdapter.add(getPlayer().getPlayService().getPlaylist());
|
||||
pollTimePosition();
|
||||
enableTrackHighlight();
|
||||
break;
|
||||
|
|
|
@ -49,9 +49,9 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.github.nutomic.controldlna.DeviceArrayAdapter;
|
||||
import com.github.nutomic.controldlna.FileArrayAdapter;
|
||||
import com.github.nutomic.controldlna.gui.MainActivity.OnBackPressedListener;
|
||||
import com.github.nutomic.controldlna.utility.DeviceArrayAdapter;
|
||||
import com.github.nutomic.controldlna.utility.FileArrayAdapter;
|
||||
|
||||
/**
|
||||
* Shows a list of media servers, upon selecting one, allows browsing their
|
||||
|
|
|
@ -1,4 +1,31 @@
|
|||
package com.github.nutomic.controldlna;
|
||||
/*
|
||||
Copyright (c) 2013, Felix Ableitner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.upnp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.service;
|
||||
package com.github.nutomic.controldlna.upnp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -69,9 +69,9 @@ import android.support.v4.app.NotificationCompat;
|
|||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.nutomic.controldlna.LoadImageTask;
|
||||
import com.github.nutomic.controldlna.R;
|
||||
import com.github.nutomic.controldlna.gui.MainActivity;
|
||||
import com.github.nutomic.controldlna.utility.LoadImageTask;
|
||||
|
||||
/**
|
||||
* Background service that handles media playback to a single UPNP media renderer.
|
|
@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.service;
|
||||
package com.github.nutomic.controldlna.upnp;
|
||||
|
||||
import android.os.Binder;
|
||||
|
|
@ -1,4 +1,31 @@
|
|||
package com.github.nutomic.controldlna;
|
||||
/*
|
||||
Copyright (c) 2013, Felix Ableitner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.upnp;
|
||||
|
||||
import org.teleal.cling.android.AndroidUpnpService;
|
||||
import org.teleal.cling.android.AndroidUpnpServiceImpl;
|
|
@ -1,4 +1,31 @@
|
|||
package com.github.nutomic.controldlna;
|
||||
/*
|
||||
Copyright (c) 2013, Felix Ableitner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.upnp;
|
||||
|
||||
import org.teleal.cling.model.action.ActionInvocation;
|
||||
import org.teleal.cling.model.message.UpnpResponse;
|
||||
|
@ -17,8 +44,6 @@ import android.content.ServiceConnection;
|
|||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.github.nutomic.controldlna.service.PlayService;
|
||||
import com.github.nutomic.controldlna.service.PlayServiceBinder;
|
||||
|
||||
/**
|
||||
* Handles connection to PlayService and provides methods related to playback.
|
|
@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna;
|
||||
package com.github.nutomic.controldlna.utility;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -42,7 +42,9 @@ import android.view.ViewGroup;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.nutomic.controldlna.DeviceListener.DeviceListenerCallback;
|
||||
import com.github.nutomic.controldlna.R;
|
||||
import com.github.nutomic.controldlna.upnp.DeviceListener.DeviceListenerCallback;
|
||||
|
||||
|
||||
/**
|
||||
* Displays the devices that are inserted through the RegistryListener (either
|
|
@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna;
|
||||
package com.github.nutomic.controldlna.utility;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -42,6 +42,8 @@ import android.view.ViewGroup;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.nutomic.controldlna.R;
|
||||
|
||||
/**
|
||||
* Allows displaying UPNP media server directory contents in a ListView.
|
||||
*
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
Copyright (c) 2013, Felix Ableitner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.utility;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Handles background task of loading a bitmap by URI.
|
||||
*
|
||||
* @author Felix Ableitner
|
||||
*
|
||||
*/
|
||||
public class LoadImageTask extends AsyncTask<URI, Void, Bitmap> {
|
||||
|
||||
private static final String TAG = "LoadImageTask";
|
||||
|
||||
@Override
|
||||
protected Bitmap doInBackground(URI... uri) {
|
||||
if (uri[0] == null)
|
||||
return null;
|
||||
|
||||
Bitmap bm = null;
|
||||
try {
|
||||
URLConnection conn = new URL(uri[0].toString())
|
||||
.openConnection();
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
bm = BitmapFactory.decodeStream(bis);
|
||||
bis.close();
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Failed to load artwork image", e);
|
||||
}
|
||||
return bm;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Copyright (c) 2013, Felix Ableitner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.github.nutomic.controldlna.utility;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* ImageView that can directly load from a UPNP URI.
|
||||
*
|
||||
* @author Felix Ableitner
|
||||
*
|
||||
*/
|
||||
public class RemoteImageView extends ImageView {
|
||||
|
||||
/**
|
||||
* Assigns the icon as image drawable when it is loaded.
|
||||
*
|
||||
* @author Felix
|
||||
*
|
||||
*/
|
||||
private class AssignImageTask extends LoadImageTask {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bm) {
|
||||
if (bm != null)
|
||||
setImageBitmap(bm);
|
||||
else
|
||||
setImageDrawable(null);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public RemoteImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RemoteImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RemoteImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URI where the image should be loaded from, loads and assigns it.
|
||||
*/
|
||||
public void setImageUri(URI uri) {
|
||||
setImageDrawable(null);
|
||||
new AssignImageTask().execute(uri);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue