Skip to content

Commit 61ced0f

Browse files
author
ehowlsla
committed
update android backbutton call close event
1 parent b8a9f2c commit 61ced0f

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

bootpay/src/main/java/kr/co/bootpay/BootpayDialog.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package kr.co.bootpay;
22

3+
import android.app.Dialog;
34
import android.app.DialogFragment;
5+
import android.content.DialogInterface;
46
import android.os.Bundle;
7+
import android.view.KeyEvent;
58
import android.view.LayoutInflater;
69
import android.view.View;
710
import android.view.ViewGroup;
@@ -16,6 +19,16 @@ public class BootpayDialog extends DialogFragment {
1619
protected BootpayWebView bootpay;
1720
private EventListener listener;
1821

22+
// @Override
23+
// public Dialog onCreateDialog(Bundle savedInstanceState) {
24+
// return new Dialog(getActivity(), getTheme()){
25+
// @Override
26+
// public void onBackPressed() {
27+
// //do your stuff
28+
// }
29+
// };
30+
// }
31+
1932
@Override
2033
public void onCreate(Bundle savedInstanceState) {
2134
super.onCreate(savedInstanceState);
@@ -31,16 +44,38 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
3144

3245
@Override
3346
public void onDestroyView() {
34-
35-
// UserInfo.getInstance(getContext()).update();
3647
super.onDestroyView();
3748
}
3849

3950
private void afterViewInit() {
40-
if (bootpay != null)
51+
if (bootpay != null) {
52+
Dialog dialog = getDialog();
53+
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
54+
@Override
55+
public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent keyEvent) {
56+
if(keyCode == KeyEvent.KEYCODE_BACK) {
57+
if(listener != null)
58+
listener.onClose("android backbutton clicked");
59+
}
60+
return false;
61+
}
62+
});
4163
bootpay.setRequest(request)
42-
.setDialog(getDialog())
64+
.setDialog(dialog)
4365
.setOnResponseListener(listener);
66+
}
67+
68+
69+
70+
// setOnKeyListener(new DialogInterface.OnKeyListener() {
71+
// @Override
72+
// public boolean onKey(android.content.DialogInterface dialog, int keyCode, android.view.KeyEvent event) {
73+
//
74+
// if ((keyCode == android.view.KeyEvent.KEYCODE_BACK)) {
75+
//
76+
// }
77+
// }
78+
// }
4479
}
4580

4681
public BootpayDialog setOnResponseListener(EventListener listener) {

sample/src/main/java/bootpay/co/kr/samplepayment/NativeActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class NativeActivity extends Activity {
3232

3333

3434

35+
36+
3537
@Override
3638
protected void onCreate(Bundle savedInstanceState) {
3739
super.onCreate(savedInstanceState);
@@ -76,8 +78,8 @@ public void onClick_request(View v) {
7678
Bootpay.init(getFragmentManager())
7779
.setContext(this)
7880
.setApplicationId(application_id) // 해당 프로젝트(안드로이드)의 application id 값
79-
.setPG(PG.INICIS) // 결제할 PG 사
80-
.setMethod(Method.VBANK)
81+
// .setPG(PG.KICC) // 결제할 PG 사
82+
// .setMethod(Method.CARD)
8183
.setBootExtra(bootExtra)
8284
.setBootUser(bootUser)
8385
// .setUserPhone("010-1234-5678") // 구매자 전화번호

0 commit comments

Comments
 (0)