package com.dbs.dbsec.activity.activityEvent;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.dbs.dbsec.R;
import com.dbs.dbsec.activity.ConsentActivity;
import com.dbs.dbsec.activity.LoginActivity;
import com.dbs.dbsec.consent.sign.SignWrapper;
import com.dbs.dbsec.customView.CustomAlertDialog;
import com.dbs.dbsec.customView.CustomSettingAlertDialog;
import com.dbs.dbsec.util.Common;

public class TopMenu {
  private static final String TAG = "TopMenu";
  private AppCompatActivity mActivity;
  private Context mContext;
  private ConsentActivity instance;

  public TopMenu(Context mContext, AppCompatActivity mActivity) {
    this.mContext  = mContext;
    this.mActivity = mActivity;
    this.instance  = (ConsentActivity) mContext;
  }

  public View.OnClickListener settingClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
//      CustomSettingAlertDialog customSettingAlertDialog = new CustomSettingAlertDialog(mContext);
//      customSettingAlertDialog.show();
    }
  };

  public View.OnClickListener logoutClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      instance.csAlert.show();
      instance.csAlert.setContent(mContext.getString(R.string.logoutMsg), "");
      instance.csAlert.btnConfirm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          instance.csAlert.dismiss();
//          SignWrapper.getInstance().deleteAll();
          Common.clearPreference(mContext, "userInfo");
          Common.clearPreference(mContext, "sessionTime");

          Intent intent = new Intent(mContext, LoginActivity.class);
          mActivity.startActivity(intent);
          mActivity.finish();
        }
      });

      instance.csAlert.btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          instance.csAlert.dismiss();
        }
      });

    }
  };
}
