package com.bahram.relationshippoints.GUI.TimelineList.Timeline.TimelineEvents.TimelineViewHolders;

import android.app.Activity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bahram.relationshippoints.GUI.GUIfunctions;
import com.bahram.relationshippoints.GUI.TimelineList.Timeline.TimelineEvent;
import com.bahram.relationshippoints.R;
import com.bam.relationshipcorelibrary.Core.DatabaseObjects.RelPerson;
import com.bam.relationshipcorelibrary.Core.DatabaseObjects.Relationship.RelationshipAchievement;

import java.util.ArrayList;

/**
 * Created by bahram on 12.01.2015.
 */
public class TimelineAchievement extends TimelineEvent
{
    private static final String TAG = "TimelineAchievement";

    public RelationshipAchievement achievement;


    public TimelineAchievement(Activity act, RelPerson eventOwner, RelationshipAchievement achievement, ArrayList<String> eventMediaUris)
    {
        super(act, eventOwner, eventMediaUris);
        this.achievement = achievement;
        this.eventMediaUris = eventMediaUris;
    }

    /**
     * This function will return the mandatory Event Icon Image that should be placed at the top
     * of the view, next to the Event Title.
     */
    @Override
    public void setupEventIconImage(ImageView imageView)
    {

    }

    /**
     * This function will return the mandatory Event Title that should be placed at the top
     * of the view, next to the Event Icon Image.
     */
    @Override
    public void setupEventTitle(TextView textView)
    {
        if( textView != null && achievement != null )
        {
            textView.setText("Achievement!");
        }
    }

    /**
     * This function setup the events Icon Image field, that should be placed at the top
     * of the view, next to the Event Type Icon. (MANDATORY)
     *
     * @param imageView
     */
    @Override
    public void setupEventTypeIconImage(ImageView imageView)
    {
        if( imageView != null )
        {
            imageView.setImageResource(R.drawable.category_adventure);
            imageView.invalidate();
        }
    }

    /**
     * The (optional) image belonging to the event.
     */
    @Override
    public void setupMainEventImage(ViewGroup view)
    {
    }

    /**
     * This function will return the mandatory Event Main Text that should be placed in the center
     * of the view.
     */
    @Override
    public void setupEventMainText(TextView textView)
    {
        textView.setText("Ach");
    }

    /**
     * The (Optional) points that go along with the event.
     */
    @Override
    public void setupEventPoints(TextView textView)
    {

    }

    @Override
    public void setupEventSubList(View view)
    {

    }

    @Override
    public void setupEventComments(ImageView imageView)
    {

//        textView.setEnabled(false);
    }

    @Override
    public void setupEventShare(ImageView imageView)
    {

//        textView.setEnabled(false);
    }

    @Override
    public void setupEventHeart(ImageView imageView)
    {

//        imageView.setEnabled(false);
    }

    @Override
    public void setupEventTimestamp(TextView textView)
    {
        if( textView != null && achievement != null )
        {
            textView.setText(GUIfunctions.getTimestampText(achievement.getRelAch_timestamp(), achievement.getRelAch_timezone()));
        }
    }


    @Override
    public void setupEventMenu(ImageView imageView)
    {

    }

    /**
     * Called when a view has been clicked.
     *
     * @param v The view that was clicked.
     */
    @Override
    public void onClick(View v)
    {
        GUIfunctions.functionNotImplementedYet(act);
    }

    /**
     * This method will be invoked when a menu item is clicked if the item itself did
     * not already handle the event.
     *
     * @param item {@link MenuItem} that was clicked
     * @return <code>true</code> if the event was handled, <code>false</code> otherwise.
     */
    @Override
    public boolean onMenuItemClick(MenuItem item)
    {
        return false;
    }
}
