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