mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	Replace LinkedHashMap with List.of().
This commit is contained in:
		| @@ -6,6 +6,7 @@ import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_UNSPECI | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.util.Log; | ||||
| import android.util.Pair; | ||||
| import android.view.ContextThemeWrapper; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.ViewGroup; | ||||
| @@ -28,9 +29,7 @@ import org.schabi.newpipe.player.Player; | ||||
| import org.schabi.newpipe.util.ThemeHelper; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.util.Collections; | ||||
| import java.util.LinkedHashMap; | ||||
| import java.util.Map; | ||||
| import java.util.List; | ||||
| import java.util.function.Supplier; | ||||
|  | ||||
| /** | ||||
| @@ -43,48 +42,32 @@ public final class VideoDetailPlayerCrasher { | ||||
|     // https://stackoverflow.com/a/54744028 | ||||
|     private static final String TAG = "VideoDetPlayerCrasher"; | ||||
|  | ||||
|     private static final Map<String, Supplier<ExoPlaybackException>> AVAILABLE_EXCEPTION_TYPES = | ||||
|             getExceptionTypes(); | ||||
|     private static final String DEFAULT_MSG = "Dummy"; | ||||
|  | ||||
|     private VideoDetailPlayerCrasher() { | ||||
|         // No impls | ||||
|     } | ||||
|  | ||||
|     private static Map<String, Supplier<ExoPlaybackException>> getExceptionTypes() { | ||||
|         final String defaultMsg = "Dummy"; | ||||
|         final Map<String, Supplier<ExoPlaybackException>> exceptionTypes = new LinkedHashMap<>(); | ||||
|         exceptionTypes.put( | ||||
|                 "Source", | ||||
|                 () -> ExoPlaybackException.createForSource( | ||||
|                         new IOException(defaultMsg), | ||||
|     private static final List<Pair<String, Supplier<ExoPlaybackException>>> | ||||
|             AVAILABLE_EXCEPTION_TYPES = List.of( | ||||
|                     new Pair<>("Source", () -> ExoPlaybackException.createForSource( | ||||
|                             new IOException(DEFAULT_MSG), | ||||
|                             ERROR_CODE_BEHIND_LIVE_WINDOW | ||||
|                 ) | ||||
|         ); | ||||
|         exceptionTypes.put( | ||||
|                 "Renderer", | ||||
|                 () -> ExoPlaybackException.createForRenderer( | ||||
|                         new Exception(defaultMsg), | ||||
|                     )), | ||||
|                     new Pair<>("Renderer", () -> ExoPlaybackException.createForRenderer( | ||||
|                             new Exception(DEFAULT_MSG), | ||||
|                             "Dummy renderer", | ||||
|                             0, | ||||
|                             null, | ||||
|                             C.FORMAT_HANDLED, | ||||
|                             /*isRecoverable=*/false, | ||||
|                             ERROR_CODE_DECODING_FAILED | ||||
|                 ) | ||||
|         ); | ||||
|         exceptionTypes.put( | ||||
|                 "Unexpected", | ||||
|                 () -> ExoPlaybackException.createForUnexpected( | ||||
|                         new RuntimeException(defaultMsg), | ||||
|                     )), | ||||
|                     new Pair<>("Unexpected", () -> ExoPlaybackException.createForUnexpected( | ||||
|                             new RuntimeException(DEFAULT_MSG), | ||||
|                             ERROR_CODE_UNSPECIFIED | ||||
|                 ) | ||||
|         ); | ||||
|         exceptionTypes.put( | ||||
|                 "Remote", | ||||
|                 () -> ExoPlaybackException.createForRemote(defaultMsg) | ||||
|                     )), | ||||
|                     new Pair<>("Remote", () -> ExoPlaybackException.createForRemote(DEFAULT_MSG)) | ||||
|             ); | ||||
|  | ||||
|         return Collections.unmodifiableMap(exceptionTypes); | ||||
|     private VideoDetailPlayerCrasher() { | ||||
|         // No impls | ||||
|     } | ||||
|  | ||||
|     private static Context getThemeWrapperContext(final Context context) { | ||||
| @@ -121,10 +104,9 @@ public final class VideoDetailPlayerCrasher { | ||||
|                 .setNegativeButton(R.string.cancel, null) | ||||
|                 .create(); | ||||
|  | ||||
|         for (final Map.Entry<String, Supplier<ExoPlaybackException>> entry | ||||
|                 : AVAILABLE_EXCEPTION_TYPES.entrySet()) { | ||||
|         for (final Pair<String, Supplier<ExoPlaybackException>> entry : AVAILABLE_EXCEPTION_TYPES) { | ||||
|             final RadioButton radioButton = ListRadioIconItemBinding.inflate(inflater).getRoot(); | ||||
|             radioButton.setText(entry.getKey()); | ||||
|             radioButton.setText(entry.first); | ||||
|             radioButton.setChecked(false); | ||||
|             radioButton.setLayoutParams( | ||||
|                     new RadioGroup.LayoutParams( | ||||
| @@ -133,7 +115,7 @@ public final class VideoDetailPlayerCrasher { | ||||
|                     ) | ||||
|             ); | ||||
|             radioButton.setOnClickListener(v -> { | ||||
|                 tryCrashPlayerWith(player, entry.getValue().get()); | ||||
|                 tryCrashPlayerWith(player, entry.second.get()); | ||||
|                 alertDialog.cancel(); | ||||
|             }); | ||||
|             binding.list.addView(radioButton); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Isira Seneviratne
					Isira Seneviratne