package uni.deepoil.com.ddshare;

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * @author Berial
 * @since 2025-06-16
 */
public class DDShareActivity extends AppCompatActivity { // implements IDDAPIEventHandler {

    // private IDDShareApi mIDDShareApi;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d("lzc" ,"onCreate==========>");
        try {
            // activity的export为true，try起来，防止第三方拒绝服务攻击。APP_ID指通过步骤一获取的应用的AppKey
            // mIDDShareApi = DDShareApiFactory.createDDShareApi(this, "dingcrhejkptu0mcsw3r", true);
            // mIDDShareApi.handleIntent(getIntent(), this);
            // DingTalkModule.shareApi.handleIntent(getIntent(), this);
        } catch (Exception e) {
            // e.printStackTrace();
            Log.d("lzc" , "e===========>" + e);
        }
    }

//    @Override
//    public void onReq(BaseReq baseReq) {
//        System.out.println(baseReq);
//        Bundle bundle = new Bundle();
//        baseReq.toBundle(bundle);
//        System.out.println(bundle);
//    }

//    @Override
//    public void onResp(BaseResp baseResp) {
//        System.out.println(baseResp);
//        int errCode = baseResp.mErrCode;
//        Log.d("lzc", "errorCode==========>" + errCode);
//        String errMsg = baseResp.mErrStr;
//        Log.d("lzc", "errMsg==========>" + errMsg);
//        if (baseResp.getType() == ShareConstant.COMMAND_SENDAUTH_V2 && (baseResp instanceof SendAuth.Resp)) {
//            SendAuth.Resp authResp = (SendAuth.Resp) baseResp;
//            switch (errCode) {
//                case BaseResp.ErrCode.ERR_OK:
//                    Toast.makeText(this, "授权成功，授权码为:" + authResp.code, Toast.LENGTH_SHORT).show();
//                    break;
//                case BaseResp.ErrCode.ERR_USER_CANCEL:
//                    Toast.makeText(this, "授权取消", Toast.LENGTH_SHORT).show();
//                    break;
//                default:
//                    Toast.makeText(this, "授权异常" + baseResp.mErrStr, Toast.LENGTH_SHORT).show();
//                    break;
//            }
//        } else {
//            switch (errCode) {
//                case BaseResp.ErrCode.ERR_OK:
//                    Toast.makeText(this, "分享成功", Toast.LENGTH_SHORT).show();
//                    break;
//                case BaseResp.ErrCode.ERR_USER_CANCEL:
//                    Toast.makeText(this, "分享取消", Toast.LENGTH_SHORT).show();
//                    break;
//                default:
//                    Toast.makeText(this, "分享失败" + baseResp.mErrStr, Toast.LENGTH_SHORT).show();
//                    break;
//            }
//        }
//        finish();
//    }
}
