From: <kro...@us...> - 2010-11-30 12:17:40
|
Revision: 3988 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3988&view=rev Author: kroko_koenig Date: 2010-11-30 12:17:31 +0000 (Tue, 30 Nov 2010) Log Message: ----------- better structure and code cleanup Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicTab.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/setup.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/splash.java Added Paths: ----------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java Removed Paths: ------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ImageAdapter.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ScrollView.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryItems.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/music.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musichandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturehandler.java Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml 2010-11-30 12:17:31 UTC (rev 3988) @@ -3,13 +3,13 @@ package="mediaportal.remote" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar" android:debuggable="true"> - <activity android:name=".splash" android:label="@string/app_name"> + <activity android:name=".Splash" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - <activity android:name=".main" android:label="@string/app_name"> + <activity android:label="@string/app_name" android:name=".Main"> <intent-filter> <action android:name="android.intent.action.DEFAULT" /> <category android:name="android.intent.category.VIEW" /> @@ -17,17 +17,17 @@ </activity> <activity android:name=".Remote_01"></activity> <activity android:name=".Remote_02"></activity> - <activity android:name=".pictures"></activity> + <activity android:name=".Pictures"></activity> <activity android:name=".picturesfullscreen"></activity> - <activity android:name=".music"></activity> - <activity android:name=".setup"></activity> + <activity android:name=".MusicDir"></activity> + <activity android:name=".Setup"></activity> <activity android:name=".nowplaying"></activity> <activity android:name=".nowplaylist"></activity> - <activity android:name=".musicArtist"></activity> - <activity android:name=".musicAlbum"></activity> - <activity android:name=".musicSong"></activity> - <activity android:name=".musicTab"></activity> - <activity android:name=".musicResults"></activity> + <activity android:name=".MusicArtist"></activity> + <activity android:name=".MusicAlbum"></activity> + <activity android:name=".MusicSong"></activity> + <activity android:name=".MusicTab"></activity> + <activity android:name=".MusicResults"></activity> </application> <uses-sdk android:minSdkVersion="3" /> Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -74,7 +74,6 @@ public static final int btnOk=0x7f050033; public static final int btnPause=0x7f05002b; public static final int btnPlay=0x7f050026; - public static final int btnReturnSetup=0x7f05003b; public static final int btnRight=0x7f050034; public static final int btnSkipBack=0x7f050029; public static final int btnSkipForw=0x7f05002c; @@ -104,6 +103,7 @@ public static final int now_stop=0x7f05001d; public static final int now_title=0x7f05001a; public static final int server_ip=0x7f050039; + public static final int server_macid=0x7f05003b; public static final int server_port=0x7f05003a; public static final int title=0x7f05003c; public static final int widget0=0x7f05000a; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml 2010-11-30 12:17:31 UTC (rev 3988) @@ -13,7 +13,10 @@ <EditText android:id="@+id/server_port" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="8200" android:inputType="number|numberSigned"></EditText> - <Button android:id="@+id/btnReturnSetup" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:text="Return"></Button> + <TextView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:text="MediaPortal MAC Adress"></TextView> + <EditText android:id="@+id/server_macid" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:text="12-34-56-78-90-12" + android:inputType="number|numberSigned"></EditText> </LinearLayout> Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ImageAdapter.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ImageAdapter.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ImageAdapter.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,136 +0,0 @@ -package mediaportal.remote; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import android.content.Context; -import android.graphics.Bitmap; -import android.view.View; -import android.view.ViewGroup; -import android.widget.*; - -import mediaportal.remote.httpHandler; - -public class ImageAdapter extends BaseAdapter { - private Context mContext; - - public ImageAdapter(Context c) { - mContext = c; - } - - public int getCount() { - directoryItems myItems = directoryXmlHandler.getSitesList(); - return myItems.gettitle().size(); - } - - public Object getItem(int position) { - return null; - } - - public long getItemId(int position) { - return 0; - } - - // create a new ImageView for each item referenced by the Adapter - public View getView(int position, View convertView, ViewGroup parent) { - ImageView imageView; - if (convertView == null) { // if it's not recycled, initialize some - // attributes - imageView = new ImageView(mContext); - imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); - imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); - imageView.setPadding(8, 8, 8, 8); - } else { - imageView = (ImageView) convertView; - } - - imageView.setImageBitmap(bmImg[position]); - return imageView; - } - - public static Bitmap[] bmImg; - - public static Bitmap downloadFile(String fileUrl) { - URL myFileUrl = null; - try { - myFileUrl = new URL(fileUrl); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - try { - HttpURLConnection conn = (HttpURLConnection) myFileUrl - .openConnection(); - conn.setReadTimeout(3000); - conn.setDoInput(true); - conn.connect(); - // int length = conn.getContentLength(); - InputStream is = conn.getInputStream(); - - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser sp = null; - try { - sp = spf.newSAXParser(); - } catch (ParserConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - XMLReader reader = null; - try { - reader = sp.getXMLReader(); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - directoryXmlHandler handler = new directoryXmlHandler(); - - reader.setContentHandler(handler); - try { - reader.parse(new InputSource(is)); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - is.close(); - sp.reset(); - - directoryItems myItems = directoryXmlHandler.getSitesList(); - bmImg = new Bitmap[myItems.gettitle().size()]; - - httpHandler h = new httpHandler(); - - for (int i = 0; i < myItems.gettitle().size(); i++) { - String tit = myItems.gettitle().get(i); - // Boolean fold = myItems.getIsFolder().get(i); - - tit = tit + ".thb"; - - bmImg[i] = h.DownloadImage("http://192.6.10.182:8200/pictures/" - + tit); - } - - // bmImg = BitmapFactory.decodeStream(is); - return null; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } -} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import mediaportal.remote.R; +import mediaportal.remote.ReceiveDirectoryXmlHandler.DirItems; +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +public class MusicDir extends Activity { + + private Handler mHandler = new Handler(); + private String actualDir = ""; + + private static ArrayList<ReceiveDirectoryXmlHandler.DirItems> musicList; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.music); + + GridView gridview = (GridView) findViewById(R.id.music_grid); + gridview.setAdapter(new ImageAdapter2(MusicDir.this)); + + /* + * gridview.setOnItemClickListener(new OnItemClickListener() { public + * void onItemClick(AdapterView<?> parent, View v, int position, long + * id) { + * + * // TextView tv = (TextView) v.findViewById(R.id.icon_text); ImageView + * iv = (ImageView) v.findViewById(R.id.icon_image); musicItem item = + * (musicItem) iv.getTag(); + * + * if (item.typ == "item") { ReceiveDirHandler h = + * ReceiveDirHandler.getinstance(); h.selectedMusic = position - 1; } + * + * if (item.typ == "folder") { + * + * musichandler h = musichandler.getinstance(); h.gotodir(item.title); + * + * GridView gridview = (GridView) findViewById(R.id.music_grid); + * gridview.setAdapter(new ImageAdapter2(parent.getContext())); + * + * parent.invalidate(); } + * + * if (item.typ == "oneup") { musichandler h = + * musichandler.getinstance(); h.oneup(); + * + * GridView gridview = (GridView) findViewById(R.id.music_grid); + * gridview.setAdapter(new ImageAdapter2(parent.getContext())); + * + * parent.invalidate(); } + * + * } }); + */ + } + + @Override + public void onStart() { + super.onStart(); + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 100); + } + + private Runnable mUpdateTimeTask = new Runnable() { + public void run() { + update(); + } + }; + + private void update() { + + Log.d("update music dir", "do update"); + + ReceiveDirHandler h = ReceiveDirHandler.getinstance(); + musicList = h.getMusicDir(actualDir); + + if (musicList.size() == 0) { + Toast.makeText(MusicDir.this, "TIME OUT SERVER", Toast.LENGTH_SHORT) + .show(); + } + + GridView gridview = (GridView) findViewById(R.id.music_grid); + gridview.invalidateViews(); + } + + public class ImageAdapter2 extends BaseAdapter { + private Context mContext; + public static final int ACTIVITY_CREATE = 10; + + public ImageAdapter2(Context c) { + mContext = c; + } + + public int getCount() { + if (musicList != null) + return musicList.size() + 1; + else + return 0; + } + + public Object getItem(int position) { + return null; + } + + public long getItemId(int position) { + return 0; + } + + // @Override + // create a new ImageView for each item referenced by the Adapter + public View getView(int position, View convertView, ViewGroup parent) { + View v; + if (convertView == null) { // if it's not recycled, initialize some + // attributes + + if (position > 0) { + position = position - 1; + + DirItems item1 = musicList.get(position); + + String txtName = item1.File; + Boolean isFolder = item1.isFolder; + + LayoutInflater li = LayoutInflater.from(mContext); + v = li.inflate(R.layout.icon, null); + + TextView tv = (TextView) v.findViewById(R.id.icon_text); + tv.setText(txtName); + + ImageView iv = (ImageView) v.findViewById(R.id.icon_image); + if (isFolder) { + iv.setImageResource(R.drawable.folder); + musicItem item = new musicItem(); + item.title = txtName; + item.typ = "folder"; + iv.setTag(item); + } else { + iv.setImageResource(R.drawable.audio); + musicItem item = new musicItem(); + item.title = txtName; + item.typ = "item"; + iv.setTag(item); + } + } else { + LayoutInflater li = LayoutInflater.from(mContext); + v = li.inflate(R.layout.icon, null); + + TextView tv = (TextView) v.findViewById(R.id.icon_text); + tv.setText(".."); + + ImageView iv = (ImageView) v.findViewById(R.id.icon_image); + iv.setImageResource(R.drawable.folderback); + musicItem item = new musicItem(); + item.title = ".."; + item.typ = "oneup"; + iv.setTag(item); + } + + } else { + v = convertView; + } + + return v; + } + } + + public class musicItem { + public String title; + public String typ; + } + +} Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import java.io.IOException; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,34 +1,33 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; import java.util.ArrayList; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - import mediaportal.remote.ReceiveDbXmlHandler.DbItems; public class ReceiveDbHandler { - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - - private static ArrayList<DbItems> Result; private static ReceiveDbHandler instance; - private String _server; - private String _port; - public int selectedMusic; public static ReceiveDbHandler getinstance() { @@ -37,104 +36,28 @@ return instance; } - public void setconnection(String server, String port) { - _server = server; - _port = port; + public ArrayList<DbItems> GetAlbums() { + return fetchData("album.xml"); } - public boolean GetAlbums() { - fetchData("album.xml"); - return true; + public ArrayList<DbItems> GetArtist() { + return fetchData("artist.xml"); } - public boolean GetArtist() { - fetchData("artist.xml"); - return true; + public ArrayList<DbItems> GetSongs() { + return fetchData("song.xml"); } - public boolean GetSongs() { - fetchData("song.xml"); - return true; + public ArrayList<DbItems> GetSongsByArtist(String Artist) { + return fetchData("song.xml?artist=" + Artist); } - - public boolean GetSongsByArtist(String Artist) { - fetchData("song.xml?artist=" + Artist); - return true; - } - public ArrayList<DbItems> GetResult() { - return Result; - } + private ArrayList<DbItems> fetchData(String Data) { - private void fetchData(String Data) { + ReceiveDbXmlHandler handler = new ReceiveDbXmlHandler(); + ReceiveHandler hand = new ReceiveHandler(handler); + hand.readValues("/db_music/" + Data); - Result = new ArrayList<DbItems>(); - - try { - Data = URLEncoder.encode(Data, "UTF-8"); - } catch (UnsupportedEncodingException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - String fileUrl = "http://" + _server + ":" + _port + "/db_music/" - + Data; - - URL myFileUrl = null; - try { - myFileUrl = new URL(fileUrl); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - try { - HttpURLConnection conn = (HttpURLConnection) myFileUrl - .openConnection(); - conn.setConnectTimeout(3000); - conn.setReadTimeout(10000); - conn.setDoInput(true); - conn.connect(); - - InputStream is = conn.getInputStream(); - - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser sp = null; - try { - sp = spf.newSAXParser(); - } catch (ParserConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - XMLReader reader = null; - try { - reader = sp.getXMLReader(); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - ReceiveDbXmlHandler handler = new ReceiveDbXmlHandler(); - - reader.setContentHandler(handler); - try { - reader.parse(new InputSource(is)); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - is.close(); - sp.reset(); - - Result = ReceiveDbXmlHandler.DbList; - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + return handler.DbList; } - } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import java.util.ArrayList; @@ -10,7 +31,8 @@ Boolean currentElement = false; String currentValue = null; - public static ArrayList<DbItems> DbList = new ArrayList<DbItems>(); + public ArrayList<DbItems> DbList = new ArrayList<DbItems>(); + public static class DbItems { public String Title = ""; @@ -18,8 +40,7 @@ public String Album= ""; public String AlbumArtist= ""; public String Track= ""; - public String Rating= ""; - + public String Rating= ""; } private DbItems currentDbItem; Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import mediaportal.remote.ReceiveDirectoryXmlHandler.DirItems; + +public class ReceiveDirHandler { + + private static ReceiveDirHandler instance; + private static String actualDir; + + public static ReceiveDirHandler getinstance() { + if (instance == null) + instance = new ReceiveDirHandler(); + return instance; + } + + public ArrayList<DirItems> getMusicDir(String Dir) { + + return fetchData("/music/" + Dir); + } + + public ArrayList<DirItems> getPictureDir(String Dir) { + + return fetchData("/pictures/" + Dir); + } + + public ArrayList<DirItems> gotodir(String dir) { + actualDir += "/" + dir; + return fetchData(actualDir); + } + + public ArrayList<DirItems> oneup() { + int x = actualDir.lastIndexOf("/"); + if (x >= 0) { + actualDir = actualDir.substring(0, x); + } + return fetchData(actualDir); + } + + private ArrayList<DirItems> fetchData(String Data) { + + ReceiveDirectoryXmlHandler handler = new ReceiveDirectoryXmlHandler(); + ReceiveHandler hand = new ReceiveHandler(handler); + hand.readValues(Data); + + return handler.DirList; + } +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +public class ReceiveDirectoryXmlHandler extends DefaultHandler { + Boolean currentElement = false; + String currentValue = null; + + public ArrayList<DirItems> DirList = new ArrayList<DirItems>(); + + public static class DirItems + { + public boolean isFolder = false; + public String File= ""; + } + private DirItems currentdirItem; + + /** + * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) + */ + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { + currentElement = true; + + currentValue = ""; + if (localName == "Directory") {DirList = new ArrayList<DirItems>(); } + if (localName == "Folder") {currentdirItem = new DirItems(); } + if (localName == "File") {currentdirItem = new DirItems(); } + } + + /** + * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> ) + */ + @Override + public void endElement(String uri, String localName, String qName) + throws SAXException { + + currentElement = false; + + /** set value */ + if (localName == "Folder") { + currentdirItem.isFolder = true; + currentdirItem.File = currentValue; + DirList.add(currentdirItem); + } + if (localName == "File") { + currentdirItem.isFolder = true; + currentdirItem.File = currentValue; + DirList.add(currentdirItem); + } + } + + /** + * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to get + * AndroidPeople Character ) + */ + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + if (currentElement) { + currentValue = new String(ch, start, length); + currentElement = false; + } + + } + +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +public class ReceiveHandler { + + private org.xml.sax.ContentHandler _handler; + + public ReceiveHandler(org.xml.sax.ContentHandler Handler) { + _handler = Handler; + } + + public void readValues(String Url) + { + String fileUrl = "http://" + Settings.Server + ":" + Settings.Port + Url; + + URL myFileUrl = null; + try { + myFileUrl = new URL(fileUrl); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + HttpURLConnection conn = (HttpURLConnection) myFileUrl + .openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(10000); + conn.setDoInput(true); + conn.connect(); + + InputStream is = conn.getInputStream(); + + SAXParserFactory spf = SAXParserFactory.newInstance(); + SAXParser sp = null; + try { + sp = spf.newSAXParser(); + } catch (ParserConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + XMLReader reader = null; + try { + reader = sp.getXMLReader(); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + reader.setContentHandler((org.xml.sax.ContentHandler) _handler); + try { + reader.parse(new InputSource(is)); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + is.close(); + sp.reset(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +} Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import java.io.IOException; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import java.io.IOException; @@ -2,5 +23,3 @@ import java.io.InputStream; - import mediaportal.remote.R; - import android.app.Activity; @@ -12,9 +31,7 @@ import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; -import android.view.View; import android.view.GestureDetector.OnGestureListener; -import android.widget.Button; public class Remote_02 extends Activity implements OnGestureListener { Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ScrollView.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ScrollView.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ScrollView.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,38 +0,0 @@ -package mediaportal.remote; - -import android.content.Context; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.widget.TextView; - -public class ScrollView extends TextView { - - public ScrollView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public ScrollView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ScrollView(Context context) { - super(context); - } - - @Override - protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { - if(focused) - super.onFocusChanged(focused, direction, previouslyFocusedRect); - } - - @Override - public void onWindowFocusChanged(boolean focused) { - if(focused) - super.onWindowFocusChanged(focused); - } - - @Override - public boolean isFocused() { - return true; - } -} \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; public class Settings{ @@ -2,8 +23,6 @@ - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - - public Settings() - { - - } + public static String Server = "192.168.0.30"; + public static String Port = "8200"; + public static String MacId = "11-22-33-44-55-66"; + } Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryItems.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryItems.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryItems.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,26 +0,0 @@ -package mediaportal.remote; - -import java.util.ArrayList; - -/** Contains getter and setter method for variables */ -public class directoryItems { - - /** Variables */ - private ArrayList<String> title = new ArrayList<String>(); - private ArrayList<Boolean> isFolder = new ArrayList<Boolean>(); - - public ArrayList<String> gettitle() { - return title; - } - public void settitle(String title) { - this.title.add(title); - } - - public ArrayList<Boolean> getIsFolder() { - return isFolder; - } - public void setIsFolder(Boolean isFolder) { - this.isFolder.add(isFolder); - } - -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryXmlHandler.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/directoryXmlHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,68 +0,0 @@ -package mediaportal.remote; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -public class directoryXmlHandler extends DefaultHandler { - Boolean currentElement = false; - String currentValue = null; - - public static directoryItems itemList = null; - - public static directoryItems getSitesList() { - return itemList; - } - - public static void setSitesList(directoryItems directoryList) { - directoryXmlHandler.itemList = directoryList; - } - - /** - * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) - */ - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - currentElement = true; - - if (localName == "Directory") { - itemList = new directoryItems(); - } - } - - /** - * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> ) - */ - @Override - public void endElement(String uri, String localName, String qName) - throws SAXException { - - currentElement = false; - - /** set value */ - if (localName == "Folder") { - itemList.setIsFolder(true); - itemList.settitle(currentValue); - } - if (localName == "File") { - itemList.setIsFolder(false); - itemList.settitle(currentValue); - } - } - - /** - * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to get - * AndroidPeople Character ) - */ - @Override - public void characters(char[] ch, int start, int length) - throws SAXException { - if (currentElement) { - currentValue = new String(ch, start, length); - currentElement = false; - } - - } - -} \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -17,7 +17,6 @@ import android.graphics.BitmapFactory; import android.os.Environment; - public class httpHandler { String extStorageDirectory; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import mediaportal.remote.R; @@ -3,4 +24,5 @@ import android.app.Activity; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.view.Menu; @@ -9,18 +31,25 @@ import android.view.View; import android.widget.*; -public class main extends Activity { +public class Main extends Activity { - /** Called when the activity is first created. */ + private static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, MODE_PRIVATE); + + Settings.Server = settings.getString("Server", "192.168.0.30"); + Settings.Port = settings.getString("Port", "8200"); + Settings.MacId = settings.getString("MacId", "11-22-33-44-55-66"); + Button btnPictures = (Button) findViewById(R.id.MainButton1); btnPictures.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), pictures.class); + Intent myIntent = new Intent(view.getContext(), Pictures.class); startActivityForResult(myIntent, 0); } }); @@ -28,7 +57,7 @@ Button btnMusic = (Button) findViewById(R.id.MainButton2); btnMusic.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), musicTab.class); + Intent myIntent = new Intent(view.getContext(), MusicTab.class); startActivityForResult(myIntent, 0); } }); @@ -61,7 +90,7 @@ public boolean onOptionsItemSelected (MenuItem item){ switch (item.getItemId()){ case 111: - Intent myIntent = new Intent(this, setup.class); + Intent myIntent = new Intent(this, Setup.class); startActivityForResult(myIntent, 0); return true; case 112: Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/music.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/music.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/music.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,193 +0,0 @@ -package mediaportal.remote; - -import mediaportal.remote.R; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.BaseAdapter; -import android.widget.GridView; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.AdapterView.OnItemClickListener; - -public class music extends Activity { - - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.music); - /* - requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); - setContentView(R.layout.music); - getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title); - - ((TextView) findViewById(R.id.title)).setText("Music"); - */ - - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - - String HttpServer = settings.getString("Server", "192.168.0.30"); - String HttpPort = settings.getString("Port", "8200"); - - musichandler h = musichandler.getinstance(); - h.setconnection(HttpServer, HttpPort); - h.getrootdirectory(); - - GridView gridview = (GridView) findViewById(R.id.music_grid); - gridview.setAdapter(new ImageAdapter2(music.this)); - - /* - gridview.setOnItemSelectedListener(new OnItemSelectedListener() { - public void onItemSelected(AdapterView<?> arg0, View arg1, - int arg2, long arg3) { - ImageView iv = (ImageView) arg1.findViewById(R.id.icon_image); - musicItem item = (musicItem) iv.getTag(); - - ((TextView) findViewById(R.id.title)).setText(item.title); - } - - public void onNothingSelected(AdapterView<?> arg0) { - // TODO Auto-generated method stub - } - }); - */ - - gridview.setOnItemClickListener(new OnItemClickListener() { - public void onItemClick(AdapterView<?> parent, View v, - int position, long id) { - - // TextView tv = (TextView) v.findViewById(R.id.icon_text); - ImageView iv = (ImageView) v.findViewById(R.id.icon_image); - musicItem item = (musicItem) iv.getTag(); - - if (item.typ == "item") { - musichandler h = musichandler.getinstance(); - h.selectedMusic = position - 1; - - // todo play or transfer - // Intent myIntent = new Intent(v.getContext(), - // picturesfullscreen.class); - // startActivityForResult(myIntent, 0); - } - - if (item.typ == "folder") { - - musichandler h = musichandler.getinstance(); - h.gotodir(item.title); - - GridView gridview = (GridView) findViewById(R.id.music_grid); - gridview.setAdapter(new ImageAdapter2(parent.getContext())); - - parent.invalidate(); - } - - if (item.typ == "oneup") { - musichandler h = musichandler.getinstance(); - h.oneup(); - - GridView gridview = (GridView) findViewById(R.id.music_grid); - gridview.setAdapter(new ImageAdapter2(parent.getContext())); - - parent.invalidate(); - } - - } - }); - } - - public class ImageAdapter2 extends BaseAdapter { - private Context mContext; - public static final int ACTIVITY_CREATE = 10; - - public ImageAdapter2(Context c) { - mContext = c; - } - - public int getCount() { - musichandler h = musichandler.getinstance(); - return h.getmusicItems().gettitle().size() + 1; - } - - public Object getItem(int position) { - return null; - } - - public long getItemId(int position) { - return 0; - } - - // @Override - // create a new ImageView for each item referenced by the Adapter - public View getView(int position, View convertView, ViewGroup parent) { - View v; - if (convertView == null) { // if it's not recycled, initialize some - // attributes - - if (position > 0) { - position = position - 1; - - musichandler h = musichandler.getinstance(); - String txtName = h.getmusicItems().gettitle().get(position); - Boolean isFolder = h.getmusicItems().getIsFolder() - .get(position); - - LayoutInflater li = LayoutInflater.from(mContext); - v = li.inflate(R.layout.icon, null); - TextView tv = (TextView) v.findViewById(R.id.icon_text); - tv.setText(txtName); - ImageView iv = (ImageView) v.findViewById(R.id.icon_image); - - if (isFolder) { - iv.setImageResource(R.drawable.folder); - musicItem item = new musicItem(); - item.title = txtName; - item.typ = "folder"; - iv.setTag(item); - } else { - iv.setImageResource(R.drawable.audio); - musicItem item = new musicItem(); - item.title = txtName; - item.typ = "item"; - iv.setTag(item); - } - } else { - LayoutInflater li = LayoutInflater.from(mContext); - v = li.inflate(R.layout.icon, null); - TextView tv = (TextView) v.findViewById(R.id.icon_text); - tv.setText(".."); - ImageView iv = (ImageView) v.findViewById(R.id.icon_image); - iv.setImageResource(R.drawable.folderback); - musicItem item = new musicItem(); - item.title = ".."; - item.typ = "oneup"; - iv.setTag(item); - } - - } else { - v = convertView; - } - - // imageView.setImageBitmap(bmImg[position]); - return v; - } - } - - public class musicItem { - public String title; - public String typ; - } - -} Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import java.util.ArrayList; @@ -4,40 +25,32 @@ import android.app.Activity; import android.content.Context; -import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.os.Handler; import android.util.Log; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ListView; -import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; -public class musicAlbum extends Activity { +public class MusicAlbum extends Activity { - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; private Handler mHandler = new Handler(); private static ArrayList<ReceiveDbXmlHandler.DbItems> albumList; - private View menuInstance = null; - public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.music_album); ListView l1 = (ListView) findViewById(R.id.list_album); - l1.setAdapter(new EfficientAdapter(musicAlbum.this)); + l1.setAdapter(new EfficientAdapter(MusicAlbum.this)); ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); l1.setDivider(divcolor); @@ -57,7 +70,7 @@ super.onStart(); mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 1000); + mHandler.postDelayed(mUpdateTimeTask, 100); } private Runnable mUpdateTimeTask = new Runnable() { @@ -70,23 +83,14 @@ Log.d("update album", "do update"); - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - - String HttpServer = settings.getString("Server", "192.168.0.30"); - String HttpPort = settings.getString("Port", "8200"); - ReceiveDbHandler handler = ReceiveDbHandler.getinstance(); - handler.setconnection(HttpServer, HttpPort); - boolean result = handler.GetAlbums(); + albumList = handler.GetAlbums(); - if (!result) { - Toast.makeText(musicAlbum.this, "TIME OUT SERVER", + if (albumList.size() == 0) { + Toast.makeText(MusicAlbum.this, "TIME OUT SERVER", Toast.LENGTH_LONG).show(); } - albumList = handler.GetResult(); - ListView l1 = (ListView) findViewById(R.id.list_album); l1.invalidateViews(); } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-11-30 07:11:25 UTC (rev 3987) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-11-30 12:17:31 UTC (rev 3988) @@ -1,11 +1,30 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + package mediaportal.remote; import java.util.ArrayList; - import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.graphics.Color; import android.graphic... [truncated message content] |