package com.gs.apidemo;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.gs.account.api.BaseAccountApi;
import com.gs.account.entity.SipAccount;
import com.gs.phone.api.audio.AudioRouteApi;
import com.gs.phone.api.call.BaseCallApi;
import com.gs.phone.context.PhoneContext;
import com.gs.phone.entity.DialResults;
import com.gs.phone.entity.DialingInfo;

import java.util.ArrayList;
import java.util.List;

/*
 */
public class TransferActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = TransferActivity.class.getSimpleName();
    private Button mAttendTransferBtn, mBlindTransferBtn;
    private EditText mEditText;
    int mLineId;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transfer);
        mEditText = (EditText) findViewById(R.id.et_number);
        mAttendTransferBtn = (Button) findViewById(R.id.btn_transfer_attend);
        mAttendTransferBtn.setOnClickListener(this);
        mBlindTransferBtn = (Button) findViewById(R.id.btn_transfer_blind);
        mBlindTransferBtn.setOnClickListener(this);

        Intent intent = getIntent();
        mLineId = intent.getIntExtra("lineId", -1);
        if (mLineId == -1) {
            Toast.makeText(this, "No line id", Toast.LENGTH_SHORT).show();
            return;
        }

    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_transfer_attend) {
            String number = mEditText.getText().toString();
            if (!TextUtils.isEmpty(number)) {
                BaseCallApi.transferAttended(mLineId, number);
                setResult(1);
                finish();
            }
        } else if (view.getId() == R.id.btn_transfer_blind) {
            String number = mEditText.getText().toString();
            if (!TextUtils.isEmpty(number)) {
                BaseCallApi.transferBlind(mLineId, number);
                finish();
            }
        }
    }
}
