package macampcorp.macamp.activities;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import macampcorp.macamp.game.Game;
import macampcorp.macamp.game.scheduler.Scheduler;

public class ErrorActivity extends AppCompatActivity {

    protected Game mGame;
    protected String mText="";
    protected String mTitle="";
    protected TextView mEt;
    protected TextView mTvTitle;
    public static int REQUEST_CODE=-1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_error);
        mEt=(TextView)findViewById(R.id.message);
        mTvTitle=(TextView)findViewById(R.id.title);
        mText=getIntent().getExtras().getString("text", "");
        mTitle=getIntent().getExtras().getString("title", "Error");
        mEt.setText(mText);
        mTvTitle.setText(mTitle);
    }

    public void onOk(View v)
    {
        setResult(0);
        finish();
    }

    public static void error(Activity ctx, String text)
    {
        Intent intent = new Intent(ctx, ErrorActivity.class);
        intent.putExtra("text", text);
        ctx.startActivityForResult(intent, REQUEST_CODE);
    }

    public static void error(Activity ctx, String title, String text)
    {
        Intent intent = new Intent(ctx, ErrorActivity.class);
        intent.putExtra("text", text);
        intent.putExtra("title", title);
        ctx.startActivityForResult(intent, REQUEST_CODE);
    }


    @Override
    public void onBackPressed() {
        setResult(0);
        super.onBackPressed();
    }

}
