Skip to content

Commit 8f7f807

Browse files
author
Chris Bellew
committed
[Chromecast] Fixed crash when using a shortcut with a Chromecast specified as the client. Fixed pause button. Fixed bug that caused client selector to show up again after a client is selected before the client scan is done.
1 parent 4f48820 commit 8f7f807

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.atomjack.vcfp.Preferences;
1717
import com.atomjack.vcfp.R;
1818
import com.atomjack.vcfp.ScanHandler;
19+
import com.atomjack.vcfp.UriDeserializer;
1920
import com.atomjack.vcfp.UriSerializer;
2021
import com.atomjack.vcfp.VoiceControlForPlexApplication;
2122
import com.atomjack.vcfp.model.PlexClient;
@@ -34,11 +35,12 @@
3435
public class ShortcutProviderActivity extends Activity {
3536
private LocalScan localScan;
3637

37-
private Gson gson = new Gson();
3838
private Gson gsonWrite = new GsonBuilder()
3939
.registerTypeAdapter(Uri.class, new UriSerializer())
4040
.create();
41-
41+
private Gson gsonRead = new GsonBuilder()
42+
.registerTypeAdapter(Uri.class, new UriDeserializer())
43+
.create();
4244
private BroadcastReceiver gdmReceiver = new GDMReceiver();
4345

4446
private PlexServer server;
@@ -71,8 +73,8 @@ public void onDeviceSelected(PlexDevice device, boolean _resume) {
7173

7274
Type serverType = new TypeToken<ConcurrentHashMap<String, PlexServer>>(){}.getType();
7375
Type clientType = new TypeToken<HashMap<String, PlexClient>>(){}.getType();
74-
servers = gson.fromJson(VoiceControlForPlexApplication.getInstance().prefs.get(Preferences.SAVED_SERVERS, ""), serverType);
75-
clients = gson.fromJson(VoiceControlForPlexApplication.getInstance().prefs.get(Preferences.SAVED_CLIENTS, ""), clientType);
76+
servers = gsonRead.fromJson(VoiceControlForPlexApplication.getInstance().prefs.get(Preferences.SAVED_SERVERS, ""), serverType);
77+
clients = gsonRead.fromJson(VoiceControlForPlexApplication.getInstance().prefs.get(Preferences.SAVED_CLIENTS, ""), clientType);
7678

7779
Logger.d("server: %s", servers);
7880
boolean didScan = false;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,10 @@ protected void onResume() {
388388
public void onSubscribed(PlexClient _client) {
389389
Logger.d("VCFPActivity: onSubscribed: %s", _client);
390390
mClient = _client;
391+
392+
subscribing = false;
391393
try {
392394
setCastIconActive();
393-
subscribing = false;
394395
} catch (Exception e) {
395396
e.printStackTrace();
396397
}

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,27 +151,30 @@ public int onStartCommand(Intent intent, int flags, int startId) {
151151
Logger.d("action: %s", intent.getAction());
152152
Logger.d("scan type: %s", intent.getStringExtra(VoiceControlForPlexApplication.Intent.SCAN_TYPE));
153153
if(intent.getAction() != null && intent.getAction().equals(VoiceControlForPlexApplication.Intent.GDMRECEIVE)) {
154-
if(intent.getStringExtra(VoiceControlForPlexApplication.Intent.SCAN_TYPE).equals(VoiceControlForPlexApplication.Intent.SCAN_TYPE_SERVER)) {
155-
// We just scanned for servers and are returning from that, so set the servers we found
156-
// and then figure out which mClient to play to
157-
Logger.d("Got back from scanning for servers.");
158-
videoPlayed = false;
159-
plexmediaServers = VoiceControlForPlexApplication.servers;
160-
didServerScan = true;
161-
setClient();
162-
} else if(intent.getStringExtra(VoiceControlForPlexApplication.Intent.SCAN_TYPE).equals(VoiceControlForPlexApplication.Intent.SCAN_TYPE_CLIENT)) {
163-
// Got back from mClient scan, so set didClientScan to true so we don't do this again, and save the clients we got, then continue
164-
didClientScan = true;
165-
ArrayList<PlexClient> cs = intent.getParcelableArrayListExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENTS);
166-
if(cs != null) {
167-
VoiceControlForPlexApplication.clients = new HashMap<String, PlexClient>();
168-
for (PlexClient c : cs) {
169-
VoiceControlForPlexApplication.clients.put(c.name, c);
170-
}
171-
clients = (HashMap) VoiceControlForPlexApplication.clients;
172-
clients.putAll(VoiceControlForPlexApplication.castClients);
173-
}
174-
startup();
154+
Class receivedClass = (Class)intent.getSerializableExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLASS);
155+
if(receivedClass == PlexSearchService.class) {
156+
if (intent.getStringExtra(VoiceControlForPlexApplication.Intent.SCAN_TYPE).equals(VoiceControlForPlexApplication.Intent.SCAN_TYPE_SERVER)) {
157+
// We just scanned for servers and are returning from that, so set the servers we found
158+
// and then figure out which mClient to play to
159+
Logger.d("Got back from scanning for servers.");
160+
videoPlayed = false;
161+
plexmediaServers = VoiceControlForPlexApplication.servers;
162+
didServerScan = true;
163+
setClient();
164+
} else if (intent.getStringExtra(VoiceControlForPlexApplication.Intent.SCAN_TYPE).equals(VoiceControlForPlexApplication.Intent.SCAN_TYPE_CLIENT)) {
165+
// Got back from mClient scan, so set didClientScan to true so we don't do this again, and save the clients we got, then continue
166+
didClientScan = true;
167+
ArrayList<PlexClient> cs = intent.getParcelableArrayListExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENTS);
168+
if (cs != null) {
169+
VoiceControlForPlexApplication.clients = new HashMap<String, PlexClient>();
170+
for (PlexClient c : cs) {
171+
VoiceControlForPlexApplication.clients.put(c.name, c);
172+
}
173+
clients = (HashMap) VoiceControlForPlexApplication.clients;
174+
clients.putAll(VoiceControlForPlexApplication.castClients);
175+
}
176+
startup();
177+
}
175178
}
176179
} else {
177180
queryText = null;
-11 Bytes
Loading

Voice Control For Plex/src/main/res/xml/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<changelog>
3+
<release version="1.9.2" versioncode="28">
4+
<change>[Chromecast] Fixed rewind/fast forward buttons.</change>
5+
<change>[Chromecast] Fixed crash when using a shortcut with a Chromecast specified as the client.</change>
6+
<change>Bug fixes.</change>
7+
</release>
38
<release version="1.9.0" versioncode="26">
49
<change>Added Chromecast support.</change>
510
<change>Updated now playing screen to be a full fledged remote control.</change>

0 commit comments

Comments
 (0)