光环助手V4.7.0-积分体系(第2期)--邀请好友(V4.7.0-积分体系(第2期)--邀请好友-UI测试问题-4、0319 产品验收问题 第1点)
This commit is contained in:
@ -244,7 +244,7 @@ class DefaultJsApi(var context: Context) {
|
||||
Base64ImageHolder.image = inviteEvent.poster.run {
|
||||
if (this.startsWith("data:image/png;base64")) this.split(",")[1] else this
|
||||
}
|
||||
MessageShareUtils.getInstance(context).shareFromWeb(context, inviteEvent.way)
|
||||
MessageShareUtils.getInstance(context).shareInviteFriends(context, inviteEvent.way)
|
||||
} else {
|
||||
ShareUtils.getInstance(context).shareInviteFriends(context, inviteEvent.url, inviteEvent.way)
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.gh.gamecenter.energy
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.constant.Constants
|
||||
@ -10,6 +10,7 @@ import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.NoviceTaskItemBinding
|
||||
import com.gh.gamecenter.entity.TaskEntity
|
||||
import com.gh.gamecenter.gamedetail.dialog.InviteCodeDialog
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
@ -63,16 +64,13 @@ class HorizontalTaskAdapter(context: Context,
|
||||
when (task.status) {
|
||||
"normal" -> {
|
||||
if (task.action == "enter_invite_code") {
|
||||
if (UserManager.getInstance().userInfoEntity?.loginMobile.isNullOrEmpty()) {
|
||||
InviteCodeHelper.showBindPhonePopUp(mContext as Activity)
|
||||
} else {
|
||||
InviteCodeHelper.showInviteCodePopUp(
|
||||
mContext as Activity,
|
||||
"task_list")
|
||||
{
|
||||
task.status = "finished"
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
InviteCodeDialog.showInviteCodeDialog(
|
||||
mContext as AppCompatActivity,
|
||||
UserManager.getInstance().userInfoEntity?.loginMobile?.isNotEmpty() ?: false,
|
||||
"task_list")
|
||||
{
|
||||
task.status = "finished"
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
} else {
|
||||
SPUtils.setBoolean(Constants.SP_SHOW_TASK_FLOAT, true)
|
||||
|
||||
@ -1,163 +0,0 @@
|
||||
package com.gh.gamecenter.energy
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.security.BindPhoneActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* 邀请码弹窗辅助类
|
||||
*/
|
||||
object InviteCodeHelper: KeyboardHeightObserver {
|
||||
|
||||
private var mKeyboardHeightProvider: KeyboardHeightProvider? = null
|
||||
private var contentView: View? = null
|
||||
|
||||
// 绑定手机弹窗
|
||||
@JvmStatic
|
||||
fun showBindPhonePopUp (activity: Activity) {
|
||||
val contentView = View.inflate(activity, R.layout.popup_invite_bind, null)
|
||||
val popWindow = PopupWindow (
|
||||
contentView,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
contentView.run {
|
||||
findViewById<ImageView>(R.id.closeIv)
|
||||
.setOnClickListener {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
findViewById<TextView>(R.id.bindBtn).setOnClickListener {
|
||||
activity.startActivity(BindPhoneActivity.getNormalIntent(activity, false))
|
||||
}
|
||||
|
||||
isFocusable = true
|
||||
isFocusableInTouchMode = true
|
||||
|
||||
setOnClickListener {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
popWindow.run {
|
||||
isClippingEnabled = false
|
||||
showAtLocation(
|
||||
activity.window.decorView,
|
||||
Gravity.BOTTOM, 0, 0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 好友邀请码弹窗
|
||||
@JvmStatic
|
||||
fun showInviteCodePopUp (activity: Activity, from: String, callback: () -> Unit) {
|
||||
mKeyboardHeightProvider = KeyboardHeightProvider(activity)
|
||||
mKeyboardHeightProvider?.start()
|
||||
mKeyboardHeightProvider?.setKeyboardHeightObserver(this)
|
||||
|
||||
contentView = View.inflate(activity, R.layout.popup_invite_code, null)
|
||||
val popWindow = PopupWindow (
|
||||
contentView,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
contentView?.run {
|
||||
findViewById<ImageView>(R.id.closeIv)
|
||||
.setOnClickListener {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
val inviteCodeEt = findViewById<EditText>(R.id.inviteEt)
|
||||
findViewById<TextView>(R.id.confirmBtn).setOnClickListener {
|
||||
val code = inviteCodeEt.text.toString().trim { it <= ' ' }.replace(" ".toRegex(), "")
|
||||
val newCallback = {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
callback.invoke()
|
||||
}
|
||||
checkInviteCode(code, from, newCallback, {})
|
||||
}
|
||||
|
||||
isFocusable = true
|
||||
isFocusableInTouchMode = true
|
||||
|
||||
setOnClickListener {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
popWindow.run {
|
||||
isFocusable = true
|
||||
isClippingEnabled = false
|
||||
|
||||
setOnDismissListener {
|
||||
mKeyboardHeightProvider?.close()
|
||||
}
|
||||
|
||||
showAtLocation(
|
||||
activity.window.decorView,
|
||||
Gravity.BOTTOM, 0, 0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun checkInviteCode(code: String, from: String, successCallback: () -> Unit, failCallback: () -> Unit) {
|
||||
val params = JSONObject()
|
||||
params.put("code", code)
|
||||
params.put("type", "new")
|
||||
params.put("from", "from")
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), params.toString())
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api.checkInviteCode(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
EnergyTaskHelper.postInviteCodeTask(code, from, successCallback, failCallback)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
ToastUtils.showToast("邀请码错误")
|
||||
failCallback.invoke()
|
||||
// EnergyTaskHelper.postInviteCodeTask(code, from, callback)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onKeyboardHeightChanged(height: Int, orientation: Int) {
|
||||
contentView?.setPadding(
|
||||
0, 0, 0,
|
||||
if (height > 0) height else 0
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
package com.gh.gamecenter.energy
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -16,6 +16,7 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.baselist.LoadStatus
|
||||
import com.gh.gamecenter.databinding.*
|
||||
import com.gh.gamecenter.gamedetail.dialog.InviteCodeDialog
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
|
||||
class TaskAdapter(context: Context) : ListAdapter<TaskItemData>(context) {
|
||||
@ -153,16 +154,13 @@ class TaskAdapter(context: Context) : ListAdapter<TaskItemData>(context) {
|
||||
when (task.status) {
|
||||
"normal" -> {
|
||||
if (task.action == "enter_invite_code") {
|
||||
if (UserManager.getInstance().userInfoEntity?.loginMobile.isNullOrEmpty()) {
|
||||
InviteCodeHelper.showBindPhonePopUp(mContext as Activity)
|
||||
} else {
|
||||
InviteCodeHelper.showInviteCodePopUp(
|
||||
mContext as Activity,
|
||||
"task_list")
|
||||
{
|
||||
task.status = "finished"
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
InviteCodeDialog.showInviteCodeDialog(
|
||||
mContext as AppCompatActivity,
|
||||
UserManager.getInstance().userInfoEntity?.loginMobile?.isNotEmpty() ?: false,
|
||||
"task_list")
|
||||
{
|
||||
task.status = "finished"
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
} else {
|
||||
SPUtils.setBoolean(Constants.SP_SHOW_TASK_FLOAT, true)
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
package com.gh.gamecenter.gamedetail.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.common.dialog.BaseDraggableDialogFragment
|
||||
import com.gh.common.util.EnergyTaskHelper
|
||||
import com.gh.common.util.ToastUtils
|
||||
import com.gh.gamecenter.databinding.DialogInviteCodeBinding
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.security.BindPhoneActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
|
||||
class InviteCodeDialog : BaseDraggableDialogFragment() {
|
||||
|
||||
private lateinit var mBinding: DialogInviteCodeBinding
|
||||
var isBind: Boolean = false
|
||||
var from: String = ""
|
||||
var callback: () -> Unit = {}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return DialogInviteCodeBinding.inflate(inflater, container, false).apply { mBinding = this }.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
mBinding.run {
|
||||
if (isBind) {
|
||||
bindPhoneContainer.visibility = View.GONE
|
||||
inviteCodeContainer.visibility = View.VISIBLE
|
||||
} else {
|
||||
bindPhoneContainer.visibility = View.VISIBLE
|
||||
inviteCodeContainer.visibility = View.GONE
|
||||
}
|
||||
|
||||
bindCloseIv.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
bindBtn.setOnClickListener {
|
||||
requireActivity().startActivity(BindPhoneActivity.getNormalIntent(requireActivity(), false))
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
inviteCloseIv.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
confirmBtn.setOnClickListener {
|
||||
val code = inviteEt.text.toString().trim { it <= ' ' }.replace(" ".toRegex(), "")
|
||||
val newCallback = {
|
||||
dismissAllowingStateLoss()
|
||||
callback.invoke()
|
||||
}
|
||||
checkInviteCode(code, from, newCallback, {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun checkInviteCode(code: String, from: String, successCallback: () -> Unit, failCallback: () -> Unit) {
|
||||
val params = JSONObject()
|
||||
params.put("code", code)
|
||||
params.put("type", "new")
|
||||
params.put("from", "from")
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), params.toString())
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api.checkInviteCode(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
EnergyTaskHelper.postInviteCodeTask(code, from, successCallback, failCallback)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
ToastUtils.showToast("邀请码错误")
|
||||
failCallback.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun getRootView(): View = mBinding.root
|
||||
override fun getDragCloseView(): View = if (isBind) mBinding.inviteCloseIv else mBinding.bindCloseIv
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun showInviteCodeDialog(activity: AppCompatActivity, isBind: Boolean, from: String, callback: () -> Unit) {
|
||||
var fragment = activity.supportFragmentManager.findFragmentByTag(InviteCodeDialog::class.java.name) as? InviteCodeDialog
|
||||
if (fragment == null) {
|
||||
fragment = InviteCodeDialog()
|
||||
fragment.isBind = isBind
|
||||
fragment.from = from
|
||||
fragment.callback = callback
|
||||
fragment.show(activity.supportFragmentManager, InviteCodeDialog::class.java.name)
|
||||
} else {
|
||||
fragment.isBind = isBind
|
||||
fragment.from = from
|
||||
fragment.callback = callback
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(fragment)
|
||||
transaction.commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,6 @@ class BindPhoneConflictFragment : NormalFragment() {
|
||||
mContentView = layoutInflater.inflate(R.layout.dialog_conflict_guide, null)
|
||||
mPopupWindow = PopupWindow(mContentView, 330f.dip2px(), ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
mPopupWindow.run {
|
||||
contentView = contentView
|
||||
isOutsideTouchable = true
|
||||
isFocusable = true
|
||||
}
|
||||
|
||||
@ -5,7 +5,56 @@
|
||||
android:background="@color/bg_popup">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/content"
|
||||
android:id="@+id/bindPhoneContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="208dp"
|
||||
android:padding="16dp"
|
||||
android:background="@drawable/bg_invite_dialog"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textColor="@color/text_333333"
|
||||
android:textStyle="bold"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/invite_bind_title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bindCloseIv"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:src="@drawable/ic_invite_close" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="48dp"
|
||||
android:lineSpacingExtra="8dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/text_333333"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/invite_no_bind_tip" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bindBtn"
|
||||
android:layout_width="296dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/login_btn_bg"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/invite_no_bind_btn" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/inviteCodeContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="240dp"
|
||||
android:padding="16dp"
|
||||
@ -14,7 +63,6 @@
|
||||
android:clickable="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
@ -24,7 +72,7 @@
|
||||
android:text="@string/invite_code_title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/closeIv"
|
||||
android:id="@+id/inviteCloseIv"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentRight="true"
|
||||
@ -53,7 +101,6 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descTv"
|
||||
android:layout_width="296dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
Reference in New Issue
Block a user