// Path: app/src/main/java/com/kejiwen/architecture/listener/OnBackStackListener.java
// public interface OnBackStackListener {
//     public void onBackStack();
// }


import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
import com.kejiwen.architecture.R;
import com.kejiwen.architecture.listener.OnBackStackListener;
package com.kejiwen.architecture.customview;



public final class TitleBar {
    private Context mContext;

    private View mRoot;
    private ImageButton mBackButton;
    private TextView mTitle;
    private ImageButton mSettingButton;

    public TitleBar(Activity activity, int titleId) {
        this(activity.getWindow().getDecorView(), titleId);
        mContext = activity;
    }

    public TitleBar(View view, int titleId) {
        mRoot = view.findViewById(titleId);
        mBackButton = (ImageButton) mRoot.findViewById(R.id.back);
        mTitle = (TextView) mRoot.findViewById(R.id.title);
        mSettingButton = (ImageButton) mRoot.findViewById(R.id.settings);
    }

    public void setTitleVisibility(boolean visibility) {
        if (visibility) {
            mRoot.setVisibility(View.VISIBLE);
        } else {
            mRoot.setVisibility(View.GONE);
        }
    }

    public void setTitle(CharSequence title) {
        mTitle.setText(title);
    }

    public void setTitle(int titleRes) {
        setTitle(mContext.getText(titleRes));
    }


// Path: app/src/main/java/com/kejiwen/architecture/listener/OnBackStackListener.java
// public interface OnBackStackListener {
//     public void onBackStack();
// }


// Path: app/src/main/java/com/kejiwen/architecture/customview/TitleBar.java
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
import com.kejiwen.architecture.R;
import com.kejiwen.architecture.listener.OnBackStackListener;

package com.kejiwen.architecture.customview;



public final class TitleBar {
    private Context mContext;

    private View mRoot;
    private ImageButton mBackButton;
    private TextView mTitle;
    private ImageButton mSettingButton;

    public TitleBar(Activity activity, int titleId) {
        this(activity.getWindow().getDecorView(), titleId);
        mContext = activity;
    }

    public TitleBar(View view, int titleId) {
        mRoot = view.findViewById(titleId);
        mBackButton = (ImageButton) mRoot.findViewById(R.id.back);
        mTitle = (TextView) mRoot.findViewById(R.id.title);
        mSettingButton = (ImageButton) mRoot.findViewById(R.id.settings);
    }

    public void setTitleVisibility(boolean visibility) {
        if (visibility) {
            mRoot.setVisibility(View.VISIBLE);
        } else {
            mRoot.setVisibility(View.GONE);
        }
    }

    public void setTitle(CharSequence title) {
        mTitle.setText(title);
    }

    public void setTitle(int titleRes) {
        setTitle(mContext.getText(titleRes));
    }


    public void setBackButton(int resid, final OnBackStackListener listener) {