Skip to content

Commit 4f48820

Browse files
author
Chris Bellew
committed
[Chromecast] Fixed crash when using a shortcut which has a Chromecast specified as the client.
1 parent 2ead548 commit 4f48820

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Voice Control For Plex/src/main/java/com/atomjack/vcfp/activities/ShortcutProviderActivity.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.DialogInterface;
77
import android.content.Intent;
88
import android.content.IntentFilter;
9+
import android.net.Uri;
910
import android.os.Bundle;
1011
import android.support.v4.content.LocalBroadcastManager;
1112

@@ -15,11 +16,13 @@
1516
import com.atomjack.vcfp.Preferences;
1617
import com.atomjack.vcfp.R;
1718
import com.atomjack.vcfp.ScanHandler;
19+
import com.atomjack.vcfp.UriSerializer;
1820
import com.atomjack.vcfp.VoiceControlForPlexApplication;
1921
import com.atomjack.vcfp.model.PlexClient;
2022
import com.atomjack.vcfp.model.PlexDevice;
2123
import com.atomjack.vcfp.model.PlexServer;
2224
import com.google.gson.Gson;
25+
import com.google.gson.GsonBuilder;
2326
import com.google.gson.reflect.TypeToken;
2427

2528
import java.lang.reflect.Type;
@@ -32,6 +35,9 @@ public class ShortcutProviderActivity extends Activity {
3235
private LocalScan localScan;
3336

3437
private Gson gson = new Gson();
38+
private Gson gsonWrite = new GsonBuilder()
39+
.registerTypeAdapter(Uri.class, new UriSerializer())
40+
.create();
3541

3642
private BroadcastReceiver gdmReceiver = new GDMReceiver();
3743

@@ -107,9 +113,9 @@ private void createShortcut(boolean use_current) {
107113

108114
Intent launchIntent = new Intent(this, ShortcutActivity.class);
109115
if(!use_current) {
110-
Logger.d("setting mClient to %s", client.name);
111-
launchIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_SERVER, gson.toJson(server));
112-
launchIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENT, gson.toJson(client));
116+
Logger.d("setting client to %s", client.name);
117+
launchIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_SERVER, gsonWrite.toJson(server));
118+
launchIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENT, gsonWrite.toJson(client));
113119
launchIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_RESUME, resume);
114120
String label = server.name.equals(client.name) ? server.name : (server.owned ? server.name : server.sourceTitle) + "/" + client.name;
115121
sendIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);

Voice Control For Plex/src/main/java/com/atomjack/vcfp/services/PlexSearchService.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ public int onStartCommand(Intent intent, int flags, int startId) {
146146
Logger.d("CAST MANAGER IS SUBSCRIBED");
147147
}
148148

149-
// TODO: Detect network connection here
150-
// if(!VoiceControlForPlexApplication.isWifiConnected(this)) {
151-
// feedback.e(getResources().getString(R.string.no_wifi_connection_message));
152-
// return Service.START_NOT_STICKY;
153-
// }
154-
155149
currentNetworkState = VCFPActivity.NetworkState.getCurrentNetworkState(this);
156150

157151
Logger.d("action: %s", intent.getAction());

0 commit comments

Comments
 (0)