• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package io.flutter.plugin.platform;
6 
7 import java.util.HashMap;
8 import java.util.Map;
9 
10 class PlatformViewRegistryImpl implements PlatformViewRegistry {
11 
PlatformViewRegistryImpl()12     PlatformViewRegistryImpl() {
13         viewFactories = new HashMap<>();
14     }
15 
16     // Maps a platform view type id to its factory.
17     private final Map<String, PlatformViewFactory> viewFactories;
18 
19     @Override
registerViewFactory(String viewTypeId, PlatformViewFactory factory)20     public boolean registerViewFactory(String viewTypeId, PlatformViewFactory factory) {
21         if (viewFactories.containsKey(viewTypeId))
22             return false;
23         viewFactories.put(viewTypeId, factory);
24         return true;
25     }
26 
getFactory(String viewTypeId)27     PlatformViewFactory getFactory(String viewTypeId) {
28         return viewFactories.get(viewTypeId);
29     }
30 }
31