package com.gensee.multi_instance.demo.player;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.gensee.multi_instance.R;
import com.gensee.player.Player;
import com.gensee.view.GSDocViewGx;

@SuppressLint("ValidFragment")
public class DocFragment extends Fragment {


//	private Player mPlayer;
	private View mView;
	private GSDocViewGx mGlDocView;

	public DocFragment() {


	}
	public Player getPlayer() {
		return ((PlayerFragment)getParentFragment()).getPlayer();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		mView = inflater.inflate(R.layout.imdoc, null);
		mGlDocView = (GSDocViewGx) mView.findViewById(R.id.imGlDocView);
		mGlDocView.post(new Runnable() {
			@Override
			public void run() {
				getPlayer().setGSDocViewGx(mGlDocView);
			}
		});



//		AnnoFreepenEx.setFreepenExDrawable(new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.freepen_ex)));
//		AnnoPointerEx.setPointerCircleDrawable(new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.anno_pointer)));
//		AnnoPointerEx.setPointerCrossDrawable(new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.anno_arrow)));
		return mView;

	}

	public void showView(boolean show) {
		if (mGlDocView != null) {
			mGlDocView.setVisibility(show ? View.VISIBLE : View.GONE);
		}
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		if (mGlDocView != null) {
			mGlDocView.destroy();
		}




	}
}
