| | |
| | | package com.dollearn.student.ui.mine |
| | | |
| | | import androidx.core.os.bundleOf |
| | | import androidx.recyclerview.widget.LinearLayoutManager |
| | | import cn.sinata.xldutils.fragment.BaseFragment |
| | | import cn.sinata.xldutils.utils.SPUtils |
| | | import cn.sinata.xldutils.utils.showAllowingStateLoss |
| | | import com.dollearn.student.MainActivity |
| | | import com.dollearn.student.R |
| | | import com.dollearn.student.WeparkApplication |
| | | import com.dollearn.student.dialog.ShareDialog |
| | | import com.dollearn.student.dialog.TipDialog |
| | | import com.dollearn.student.network.entity.Commodity |
| | | import com.dollearn.student.network.Apis |
| | | import com.dollearn.student.network.HttpManager |
| | | import com.dollearn.student.network.entity.UserBean |
| | | import com.dollearn.student.network.entity.WelfareHomeData |
| | | import com.dollearn.student.ui.course.WelfareActivity |
| | | import com.dollearn.student.ui.home.JoinVipActivity |
| | | import com.dollearn.student.network.requestByF |
| | | import com.dollearn.student.ui.login.LoginActivity |
| | | import com.dollearn.student.ui.welfare.* |
| | | import com.dollearn.student.ui.welfare.adapter.WelfareGoodsAdapter |
| | | import com.dollearn.student.utils.Const |
| | | import com.dollearn.student.utils.event.EmptyEvent |
| | | import com.dollearn.student.utils.extention.clickDelay |
| | | import com.dollearn.student.utils.extention.formatToChinese |
| | | import com.dollearn.student.utils.interfaces.StringCallback |
| | | import com.share.utils.ShareUtils |
| | | import com.umeng.socialize.UMShareListener |
| | | import com.umeng.socialize.bean.SHARE_MEDIA |
| | | import com.umeng.socialize.media.UMImage |
| | | import kotlinx.android.synthetic.main.form_view_layout.* |
| | | import kotlinx.android.synthetic.main.fragment_mine.* |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.greenrobot.eventbus.Subscribe |
| | | import org.jetbrains.anko.support.v4.startActivity |
| | | import org.jetbrains.anko.support.v4.toast |
| | | |
| | | class MineFragment : BaseFragment() { |
| | | override fun contentViewId() = R.layout.fragment_mine |
| | |
| | | |
| | | override fun onFirstVisibleToUser() { |
| | | EventBus.getDefault().register(this) |
| | | iv_avatar.clickDelay { startActivity<UserInfoActivity>() } |
| | | tv_name.clickDelay { startActivity<UserInfoActivity>() } |
| | | // tv_coin.clickDelay { startActivityForResult<RechargeRecordActivity>(1) } |
| | | tv_record.clickDelay { startActivity<CoinRecordActivity>() } |
| | | showInfo() |
| | | tv_logout.setOnClickListener { |
| | | val tipDialog = TipDialog() |
| | |
| | | tv_address.setOnClickListener { |
| | | startActivity<AddressManageActivity>() |
| | | } |
| | | tv_share.setOnClickListener { |
| | | val shareDialog = ShareDialog() |
| | | shareDialog.callback = object :StringCallback{ |
| | | override fun onResult(rst: String) { |
| | | HttpManager.shareInfo().requestByF(this@MineFragment){_,data-> |
| | | ShareUtils.share(requireActivity(),if (rst == "wx") SHARE_MEDIA.WEIXIN else SHARE_MEDIA.WEIXIN_CIRCLE,data?.title?:"孩子自己就学会的英语",if (rst == "wx") "哆能智学教育平台" else data?.title?:"孩子自己就学会的英语", Apis.SHARE_URL, |
| | | UMImage(requireContext(),data?.img?:""),object :UMShareListener{ |
| | | override fun onStart(p0: SHARE_MEDIA?) { |
| | | } |
| | | |
| | | override fun onResult(p0: SHARE_MEDIA?) { |
| | | toast("已分享") |
| | | } |
| | | |
| | | override fun onError(p0: SHARE_MEDIA?, p1: Throwable?) { |
| | | } |
| | | |
| | | override fun onCancel(p0: SHARE_MEDIA?) { |
| | | } |
| | | },"" |
| | | ) |
| | | } |
| | | } |
| | | } |
| | | shareDialog.showAllowingStateLoss(childFragmentManager,"share") |
| | | } |
| | | } |
| | | |
| | | @Subscribe |
| | |
| | | homeData?.apply { |
| | | iv_avatar.setImageURI(user.headImg) |
| | | tv_name.text = user.name |
| | | tv_record.text = "剩余积分:%d|学习进度:周目%d|学习总时长:%d小时".format(user.integral,userStudy.week,userStudy.totalStudy) |
| | | tv_record.text = "剩余积分:%d|学习进度:周目%s|学习总时长:%d小时".format(user.integral,userStudy.week.formatToChinese(),userStudy.totalStudy) |
| | | } |
| | | } |
| | | |