/*
 * Copyright (C) 2017 Yaroslav Mytkalyk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.doctoror.fuckoffmusicplayer.presentation.queue;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.doctoror.fuckoffmusicplayer.R;
import com.doctoror.fuckoffmusicplayer.presentation.util.ThemeUtils;
import com.doctoror.fuckoffmusicplayer.presentation.widget.ItemTouchHelperViewHolder;

import butterknife.BindDimen;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * View holder for media in playlist
 */
final class QueueItemViewHolder extends RecyclerView.ViewHolder implements
        ItemTouchHelperViewHolder {

    @BindView(R.id.btnMenu)
    ImageView btnMenu;

    @BindView(R.id.textTitle)
    TextView textTitle;

    @BindView(R.id.textArtist)
    TextView textArtist;

    @BindView(R.id.textDuration)
    TextView textDuration;

    @Nullable
    private final Drawable mDefaultBackground;
    private final float mDefaultElevation;

    @BindDimen(R.dimen.list_drag_selected_item_elevation)
    float mElevationSelected;

    private Drawable mSelectedBackground;

    QueueItemViewHolder(@NonNull final View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);

        mDefaultBackground = itemView.getBackground();
        mDefaultElevation = ViewCompat.getElevation(itemView);
    }

    @Override
    public void onItemSelected() {
        itemView.setBackground(getSelectedBackground(itemView.getContext()));
        ViewCompat.setElevation(itemView, mElevationSelected);
    }

    @Override
    public void onItemClear() {
        itemView.setBackground(mDefaultBackground);
        ViewCompat.setElevation(itemView, mDefaultElevation);
    }

    @NonNull
    private Drawable getSelectedBackground(@NonNull final Context context) {
        if (mSelectedBackground != null) {
            return mSelectedBackground;
        }

        mSelectedBackground = new LayerDrawable(new Drawable[]{
                new ColorDrawable(ThemeUtils.getColor(context.getTheme(),
                        android.R.attr.windowBackground)),
                new ColorDrawable(ContextCompat.getColor(context, R.color.dividerBackground))
        });

        return mSelectedBackground;
    }
}

@@ -1351,100 +1351,8 @@
 r;%0A%0A
-import butterknife.BindDimen;%0Aimport butterknife.BindView;%0Aimport butterknife.ButterKnife;%0A%0A
 /**%0A
@@ -1512,204 +1512,106 @@
     
-@BindView(R.id.btnMenu)%0A    ImageView btnMenu;%0A%0A    @BindView(R.id.textTitle)%0A    TextView textTitle;%0A%0A    @BindView(R.id.textArtist)%0A    TextView textArtist;%0A%0A    @BindView(R.id.textDuration)%0A   
+final ImageView btnMenu;%0A%0A    final TextView textTitle;%0A%0A    final TextView textArtist;%0A%0A    final
  Tex
@@ -1744,65 +1744,13 @@
     
-@BindDimen(R.dimen.list_drag_selected_item_elevation)%0A   
+final
  flo
@@ -1909,158 +1909,484 @@
     
-ButterKnife.bind(this, itemView);%0A%0A        mDefaultBackground = itemView.getBackground();%0A        mDefaultElevation = ViewCompat.getElevation(itemView
+btnMenu = itemView.findViewById(R.id.btnMenu);%0A        textTitle = itemView.findViewById(R.id.textTitle);%0A        textArtist = itemView.findViewById(R.id.textArtist);%0A        textDuration = itemView.findViewById(R.id.textDuration);%0A%0A        mDefaultBackground = itemView.getBackground();%0A        mDefaultElevation = ViewCompat.getElevation(itemView);%0A%0A        mElevationSelected = itemView.getResources()%0A                .getDimension(R.dimen.list_drag_selected_item_elevation
 );%0A 

Remove ButterKnife dependency from QueueItemViewHolder