Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NativeAdWrapper.java « placepage « widget « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd77c7d4e52833be1aa87caff7dd78458d5f60cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package com.mapswithme.maps.widget.placepage;

import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.mapswithme.maps.R;
import com.mapswithme.maps.ads.MwmNativeAd;
import com.mapswithme.maps.ads.NetworkType;

import java.util.EnumMap;
import java.util.Map;

public class NativeAdWrapper implements MwmNativeAd
{
  private final static Map<NetworkType, UiType> TYPES
      = new EnumMap<NetworkType, UiType>(NetworkType.class)
  {
    {
      put(NetworkType.MOPUB, UiType.DEFAULT);
      put(NetworkType.FACEBOOK, UiType.DEFAULT);
      put(NetworkType.MYTARGET, UiType.DEFAULT);
    }
  };

  @NonNull
  private final MwmNativeAd mNativeAd;
  @NonNull
  private final UiType mType;

  NativeAdWrapper(@NonNull MwmNativeAd nativeAd)
  {
    mNativeAd = nativeAd;
    mType = TYPES.get(nativeAd.getNetworkType());
  }

  @NonNull
  @Override
  public String getBannerId()
  {
    return mNativeAd.getBannerId();
  }

  @NonNull
  @Override
  public String getTitle()
  {
    return mNativeAd.getTitle();
  }

  @NonNull
  @Override
  public String getDescription()
  {
    return mNativeAd.getDescription();
  }

  @NonNull
  @Override
  public String getAction()
  {
    return mNativeAd.getAction();
  }

  @Override
  public void loadIcon(@NonNull View view)
  {
    mNativeAd.loadIcon(view);
  }

  @Override
  public void registerView(@NonNull View bannerView)
  {
    mNativeAd.registerView(bannerView);
  }

  @Override
  public void unregisterView(@NonNull View bannerView)
  {
    mNativeAd.unregisterView(bannerView);
  }

  @NonNull
  @Override
  public String getProvider()
  {
    return mNativeAd.getProvider();
  }

  @Nullable
  @Override
  public String getPrivacyInfoUrl()
  {
    return mNativeAd.getPrivacyInfoUrl();
  }

  @NonNull
  @Override
  public NetworkType getNetworkType()
  {
    throw new UnsupportedOperationException("It's not supported for UI!");
  }

  @NonNull
  public UiType getType()
  {
    return mType;
  }

  public enum UiType
  {
    DEFAULT(R.layout.place_page_banner, true);

    @LayoutRes
    private final int mLayoutId;
    private final boolean mShowAdChoiceIcon;

    UiType(int layoutId, boolean showAdChoiceIcon)
    {
      mLayoutId = layoutId;
      mShowAdChoiceIcon = showAdChoiceIcon;
    }

    @LayoutRes
    public int getLayoutId()
    {
      return mLayoutId;
    }

    public boolean showAdChoiceIcon()
    {
      return mShowAdChoiceIcon;
    }
  }
}