From: <Rol...@us...> - 2010-12-16 20:31:25
|
Revision: 4039 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4039&view=rev Author: Rollsroyc3 Date: 2010-12-16 20:31:18 +0000 (Thu, 16 Dec 2010) Log Message: ----------- updated swipe, added alertdialog, pause and resume to slideshow. Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java 2010-12-16 16:55:31 UTC (rev 4038) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java 2010-12-16 20:31:18 UTC (rev 4039) @@ -29,7 +29,9 @@ import mediaportal.remote.R; import mediaportal.remote.ReceiveDirectoryXmlHandler.DirItems; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; @@ -48,6 +50,7 @@ import android.view.WindowManager; import android.view.ContextMenu.ContextMenuInfo; import android.view.GestureDetector.OnGestureListener; +import android.view.View.OnCreateContextMenuListener; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -74,58 +77,54 @@ WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.picturesfullscreen); - ImageView imagev = (ImageView) findViewById(R.id.ImageView01); - //registerForContextMenu(imagev); - - gestureScanner = new GestureDetector(this); - + + gestureScanner = new GestureDetector(picturesfullscreen.this); + new setPicture().execute(); - + } - - - - private class setPicture extends AsyncTask<String, Void, Void> { - private final ProgressDialog dialog = new ProgressDialog(picturesfullscreen.this); - DirItems item = pictures.pictureList.get(pictures.selectedPicture); - - // can use UI thread here - protected void onPreExecute() { - this.dialog.setMessage("Loading..."); - this.dialog.show(); - } - - // automatically done on worker thread (separate from UI thread) - protected Void doInBackground(final String... args) { - if (!item.isFolder) { - httpHandler http = new httpHandler(); - String file = "http://" + Settings.Server + ":" + Settings.Port - + "/pictures/"; - file += pictures.actualDir + item.File; - item.Picture = http.DownloadImage(file.replaceAll(" ", "%20")); - } - - return null; - } - - // can use UI thread here - protected void onPostExecute(final Void unused) { - if (this.dialog.isShowing()) { - this.dialog.dismiss(); - } - - if (item.isFolder != true){ - ImageView imagev = (ImageView) findViewById(R.id.ImageView01); - imagev.setImageBitmap(item.Picture); - TextView txt = (TextView) findViewById(R.id.full_text); - txt.setText(item.File); - } - } - } - + private class setPicture extends AsyncTask<String, Void, Void> { + private final ProgressDialog dialog = new ProgressDialog(picturesfullscreen.this); + DirItems item = pictures.pictureList.get(pictures.selectedPicture); + // can use UI thread here + protected void onPreExecute() { + this.dialog.setMessage("Loading..."); + this.dialog.show(); + } + + // automatically done on worker thread (separate from UI thread) + protected Void doInBackground(final String... args) { + if (!item.isFolder) { + httpHandler http = new httpHandler(); + String file = "http://" + Settings.Server + ":" + Settings.Port + + "/pictures/"; + file += pictures.actualDir + item.File; + item.Picture = http.DownloadImage(file.replaceAll(" ", "%20")); + } + + return null; + } + + // can use UI thread here + protected void onPostExecute(final Void unused) { + if (this.dialog.isShowing()) { + this.dialog.dismiss(); + } + + if (item.isFolder != true){ + ImageView imagev = (ImageView) findViewById(R.id.ImageView01); + imagev.setImageBitmap(item.Picture); + TextView txt = (TextView) findViewById(R.id.full_text); + txt.setText(item.File); + } + + } + } + + @Override public void onStart() { super.onStart(); @@ -145,18 +144,18 @@ pictures.selectedPicture++; else pictures.selectedPicture = 0; - - new setPicture().execute(); + + new setPicture().execute(); } else { String req = "http://" + Settings.Server + ":" - + Settings.Port + "/random/pictures/random.jpg"; + + Settings.Port + "/random/pictures/random.jpg"; httpHandler handler = new httpHandler(); Bitmap pic = handler.DownloadImage(req); ImageView imagev = (ImageView) findViewById(R.id.ImageView01); imagev.setImageBitmap(pic); - + TextView txt = (TextView) findViewById(R.id.full_text); txt.setText("Random slide show"); } @@ -169,78 +168,27 @@ @Override public void onPause() { super.onPause(); - SlideshowPaused = true; + SlideshowPaused = true; mHandler.removeCallbacks(mUpdateTimeTask); } - - - @Override - protected void onResume() { - super.onResume(); - SlideshowPaused = false; - mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, SlideInterval); - } - - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) { - super.onCreateContextMenu(menu, v, menuInfo); - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.picturefullscreenmenu, menu); - if (slideShow) { - if (randomShow) { - MenuItem item = menu.findItem(R.id.rslide); - item.setChecked(slideShow); - } else { - MenuItem item = menu.findItem(R.id.slide); - item.setChecked(slideShow); - } - } - } - @Override - public boolean onContextItemSelected(MenuItem item) { - - String title = (String) item.getTitle(); - - if (title.compareTo("Save to sd card") == 0) { - SavetoSDCard(); - return true; - } else if (title.compareTo("Open in browser") == 0) { - OpenURL(); - return true; - } else if (title.compareTo("Send Picture") == 0) { - SendPicture(); - return true; - } else if (title.compareTo("Slide show") == 0) { - if ((slideShow == false) || (slideShow && randomShow)) { - slideShow = true; - randomShow = false; - } else { - slideShow = false; - } - return true; - } else if (title.compareTo("Random slide show") == 0) { - if ((slideShow == false) || (slideShow && !randomShow)) { - slideShow = true; - randomShow = true; - } else { - slideShow = false; - } - return true; - } - return false; + protected void onResume() { + super.onResume(); + SlideshowPaused = false; + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, SlideInterval); } + // **************** // Menu Functions // ****************** private void OpenURL() { DirItems item = pictures.pictureList.get(pictures.selectedPicture); String file = "http://" + Settings.Server + ":" + Settings.Port - + "/pictures/"; + + "/pictures/"; file += pictures.actualDir + item.File; String url = file.replaceAll(" ", "%20"); Intent i = new Intent(Intent.ACTION_VIEW); @@ -301,21 +249,20 @@ picMessageIntent.setType("image/jpeg"); picMessageIntent.putExtra(Intent.EXTRA_STREAM, item.Picture); startActivity(Intent.createChooser(picMessageIntent, - "Send picture using:")); + "Send picture using:")); } catch (Exception e) { Log.e("Debug", "SendPicture " + e.getMessage().toString() + " |||| " + e.getLocalizedMessage().toString()); // e.printStackTrace(); } } - - + + @Override public boolean onTouchEvent(MotionEvent me) { - this.gestureScanner.onTouchEvent(me); - return super.onTouchEvent(me); + return gestureScanner.onTouchEvent(me); } - + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { @@ -342,8 +289,8 @@ pictures.selectedPicture--; new setPicture().execute(); } else - Toast.makeText(this, "reached end -", - Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "reached end -", + Toast.LENGTH_SHORT).show(); return true; } } catch (Exception e) { @@ -357,6 +304,54 @@ } public void onLongPress(MotionEvent arg0) { + String slidestatus; + String randomslidestatus; + + if (slideShow == true) + slidestatus = "Stop slideshow"; + else + slidestatus = "Start slideshow"; + + if (randomShow == true) + randomslidestatus = "Stop random slideshow"; + else + randomslidestatus = "Start random slideshow"; + + + final CharSequence[] items = { "Save to sd card", "Open in browser", + "Send Picture", slidestatus ,randomslidestatus, "Cancel" }; + + AlertDialog.Builder builder = new AlertDialog.Builder(picturesfullscreen.this); + builder.setTitle("Picture optoins"); + builder.setItems(items, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int item) { + switch (item) { + case 0: + SavetoSDCard(); + break; + case 1: + OpenURL(); + break; + case 2: + SendPicture(); + break; + case 3: + if (slideShow == true) + slideShow = false; + else + slideShow = true; + break; + case 4: + if (randomShow == true) + randomShow = false; + else + randomShow = true; + break; + } + } + }); + AlertDialog alert = builder.create(); + alert.show(); } public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, @@ -372,16 +367,16 @@ if (SlideshowPaused == false) { onPause(); - Toast.makeText(this, "Pause", - Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "Pause slideshow", + Toast.LENGTH_SHORT).show(); return true; } else { - onResume(); - Toast.makeText(this, "Play", - Toast.LENGTH_SHORT).show(); - return true; + onResume(); + Toast.makeText(this, "Resume slideshow", + Toast.LENGTH_SHORT).show(); + return true; } } else @@ -389,7 +384,7 @@ return false; } } - - + + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |