Skip to content
Permalink
Browse files

* Use m.imdb.com instaed of www.imdb.com

* Factor out some stuff to a new "IntenFactory"
  • Loading branch information...
sreichholf committed Jun 4, 2011
1 parent b1720c3 commit 01a68879066b210e4eaac62003341729be45ccf7
@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="net.reichholf.dreamdroid"
android:installLocation="auto"
android:versionName="0.9.6.8" android:versionCode="100">
android:versionCode="101" android:versionName="0.9.7b1">

<uses-sdk
android:minSdkVersion="4" android:maxSdkVersion="12" android:targetSdkVersion="4"></uses-sdk>
@@ -80,6 +80,6 @@
android:name="android.app.default_searchable"
android:value=".activities.SearchEpgActivity" ></meta-data>
<activity android:name=".activities.ExtrasActivity"></activity>
<activity android:name=".activities.DreamDroidPreferenceActivity"></activity>
<activity android:name="activities.DreamDroidPreferenceActivity"></activity>
</application>
</manifest>
@@ -28,9 +28,7 @@

import android.app.Activity;
import android.app.SearchManager;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.KeyEvent;
@@ -291,22 +289,6 @@ protected void updateProgress(String progress){
setProgressBarIndeterminateVisibility(true);
}

/**
* @param event
*/
protected void queryImdb(ExtendedHashMap event){
Intent intent = new Intent(Intent.ACTION_VIEW);
String uriString = "imdb:///find?q=" + event.getString(Event.EVENT_TITLE);
intent.setData(Uri.parse(uriString));
try{
startActivity(intent);
} catch(ActivityNotFoundException anfex) {
uriString = "http://www.imdb.com/find?q=" + event.getString(Event.EVENT_TITLE);
intent.setData(Uri.parse(uriString));
startActivity(intent);
}
}

/**
* @param event
*/
@@ -15,7 +15,7 @@
import net.reichholf.dreamdroid.helpers.enigma2.SimpleResult;
import net.reichholf.dreamdroid.helpers.enigma2.Timer;
import net.reichholf.dreamdroid.helpers.enigma2.requesthandler.impl.TimerAddByEventIdRequestHandler;

import net.reichholf.dreamdroid.intents.IntentFactory;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
@@ -98,7 +98,7 @@ public void onClick(View v) {
buttonIMDb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
queryImdb(mCurrentItem);
startActivity( IntentFactory.getIMDbQueryIntent(mCurrentItem) );
dialog.dismiss();
}
});
@@ -15,7 +15,6 @@
import net.reichholf.dreamdroid.helpers.ExtendedHashMap;
import net.reichholf.dreamdroid.helpers.Python;
import net.reichholf.dreamdroid.helpers.SimpleHttpClient;
import net.reichholf.dreamdroid.helpers.enigma2.Event;
import net.reichholf.dreamdroid.helpers.enigma2.SimpleResult;
import net.reichholf.dreamdroid.helpers.enigma2.Volume;
import net.reichholf.dreamdroid.helpers.enigma2.requesthandler.ListRequestHandler;
@@ -27,9 +26,7 @@
import org.apache.http.message.BasicNameValuePair;

import android.app.ListActivity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.KeyEvent;
@@ -233,22 +230,6 @@ protected void onPostExecute(Boolean result) {
onSimpleResult(result, mResult);
}
}

/**
* @param event
*/
protected void queryImdb(ExtendedHashMap event){
Intent intent = new Intent(Intent.ACTION_VIEW);
String uriString = "imdb:///find?q=" + event.getString(Event.EVENT_TITLE);
intent.setData(Uri.parse(uriString));
try{
startActivity(intent);
} catch(ActivityNotFoundException anfex) {
uriString = "http://www.imdb.com/find?q=" + event.getString(Event.EVENT_TITLE);
intent.setData(Uri.parse(uriString));
startActivity(intent);
}
}

protected class SetVolumeTask extends AsyncTask<ArrayList<NameValuePair>, Void, Boolean> {
private ExtendedHashMap mVolume;
@@ -17,6 +17,7 @@
import net.reichholf.dreamdroid.helpers.enigma2.Service;
import net.reichholf.dreamdroid.helpers.enigma2.Timer;
import net.reichholf.dreamdroid.helpers.enigma2.requesthandler.impl.TimerAddByEventIdRequestHandler;
import net.reichholf.dreamdroid.intents.IntentFactory;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
@@ -29,8 +30,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -377,7 +378,7 @@ public void onClick(View v) {
buttonIMDb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
queryImdb(mCurrentItem);
startActivity( IntentFactory.getIMDbQueryIntent(mCurrentItem) );
dialog.dismiss();
}
});
@@ -20,6 +20,7 @@
import net.reichholf.dreamdroid.helpers.enigma2.URIStore;
import net.reichholf.dreamdroid.helpers.enigma2.requesthandler.impl.MovieDeleteRequestHandler;
import net.reichholf.dreamdroid.helpers.enigma2.requesthandler.impl.MovieListRequestHandler;
import net.reichholf.dreamdroid.intents.IntentFactory;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@@ -338,6 +339,12 @@ public void onClick(DialogInterface dialog, int which) {
return dialog;
}

/**
* @param v
* @param position
* @param id
* @param isLong
*/
private void onListItemClick(View v, int position, long id, boolean isLong){
mMovie = mMapList.get(position);
boolean isInsta = DreamDroid.SP.getBoolean("instant_zap", false);
@@ -369,7 +376,7 @@ public void onClick(DialogInterface dialog, int which) {
startActivity(intent);
break;
case 3:
streamFile(mMovie.getString(Movie.FILE_NAME));
startActivity( IntentFactory.getStreamFileIntent(mMovie.getString(Movie.FILE_NAME)) );
break;
default:
return;
@@ -421,21 +428,6 @@ protected void onSimpleResult(boolean success, ExtendedHashMap result) {
}
}

/**
* @param ref
* A ServiceReference
*/
private void streamFile(String fileName) {
Intent intent = new Intent(Intent.ACTION_VIEW);
SimpleHttpClient shc = SimpleHttpClient.getInstance();
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("file", fileName));
String uriString = shc.buildStreamUrl(URIStore.FILE, params);

intent.setDataAndType(Uri.parse(uriString), "video/*");
startActivity(intent);
}

/**
* Reload the list of movies
*/
@@ -14,6 +14,7 @@
import net.reichholf.dreamdroid.helpers.ExtendedHashMap;
import net.reichholf.dreamdroid.helpers.enigma2.Event;
import net.reichholf.dreamdroid.helpers.enigma2.Service;
import net.reichholf.dreamdroid.intents.IntentFactory;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@@ -22,10 +23,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -401,19 +400,6 @@ public void openEpg(String ref, String nam) {
startActivity(intent);
}

/**
* @param ref
* A ServiceReference
*/
private void streamService(String ref) {
Intent intent = new Intent(Intent.ACTION_VIEW);
String uriString = "http://" + DreamDroid.PROFILE.getStreamHost().trim() + ":8001/" + ref;
Log.i(DreamDroid.LOG_TAG, "Streaming URL set to '" + uriString + "'");

intent.setDataAndType(Uri.parse(uriString), "video/*");
startActivity(intent);
}

private void onListItemClick(View v, int position, long id, boolean isLong) {
mCurrentItem = mMapList.get(position);
final String ref = mCurrentItem.getString(Event.SERVICE_REFERENCE);
@@ -483,7 +469,7 @@ public void onClick(DialogInterface dialog, int which) {
break;

case 3:
streamService(ref);
startActivity( IntentFactory.getStreamServiceIntent(ref) );
break;
}
}
@@ -0,0 +1,73 @@
/* © 2010 Stephan Reichholf <stephan at reichholf dot net>
*
* Licensed under the Create-Commons Attribution-Noncommercial-Share Alike 3.0 Unported
* http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

package net.reichholf.dreamdroid.intents;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import net.reichholf.dreamdroid.DreamDroid;
import net.reichholf.dreamdroid.helpers.ExtendedHashMap;
import net.reichholf.dreamdroid.helpers.SimpleHttpClient;
import net.reichholf.dreamdroid.helpers.enigma2.Event;
import net.reichholf.dreamdroid.helpers.enigma2.URIStore;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

/**
* @author sre
*
*/
public class IntentFactory {
/**
* @param event
*/
public static Intent getIMDbQueryIntent(ExtendedHashMap event){
Intent intent = new Intent(Intent.ACTION_VIEW);
String uriString = "imdb:///find?q=" + event.getString(Event.EVENT_TITLE);
intent.setData(Uri.parse(uriString));
try{
return intent;
} catch(ActivityNotFoundException anfex) {
uriString = "http://m.imdb.com/find?q=" + event.getString(Event.EVENT_TITLE);
intent.setData(Uri.parse(uriString));
return intent;
}
}

/**
* @param ref
* A ServiceReference
*/
public static Intent getStreamServiceIntent(String ref) {
Intent intent = new Intent(Intent.ACTION_VIEW);
String uriString = "http://" + DreamDroid.PROFILE.getStreamHost().trim() + ":8001/" + ref;
Log.i(DreamDroid.LOG_TAG, "Streaming URL set to '" + uriString + "'");

intent.setDataAndType(Uri.parse(uriString), "video/*");

return intent;
}

/**
* @param ref
* A ServiceReference
*/
public static Intent getStreamFileIntent(String fileName) {
Intent intent = new Intent(Intent.ACTION_VIEW);
SimpleHttpClient shc = SimpleHttpClient.getInstance();
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("file", fileName));
String uriString = shc.buildStreamUrl(URIStore.FILE, params);

intent.setDataAndType(Uri.parse(uriString), "video/*");
return intent;
}
}

0 comments on commit 01a6887

Please sign in to comment.
You can’t perform that action at this time.