package com.xypower.mpapp.video;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import android.content.Intent;
import android.os.Bundle;

import com.xypower.mpapp.R;

public class VideoActivity extends AppCompatActivity {

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

        if (null == savedInstanceState) {
        	Bundle bundle = new Bundle();
            Intent intent = getIntent();

            int duration = intent.getIntExtra("duration", 0);
            if (intent.hasExtra("cameraId")) {
                bundle.putInt("cameraId", intent.getIntExtra("cameraId", 0));
            }
            if (intent.hasExtra("videoId")) {
                bundle.putLong("videoId", intent.getLongExtra("videoId", 0));
            }

            bundle.putInt("duration", duration);
            String act = intent.getStringExtra("action");
            if (act != null) {
                bundle.putString("action", act);
            }

            bundle.putInt("width", intent.getIntExtra("width", 0));
            bundle.putInt("height", intent.getIntExtra("height", 0));

            Fragment fragment = VideoFragment.newInstance();
            fragment.setArguments(bundle);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, fragment)
                    .commit();
        }
    }
}