<commit_before>package com.mapswithme.maps.widget.placepage;

import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.Banner;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.UiUtils;

import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.mapswithme.util.SharedPropertiesUtils.isShowcaseSwitchedOnLocal;

final class BannerController implements View.OnClickListener
{
  @Nullable
  private Banner mBanner;
  @Nullable
  private OnBannerClickListener mListener;

  @NonNull
  private final View mFrame;
  @Nullable
  private final ImageView mIcon;
  @Nullable
  private final TextView mTitle;
  @Nullable
  private final TextView mMessage;
  @Nullable
  private final View mAdMarker;

  private final float mCloseFrameHeight;
  private final float mCloseIconSize;
  private final float mOpenIconSize;
  private final float mMarginBase;
  private final float mMarginHalfPlus;

  private boolean mIsOpened = false;

  BannerController(@NonNull View bannerView, @Nullable OnBannerClickListener listener)
  {
    mFrame = bannerView;
    mListener = listener;
    Resources res = mFrame.getResources();
    mCloseFrameHeight = res.getDimension(R.dimen.placepage_banner_height);
    mCloseIconSize = res.getDimension(R.dimen.placepage_banner_icon_size);
    mOpenIconSize = res.getDimension(R.dimen.placepage_banner_icon_size_full);
    mMarginBase = res.getDimension(R.dimen.margin_base);
    mMarginHalfPlus = res.getDimension(R.dimen.margin_half_plus);
    mIcon = (ImageView) bannerView.findViewById(R.id.iv__banner_icon);
    mTitle = (TextView) bannerView.findViewById(R.id.tv__banner_title);
    mMessage = (TextView) bannerView.findViewById(R.id.tv__banner_message);
    mAdMarker = bannerView.findViewById(R.id.tv__banner);
  }

  void updateData(@Nullable Banner banner)
  {
    mBanner = banner;
    boolean showBanner = banner != null && ConnectionState.isConnected()
                         && isShowcaseSwitchedOnLocal();
    UiUtils.showIf(showBanner, mFrame);
    if (!showBanner)
      return;

    loadIcon(banner);
    if (mTitle != null)
      mTitle.setText(banner.getTitle());
    if (mMessage != null)
      mMessage.setText(banner.getMessage());

    if (UiUtils.isLandscape(mFrame.getContext()))
      open();
  }

  boolean isShowing()
  {
    return !UiUtils.isHidden(mFrame);
  }

  void open()
  {<commit_msg>[android] Fixed the getting title and message for banners in PP<commit_after>package com.mapswithme.maps.widget.placepage;

import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.Banner;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.UiUtils;

import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.mapswithme.util.SharedPropertiesUtils.isShowcaseSwitchedOnLocal;

final class BannerController implements View.OnClickListener
{
  @Nullable
  private Banner mBanner;
  @Nullable
  private OnBannerClickListener mListener;

  @NonNull
  private final View mFrame;
  @Nullable
  private final ImageView mIcon;
  @Nullable
  private final TextView mTitle;
  @Nullable
  private final TextView mMessage;
  @Nullable
  private final View mAdMarker;

  private final float mCloseFrameHeight;
  private final float mCloseIconSize;
  private final float mOpenIconSize;
  private final float mMarginBase;
  private final float mMarginHalfPlus;

  @NonNull
  private final Resources mResources;

  private boolean mIsOpened = false;

  BannerController(@NonNull View bannerView, @Nullable OnBannerClickListener listener)
  {
    mFrame = bannerView;
    mListener = listener;
    mResources = mFrame.getResources();
    mCloseFrameHeight = mResources.getDimension(R.dimen.placepage_banner_height);
    mCloseIconSize = mResources.getDimension(R.dimen.placepage_banner_icon_size);
    mOpenIconSize = mResources.getDimension(R.dimen.placepage_banner_icon_size_full);
    mMarginBase = mResources.getDimension(R.dimen.margin_base);
    mMarginHalfPlus = mResources.getDimension(R.dimen.margin_half_plus);
    mIcon = (ImageView) bannerView.findViewById(R.id.iv__banner_icon);
    mTitle = (TextView) bannerView.findViewById(R.id.tv__banner_title);
    mMessage = (TextView) bannerView.findViewById(R.id.tv__banner_message);
    mAdMarker = bannerView.findViewById(R.id.tv__banner);
  }

  void updateData(@Nullable Banner banner)
  {
    mBanner = banner;
    boolean showBanner = banner != null && ConnectionState.isConnected()
                         && isShowcaseSwitchedOnLocal();
    UiUtils.showIf(showBanner, mFrame);
    if (!showBanner)
      return;

    loadIcon(banner);
    if (mTitle != null)
    {
      String title = mResources.getString(mResources.getIdentifier(banner.getTitle(), "string", mFrame.getContext().getPackageName()));
      if (!TextUtils.isEmpty(title))
        mTitle.setText(title);
    }
    if (mMessage != null)
    {
      String message = mResources.getString(mResources.getIdentifier(banner.getMessage(), "string", mFrame.getContext().getPackageName()));
      if (!TextUtils.isEmpty(message))
        mMessage.setText(message);
    }

    if (UiUtils.isLandscape(mFrame.getContext()))
      open();
  }

  boolean isShowing()
  {
    return !UiUtils.isHidden(mFrame);
  }

  void open()
  {
{'fraction_non_alphanumeric': 0.0955434434113498, 'fraction_numerical': 0.0, 'mean_word_length': 4.63086642599278, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3751850', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1906, 'n_words': 370}