package com.mapswithme.maps.discovery;

import android.support.annotation.NonNull;
import android.support.annotation.StringRes;

import com.mapswithme.maps.R;
import com.mapswithme.maps.search.SearchResult;
import com.mapswithme.util.UiUtils;

public enum ItemType
{
  VIATOR,

  ATTRACTIONS(R.string.discovery_button_subtitle_attractions,
              DiscoveryUserEvent.MORE_ATTRACTIONS_CLICKED,
              DiscoveryUserEvent.ATTRACTIONS_CLICKED)
      {
        @Override
        public void onResultReceived(@NonNull DiscoveryResultReceiver callback,
                                     @NonNull SearchResult[] results)
        {
          callback.onAttractionsReceived(results);
        }

        @Override
        public int getSearchCategory()
        {
          return getSearchCategoryInternal();
        }
      },

  CAFES(R.string.eat, DiscoveryUserEvent.MORE_CAFES_CLICKED, DiscoveryUserEvent.CAFES_CLICKED)
      {
        @Override
        public void onResultReceived(@NonNull DiscoveryResultReceiver callback,
                                     @NonNull SearchResult[] results)
        {
          callback.onCafesReceived(results);
        }

        @Override
        public int getSearchCategory()
        {
          return getSearchCategoryInternal();
        }
      },

  HOTELS(R.string.discovery_button_subtitle_attractions, DiscoveryUserEvent.MORE_HOTELS_CLICKED,
         DiscoveryUserEvent.HOTELS_CLICKED)
      {
        @Override
        public void onResultReceived(@NonNull DiscoveryResultReceiver callback,
                                     @NonNull SearchResult[] results)
        {
          callback.onHotelsReceived(results);
        }
      },

  LOCAL_EXPERTS(R.string.discovery_button_subtitle_attractions,
                DiscoveryUserEvent.MORE_LOCALS_CLICKED,
                DiscoveryUserEvent.LOCALS_CLICKED);

  @StringRes
  private final int mSearchCategory;
  @NonNull
  private final DiscoveryUserEvent mMoreClickEvent;
  @NonNull
  private final DiscoveryUserEvent mItemClickEvent;

  ItemType(@StringRes int searchCategory, @NonNull DiscoveryUserEvent moreClickEvent,
           @NonNull DiscoveryUserEvent itemClickEvent)
  {
    mSearchCategory = searchCategory;
    mMoreClickEvent = moreClickEvent;
    mItemClickEvent = itemClickEvent;
  }

  ItemType()
  {
    this(UiUtils.NO_ID, DiscoveryUserEvent.STUB, DiscoveryUserEvent.STUB);
  }

  @NonNull
  public DiscoveryUserEvent getMoreClickEvent()
  {
    return mMoreClickEvent;
  }

  @NonNull
  public DiscoveryUserEvent getItemClickEvent()
  {
    return mItemClickEvent;
  }

  @StringRes
  protected int getSearchCategoryInternal()
  {
    return mSearchCategory;
  }

  @StringRes
  public int getSearchCategory()
  {
    throw new UnsupportedOperationException("Unsupported by default for " + name());
  }

  public void onResultReceived(@NonNull DiscoveryResultReceiver callback,
                               @NonNull SearchResult[] results)
  {
    /* Do nothing by default */
  }
}

@@ -298,45 +298,15 @@
 ing.
-discovery_button_subtitle_attractions
+tourism
 ,%0A  
@@ -1280,54 +1280,21 @@
 ELS(
-R.string.discovery_button_subtitle_attractions
+UiUtils.NO_ID
 , Di
@@ -1393,32 +1393,176 @@
       @Override%0A
+        public int getSearchCategory()%0A        %7B%0A          throw new UnsupportedOperationException(%22Unsupported.%22);%0A        %7D%0A        @Override%0A
         public v
@@ -1791,54 +1791,61 @@
 RTS(
-R.string.discovery_button_subtitle_attractions
+UiUtils.NO_ID, DiscoveryUserEvent.MORE_LOCALS_CLICKED
 ,%0A  
@@ -1869,37 +1869,32 @@
 coveryUserEvent.
-MORE_
 LOCALS_CLICKED,%0A
@@ -1891,32 +1891,34 @@
 _CLICKED
-,
+)
 %0A      
+%7B%0A
         
   Discov
@@ -1913,44 +1913,151 @@
     
-  DiscoveryUserEvent.LOCALS_CLICKED)
+@Override%0A        public int getSearchCategory()%0A        %7B%0A          throw new UnsupportedOperationException(%22Unsupported.%22);%0A        %7D%0A      %7D
 ;%0A%0A 

Make attractions search in discovery consistent with search categories & minor.