package epson.print;

import android.view.MenuItem;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

/**
 * 基类
 */
public abstract class ActivityIACommon extends AppCompatActivity {

    /**
     * 设置标题栏
     *
     * @param i
     * @param z
     */
    protected void setActionBar(int resId, boolean z) {
        setActionBar(getResources().getString(resId), z);
    }

    protected void setActionBar(String str, boolean z) {
        setTitle(str);
        setSupportActionBar((Toolbar) findViewById(R.id.navigation_bar));
        if (z) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        onBackPressed();
        return true;
    }
}
