Skip to content

Commit

Permalink
Format cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LTPhantom committed Feb 13, 2024
1 parent c260998 commit 58c571b
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* Encodes and decodes values by reading from a ByteBuffer and writing to a ByteArrayOutputStream.
Expand Down Expand Up @@ -70,14 +69,10 @@ class AdMessageCodec extends StandardMessageCodec {
private static final byte VALUE_COLOR = (byte) 153;
private static final byte VALUE_MEDIATION_EXTRAS = (byte) 154;

@NonNull
Context context;
@NonNull
final FlutterAdSize.AdSizeFactory adSizeFactory;
@Nullable
private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;
@NonNull
private final FlutterRequestAgentProvider requestAgentProvider;
@NonNull Context context;
@NonNull final FlutterAdSize.AdSizeFactory adSizeFactory;
@Nullable private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;
@NonNull private final FlutterRequestAgentProvider requestAgentProvider;

AdMessageCodec(
@NonNull Context context, @NonNull FlutterRequestAgentProvider requestAgentProvider) {
Expand Down Expand Up @@ -259,13 +254,14 @@ protected void writeValue(ByteArrayOutputStream stream, Object value) {
@Override
protected Object readValueOfType(byte type, ByteBuffer buffer) {
switch (type) {
case VALUE_INLINE_ADAPTIVE_BANNER_AD_SIZE: {
final Integer width = (Integer) readValueOfType(buffer.get(), buffer);
final Integer height = (Integer) readValueOfType(buffer.get(), buffer);
final Integer orientation = (Integer) readValueOfType(buffer.get(), buffer);
return new FlutterAdSize.InlineAdaptiveBannerAdSize(
adSizeFactory, context, width, orientation, height);
}
case VALUE_INLINE_ADAPTIVE_BANNER_AD_SIZE:
{
final Integer width = (Integer) readValueOfType(buffer.get(), buffer);
final Integer height = (Integer) readValueOfType(buffer.get(), buffer);
final Integer orientation = (Integer) readValueOfType(buffer.get(), buffer);
return new FlutterAdSize.InlineAdaptiveBannerAdSize(
adSizeFactory, context, width, orientation, height);
}
case VALUE_ANCHORED_ADAPTIVE_BANNER_AD_SIZE:
final String orientation = (String) readValueOfType(buffer.get(), buffer);
final Integer width = (Integer) readValueOfType(buffer.get(), buffer);
Expand All @@ -290,8 +286,9 @@ protected Object readValueOfType(byte type, ByteBuffer buffer) {
.setMediationNetworkExtrasProvider(mediationNetworkExtrasProvider)
.setAdMobExtras((Map<String, String>) readValueOfType(buffer.get(), buffer))
.setRequestAgent(requestAgentProvider.getRequestAgent())
.setMediationExtras((List<FlutterMediationExtras>) readValueOfType(buffer.get(), buffer))
.build();
.setMediationExtras(
(List<FlutterMediationExtras>) readValueOfType(buffer.get(), buffer))
.build();
case VALUE_MEDIATION_EXTRAS:
String className = (String) readValueOfType(buffer.get(), buffer);
Map<String, Object> extras = (Map<String, Object>) readValueOfType(buffer.get(), buffer);
Expand Down Expand Up @@ -357,7 +354,8 @@ protected Object readValueOfType(byte type, ByteBuffer buffer) {
builder.setMediationNetworkExtrasProvider(mediationNetworkExtrasProvider);
builder.setAdMobExtras((Map<String, String>) readValueOfType(buffer.get(), buffer));
builder.setRequestAgent(requestAgentProvider.getRequestAgent());
builder.setMediationExtras((List<FlutterMediationExtras>) readValueOfType(buffer.get(), buffer));
builder.setMediationExtras(
(List<FlutterMediationExtras>) readValueOfType(buffer.get(), buffer));
return builder.build();
case VALUE_INITIALIZATION_STATE:
final String state = (String) readValueOfType(buffer.get(), buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ private void addNetworkExtras(AdRequest.Builder builder, String adUnitId) {
Map<Class<? extends MediationExtrasReceiver>, Bundle> networkExtras = new HashMap<>();
if (mediationExtras != null) {
for (FlutterMediationExtras flutterExtras : mediationExtras) {
Pair<Class<? extends MediationExtrasReceiver>, Bundle> pair = flutterExtras.getMediationExtras();
Pair<Class<? extends MediationExtrasReceiver>, Bundle> pair =
flutterExtras.getMediationExtras();
networkExtras.put(pair.first, pair.second);
}
} else if (mediationNetworkExtrasProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public interface FlutterMediationExtras {

void setMediationExtras(Map<String, Object> extras);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3D7E269FA8038A55BBCBF250 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2AB4EE7241D0927BB957D65 /* Pods_Runner.framework */; };
588A95C9AF0A9F291BFBAA5B /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86606948223BE74D544C6A9E /* Pods_RunnerTests.framework */; };
588A95C9AF0A9F291BFBAA5B /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86606948223BE74D544C6A9E /* Pods_RunnerTests.framework */; };
8FC897F52411A9F100415930 /* NativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8FC897F42411A9F100415930 /* NativeAdView.xib */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
Expand Down
6 changes: 4 additions & 2 deletions packages/google_mobile_ads/ios/Classes/FLTAd_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@
@property NSString *_Nullable contentURL;
@property BOOL nonPersonalizedAds;
@property NSArray<NSString *> *_Nullable neighboringContentURLs;
@property NSString *_Nullable mediationExtrasIdentifier DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property NSString *_Nullable mediationExtrasIdentifier
DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property id<
FLTMediationNetworkExtrasProvider> _Nullable mediationNetworkExtrasProvider DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
FLTMediationNetworkExtrasProvider> _Nullable mediationNetworkExtrasProvider
DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property NSDictionary<NSString *, NSString *> *_Nullable adMobExtras;
@property NSString *_Nonnull requestAgent;
@property NSArray<FlutterMediationExtras> *_Nullable mediationExtras;
Expand Down
9 changes: 5 additions & 4 deletions packages/google_mobile_ads/ios/Classes/FLTAd_Internal.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@ - (void)addNetworkExtrasToGADRequest:(GADRequest *)request
NSArray<id<GADAdNetworkExtras>> *extras;

if (_mediationExtras != NULL) {
NSMutableArray<id<GADAdNetworkExtras>> *flutterExtras = [NSMutableArray array];
for(id<FlutterMediationExtras> extra in _mediationExtras) {
NSMutableArray<id<GADAdNetworkExtras>> *flutterExtras =
[NSMutableArray array];
for (id<FlutterMediationExtras> extra in _mediationExtras) {
[flutterExtras addObject:[extra getMediationExtras]];
}
extras = [NSArray arrayWithArray:flutterExtras];
} else {
extras = [_mediationNetworkExtrasProvider
getMediationExtras:adUnitId
mediationExtrasIdentifier:_mediationExtrasIdentifier];
getMediationExtras:adUnitId
mediationExtrasIdentifier:_mediationExtrasIdentifier];
}
BOOL addedNpaToGADExtras = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ - (id _Nullable)readValueOfType:(UInt8)type {
return request;
}
case FLTAdmobFieldMediationExtras: {
id<FlutterMediationExtras> flutterMediationExtras = [[NSClassFromString([self readValueOfType:[self readByte]]) alloc] init];
id<FlutterMediationExtras> flutterMediationExtras =
[[NSClassFromString([self readValueOfType:[self readByte]]) alloc]
init];
NSMutableDictionary *flutterExtras = [self readValueOfType:[self readByte]];
flutterMediationExtras.extras = flutterExtras;
return flutterMediationExtras;
Expand Down
4 changes: 2 additions & 2 deletions packages/google_mobile_ads/ios/Classes/FLTMediationExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

@protocol FlutterMediationExtras

@property NSMutableDictionary * _Nullable extras;
@property NSMutableDictionary *_Nullable extras;

- (id<GADAdNetworkExtras> _Nonnull) getMediationExtras;
- (id<GADAdNetworkExtras> _Nonnull)getMediationExtras;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ class AdMessageCodec extends StandardMessageCodec {
writeValue(buffer, value.getIOSClassName());
}
writeValue(buffer, value.getExtras());
} else if (value is RewardItem) {
} else if (value is RewardItem) {
buffer.putUint8(_valueRewardItem);
writeValue(buffer, value.amount);
writeValue(buffer, value.type);
Expand Down
1 change: 0 additions & 1 deletion packages/google_mobile_ads/lib/src/mediation_extras.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'package:google_mobile_ads/src/ad_containers.dart';

/// Contains information for a particular ad network set by developer.
abstract class MediationExtras {

/// Fully-qualified name of an Android FlutterMediationExtras class.
///
/// The name of the class must implement the FlutterMediationExtras interface.
Expand Down

0 comments on commit 58c571b

Please sign in to comment.