Convert Java tabs to spaces.
This commit is contained in:
parent
1ac687cedc
commit
cc2b10834b
File diff suppressed because it is too large
Load Diff
|
@ -12,46 +12,46 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||||
*/
|
*/
|
||||||
public class JustAudioPlugin implements FlutterPlugin {
|
public class JustAudioPlugin implements FlutterPlugin {
|
||||||
|
|
||||||
private MethodChannel channel;
|
private MethodChannel channel;
|
||||||
private MainMethodCallHandler methodCallHandler;
|
private MainMethodCallHandler methodCallHandler;
|
||||||
|
|
||||||
public JustAudioPlugin() {
|
public JustAudioPlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v1 plugin registration.
|
* v1 plugin registration.
|
||||||
*/
|
*/
|
||||||
public static void registerWith(Registrar registrar) {
|
public static void registerWith(Registrar registrar) {
|
||||||
final JustAudioPlugin plugin = new JustAudioPlugin();
|
final JustAudioPlugin plugin = new JustAudioPlugin();
|
||||||
plugin.startListening(registrar.context(), registrar.messenger());
|
plugin.startListening(registrar.context(), registrar.messenger());
|
||||||
registrar.addViewDestroyListener(
|
registrar.addViewDestroyListener(
|
||||||
view -> {
|
view -> {
|
||||||
plugin.stopListening();
|
plugin.stopListening();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
|
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
|
||||||
startListening(binding.getApplicationContext(), binding.getBinaryMessenger());
|
startListening(binding.getApplicationContext(), binding.getBinaryMessenger());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
|
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
|
||||||
stopListening();
|
stopListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startListening(Context applicationContext, BinaryMessenger messenger) {
|
private void startListening(Context applicationContext, BinaryMessenger messenger) {
|
||||||
methodCallHandler = new MainMethodCallHandler(applicationContext, messenger);
|
methodCallHandler = new MainMethodCallHandler(applicationContext, messenger);
|
||||||
|
|
||||||
channel = new MethodChannel(messenger, "com.ryanheise.just_audio.methods");
|
channel = new MethodChannel(messenger, "com.ryanheise.just_audio.methods");
|
||||||
channel.setMethodCallHandler(methodCallHandler);
|
channel.setMethodCallHandler(methodCallHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopListening() {
|
private void stopListening() {
|
||||||
methodCallHandler.dispose();
|
methodCallHandler.dispose();
|
||||||
methodCallHandler = null;
|
methodCallHandler = null;
|
||||||
|
|
||||||
channel.setMethodCallHandler(null);
|
channel.setMethodCallHandler(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,46 +13,46 @@ import java.util.Map;
|
||||||
|
|
||||||
public class MainMethodCallHandler implements MethodCallHandler {
|
public class MainMethodCallHandler implements MethodCallHandler {
|
||||||
|
|
||||||
private final Context applicationContext;
|
private final Context applicationContext;
|
||||||
private final BinaryMessenger messenger;
|
private final BinaryMessenger messenger;
|
||||||
|
|
||||||
private final Map<String, AudioPlayer> players = new HashMap<>();
|
private final Map<String, AudioPlayer> players = new HashMap<>();
|
||||||
|
|
||||||
public MainMethodCallHandler(Context applicationContext,
|
public MainMethodCallHandler(Context applicationContext,
|
||||||
BinaryMessenger messenger) {
|
BinaryMessenger messenger) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.messenger = messenger;
|
this.messenger = messenger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMethodCall(MethodCall call, @NonNull Result result) {
|
public void onMethodCall(MethodCall call, @NonNull Result result) {
|
||||||
final Map<?, ?> request = call.arguments();
|
final Map<?, ?> request = call.arguments();
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "init": {
|
case "init": {
|
||||||
String id = (String)request.get("id");
|
String id = (String)request.get("id");
|
||||||
players.put(id, new AudioPlayer(applicationContext, messenger, id));
|
players.put(id, new AudioPlayer(applicationContext, messenger, id));
|
||||||
result.success(null);
|
result.success(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "disposePlayer": {
|
case "disposePlayer": {
|
||||||
String id = (String)request.get("id");
|
String id = (String)request.get("id");
|
||||||
AudioPlayer player = players.get(id);
|
AudioPlayer player = players.get(id);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.dispose();
|
player.dispose();
|
||||||
players.remove(id);
|
players.remove(id);
|
||||||
}
|
}
|
||||||
result.success(new HashMap<String, Object>());
|
result.success(new HashMap<String, Object>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
result.notImplemented();
|
result.notImplemented();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
for (AudioPlayer player : new ArrayList<AudioPlayer>(players.values())) {
|
for (AudioPlayer player : new ArrayList<AudioPlayer>(players.values())) {
|
||||||
player.dispose();
|
player.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue