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);
|
||||
|
||||
Reference in New Issue
Block a user