optimisation
This commit is contained in:
@@ -38,6 +38,8 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final int WRITE_EXTERNAL_STORAGE_RC = 100;
|
||||
@@ -62,7 +64,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private DrawerLayout drawerLayout;
|
||||
private Toolbar toolbar;
|
||||
|
||||
@SuppressLint({"SetJavaScriptEnabled", "WrongViewCast", "JavascriptInterface"})
|
||||
@SuppressLint({"SetJavaScriptEnabled", "WrongViewCast", "JavascriptInterface", "MissingInflatedId"})
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -73,7 +75,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
|
||||
// Navigation drawer item
|
||||
switch (item.getItemId()) {
|
||||
@@ -82,12 +84,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
break;
|
||||
|
||||
case R.id.live:
|
||||
Toast.makeText(MainActivity.this, "Vous écoutez Radio Mercure en direct", Toast.LENGTH_SHORT).show();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
lectureAudio(URL_STREAM);
|
||||
} else {
|
||||
Toast.makeText(MainActivity.this, "Votre version d'Android n'est pas compatible", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
Toast.makeText(MainActivity.this, R.string.toast_live, Toast.LENGTH_SHORT).show();
|
||||
lectureAudio(URL_STREAM);
|
||||
break;
|
||||
|
||||
case R.id.tel:
|
||||
@@ -252,9 +250,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
break;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
//
|
||||
}
|
||||
return false;
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void createDialog()
|
||||
@@ -305,8 +303,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (web.canGoBack()) {
|
||||
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
|
||||
drawerLayout.closeDrawer(GravityCompat.START);
|
||||
}
|
||||
else if (web.canGoBack()) {
|
||||
web.goBack();
|
||||
if (Objects.equals(web.getOriginalUrl(), URL_PLATEFORM + "/")) { // Cliquez sur retour pour quitter
|
||||
Toast.makeText(this, R.string.toast_quitter, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
System.exit(0);
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
app:headerLayout="@layout/drawer_header"
|
||||
app:itemIconTint="?attr/colorPrimary"
|
||||
app:menu="@menu/menu_drawer">
|
||||
|
||||
</com.google.android.material.navigation.NavigationView>
|
||||
|
||||
|
||||
|
||||
@@ -38,5 +38,7 @@
|
||||
<string name="menu_application">Application</string>
|
||||
<string name="menu_share">Partager la page</string>
|
||||
<string name="menu_politique_de_confidentialit">Politique de Confidentialité</string>
|
||||
<string name="toast_quitter">Cliquez sur retour pour quitter</string>
|
||||
<string name="toast_live">Vous écoutez Radio Mercure en direct</string>
|
||||
|
||||
</resources>
|
||||
@@ -11,6 +11,7 @@
|
||||
<item name="colorOnSecondary">#FF5722</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<item name="colorControlNormal">@android:color/white</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="Theme.NavigationDrawer.NoActionBar">
|
||||
|
||||
Reference in New Issue
Block a user