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

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Toast;

import com.mapswithme.maps.traffic.TrafficManager;

public class TrafficButtonController implements TrafficManager.TrafficCallback
{
  @NonNull
  private final TrafficButton mButton;
  @NonNull
  private final Activity mActivity;

  public TrafficButtonController(@NonNull TrafficButton button, @NonNull Activity activity)
  {
    mButton = button;
    mButton.setClickListener(new OnTrafficClickListener());
    mActivity = activity;
  }

  @Override
  public void onEnabled()
  {
    mButton.turnOn();
  }

  @Override
  public void onDisabled()
  {
    mButton.turnOff();
  }

  @Override
  public void onWaitingData()
  {
    mButton.setLoading(true);
  }

  @Override
  public void onOutdated()
  {
    mButton.markAsOutdated();
  }

  @Override
  public void onNoData()
  {
    //TODO: put localized string
    Toast.makeText(mActivity, "There is not traffic data here", Toast.LENGTH_SHORT).show();
  }

  @Override
  public void onNetworkError()
  {
    //TODO: put localized string
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
        .setMessage("Network problem encountered. Traffic data cannot be obtained.")
        .setPositiveButton("OK", new DialogInterface.OnClickListener()
        {
          @Override
          public void onClick(DialogInterface dialog, int which)
          {
            TrafficManager.INSTANCE.disable();
          }
        })
        .setCancelable(false);
    builder.show();
  }

  @Override
  public void onExpiredData()
  {
    //TODO: put localized string
    Toast.makeText(mActivity, "Traffic data is outdated", Toast.LENGTH_SHORT).show();
  }

  @Override
  public void onExpiredApp()
  {
    //TODO: put localized string
    Toast.makeText(mActivity, "The app needs to be updated to get traffic data", Toast.LENGTH_SHORT).show();
  }

  private class OnTrafficClickListener implements View.OnClickListener
  {
    @Override
    public void onClick(View v)
    {
      TrafficManager.INSTANCE.toggle();
    }
  }
}<commit_msg>[android] Fixed the traffic button icon during screen rotation<commit_after>package com.mapswithme.maps.traffic.widget;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Toast;

import com.mapswithme.maps.traffic.TrafficManager;

public class TrafficButtonController implements TrafficManager.TrafficCallback
{
  @NonNull
  private final TrafficButton mButton;
  @NonNull
  private final Activity mActivity;

  public TrafficButtonController(@NonNull TrafficButton button, @NonNull Activity activity)
  {
    mButton = button;
    mButton.setClickListener(new OnTrafficClickListener());
    mActivity = activity;
  }

  @Override
  public void onEnabled()
  {
    mButton.turnOn();
  }

  @Override
  public void onDisabled()
  {
    mButton.turnOff();
  }

  @Override
  public void onWaitingData()
  {
    mButton.setLoading(true);
  }

  @Override
  public void onOutdated()
  {
    mButton.markAsOutdated();
  }

  @Override
  public void onNoData()
  {
    mButton.turnOn();
    //TODO: put localized string
    Toast.makeText(mActivity, "There is not traffic data here", Toast.LENGTH_SHORT).show();

  }

  @Override
  public void onNetworkError()
  {
    //TODO: put localized string
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
        .setMessage("Network problem encountered. Traffic data cannot be obtained.")
        .setPositiveButton("OK", new DialogInterface.OnClickListener()
        {
          @Override
          public void onClick(DialogInterface dialog, int which)
          {
            TrafficManager.INSTANCE.disable();
          }
        })
        .setCancelable(false);
    builder.show();
  }

  @Override
  public void onExpiredData()
  {
    mButton.turnOn();
    //TODO: put localized string
    Toast.makeText(mActivity, "Traffic data is outdated", Toast.LENGTH_SHORT).show();
  }

  @Override
  public void onExpiredApp()
  {
    mButton.turnOn();
    //TODO: put localized string
    Toast.makeText(mActivity, "The app needs to be updated to get traffic data", Toast.LENGTH_SHORT).show();
  }

  private class OnTrafficClickListener implements View.OnClickListener
  {
    @Override
    public void onClick(View v)
    {
      TrafficManager.INSTANCE.toggle();
    }
  }
}
{'fraction_non_alphanumeric': 0.09577221742881795, 'fraction_numerical': 0.0, 'mean_word_length': 3.333644859813084, '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': '7252079', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1322, 'n_words': 329}