Commit 820e7f59 by 霍志良

feat:发布动态UI

parent ae7d6776
package com.yidianling.dynamic.dialog
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import com.yidianling.dynamic.R
import com.yidianling.dynamic.dialog.listener.CancelFocusDialogListener
import com.yidianling.dynamic.dialog.listener.TrendsQuestionListener
import kotlinx.android.synthetic.main.dynamic_cancel_focus_dialog_layout.*
import kotlinx.android.synthetic.main.dynamic_cancel_focus_dialog_layout.cancel_focus_dialog_cancel
import kotlinx.android.synthetic.main.dynamic_question_and_trends_dialog_layout.*
/**
* Created by xj on 2019/9/25.
*/
class TrendsAndQuestionDialog(val mContext: Context, val listener: TrendsQuestionListener): Dialog(mContext, R.style.dialog_default_style) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.dynamic_question_and_trends_dialog_layout)
val params = window.attributes
params.width = WindowManager.LayoutParams.MATCH_PARENT
params.height = WindowManager.LayoutParams.MATCH_PARENT
window.attributes = params
window.setGravity(Gravity.BOTTOM)
ll_publish_trends.setOnClickListener {
listener.publishTrends()
hide()
}
cancel_focus_dialog_sure.setOnClickListener {
listener.publishQuestion()
hide()
}
}
}
\ No newline at end of file
package com.yidianling.dynamic.dialog.listener
interface TrendsQuestionListener {
fun publishTrends()//发布动态
fun publishQuestion()//提问题
}
\ No newline at end of file
package com.yidianling.dynamic.trendsHome; package com.yidianling.dynamic.trendsHome
import android.content.Intent; import android.content.Intent
import android.os.Build; import android.os.Build
import android.os.Bundle; import android.os.Bundle
import android.os.Handler; import android.os.Handler
import androidx.constraintlayout.widget.ConstraintLayout; import android.view.View
import com.google.android.material.appbar.AppBarLayout; import android.widget.FrameLayout
import com.google.android.material.appbar.CollapsingToolbarLayout; import android.widget.ImageView
import com.google.android.material.floatingactionbutton.FloatingActionButton; import android.widget.TextView
import androidx.fragment.app.Fragment; import androidx.appcompat.widget.Toolbar
import androidx.viewpager.widget.ViewPager; import androidx.constraintlayout.widget.ConstraintLayout
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.fragment.app.Fragment
import androidx.appcompat.widget.Toolbar; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import android.view.View; import androidx.viewpager.widget.ViewPager
import android.widget.FrameLayout; import butterknife.BindView
import android.widget.ImageView; import butterknife.ButterKnife
import android.widget.TextView; import butterknife.OnClick
import butterknife.Unbinder
import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydl_image.module.GlideApp; import com.google.android.material.appbar.AppBarLayout
import com.ydl.ydlcommon.base.BaseFragment; import com.google.android.material.appbar.CollapsingToolbarLayout
import com.ydl.ydlcommon.utils.BuryPointUtils; import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.ydl.ydlcommon.utils.LogUtil; import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.utils.ScreenUtil; import com.ydl.ydlcommon.base.BaseFragment
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils; import com.ydl.ydlcommon.utils.BuryPointUtils
import com.yidianling.common.tools.RxDeviceTool; import com.ydl.ydlcommon.utils.ScreenUtil
import com.yidianling.common.tools.RxImageTool; import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils.Companion.count
import com.yidianling.dynamic.R; import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.dynamic.R2; import com.yidianling.common.tools.RxImageTool
import com.yidianling.dynamic.bean.DynamicConstants; import com.yidianling.dynamic.R
import com.yidianling.dynamic.common.view.LooperTextView; import com.yidianling.dynamic.R2
import com.yidianling.dynamic.model.TopicListDataBean; import com.yidianling.dynamic.bean.DynamicConstants
import com.yidianling.dynamic.model.TrendsListBean; import com.yidianling.dynamic.common.view.LooperTextView
import com.yidianling.dynamic.publishTrend.PublishTrendActivity; import com.yidianling.dynamic.model.TopicListDataBean
import com.yidianling.dynamic.router.DynamicIn; import com.yidianling.dynamic.model.TrendsListBean
import com.yidianling.dynamic.topic.AllTopicActivity; import com.yidianling.dynamic.model.TrendsListBean.ExtData
import com.yidianling.dynamic.topic.topicDetail.TopicDetailActivity; import com.yidianling.dynamic.publishTrend.PublishTrendActivity
import com.yidianling.dynamic.trendsHome.content.TrendsContentListFragment; import com.yidianling.dynamic.router.DynamicIn.loginByOneKeyLogin
import com.yidianling.dynamic.trendsHome.view.TrendsHomeBannerView; import com.yidianling.dynamic.topic.AllTopicActivity
import com.yidianling.dynamic.topic.topicDetail.TopicDetailActivity
import java.util.List; import com.yidianling.dynamic.trendsHome.content.TrendsContentListFragment
import com.yidianling.dynamic.trendsHome.view.TrendsHomeBannerView
import butterknife.BindView; import jp.wasabeef.glide.transformations.RoundedCornersTransformation
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import static com.yidianling.dynamic.bean.DynamicConstants.YDL_USER_ASK_PAGE_STAY_VISIT;
import static com.yidianling.dynamic.bean.DynamicConstants.YDL_USER_ASK_PAGE_VISIT;
import static com.yidianling.dynamic.bean.DynamicConstants.YDL_USER_ASK_QUESTIONS_BUTTON_CLICK;
import static com.yidianling.dynamic.bean.DynamicConstants.YDL_USER_ASK_TYPE_CLICK;
import static com.yidianling.dynamic.bean.DynamicConstants.YDL_USER_THOUGHTS_GROUP_MORE_CLICK;
import static com.yidianling.dynamic.bean.DynamicConstants.YDL_USER_THOUGHTS_GROUP_TYPE_CLICK;
/** /**
* Created by Jim on 2017/9/22 0022. * Created by Jim on 2017/9/22 0022.
* 首页问答fragment * 首页问答fragment
*/ */
@Route(path = "/dynamic/dynamic") @Route(path = "/dynamic/dynamic")
public class TrendsHomeFragment extends BaseFragment implements ITrendHomeView, SwipeRefreshLayout.OnRefreshListener { class TrendsHomeFragment : BaseFragment(), ITrendHomeView, SwipeRefreshLayout.OnRefreshListener {
@JvmField
@BindView(R2.id.trend_home_swl) @BindView(R2.id.trend_home_swl)
SwipeRefreshLayout swl; var swl: SwipeRefreshLayout? = null
@JvmField
@BindView(R2.id.vp_content) @BindView(R2.id.vp_content)
ViewPager vpContent; var vpContent: ViewPager? = null
@JvmField
@BindView(R2.id.trends_topic_iv1) @BindView(R2.id.trends_topic_iv1)
ImageView topicRoundIv1; var topicRoundIv1: ImageView? = null
@JvmField
@BindView(R2.id.trends_topic_iv2) @BindView(R2.id.trends_topic_iv2)
ImageView topicRoundIv2; var topicRoundIv2: ImageView? = null
@JvmField
@BindView(R2.id.trends_topic_iv3) @BindView(R2.id.trends_topic_iv3)
ImageView topicRoundIv3; var topicRoundIv3: ImageView? = null
@JvmField
@BindView(R2.id.trends_home_csl) @BindView(R2.id.trends_home_csl)
ConstraintLayout mConstraintLayout; var mConstraintLayout: ConstraintLayout? = null
@JvmField
@BindView(R2.id.trends_tv_mind_group) @BindView(R2.id.trends_tv_mind_group)
TextView tvMindGroup; var tvMindGroup: TextView? = null
@JvmField
@BindView(R2.id.trends_tv_mind_more) @BindView(R2.id.trends_tv_mind_more)
TextView tvMindMore; var tvMindMore: TextView? = null
@JvmField
@BindView(R2.id.frl_topic_iv3) @BindView(R2.id.frl_topic_iv3)
FrameLayout frlTopicIv3; var frlTopicIv3: FrameLayout? = null
@JvmField
@BindView(R2.id.frl_topic_iv2) @BindView(R2.id.frl_topic_iv2)
FrameLayout frlTopicIv2; var frlTopicIv2: FrameLayout? = null
@JvmField
@BindView(R2.id.frl_topic_iv1) @BindView(R2.id.frl_topic_iv1)
FrameLayout frlTopicIv1; var frlTopicIv1: FrameLayout? = null
@JvmField
@BindView(R2.id.trends_home_appBar) @BindView(R2.id.trends_home_appBar)
AppBarLayout mAppBarLayout; var mAppBarLayout: AppBarLayout? = null
@JvmField
@BindView(R2.id.item_recommend_tv) @BindView(R2.id.item_recommend_tv)
TextView mItemRecommendTv; var mItemRecommendTv: TextView? = null
@JvmField
@BindView(R2.id.item_hot_tv) @BindView(R2.id.item_hot_tv)
TextView mItemHotTv; var mItemHotTv: TextView? = null
@JvmField
@BindView(R2.id.item_focus_tv) @BindView(R2.id.item_focus_tv)
TextView mItemFocusTv; var mItemFocusTv: TextView? = null
@JvmField
@BindView(R2.id.trends_topic_tv3) @BindView(R2.id.trends_topic_tv3)
TextView trendsTopicTv3; var trendsTopicTv3: TextView? = null
@JvmField
@BindView(R2.id.trends_topic_tv2) @BindView(R2.id.trends_topic_tv2)
TextView trendsTopicTv2; var trendsTopicTv2: TextView? = null
@JvmField
@BindView(R2.id.trends_topic_tv1) @BindView(R2.id.trends_topic_tv1)
TextView trendsTopicTv1; var trendsTopicTv1: TextView? = null
@JvmField
@BindView(R2.id.publish_trend_btn) @BindView(R2.id.publish_trend_btn)
FloatingActionButton mPublishTrendButton; var mPublishTrendButton: FloatingActionButton? = null
@JvmField
@BindView(R2.id.ternd_loop_tv) @BindView(R2.id.ternd_loop_tv)
LooperTextView mLooperTextView; var mLooperTextView: LooperTextView? = null
@BindView(R2.id.toolbar_tv)
Toolbar mToolBarTv;
@BindView(R2.id.v_banner)
TrendsHomeBannerView v_banner;
private Unbinder mUnbinder;
private TrendsHomePresenter mPresenter;
private Fragment[] mFragments;
private TrendsHomeVpAdapter vpAdapter;
private long lastTabClick = 0;
private int currentPostion = -1;
String tab;
private long startTime ;
private long endTime;
public TrendsHomeFragment setTab(String tab) { @JvmField
this.tab = tab; @BindView(R2.id.toolbar_tv)
return this; var mToolBarTv: Toolbar? = null
}
public static TrendsHomeFragment newInstance() { @JvmField
return new TrendsHomeFragment(); @BindView(R2.id.v_banner)
var v_banner: TrendsHomeBannerView? = null
private var mUnbinder: Unbinder? = null
private var mPresenter: TrendsHomePresenter? = null
private lateinit var mFragments: Array<Fragment>
private var vpAdapter: TrendsHomeVpAdapter? = null
private val lastTabClick: Long = 0
private var currentPostion = -1
var tab: String? = null
private var startTime: Long = 0
private var endTime: Long = 0
fun setTab(tab: String?): TrendsHomeFragment {
this.tab = tab
return this
} }
override fun layoutResId(): Int {
@Override return R.layout.dynamic_fragment_moments
public int layoutResId() {
return R.layout.dynamic_fragment_moments;
} }
@Override override fun initDataAndEvent() {
public void initDataAndEvent() { mUnbinder = ButterKnife.bind(this, requireView())
mUnbinder = ButterKnife.bind(this, getView()); initViews()
initViews(); initDatas()
initDatas();
} }
@Override override fun initDataAndEventLazy() {
public void initDataAndEventLazy() {
// initDatas(); // initDatas();
} }
private void initViews() { private fun initViews() {
initBannerView(); initBannerView()
swl.setOnRefreshListener(this); swl!!.setOnRefreshListener(this)
swl.setColorSchemeResources(R.color.platform_main_theme); swl!!.setColorSchemeResources(R.color.platform_main_theme)
mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { mAppBarLayout!!.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) { if (verticalOffset == 0) {
swl.setEnabled(true); swl!!.isEnabled = true
} else { } else {
swl.setEnabled(false); swl!!.isEnabled = false
} }
if (verticalOffset <= -appBarLayout.getTotalScrollRange() + mToolBarTv.getHeight()) { if (verticalOffset <= -appBarLayout.totalScrollRange + mToolBarTv!!.height) {
mToolBarTv.setAlpha(1f); mToolBarTv!!.alpha = 1f
} else { } else {
mToolBarTv.setAlpha(0f); mToolBarTv!!.alpha = 0f
} }
} })
}); initStatus()
initStatus(); }
}
private fun initStatus() {
private void initStatus() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //4.4以下不支持状态栏变色
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色 val statusBarHeight = ScreenUtil.getStatusBarHeight(activity)
int statusBarHeight = ScreenUtil.getStatusBarHeight(getActivity()); val layoutParams = mToolBarTv!!.layoutParams as CollapsingToolbarLayout.LayoutParams
CollapsingToolbarLayout.LayoutParams layoutParams = (CollapsingToolbarLayout.LayoutParams) mToolBarTv.getLayoutParams(); layoutParams.height =
layoutParams.height = (int) (getResources().getDimension(R.dimen.title_bar_height) + statusBarHeight); (resources.getDimension(R.dimen.title_bar_height) + statusBarHeight).toInt()
mToolBarTv.setPadding(0, statusBarHeight, 0, 0); mToolBarTv!!.setPadding(0, statusBarHeight, 0, 0)
mToolBarTv.setLayoutParams(layoutParams); mToolBarTv!!.layoutParams = layoutParams
}
} }
}
private fun initDatas() {
private void initDatas() { mPresenter = TrendsHomePresenter()
mPresenter = new TrendsHomePresenter(); mPresenter!!.callBack = this
mPresenter.callBack = this; mPresenter!!.fetchDats()
mPresenter.fetchDats(); }
}
private fun initBannerView() {
private void initBannerView() { val screenSize = RxDeviceTool.getScreenWidth(activity)
int screenSize = RxDeviceTool.getScreenWidth(getActivity()); val topicRoundIv1Width = (screenSize - RxImageTool.dip2px(31f)) * 2 / 3
int topicRoundIv1Width = (screenSize - RxImageTool.dip2px(31)) * 2 / 3; val topicRoundIv23Width = (screenSize - RxImageTool.dip2px(31f)) / 3
int topicRoundIv23Width = (screenSize - RxImageTool.dip2px(31)) / 3; val topicRoundIv1Height = (topicRoundIv1Width / 1.5f).toInt()
val topicRoundIv23Height = ((topicRoundIv1Height - RxImageTool.dip2px(1f)) / 2f).toInt()
int topicRoundIv1Height = (int) (topicRoundIv1Width / 1.5f); val params1 = ConstraintLayout.LayoutParams(topicRoundIv1Width, topicRoundIv1Height)
int topicRoundIv23Height = (int) ((topicRoundIv1Height - RxImageTool.dip2px(1)) / 2f); params1.topMargin = RxImageTool.dp2px(10f)
params1.leftMargin = RxImageTool.dp2px(15f)
ConstraintLayout.LayoutParams params1 = new ConstraintLayout.LayoutParams(topicRoundIv1Width, topicRoundIv1Height); params1.leftToRight = mConstraintLayout!!.id
params1.topMargin = RxImageTool.dp2px(10); params1.topToBottom = tvMindGroup!!.id
params1.leftMargin = RxImageTool.dp2px(15); frlTopicIv1!!.layoutParams = params1
params1.leftToRight = mConstraintLayout.getId(); val params2 = ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height)
params1.topToBottom = tvMindGroup.getId(); params2.topMargin = RxImageTool.dp2px(10f)
frlTopicIv1.setLayoutParams(params1); params2.leftMargin = RxImageTool.dp2px(1f)
params2.leftToRight = frlTopicIv1!!.id
ConstraintLayout.LayoutParams params2 = new ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height); params2.topToBottom = tvMindGroup!!.id
params2.topMargin = RxImageTool.dp2px(10); frlTopicIv2!!.layoutParams = params2
params2.leftMargin = RxImageTool.dp2px(1); val params3 = ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height)
params2.leftToRight = frlTopicIv1.getId(); params3.topMargin = RxImageTool.dp2px(1f)
params2.topToBottom = tvMindGroup.getId(); params3.leftMargin = RxImageTool.dp2px(1f)
frlTopicIv2.setLayoutParams(params2); params3.leftToRight = frlTopicIv1!!.id
params3.topToBottom = frlTopicIv2!!.id
ConstraintLayout.LayoutParams params3 = new ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height); frlTopicIv3!!.layoutParams = params3
params3.topMargin = RxImageTool.dp2px(1); }
params3.leftMargin = RxImageTool.dp2px(1);
params3.leftToRight = frlTopicIv1.getId(); override fun setUserVisibleHint(isVisibleToUser: Boolean) {
params3.topToBottom = frlTopicIv2.getId(); super.setUserVisibleHint(isVisibleToUser)
frlTopicIv3.setLayoutParams(params3); if (isVisibleToUser && isResumed) {
} startTime = System.currentTimeMillis()
count(DynamicConstants.YDL_USER_ASK_PAGE_VISIT)
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser && isResumed()) {
startTime=System.currentTimeMillis();
ActionCountUtils.Companion.count(YDL_USER_ASK_PAGE_VISIT);
} else { } else {
if (startTime!=0L){ if (startTime != 0L) {
endTime=System.currentTimeMillis(); endTime = System.currentTimeMillis()
ActionCountUtils.Companion.count(YDL_USER_ASK_PAGE_STAY_VISIT,String.valueOf(endTime-startTime)); count(
DynamicConstants.YDL_USER_ASK_PAGE_STAY_VISIT,
(endTime - startTime).toString()
)
} }
} }
if (isVisibleToUser && isResumed()) { if (isVisibleToUser && isResumed) {
onResume(); onResume()
} }
} }
private void initViewPager() { private fun initViewPager() {
vpAdapter = new TrendsHomeVpAdapter(getChildFragmentManager(), mFragments); vpAdapter = TrendsHomeVpAdapter(childFragmentManager, mFragments)
vpContent.setAdapter(vpAdapter); vpContent!!.adapter = vpAdapter
vpContent.setOffscreenPageLimit(1); vpContent!!.offscreenPageLimit = 1
vpContent.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { vpContent!!.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
@Override override fun onPageScrolled(
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
} }
@Override override fun onPageSelected(position: Int) {
public void onPageSelected(int position) {
if (position == currentPostion) { if (position == currentPostion) {
return; return
} }
currentPostion = position; currentPostion = position
if (position >= 1) { if (position >= 1) {
vpContent.setOffscreenPageLimit(2); vpContent!!.offscreenPageLimit = 2
} }
switchTab(position)
switchTab(position); when (position) {
switch (position) { 0 -> {
case 0:
BuryPointUtils.getInstance().createMap() BuryPointUtils.getInstance().createMap()
.put("toptab_name", "推荐") .put("toptab_name", "推荐")
.burryPoint("topTabClick"); .burryPoint("topTabClick")
BuryPointUtils.getInstance().trackViewScreen(getActivity(), "动态-推荐", "com.cxzapp.yidianling.trends.trendList.TrendsListFragment"); BuryPointUtils.getInstance().trackViewScreen(
break; activity,
case 1: "动态-推荐",
"com.cxzapp.yidianling.trends.trendList.TrendsListFragment"
)
}
1 -> {
BuryPointUtils.getInstance().createMap() BuryPointUtils.getInstance().createMap()
.put("toptab_name", "最新") .put("toptab_name", "最新")
.burryPoint("topTabClick"); .burryPoint("topTabClick")
BuryPointUtils.getInstance().trackViewScreen(getActivity(), "动态-最新", "com.cxzapp.yidianling.trends.trendList.TrendsListFragment"); BuryPointUtils.getInstance().trackViewScreen(
break; activity,
case 2: "动态-最新",
"com.cxzapp.yidianling.trends.trendList.TrendsListFragment"
)
}
2 -> {
BuryPointUtils.getInstance().createMap() BuryPointUtils.getInstance().createMap()
.put("toptab_name", "关注") .put("toptab_name", "关注")
.burryPoint("topTabClick"); .burryPoint("topTabClick")
if (!DynamicIn.INSTANCE.loginByOneKeyLogin(getActivity(),true)) { if (!loginByOneKeyLogin(activity!!, true)) {
return; return
} }
BuryPointUtils.getInstance().trackViewScreen(getActivity(), "动态-关注", "com.cxzapp.yidianling.trends.trendList.TrendsListFragment"); BuryPointUtils.getInstance().trackViewScreen(
break; activity,
"动态-关注",
"com.cxzapp.yidianling.trends.trendList.TrendsListFragment"
)
} }
} }
@Override
public void onPageScrollStateChanged(int state) {
} }
});
if ("hot".equals(tab)) { override fun onPageScrollStateChanged(state: Int) {}
vpContent.setCurrentItem(1); })
switchTab(1); if ("hot" == tab) {
} else if ("new".equals(tab)) { vpContent!!.currentItem = 1
vpContent.setCurrentItem(0); switchTab(1)
switchTab(0); } else if ("new" == tab) {
vpContent!!.currentItem = 0
switchTab(0)
} else { } else {
vpContent.setCurrentItem(0); vpContent!!.currentItem = 0
switchTab(0); switchTab(0)
} }
} }
private fun switchTab(index: Int) {
private void switchTab(int index) { when (index) {
switch (index) { 0 -> {
case 0: mItemRecommendTv!!.isSelected = false
mItemRecommendTv.setSelected(false); mItemRecommendTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemRecommendTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666)); mItemFocusTv!!.isSelected = false
mItemFocusTv.setSelected(false); mItemFocusTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemFocusTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666)); mItemHotTv!!.isSelected = true
mItemHotTv.setSelected(true); mItemHotTv!!.setTextColor(resources.getColor(R.color.platform_but_text_color))
mItemHotTv.setTextColor(getResources().getColor(R.color.platform_but_text_color)); }
break; 1 -> {
case 1: mItemRecommendTv!!.isSelected = true
mItemRecommendTv.setSelected(true); mItemRecommendTv!!.setTextColor(resources.getColor(R.color.platform_but_text_color))
mItemRecommendTv.setTextColor(getResources().getColor(R.color.platform_but_text_color)); mItemFocusTv!!.isSelected = false
mItemFocusTv.setSelected(false); mItemFocusTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemFocusTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666)); mItemHotTv!!.isSelected = false
mItemHotTv.setSelected(false); mItemHotTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemHotTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666)); }
break; 2 -> {
case 2: mItemRecommendTv!!.isSelected = false
mItemRecommendTv.setSelected(false); mItemRecommendTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemRecommendTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666)); mItemFocusTv!!.isSelected = true
mItemFocusTv.setSelected(true); mItemFocusTv!!.setTextColor(resources.getColor(R.color.platform_but_text_color))
mItemFocusTv.setTextColor(getResources().getColor(R.color.platform_but_text_color)); mItemHotTv!!.isSelected = false
mItemHotTv.setSelected(false); mItemHotTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemHotTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666)); }
break; }
} }
}
@OnClick(
R2.id.trends_tv_mind_more,
@OnClick({R2.id.trends_tv_mind_more, R2.id.publish_trend_btn, R2.id.item_recommend_tv, R2.id.item_hot_tv, R2.id.item_focus_tv}) R2.id.publish_trend_btn,
public void doClick(View view) { R2.id.item_recommend_tv,
if (view.getId() == R.id.item_recommend_tv) { R2.id.item_hot_tv,
ActionCountUtils.Companion.count(YDL_USER_ASK_TYPE_CLICK,"推荐"); R2.id.item_focus_tv
vpContent.setCurrentItem(1); )
} else if (view.getId() == R.id.item_hot_tv) { fun doClick(view: View) {
ActionCountUtils.Companion.count(YDL_USER_ASK_TYPE_CLICK,"最新"); if (view.id == R.id.item_recommend_tv) {
vpContent.setCurrentItem(0); count(DynamicConstants.YDL_USER_ASK_TYPE_CLICK, "推荐")
} else if (view.getId() == R.id.item_focus_tv) { vpContent!!.currentItem = 1
ActionCountUtils.Companion.count(YDL_USER_ASK_TYPE_CLICK,"关注"); } else if (view.id == R.id.item_hot_tv) {
vpContent.setCurrentItem(2); count(DynamicConstants.YDL_USER_ASK_TYPE_CLICK, "最新")
} else if (view.getId() == R.id.publish_trend_btn) { vpContent!!.currentItem = 0
ActionCountUtils.Companion.count(YDL_USER_ASK_QUESTIONS_BUTTON_CLICK); } else if (view.id == R.id.item_focus_tv) {
if (DynamicIn.INSTANCE.loginByOneKeyLogin(getActivity(),true)) { count(DynamicConstants.YDL_USER_ASK_TYPE_CLICK, "关注")
Intent intent = new Intent(getActivity().getApplicationContext(), PublishTrendActivity.class); vpContent!!.currentItem = 2
} else if (view.id == R.id.publish_trend_btn) {
//发布动态
count(DynamicConstants.YDL_USER_ASK_QUESTIONS_BUTTON_CLICK)
if (loginByOneKeyLogin(requireActivity(), true)) {
val intent = Intent(requireActivity().applicationContext, PublishTrendActivity::class.java)
//默认改为今日打卡 //默认改为今日打卡
Bundle bundle = new Bundle(); val bundle = Bundle()
bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish"); bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish")
bundle.putString("topic_id", "44"); bundle.putString("topic_id", "44")
bundle.putString("topic_title", "今日打卡"); bundle.putString("topic_title", "今日打卡")
intent.putExtra("bundle", bundle); intent.putExtra("bundle", bundle)
startActivity(intent); startActivity(intent)
} }
} else if (view.getId() == R.id.trends_tv_mind_more) { } else if (view.id == R.id.trends_tv_mind_more) {
ActionCountUtils.Companion.count(YDL_USER_THOUGHTS_GROUP_MORE_CLICK); count(DynamicConstants.YDL_USER_THOUGHTS_GROUP_MORE_CLICK)
Intent intent = new Intent(getActivity(), AllTopicActivity.class); val intent = Intent(activity, AllTopicActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent); startActivity(intent)
} }
// else if (view.getId() == R.id.iv_background) { // else if (view.getId() == R.id.iv_background) {
// YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_FM_LIST); // YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_FM_LIST);
// } // }
} }
@Override override fun onFetchedDatas(fragments: Array<Fragment>) {
public void onFetchedDatas(Fragment[] fragments) { mFragments = fragments
mFragments = fragments; initViewPager()
initViewPager();
}
public void setBannerData(List<TrendsListBean.Banner> list) {
v_banner.initData(list);
}
@Override
public void onFetchedDataFailed() {
} }
public void displayShowCase() { fun setBannerData(list: List<TrendsListBean.Banner>) {
v_banner!!.initData(list)
} }
@Override override fun onFetchedDataFailed() {}
public void onDestroyView() { fun displayShowCase() {}
super.onDestroyView(); override fun onDestroyView() {
mUnbinder.unbind(); super.onDestroyView()
mUnbinder!!.unbind()
} }
override fun onRefresh() {
swl!!.isRefreshing = true
@Override Handler().postDelayed({
public void onRefresh() { (mFragments[vpContent!!.currentItem] as TrendsContentListFragment).onRefresh()
swl.setRefreshing(true); swl!!.isRefreshing = false
new Handler().postDelayed(new Runnable() { }, 300)
@Override
public void run() {
((TrendsContentListFragment) mFragments[vpContent.getCurrentItem()]).onRefresh();
swl.setRefreshing(false);
}
}, 300);
} }
public void showMindsGroup(TopicListDataBean topicListDatas) { fun showMindsGroup(topicListDatas: TopicListDataBean) {
if (topicListDatas.list == null || topicListDatas.list.size() <= 0) { if (topicListDatas.list == null || topicListDatas.list.size <= 0) {
return; return
} }
for (int i = 0; i < 3 && i < topicListDatas.list.size(); i++) { var i = 0
switch (i) { while (i < 3 && i < topicListDatas.list.size) {
case 0: when (i) {
0 -> {
GlideApp.with(this) GlideApp.with(this)
.load(topicListDatas.list.get(i).getImg_bg_url()) .load(topicListDatas.list[i].img_bg_url)
.centerCrop() .centerCrop()
.transform(new RoundedCornersTransformation(20, 0, RoundedCornersTransformation.CornerType.LEFT)) .transform(
.into(topicRoundIv1); RoundedCornersTransformation(
trendsTopicTv1.setText(topicListDatas.list.get(i).getTopic_title()); 20,
frlTopicIv1.setOnClickListener(view -> { 0,
mindTopicClick(topicListDatas.list.get(0).getTopic_title(), topicListDatas.list.get(0).getTopic_id(),trendsTopicTv1.getText().toString()); RoundedCornersTransformation.CornerType.LEFT
}); )
break; )
case 1: .into(topicRoundIv1!!)
trendsTopicTv1!!.text = topicListDatas.list[i].topic_title
frlTopicIv1!!.setOnClickListener { view: View? ->
mindTopicClick(
topicListDatas.list[0].topic_title,
topicListDatas.list[0].topic_id,
trendsTopicTv1!!.text.toString()
)
}
}
1 -> {
GlideApp.with(this) GlideApp.with(this)
.load(topicListDatas.list.get(i).getImg_bg_url()) .load(topicListDatas.list[i].img_bg_url)
.centerCrop() .centerCrop()
.transform(new RoundedCornersTransformation(20, 0, RoundedCornersTransformation.CornerType.TOP_RIGHT)) .transform(
.into(topicRoundIv2); RoundedCornersTransformation(
trendsTopicTv2.setText(topicListDatas.list.get(i).getTopic_title()); 20,
frlTopicIv2.setOnClickListener(view -> { 0,
mindTopicClick(topicListDatas.list.get(1).getTopic_title(), topicListDatas.list.get(1).getTopic_id(),trendsTopicTv2.getText().toString()); RoundedCornersTransformation.CornerType.TOP_RIGHT
}); )
break; )
case 2: .into(topicRoundIv2!!)
trendsTopicTv2!!.text = topicListDatas.list[i].topic_title
frlTopicIv2!!.setOnClickListener { view: View? ->
mindTopicClick(
topicListDatas.list[1].topic_title,
topicListDatas.list[1].topic_id,
trendsTopicTv2!!.text.toString()
)
}
}
2 -> {
GlideApp.with(this) GlideApp.with(this)
.load(topicListDatas.list.get(i).getImg_bg_url()) .load(topicListDatas.list[i].img_bg_url)
.centerCrop() .centerCrop()
.transform(new RoundedCornersTransformation(20, 0, RoundedCornersTransformation.CornerType.BOTTOM_RIGHT)) .transform(
.into(topicRoundIv3); RoundedCornersTransformation(
trendsTopicTv3.setText(topicListDatas.list.get(i).getTopic_title()); 20,
frlTopicIv3.setOnClickListener(view -> { 0,
mindTopicClick(topicListDatas.list.get(2).getTopic_title(), topicListDatas.list.get(2).getTopic_id(),trendsTopicTv3.getText().toString()); RoundedCornersTransformation.CornerType.BOTTOM_RIGHT
}); )
break; )
.into(topicRoundIv3!!)
trendsTopicTv3!!.text = topicListDatas.list[i].topic_title
frlTopicIv3!!.setOnClickListener { view: View? ->
mindTopicClick(
topicListDatas.list[2].topic_title,
topicListDatas.list[2].topic_id,
trendsTopicTv3!!.text.toString()
)
} }
} }
}
i++
}
} }
private void mindTopicClick(String title, String id,String imgName) { private fun mindTopicClick(title: String, id: String, imgName: String) {
BuryPointUtils.getInstance().createMap() BuryPointUtils.getInstance().createMap()
.put("theme_name", title) .put("theme_name", title)
.put("theme_ID", id) .put("theme_ID", id)
.burryPoint("Theme_click"); .burryPoint("Theme_click")
ActionCountUtils.Companion.count(YDL_USER_THOUGHTS_GROUP_TYPE_CLICK,imgName); count(DynamicConstants.YDL_USER_THOUGHTS_GROUP_TYPE_CLICK, imgName)
Intent intent = new Intent(); val intent = Intent()
intent.setClass(getActivity(), TopicDetailActivity.class); intent.setClass(activity, TopicDetailActivity::class.java)
intent.putExtra("topic_id", id); intent.putExtra("topic_id", id)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
getActivity().startActivity(intent); requireActivity().startActivity(intent)
}
fun showTopTrend(extDatas: List<ExtData?>?) {
mLooperTextView!!.setTipList(extDatas)
}
fun setGoneLooperTextView() {
mLooperTextView!!.visibility = View.GONE
} }
public void showTopTrend(List<TrendsListBean.ExtData> extDatas) { companion object {
mLooperTextView.setTipList(extDatas); fun newInstance(): TrendsHomeFragment {
return TrendsHomeFragment()
} }
public void setGoneLooperTextView() {
mLooperTextView.setVisibility(View.GONE);
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="@dimen/platform_dp_10"
android:topRightRadius="@dimen/platform_dp_10"
/>
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="232dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/dynamic_publish_trends_question_background">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/publish_close"
android:src="@drawable/picture_icon_close"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/platform_dp_16"
android:layout_marginEnd="@dimen/platform_dp_10"
android:padding="@dimen/platform_dp_5"
android:tint="#afb1bc"
tools:ignore="UseAppTint" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你的感受我在乎"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/publish_close"
android:layout_marginTop="@dimen/platform_dp_16"
android:id="@+id/publish_title"
android:textColor="#afb1bc"
android:textSize="@dimen/platform_sp_16"
/>
<LinearLayout
android:id="@+id/ll_publish_trends"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dynamic_publish_trends"
app:layout_constraintTop_toBottomOf="@id/publish_title"
android:layout_marginTop="@dimen/platform_dp_16"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="@dimen/platform_dp_16"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发动态"
android:textSize="@dimen/dynamic_text_size_18"
android:textStyle="bold"
android:textColor="@color/white"
android:includeFontPadding="false"
android:drawableRight="@drawable/dynamic_publish_right_icon"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_12"
android:drawablePadding="@dimen/platform_dp_5"
>
</TextView>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="这一刻你的真实想法"
android:textColor="@color/white"
android:textSize="@dimen/dynamic_text_size_12"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_3"
>
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ll_publish_question"
android:orientation="vertical"
android:background="@drawable/dynamic_publish_question"
app:layout_constraintTop_toBottomOf="@id/publish_title"
android:layout_marginTop="@dimen/platform_dp_16"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="@dimen/platform_dp_16"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提问题"
android:textSize="@dimen/dynamic_text_size_18"
android:textStyle="bold"
android:textColor="@color/white"
android:includeFontPadding="false"
android:drawableRight="@drawable/dynamic_publish_right_icon"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_12"
android:drawablePadding="@dimen/platform_dp_5"
>
</TextView>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="数万心理师为您答疑解惑"
android:textColor="@color/white"
android:textSize="@dimen/dynamic_text_size_12"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_3"
>
</TextView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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