| | |
| | | package com.dayu.baselibrary.view; |
| | | |
| | | import static android.view.Gravity.CENTER; |
| | | |
| | | import static com.dayu.baselibrary.utils.BaseCommon.HeNanLibrary; |
| | | import static com.dayu.baselibrary.utils.BaseCommon.QHAloneLibrary; |
| | | import static com.dayu.baselibrary.utils.BaseCommon.QHOnLineLibrary; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Intent; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | */ |
| | | public class LibraryDialog extends Dialog { |
| | | |
| | | Intent intent; |
| | | Activity mContext; |
| | | LibraryBean libraryBean; |
| | | LibraryDao libraryDao; |
| | |
| | | |
| | | libraryBack mLibraryBack; |
| | | int type; |
| | | String data; |
| | | |
| | | ConfirmDialog confirmDialog; |
| | | |
| | | public LibraryDialog(Activity context, libraryBack libraryBack) { |
| | | super(context, com.dayu.baselibrary.R.style.ws_pay_showSelfDialog); |
| | | this.intent = intent; |
| | | mContext = context; |
| | | mLibraryBack = libraryBack; |
| | | initView(); |
| | | } |
| | | |
| | | private void initView() { |
| | | getWindow().setGravity(Gravity.CENTER); |
| | | getWindow().setGravity(CENTER); |
| | | setContentView(R.layout.library_dialog); |
| | | setCanceledOnTouchOutside(false); |
| | | setCancelable(false); |
| | | RadioGroup radioGroup = findViewById(R.id.radioLibrary); |
| | | libraryDao = BaseDaoSingleton.getInstance(mContext).libraryDao(); |
| | | libraryBean = libraryDao.findFirst(); |
| | | if (libraryBean == null) { |
| | | libraryBean = new LibraryBean(); |
| | | } |
| | | if (libraryDao != null) { |
| | | libraryBean = libraryDao.findFirst(); |
| | | if (libraryBean == null) { |
| | | libraryBean = new LibraryBean(); |
| | | } |
| | | |
| | | radioGroup.setOnCheckedChangeListener((group, checkedId) -> { |
| | | ischose = true; |
| | | // 当选中的RadioButton发生变化时调用 |
| | | if (checkedId == R.id.henanLibrary) { |
| | | type = 0; |
| | | libraryBean.setType(type); |
| | | } else if (checkedId == R.id.qhAloneLibrary) {// 处理选中Option 2的逻辑 |
| | | type = 1; |
| | | libraryBean.setType(type); |
| | | } |
| | | }); |
| | | TextView okBtn = findViewById(R.id.ok); |
| | | okBtn.setOnClickListener(v -> { |
| | | if (ischose) { |
| | | libraryDao.insert(libraryBean); |
| | | mLibraryBack.listener(type); |
| | | } |
| | | }); |
| | | radioGroup.setOnCheckedChangeListener((group, checkedId) -> { |
| | | ischose = true; |
| | | // 当选中的RadioButton发生变化时调用 |
| | | if (checkedId == R.id.henanLibrary) { |
| | | type = HeNanLibrary; |
| | | libraryBean.setType(type); |
| | | data = "确认选择河南版本吗?"; |
| | | } else if (checkedId == R.id.qhAloneLibrary) {// 处理选中Option 2的逻辑 |
| | | type = QHAloneLibrary; |
| | | libraryBean.setType(type); |
| | | data = "确认选择齐河单机版本吗?"; |
| | | } else if (checkedId == R.id.qhOnLineLibrary) {// 处理选中Option 2的逻辑 |
| | | type = QHOnLineLibrary; |
| | | libraryBean.setType(type); |
| | | data = "确认选择齐河联网版本吗?"; |
| | | } |
| | | }); |
| | | TextView okBtn = findViewById(R.id.ok); |
| | | okBtn.setOnClickListener(v -> { |
| | | if (ischose) { |
| | | //二次确认 |
| | | confirmDialog = new ConfirmDialog(mContext, data, new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | libraryDao.insert(libraryBean); |
| | | mLibraryBack.listener(type); |
| | | LibraryDialog.this.dismiss(); |
| | | confirmDialog.dismiss(); |
| | | } |
| | | }); |
| | | confirmDialog.show(); |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | * 设置宽度全屏,要设置在show的后面 |
| | | */ |
| | | WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); |
| | | layoutParams.gravity = Gravity.CENTER; |
| | | layoutParams.gravity = CENTER; |
| | | layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; |
| | | layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; |
| | | getWindow().getDecorView().setPadding(0, 0, 0, 0); |