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 android.content.Context; 8 import io.flutter.plugin.common.MessageCodec; 9 10 public abstract class PlatformViewFactory { 11 private final MessageCodec<Object> createArgsCodec; 12 13 /** 14 * 15 * @param createArgsCodec the codec used to decode the args parameter of {@link #create}. 16 */ PlatformViewFactory(MessageCodec<Object> createArgsCodec)17 public PlatformViewFactory(MessageCodec<Object> createArgsCodec) { 18 this.createArgsCodec = createArgsCodec; 19 } 20 21 /** 22 * Creates a new Android view to be embedded in the Flutter hierarchy. 23 * 24 * @param context the context to be used when creating the view, this is different than FlutterView's context. 25 * @param viewId unique identifier for the created instance, this value is known on the Dart side. 26 * @param args arguments sent from the Flutter app. The bytes for this value are decoded using the createArgsCodec 27 * argument passed to the constructor. This is null if createArgsCodec was null, or no arguments were 28 * sent from the Flutter app. 29 */ create(Context context, int viewId, Object args)30 public abstract PlatformView create(Context context, int viewId, Object args); 31 32 /** 33 * Returns the codec to be used for decoding the args parameter of {@link #create}. 34 */ getCreateArgsCodec()35 public final MessageCodec<Object> getCreateArgsCodec() { 36 return createArgsCodec; 37 } 38 } 39