Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
I always forget to format
  • Loading branch information
bparrishMines committed Oct 7, 2019
commit 3e73439320218a0d7b05774d7a68a1a3370113d4
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import android.content.Context;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;

public class FirebaseCoreHandler implements MethodChannel.MethodCallHandler {
private final Context context;
Expand Down Expand Up @@ -36,50 +36,50 @@ private Map<String, Object> asMap(FirebaseApp app) {
public void onMethodCall(MethodCall call, final MethodChannel.Result result) {
switch (call.method) {
case "FirebaseApp#configure":
{
Map<String, Object> arguments = call.arguments();
String name = (String) arguments.get("name");
@SuppressWarnings("unchecked")
Map<String, String> optionsMap = (Map<String, String>) arguments.get("options");
FirebaseOptions options =
new FirebaseOptions.Builder()
.setApiKey(optionsMap.get("APIKey"))
.setApplicationId(optionsMap.get("googleAppID"))
.setDatabaseUrl(optionsMap.get("databaseURL"))
.setGcmSenderId(optionsMap.get("GCMSenderID"))
.setProjectId(optionsMap.get("projectID"))
.setStorageBucket(optionsMap.get("storageBucket"))
.build();
FirebaseApp.initializeApp(context, options, name);
result.success(null);
break;
}
{
Map<String, Object> arguments = call.arguments();
String name = (String) arguments.get("name");
@SuppressWarnings("unchecked")
Map<String, String> optionsMap = (Map<String, String>) arguments.get("options");
FirebaseOptions options =
new FirebaseOptions.Builder()
.setApiKey(optionsMap.get("APIKey"))
.setApplicationId(optionsMap.get("googleAppID"))
.setDatabaseUrl(optionsMap.get("databaseURL"))
.setGcmSenderId(optionsMap.get("GCMSenderID"))
.setProjectId(optionsMap.get("projectID"))
.setStorageBucket(optionsMap.get("storageBucket"))
.build();
FirebaseApp.initializeApp(context, options, name);
result.success(null);
break;
}
case "FirebaseApp#allApps":
{
List<Map<String, Object>> apps = new ArrayList<>();
for (FirebaseApp app : FirebaseApp.getApps(context)) {
apps.add(asMap(app));
{
List<Map<String, Object>> apps = new ArrayList<>();
for (FirebaseApp app : FirebaseApp.getApps(context)) {
apps.add(asMap(app));
}
result.success(apps);
break;
}
result.success(apps);
break;
}
case "FirebaseApp#appNamed":
{
String name = call.arguments();
try {
FirebaseApp app = FirebaseApp.getInstance(name);
result.success(asMap(app));
} catch (IllegalStateException ex) {
// App doesn't exist, so successfully return null.
result.success(null);
{
String name = call.arguments();
try {
FirebaseApp app = FirebaseApp.getInstance(name);
result.success(asMap(app));
} catch (IllegalStateException ex) {
// App doesn't exist, so successfully return null.
result.success(null);
}
break;
}
break;
}
default:
{
result.notImplemented();
break;
}
{
result.notImplemented();
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package io.flutter.plugins.firebase.core;

import androidx.annotation.NonNull;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
Expand All @@ -20,7 +19,9 @@ public static void registerWith(PluginRegistry.Registrar registrar) {

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
channel = new MethodChannel(binding.getFlutterEngine().getDartExecutor(), "plugins.flutter.io/firebase_core");
channel =
new MethodChannel(
binding.getFlutterEngine().getDartExecutor(), "plugins.flutter.io/firebase_core");
channel.setMethodCallHandler(new FirebaseCoreHandler(binding.getApplicationContext()));
}

Expand Down