package epson.print;

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

import androidx.appcompat.app.AppCompatActivity;


/**
 * 分享页面
 */
public class WebShareActivity extends AppCompatActivity implements CustomTitleDialogFragment.Callback {
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_web_share);
        checkAndStartNextActivity();
    }

    private void checkAndStartNextActivity() {
        if (((IprintApplication) getApplication()).getPrinting()) {
            CustomTitleDialogFragment.newInstance(0, getString(R.string.EPS_PRNST_PRINTING_TITLE), 0, R.string.ok, 0).show(getSupportFragmentManager(), "simple-dialog");
        } else {
            startWebActivity();
        }
    }

    /**
     * 打开web页面
     */
    private void startWebActivity() {
        Intent intent = getIntent();
        intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
        intent.setClass(this, WebviewActivity.class);
        startActivity(intent);
        finish();
    }

    public void onLocalPositiveCallback(int i) {
        finish();
    }

    public void onLocalNegativeCallback(int i) {
        finish();
    }
}
