|
69 | 69 | import com.google.android.material.floatingactionbutton.FloatingActionButton; |
70 | 70 | import com.google.android.material.snackbar.Snackbar; |
71 | 71 |
|
| 72 | +import androidx.activity.EdgeToEdge; |
72 | 73 | import androidx.annotation.NonNull; |
73 | 74 | import androidx.appcompat.app.AlertDialog; |
74 | 75 | import androidx.appcompat.app.AppCompatDialogFragment; |
@@ -232,6 +233,9 @@ public void onCreate(Bundle savedInstanceState) { |
232 | 233 | super.onCreate(savedInstanceState); |
233 | 234 | if (BuildConfig.DEBUG) |
234 | 235 | Log.d(tag, "onCreate"); |
| 236 | + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {//zzedge-2-edge |
| 237 | + EdgeToEdge.enable(this);//importante: deve essere eseguito prima di setContentView() |
| 238 | + } |
235 | 239 |
|
236 | 240 | setContentView(R.layout.main); |
237 | 241 |
|
@@ -472,26 +476,27 @@ public boolean onOptionsItemSelected(MenuItem item) { |
472 | 476 | RSSFeed feed = (RSSFeed) is.readObject(); |
473 | 477 | if ((feed != null) && mTts.checkTTS(feed.getLanguage(pref_lang))) { |
474 | 478 | List<RSSItem> items = feed.getAllItems(); |
475 | | - String[] segments = new String[items.size()]; |
476 | | - int k = 0; |
477 | | - boolean smart_titles = prefs.getBoolean(PREF_SMART_TITLES, false); |
478 | | - for (RSSItem ritem : items) { |
479 | | - segments[k++] = ritem.getTitle(smart_titles); |
480 | | - } |
481 | | - AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
| 479 | + if (!items.isEmpty()) { |
| 480 | + String[] segments = new String[items.size()]; |
| 481 | + int k = 0; |
| 482 | + boolean smart_titles = prefs.getBoolean(PREF_SMART_TITLES, false); |
| 483 | + for (RSSItem ritem : items) { |
| 484 | + segments[k++] = ritem.getTitle(smart_titles); |
| 485 | + } |
| 486 | + AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
482 | 487 | // Request audio focus for playback |
483 | | - if (am != null) { |
484 | | - int result = am.requestAudioFocus(this, |
485 | | - AudioManager.STREAM_MUSIC,// Use the music stream. |
486 | | - AudioManager.AUDIOFOCUS_GAIN);// Request permanent focus. |
| 488 | + if (am != null) { |
| 489 | + int result = am.requestAudioFocus(this, |
| 490 | + AudioManager.STREAM_MUSIC,// Use the music stream. |
| 491 | + AudioManager.AUDIOFOCUS_GAIN);// Request permanent focus. |
487 | 492 |
|
488 | | - if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { |
489 | | - // Start playback. |
| 493 | + if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { |
| 494 | + // Start playback. |
| 495 | + } |
490 | 496 | } |
| 497 | + if (mTts.speakSegments(segments)) |
| 498 | + item.setIcon(R.drawable.ic_stop_white_36dp);//play |
491 | 499 | } |
492 | | - if (mTts.speakSegments(segments)) |
493 | | - item.setIcon(R.drawable.ic_stop_white_36dp);//play |
494 | | - |
495 | 500 | } |
496 | 501 | } catch (IOException e) { |
497 | 502 | //do nothing |
|
0 commit comments