package com.drabarz.karola.raillearn.trip.details;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.drabarz.karola.raillearn.R;
import com.drabarz.karola.raillearn.model.Trip;

public abstract class FullTripActivity extends AppCompatActivity {

    protected static final String TRIP = "trip";
    protected Trip trip;
    protected abstract String getConfirmButtonText();

    protected abstract void onConfirmButtonClicked();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.full_trip_activity);
        bindLayout();

        Button deleteButton = (Button) findViewById(R.id.deleteButton);
        deleteButton.setVisibility(Button.GONE);
        Button confirmButton = (Button) findViewById(R.id.confirmButton);
        confirmButton.setText(getConfirmButtonText());
        addConfirmButtonListener();
    }

    private void addConfirmButtonListener() {
        Button confirmButton = (Button) findViewById(R.id.confirmButton);
        confirmButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onConfirmButtonClicked();
            }
        });
    }

    private void bindLayout() {
        trip = (Trip) getIntent().getSerializableExtra(TRIP);
        setTripTitle(trip.getOffer().getTitle());
        setMainTripRoute(trip.getRoute().getMainRoute());
        setTripDate(trip.getRoute().getDeparture().getDate());
        setTripTime(trip.getRoute().getDeparture().getTime());
        setUserName(trip.getUser().getName());
        setTripDescription(trip.getOffer().getDescription());
    }

    private void setTripTitle(String tripTitle) {
        TextView tripTitleTextView = (TextView) findViewById(R.id.tripTitleTextView);
        tripTitleTextView.setText(tripTitle);
    }

    private void setMainTripRoute(String mainRoute) {
        TextView mainRouteTextView = (TextView) findViewById(R.id.tripRouteTextView);
        mainRouteTextView.setText(mainRoute);
    }

    private void setTripDate(String tripDate) {
        TextView tripDateTextView = (TextView) findViewById(R.id.tripDateTextView);
        tripDateTextView.setText(tripDate);
    }

    private void setTripTime(String tripTime) {
        TextView tripTimeTextView = (TextView) findViewById(R.id.tripTimeTextView);
        tripTimeTextView.setText(tripTime);
    }

    private void setUserName(String userName) {
        TextView userNameTextView = (TextView) findViewById(R.id.userNameTextView);
        userNameTextView.setText(userName);
    }

    public void setTripDescription(String tripDescription) {
        TextView tripDescriptionTextView = (TextView) findViewById(R.id.tripDescriptionTextView);
        tripDescriptionTextView.setText(tripDescription);
    }
}

@@ -176,16 +176,49 @@
 Button;%0A
+import android.widget.ImageView;%0A
 import a
@@ -241,16 +241,16 @@
 xtView;%0A
-
 %0Aimport 
@@ -328,16 +328,53 @@
 el.Trip;
+%0Aimport com.squareup.picasso.Picasso;
 %0A%0Apublic
@@ -1865,24 +1865,145 @@
 ription());%0A
+        setUserProfilePhoto(trip.getUser().getProfilPhoto());%0A        setUserCoverPhoto(trip.getUser().getCoverPhoto());%0A
     %7D%0A%0A    p
@@ -2869,32 +2869,32 @@
 rNameTextView);%0A
-
         userName
@@ -2924,24 +2924,476 @@
 me);%0A    %7D%0A%0A
+    private void setUserProfilePhoto(String profilePhotoURL) %7B%0A        ImageView profilePicture = (ImageView) findViewById(R.id.profilePictureImageView);%0A        Picasso.with(this).load(profilePhotoURL).into(profilePicture);%0A    %7D%0A%0A    private void setUserCoverPhoto(String coverPhotoURL) %7B%0A        ImageView coverPicture = (ImageView) findViewById(R.id.coverPictureImageView);%0A        Picasso.with(this).load(coverPhotoURL).into(coverPicture);%0A    %7D%0A%0A
     public v

Set and show users cover and profile photo in FullTripActivity