package code.abdulrahman.bookStore;

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

import androidx.fragment.app.FragmentTransaction;

public class NewMainActivity extends BaseActivity implements OnItemSelectedListener {

    LinearLayout linearLayout;

    @Override
    protected int getContentView() {
        return R.layout.first_page;
    }

    @Override
    protected void onViewReady(Bundle savedInstanceState, Intent intent) {
        super.onViewReady(savedInstanceState, intent);

        linearLayout = findViewById(R.id.baseLayout);
        LayoutInflater layoutInflater = LayoutInflater.from(NewMainActivity.this);
        layoutInflater.inflate(getContentView(), linearLayout, true);

//        if (savedInstanceState == null) {
//            BookTitleListFragment firstFragment = new BookTitleListFragment();
//            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//            ft.add(R.id.frame1, firstFragment);
//            if (findViewById(R.id.layoutWithDaulFragments) != null) {
//                BookTitleAndDescriptionlFragment secondFragment = new BookTitleAndDescriptionlFragment();
//                Bundle args = new Bundle();
//                args.putInt("position", 0);
//                secondFragment.setArguments(args);   // (1) Communicate with Fragment using Bundle
//                ft.add(R.id.frame2, secondFragment);     // add    Fragment
//            }
//            ft.commit();
//        }
    }


    @Override
    public void onBookItemSelected(int position) {
//        Toast.makeText(this, "Called By Fragment A: position - " + position, Toast.LENGTH_SHORT).show();
//
//        // Load Book Detail Fragment
//        BookTitleAndDescriptionlFragment secondFragment = new BookTitleAndDescriptionlFragment();
//
//        Bundle args = new Bundle();
//        args.putInt("position", position);
//        secondFragment.setArguments(args);

//        if (findViewById(R.id.frame2) != null) {
//
//            getSupportFragmentManager()
//                    .beginTransaction()
//                    .replace(R.id.frame2, secondFragment)
//                    .addToBackStack(null)
//                    .commit();
//        } else {
//            getSupportFragmentManager()
//                    .beginTransaction()
//                    .replace(R.id.frame1, secondFragment)
//                    .addToBackStack(null)
//                    .commit();
//        }
    }
}
