resolve occasional NPE

This commit is contained in:
sonora 2016-07-06 06:07:18 +02:00
parent a62b4b6bd2
commit da731a56b5

View file

@ -144,19 +144,21 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
i.putExtra("messageType", PEBBLE_ALERT);
i.putExtra("sender", "OsmAnd");
i.putExtra("notificationData", notificationData);
mTtsContext.sendBroadcast(i);
if (mTtsContext != null) {
mTtsContext.sendBroadcast(i);
log.info("Send message to pebble failed" + bld.toString());
}
log.info("Send message to pebble " + bld.toString());
}
private void initializeEngine(final Context ctx, final Activity act)
{
if (mTts != null && mTtsContext != ctx) {
if (mTtsContext != ctx) {
internalClear();
}
if (mTts == null) {
mTtsContext = ctx;
ttsRequests = 0;
final float speechRate = cSpeechRate;
mTts = new TextToSpeech(ctx, new OnInitListener() {
@Override
@ -235,10 +237,10 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
private void internalClear() {
if (mTts != null) {
mTts.shutdown();
mTtsContext = null;
mTts = null;
ttsRequests = 0;
}
mTtsContext = null;
ttsRequests = 0;
}
@Override