package org.keyscience.app;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import org.keyscience.BackgroundTask.HttpDrawableAsync;
import org.keyscience.R;
import org.keyscience.SingletonPattern.SingletonEcoQuests;
import org.keyscience.adapters.MapItemAdapter;
import org.keyscience.models.EcoQuestModel;
import org.keyscience.network.DatabaseConnection;

import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;

public class EcoQuestInfoActivity extends AppCompatActivity {

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

        final Intent intent = getIntent();

        TextView title = findViewById(R.id.ecoquest_title);
        TextView content = findViewById(R.id.ecoquest_content);
        ImageView imageView = findViewById(R.id.ecoquest_image);
        Button button = findViewById(R.id.ecoquest_learnMore);

        title.setText(intent.getStringExtra("TITLE"));
        content.setText(Html.fromHtml(intent.getStringExtra("CONTENT"), Html.FROM_HTML_MODE_LEGACY));
        Picasso.get().load(intent.getStringExtra("IMAGE"))
                .noFade()
                .into(imageView);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intentInfo = new Intent(Intent.ACTION_VIEW, Uri.parse(intent.getStringExtra("MORE")));
                if (intentInfo.resolveActivity(getPackageManager()) != null) {
                    startActivity(intentInfo);
                }
            }
        });

    }
}
