|
| 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 | +// Autogenerated from Pigeon (v3.1.5), do not edit directly. |
| 5 | +// See also: https://pub.dev/packages/pigeon |
| 6 | + |
| 7 | +package io.flutter.plugins.pathprovider; |
| 8 | + |
| 9 | +import android.util.Log; |
| 10 | +import androidx.annotation.NonNull; |
| 11 | +import androidx.annotation.Nullable; |
| 12 | +import io.flutter.plugin.common.BasicMessageChannel; |
| 13 | +import io.flutter.plugin.common.BinaryMessenger; |
| 14 | +import io.flutter.plugin.common.MessageCodec; |
| 15 | +import io.flutter.plugin.common.StandardMessageCodec; |
| 16 | +import java.util.ArrayList; |
| 17 | +import java.util.HashMap; |
| 18 | +import java.util.List; |
| 19 | +import java.util.Map; |
| 20 | + |
| 21 | +/** Generated class from Pigeon. */ |
| 22 | +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) |
| 23 | +public class Messages { |
| 24 | + |
| 25 | + public enum StorageDirectory { |
| 26 | + music(0), |
| 27 | + podcasts(1), |
| 28 | + ringtones(2), |
| 29 | + alarms(3), |
| 30 | + notifications(4), |
| 31 | + pictures(5), |
| 32 | + movies(6), |
| 33 | + downloads(7), |
| 34 | + dcim(8), |
| 35 | + documents(9); |
| 36 | + |
| 37 | + private int index; |
| 38 | + |
| 39 | + private StorageDirectory(final int index) { |
| 40 | + this.index = index; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + private static class PathProviderApiCodec extends StandardMessageCodec { |
| 45 | + public static final PathProviderApiCodec INSTANCE = new PathProviderApiCodec(); |
| 46 | + |
| 47 | + private PathProviderApiCodec() {} |
| 48 | + } |
| 49 | + |
| 50 | + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ |
| 51 | + public interface PathProviderApi { |
| 52 | + @Nullable |
| 53 | + String getTemporaryPath(); |
| 54 | + |
| 55 | + @Nullable |
| 56 | + String getApplicationSupportPath(); |
| 57 | + |
| 58 | + @Nullable |
| 59 | + String getApplicationDocumentsPath(); |
| 60 | + |
| 61 | + @Nullable |
| 62 | + String getExternalStoragePath(); |
| 63 | + |
| 64 | + @NonNull |
| 65 | + List<String> getExternalCachePaths(); |
| 66 | + |
| 67 | + @NonNull |
| 68 | + List<String> getExternalStoragePaths(@NonNull StorageDirectory directory); |
| 69 | + |
| 70 | + /** The codec used by PathProviderApi. */ |
| 71 | + static MessageCodec<Object> getCodec() { |
| 72 | + return PathProviderApiCodec.INSTANCE; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Sets up an instance of `PathProviderApi` to handle messages through the `binaryMessenger`. |
| 77 | + */ |
| 78 | + static void setup(BinaryMessenger binaryMessenger, PathProviderApi api) { |
| 79 | + { |
| 80 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 81 | + BasicMessageChannel<Object> channel = |
| 82 | + new BasicMessageChannel<>( |
| 83 | + binaryMessenger, |
| 84 | + "dev.flutter.pigeon.PathProviderApi.getTemporaryPath", |
| 85 | + getCodec(), |
| 86 | + taskQueue); |
| 87 | + if (api != null) { |
| 88 | + channel.setMessageHandler( |
| 89 | + (message, reply) -> { |
| 90 | + Map<String, Object> wrapped = new HashMap<>(); |
| 91 | + try { |
| 92 | + String output = api.getTemporaryPath(); |
| 93 | + wrapped.put("result", output); |
| 94 | + } catch (Error | RuntimeException exception) { |
| 95 | + wrapped.put("error", wrapError(exception)); |
| 96 | + } |
| 97 | + reply.reply(wrapped); |
| 98 | + }); |
| 99 | + } else { |
| 100 | + channel.setMessageHandler(null); |
| 101 | + } |
| 102 | + } |
| 103 | + { |
| 104 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 105 | + BasicMessageChannel<Object> channel = |
| 106 | + new BasicMessageChannel<>( |
| 107 | + binaryMessenger, |
| 108 | + "dev.flutter.pigeon.PathProviderApi.getApplicationSupportPath", |
| 109 | + getCodec(), |
| 110 | + taskQueue); |
| 111 | + if (api != null) { |
| 112 | + channel.setMessageHandler( |
| 113 | + (message, reply) -> { |
| 114 | + Map<String, Object> wrapped = new HashMap<>(); |
| 115 | + try { |
| 116 | + String output = api.getApplicationSupportPath(); |
| 117 | + wrapped.put("result", output); |
| 118 | + } catch (Error | RuntimeException exception) { |
| 119 | + wrapped.put("error", wrapError(exception)); |
| 120 | + } |
| 121 | + reply.reply(wrapped); |
| 122 | + }); |
| 123 | + } else { |
| 124 | + channel.setMessageHandler(null); |
| 125 | + } |
| 126 | + } |
| 127 | + { |
| 128 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 129 | + BasicMessageChannel<Object> channel = |
| 130 | + new BasicMessageChannel<>( |
| 131 | + binaryMessenger, |
| 132 | + "dev.flutter.pigeon.PathProviderApi.getApplicationDocumentsPath", |
| 133 | + getCodec(), |
| 134 | + taskQueue); |
| 135 | + if (api != null) { |
| 136 | + channel.setMessageHandler( |
| 137 | + (message, reply) -> { |
| 138 | + Map<String, Object> wrapped = new HashMap<>(); |
| 139 | + try { |
| 140 | + String output = api.getApplicationDocumentsPath(); |
| 141 | + wrapped.put("result", output); |
| 142 | + } catch (Error | RuntimeException exception) { |
| 143 | + wrapped.put("error", wrapError(exception)); |
| 144 | + } |
| 145 | + reply.reply(wrapped); |
| 146 | + }); |
| 147 | + } else { |
| 148 | + channel.setMessageHandler(null); |
| 149 | + } |
| 150 | + } |
| 151 | + { |
| 152 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 153 | + BasicMessageChannel<Object> channel = |
| 154 | + new BasicMessageChannel<>( |
| 155 | + binaryMessenger, |
| 156 | + "dev.flutter.pigeon.PathProviderApi.getExternalStoragePath", |
| 157 | + getCodec(), |
| 158 | + taskQueue); |
| 159 | + if (api != null) { |
| 160 | + channel.setMessageHandler( |
| 161 | + (message, reply) -> { |
| 162 | + Map<String, Object> wrapped = new HashMap<>(); |
| 163 | + try { |
| 164 | + String output = api.getExternalStoragePath(); |
| 165 | + wrapped.put("result", output); |
| 166 | + } catch (Error | RuntimeException exception) { |
| 167 | + wrapped.put("error", wrapError(exception)); |
| 168 | + } |
| 169 | + reply.reply(wrapped); |
| 170 | + }); |
| 171 | + } else { |
| 172 | + channel.setMessageHandler(null); |
| 173 | + } |
| 174 | + } |
| 175 | + { |
| 176 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 177 | + BasicMessageChannel<Object> channel = |
| 178 | + new BasicMessageChannel<>( |
| 179 | + binaryMessenger, |
| 180 | + "dev.flutter.pigeon.PathProviderApi.getExternalCachePaths", |
| 181 | + getCodec(), |
| 182 | + taskQueue); |
| 183 | + if (api != null) { |
| 184 | + channel.setMessageHandler( |
| 185 | + (message, reply) -> { |
| 186 | + Map<String, Object> wrapped = new HashMap<>(); |
| 187 | + try { |
| 188 | + List<String> output = api.getExternalCachePaths(); |
| 189 | + wrapped.put("result", output); |
| 190 | + } catch (Error | RuntimeException exception) { |
| 191 | + wrapped.put("error", wrapError(exception)); |
| 192 | + } |
| 193 | + reply.reply(wrapped); |
| 194 | + }); |
| 195 | + } else { |
| 196 | + channel.setMessageHandler(null); |
| 197 | + } |
| 198 | + } |
| 199 | + { |
| 200 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 201 | + BasicMessageChannel<Object> channel = |
| 202 | + new BasicMessageChannel<>( |
| 203 | + binaryMessenger, |
| 204 | + "dev.flutter.pigeon.PathProviderApi.getExternalStoragePaths", |
| 205 | + getCodec(), |
| 206 | + taskQueue); |
| 207 | + if (api != null) { |
| 208 | + channel.setMessageHandler( |
| 209 | + (message, reply) -> { |
| 210 | + Map<String, Object> wrapped = new HashMap<>(); |
| 211 | + try { |
| 212 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 213 | + StorageDirectory directoryArg = |
| 214 | + args.get(0) == null ? null : StorageDirectory.values()[(int) args.get(0)]; |
| 215 | + if (directoryArg == null) { |
| 216 | + throw new NullPointerException("directoryArg unexpectedly null."); |
| 217 | + } |
| 218 | + List<String> output = api.getExternalStoragePaths(directoryArg); |
| 219 | + wrapped.put("result", output); |
| 220 | + } catch (Error | RuntimeException exception) { |
| 221 | + wrapped.put("error", wrapError(exception)); |
| 222 | + } |
| 223 | + reply.reply(wrapped); |
| 224 | + }); |
| 225 | + } else { |
| 226 | + channel.setMessageHandler(null); |
| 227 | + } |
| 228 | + } |
| 229 | + } |
| 230 | + } |
| 231 | + |
| 232 | + private static Map<String, Object> wrapError(Throwable exception) { |
| 233 | + Map<String, Object> errorMap = new HashMap<>(); |
| 234 | + errorMap.put("message", exception.toString()); |
| 235 | + errorMap.put("code", exception.getClass().getSimpleName()); |
| 236 | + errorMap.put( |
| 237 | + "details", |
| 238 | + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); |
| 239 | + return errorMap; |
| 240 | + } |
| 241 | +} |
0 commit comments