Commit cc15d588 authored by jyx's avatar jyx

修改分享逻辑返回逻辑,部分bug修改

parent 36e1e3f4
......@@ -118,9 +118,9 @@ public abstract class BannerBaseAdapter<T> extends PagerAdapter {
this.mDatas = new ArrayList<>(datas);
notifyDataSetChanged();
if (mBannerView != null) {
mBannerView.resetCurrentPosition(datas.size());
}
// if (mBannerView != null) {
// mBannerView.resetCurrentPosition(datas.size());
// }
}
......
package com.mints.goodmoney.ui.adapter
import android.content.Context
import android.graphics.Color
import android.view.View
import android.widget.Button
import android.widget.TextView
import com.mints.goodmoney.R
import com.mints.goodmoney.mvp.model.FriendsTaskBean
class BannerTaskAdapter(context: Context) : BannerBaseAdapter<FriendsTaskBean.ChallengeBean.ListBean>(context) {
private val mContext: Context = context
override fun getLayoutResID() = R.layout.item_bv_friends_task
override fun convert(convertView: View, data: FriendsTaskBean.ChallengeBean.ListBean) {
convertView.findViewById<TextView>(R.id.item_bv_friends_task_title).text = data.title
convertView.findViewById<TextView>(R.id.item_bv_friends_task_info).text = data.remarks
convertView.findViewById<TextView>(R.id.item_bv_friends_task_btn).text = data.button
if (data.button == "去邀请") {
convertView.findViewById<TextView>(R.id.item_bv_friends_task_btn).setBackgroundResource(R.drawable.shape_btn_orange)
convertView.findViewById<TextView>(R.id.item_bv_friends_task_btn).setTextColor(mContext.resources.getColor(R.color.my_color_orange))
} else {
convertView.findViewById<TextView>(R.id.item_bv_friends_task_btn).setBackgroundResource(R.drawable.shape_btn_orange_complete)
convertView.findViewById<TextView>(R.id.item_bv_friends_task_btn).setTextColor(Color.WHITE)
}
}
}
\ No newline at end of file
......@@ -2,13 +2,11 @@ package com.mints.goodmoney.ui.fragment
import android.graphics.Typeface
import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration
import cn.sharesdk.framework.Platform
import cn.sharesdk.framework.PlatformActionListener
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.mints.goodmoney.R
......@@ -30,14 +28,13 @@ import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.fragment_main_friends.*
import kotlinx.android.synthetic.main.fragment_main_friends.srl_my
import kotlinx.android.synthetic.main.header_layout.*
import java.util.HashMap
/**
* 描述:邀请好友
* 作者:孟崔广
* 时间:2020/9/20 17:30
*/
class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, PlatformActionListener {
class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener {
private val friendsPresenter by lazy { FriendsPresenter() }
......@@ -77,7 +74,7 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
override fun onTabUnselected(tab: TabLayout.Tab) {
val title =
((tab_friends.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
((tab_friends.getChildAt(0) as LinearLayout).getChildAt(tab.position) as LinearLayout).getChildAt(
1
) as TextView
title.apply {
......@@ -88,7 +85,7 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
override fun onTabSelected(tab: TabLayout.Tab) {
val title =
((tab_friends.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
((tab_friends.getChildAt(0) as LinearLayout).getChildAt(tab.position) as LinearLayout).getChildAt(
1
) as TextView
title.apply {
......@@ -110,12 +107,6 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
recy_friends.addItemDecoration(DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL))
invitedAdapter = InvitedAdapter(mContext, invitedData)
recy_friends.adapter = invitedAdapter
invitedAdapter?.setOnItemClickListener(object : InvitedAdapter.OnItemClickListener {
override fun onItemClick(view: View?, position: Int) {
}
})
}
private fun initBanner() {
......@@ -132,13 +123,9 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
}
}
override fun onPageDown() {
// bv_friends_task.stopAutoScroll()
}
override fun onPageDown() {}
override fun onPageUp() {
// bv_friends_task.startAutoScroll()
}
override fun onPageUp() {}
})
bv_friends_task.setAdapter(bannerTaskAdapter)
......@@ -159,17 +146,11 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
// if (!TextUtils.isEmpty(userManager?.userID)) {
// friendsPresenter.getFriendsMsg()
// }
}
// bv_friends_task.startAutoScroll()
}
override fun onPause() {
super.onPause()
// bv_friends_task.stopAutoScroll()
}
override fun onDestroy() {
super.onDestroy()
......@@ -183,18 +164,19 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
}
private fun invitedFriends() {
val wechatSp = Platform.ShareParams()
wechatSp.shareType = Platform.SHARE_WEBPAGE
wechatSp.title = Constant.SHARE_TITLE
wechatSp.text = Constant.SHARE_CONTENT
wechatSp.imageData = ImageUtil.drawableToBitmap(ContextCompat.getDrawable(context!!, R.mipmap.ic_launcher))
wechatSp.url = Constant.SHARE_URL
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (wechat.isClientValid) {
friendsPresenter.cmtShareStatus()
wechat.platformActionListener = this // 设置分享事件回调
val wechatSp = Platform.ShareParams()
wechatSp.shareType = Platform.SHARE_WEBPAGE
wechatSp.title = Constant.SHARE_TITLE
wechatSp.text = Constant.SHARE_CONTENT
wechatSp.imageData = ImageUtil.drawableToBitmap(ContextCompat.getDrawable(context!!, R.mipmap.ic_launcher))
wechatSp.url = Constant.SHARE_URL
// 执行图文分享
wechat.share(wechatSp)
} else {
showToast("请先安装微信")
}
......@@ -203,31 +185,30 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
override fun getWorldRankSuc(data: FriendsTaskBean.FriendsBean) {
srl_my.finishRefresh(true)
// if (data.list.size == 0) {
// iv_empty.visibility = View.VISIBLE
// recy_friends.visibility = View.GONE
// } else {
// iv_empty.visibility = View.GONE
// recy_friends.visibility = View.VISIBLE
invitedData.clear()
invitedData.addAll(data.list)
invitedAdapter?.notifyDataSetChanged()
// }
}
override fun getFriendsRankSuc(data: FriendsTaskBean) {
srl_my.finishRefresh(true)
// var currentPostion: Int
// for (i in 0..data.challenge.list.size) {
// if (data.challenge.list[i].status == 1 && data.challenge.list[i + 1].status == 0) {
// currentPostion = i
// }
// }
bvTaskData = data.challenge.list
bannerTaskAdapter?.setData(bvTaskData)
// 跳转当前完成的页面
var currentPosition = 0
for (i in 0 until bvTaskData.size) {
if (i == bvTaskData.size - 1 && bvTaskData[i].status == 1) {
currentPosition = i
}
if (bvTaskData[i].status == 1 && i + 1 < bvTaskData.size && bvTaskData[i + 1].status == 0) {
currentPosition = i
break
}
}
bv_friends_task.setCurrentIndex(currentPosition)
if (tab_friends.selectedTabPosition == 0) {
invitedData.clear()
invitedData.addAll(data.friends.list)
......@@ -235,15 +216,4 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, Platform
}
}
override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) {
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, 50)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CHALLENGE_SHAREFRIEND)
readyGo(AwardActivity::class.java, bundle)
}
override fun onError(p0: Platform?, p1: Int, p2: Throwable?) = showToast("邀请取消")
override fun onCancel(p0: Platform?, p1: Int) = showToast("邀请取消")
}
\ No newline at end of file
......@@ -80,6 +80,13 @@ class MyFragment : BaseFragment(), MyView, MainMyAdapter.OnItemChildClickListene
initView()
initRecy()
if (!TextUtils.isEmpty(userManager.userID)) {
myPresenter.getUserHallBaseMsg()
} else {
// 游客登录
myPresenter.userLogin(ps)
}
}
private fun initView() {
......@@ -121,12 +128,12 @@ class MyFragment : BaseFragment(), MyView, MainMyAdapter.OnItemChildClickListene
override fun onResume() {
super.onResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_MY) {
if (!TextUtils.isEmpty(userManager.userID)) {
myPresenter.getUserHallBaseMsg()
} else {
// 游客登录
myPresenter.userLogin(ps)
}
// if (!TextUtils.isEmpty(userManager.userID)) {
// myPresenter.getUserHallBaseMsg()
// } else {
// // 游客登录
// myPresenter.userLogin(ps)
// }
}
}
......
......@@ -11,12 +11,14 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
......@@ -361,4 +363,8 @@ public class BannerView extends FrameLayout {
public void setAnimDuration(long animDuration) {
mAnimDuration = animDuration;
}
public void setCurrentIndex(int position) {
mViewPager.setCurrentItem(position);
}
}
......@@ -20,8 +20,8 @@
android:id="@+id/item_bv_friends_task_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="任务1"
android:textColor="@color/black"
android:textSize="18sp"
......@@ -33,8 +33,8 @@
android:id="@+id/item_bv_friends_task_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="12dp"
android:text="邀请1名好友"
android:textColor="@color/main_bg_text"
app:layout_constraintBottom_toBottomOf="parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment