package com.usai.apex;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

public class LicenseActivity extends AppCompatActivity {
    private void setCustomActionBar() {
        ActionBar.LayoutParams lp =new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
        View mActionBarView = LayoutInflater.from(this).inflate(R.layout.actionbar_customtitle, null);

        TextView mtitleview= mActionBarView.findViewById(R.id.title);

//        String license_name=getIntent().getStringExtra("function_name");
        String function_name = getIntent().getStringExtra("function_name");
//        String title = "";
//        if(function_name.equals("Ocean Booking"))
//            title="Booking Detail";
//        else if(function_name.equals("Ocean B/L info."))
//            title="B/L info. Detail";
//        else if(function_name.equals("Container detail"))
//            title="Container Detail";
//        else if(function_name.equals("Cargo Tracking"))
//            title="Cargo Detail";
        mtitleview.setText(function_name);
        setTitle(function_name);
////
//        mActionBarView.setBackgroundColor(Color.YELLOW);
//        titleview.setBackgroundColor(Color.BLUE);
        ActionBar actionBar = getSupportActionBar();
        actionBar.setCustomView(mActionBarView, lp);
//        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
//        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);


//        actionBar.setIcon(getNumberDrawable());
//        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_license);
        setCustomActionBar();
        String license_content=getIntent().getStringExtra("content");

        TextView tv = findViewById(R.id.tv_license);
        tv.setText(license_content);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {


            case android.R.id.home:
                finish();
                break;
                default:
                    break;
        }
        return super.onOptionsItemSelected(item);
    }
}
