package code.abdulrahman.bookStore;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.Toast;

public class ChildActivity extends BaseActivity {
    LinearLayout linearLayout;
    @Override
    protected int getContentView() {
        return R.layout.activity_child;
    }
    @Override
    protected void onViewReady(Bundle savedInstanceState, Intent intent) {
        super.onViewReady(savedInstanceState, intent);
        linearLayout = findViewById(R.id.baseLayout);
        LayoutInflater layoutInflater = LayoutInflater.from(ChildActivity.this);
        layoutInflater.inflate(getContentView(), linearLayout, true);
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int id = menuItem.getItemId();
        String phoneNumber = "613 000 0000";
        switch (id) {
            case R.id.action_one:
               Intent intent = new Intent(ChildActivity.this, ThirdActivity.class);
                startActivity(intent);
                break;
                case R.id.action_two:

                intent = new Intent(ChildActivity.this, NewMainActivity.class);
                startActivity(intent);
                break;

            case R.id.action_three:
//                Uri webpage = Uri.parse("http://www.wlu.ca/faculty/abdul-rahman-mawlood-yunis");
//                intent = new Intent(Intent.ACTION_VIEW, webpage);
//                if (intent.resolveActivity(getPackageManager()) != null) {
//                    startActivity(intent);
//                }
//                intent = new Intent(ChildActivity.this, ThirdActivity.class);
//                startActivity(intent);
//                break;
                intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:" + phoneNumber));
                if (intent.resolveActivity(getPackageManager()) != null) {
                    startActivity(intent);
                }
                break;

            case R.id.action_about:
                Toast.makeText(this,
                        "Version 1.0," + " Abdul-Rahman Mawlood-Yunis",
                        Toast.LENGTH_LONG).show();
        }
        return true;
    }
}
