Commit 898fc71b by 霍志良

feat:底部布局浮在输入法上面

parent 820e7f59
......@@ -8,8 +8,8 @@ import com.ydl.component.mvp.DemoPresenter
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
import com.yidianling.consultant.ExpertSearchFragment
//import com.yidianling.consultant.ExpertSearchFragment
import com.yidianling.dynamic.trendsHome.TrendsHomeFragment
//import com.yidianling.consultant.ExpertSearchFragment
import com.yidianling.home.ui.fragment.YdlHomeFragment
//import com.yidianling.dynamic.trendsHome.TrendsHomeFragment
//import com.yidianling.home.ui.fragment.YdlHomeFragment
......
......@@ -43,6 +43,10 @@
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".publishTrend.PublishTrendActivityTrends"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".topic.AllTopicActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
......
......@@ -6,10 +6,7 @@ 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.*
/**
......@@ -19,24 +16,27 @@ class TrendsAndQuestionDialog(val mContext: Context, val listener: TrendsQuestio
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
params.height = WindowManager.LayoutParams.WRAP_CONTENT
params.gravity=Gravity.BOTTOM
window.attributes = params
window.setGravity(Gravity.BOTTOM)
setCanceledOnTouchOutside(true)
ll_publish_trends.setOnClickListener {
listener.publishTrends()
hide()
}
cancel_focus_dialog_sure.setOnClickListener {
ll_publish_question.setOnClickListener {
listener.publishQuestion()
hide()
}
publish_close.setOnClickListener {
hide()
}
}
......
......@@ -11,6 +11,7 @@ import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
......@@ -33,6 +34,8 @@ import com.yidianling.dynamic.R;
import com.yidianling.dynamic.bean.TrendTabEntity;
import com.yidianling.dynamic.publishTrend.fragment.PublishQuestionAndTrendFragment;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
......@@ -57,6 +60,12 @@ public class PublishTrendActivity extends BaseActivity {
private Handler handler;
private LinearLayout mPublishTrendTitle;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
public static Intent newIntent(Activity activity, String url, String cover, String title) {
Intent intent = new Intent(activity, PublishTrendActivity.class);
Bundle bundle = new Bundle();
......@@ -127,11 +136,11 @@ public class PublishTrendActivity extends BaseActivity {
}
private void initData() {
titleList.add(new TrendTabEntity("动态", 0, 0));
// titleList.add(new TrendTabEntity("发动态", 0, 0));
titleList.add(new TrendTabEntity("提问", 0, 0));
mTableLayout.setTabData(titleList);
fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_TREND));
// fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_TREND));
fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_QUESTION));
FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
......
package com.yidianling.dynamic.publishTrend
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Handler
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.listener.OnResultCallbackListener
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker.startPicker
import com.ydl.ydlcommon.adapter.custom.PublishImageAdapter
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.ui.ParcelableImage
import com.ydl.ydlcommon.view.dialog.NormalDialog
import com.yidianling.common.tools.ToastUtil
import com.yidianling.dynamic.R
import com.yidianling.dynamic.bean.DynamicConstants
import com.yidianling.dynamic.common.emoji.IEmoticonSelectedListener
import kotlinx.android.synthetic.main.activity_dynamic_publish_trends.*
import kotlinx.android.synthetic.main.dynamic_layout_publish_trend_bottom.*
import kotlin.collections.ArrayList
class PublishTrendActivityTrends :BaseActivity(), View.OnClickListener, IEmoticonSelectedListener {
private var adapter: PublishImageAdapter? = null
private var publishTrendImgs:ArrayList<ParcelableImage>?=null
private var publishTrendImgBrows:ArrayList<ParcelableImage>?=null
var is_niming = 1 //是否匿名:1否,2匿名
private var isKeyboardShowed = true // 是否显示键盘
protected var uiHandler: Handler? = null
//测试结果页(或者fm页面、文章页面)传过来的数据
private val Test_url: String? = null
private val Test_cover: String? = null
private val Test_title: String? = null
var topic_id: String? = null
var topic_title: String? = null
/**
* 表情弹窗是否显示
*/
private var emojilayot_ishow = false
var writeing_title = false
/**
* 仅对专家可见
* 1仅专家可见 2所有可见
* 默认所有可见
*/
private var isDoctorShow = 2
companion object{
fun start(context: Context,topic_id:String,topic_title:String) {
val intent = Intent(context, PublishTrendActivityTrends::class.java)
intent.putExtra("topic_id", topic_id)
intent.putExtra("topic_title", topic_title)
context.startActivity(intent)
}
}
override fun initDataAndEvent() {
// 从话题详情进来的发布
topic_id = intent.getStringExtra("topic_id")
topic_title = intent.getStringExtra("topic_title")
if (adapter == null) {
adapter = PublishImageAdapter(publishTrendImgs, this)
} else {
adapter!!.notifyDataSetChanged()
}
publishTrendImgs = ArrayList()
publish_trend_img_rcv.setLayoutManager(GridLayoutManager(this, 4))
publish_trend_img_rcv.setAdapter(adapter)
publish_trend_img_rcv.setOnClickListener(this)
publish_trend_bottom_img_iv.setOnClickListener(this)
publish_trend_bottom_topic_tv.setOnClickListener(this)
publish_anonymity_rel.setOnClickListener(this)
publish_emoji_iv.setOnClickListener(this)
ll_to_expert.setOnClickListener(this)
}
override fun layoutResId(): Int {
return R.layout.activity_dynamic_publish_trends
}
override fun onClick(v: View) {
if (v.getId() == R.id.publish_anonymity_rel) {
if (is_niming == 1) { //是否匿名:1否,2匿名
val builder = NormalDialog.Builder(this)
builder.setTitle("")
builder.setMessage("设置匿名后,将会隐藏你的个人头像、昵称")
builder.setPositiveButton(
"确定匿名"
) { dialog, which ->
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox_sel)
is_niming = 2
dialog.dismiss()
}
builder.setNegativeButton(
"公开"
) { dialog, which -> dialog.dismiss() }
builder.create().show()
} else {
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox)
is_niming = 1
}
} else if (v.getId() == R.id.publish_trend_bottom_img_iv) {
if ("" == Test_url || Test_url == null || "" == Test_cover || Test_cover == null || "" == Test_title || Test_title == null) {
if (publishTrendImgs!!.size < 9) {
showSelector()
} else {
if ("default" == publishTrendImgs!![8].image_url) {
showSelector()
} else {
ToastUtil.toastShort("最多选择9张照片")
}
}
}
} else if (v.getId() == R.id.publish_trend_bottom_topic_tv) {
val intent = Intent()
intent.setClass(this, SelecTopicActivity::class.java)
startActivityForResult(intent, DynamicConstants.REQUEST_CODE_SELECT_TOPIC)
} else if (v.getId() == R.id.publish_emoji_iv) {
if (writeing_title == false) {
toggleEmojiLayout()
}
} else if (v.getId() == R.id.ll_to_expert) { //仅对专家可见
if (isDoctorShow == 1) {
isDoctorShow = 2
iv_to_expert.setImageResource(R.drawable.dynamic_checkbox)
} else {
isDoctorShow = 1
iv_to_expert.setImageResource(R.drawable.dynamic_checkbox_sel)
}
}
}
private fun showSelector() {
val selectedSize = if (publishTrendImgs!!.size != 0) publishTrendImgs!!.size - 1 else 0
startPicker(
(this)!!,
9 - selectedSize,
object : OnResultCallbackListener {
override fun onResult(list: List<LocalMedia>) {
if (list.isEmpty()) {
return
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
for (i in list.indices) {
AddImag(list[i].androidQToPath)
}
} else {
for (i in list.indices) {
AddImag(list[i].path)
}
}
}
override fun onCancel() {}
})
}
/**
* 添加照片
*/
private fun AddImag(pic_path: String) {
val trendImage = ParcelableImage(pic_path)
if (publishTrendImgs!!.size < 9 && publishTrendImgs!!.size > 0) {
publishTrendImgs!!.add(publishTrendImgs!!.size - 1, trendImage)
} else if (publishTrendImgs!!.size == 0) {
publishTrendImgs!!.add(ParcelableImage("default"))
publishTrendImgs!!.add(publishTrendImgs!!.size - 1, trendImage)
} else {
publishTrendImgs!!.removeAt(8)
publishTrendImgs!!.add(8, trendImage)
}
adapter!!.updateDate(publishTrendImgs)
}
@SuppressLint("WrongConstant")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == RESULT_OK) {
when (requestCode) {
DynamicConstants.PUBLISH_PIC_BROW -> {
if (data == null) {
return
}
val chane_state = data.getBooleanExtra("chane_state", false)
if (chane_state) {
val bundle = data.getBundleExtra("bundle")
publishTrendImgs = bundle.getParcelableArrayList("publish_img")
if ((publishTrendImgs as ArrayList<ParcelableImage>?)?.size!! > 0) {
(publishTrendImgs as ArrayList<ParcelableImage>?)?.add(ParcelableImage("default"))
}
adapter!!.updateDate(publishTrendImgs)
}
}
DynamicConstants.REQUEST_CODE_SELECT_TOPIC -> {
val type = data!!.getStringExtra("type")
if ("topic_select" == type) {
val bd = data.getBundleExtra("bundle")
if (bd != null) {
topic_id = bd.getString("topic_id")
topic_title = bd.getString("topic_title")
}
publish_trend_bottom_topic_tv.visibility = View.VISIBLE
publish_trend_bottom_topic_tv.text = "# $topic_title"
publish_trend_bottom_topic_tv.setTextColor(
ContextCompat.getColor(
this,
R.color.platform_main_theme
)
)
// 获取编辑框焦点
publish_trend_content_editext.isFocusable = true
hideEmojiLayout()
//打开软键盘
val imm =
this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS)
}
}
}
}
}
// 点击表情,切换到表情布局
@SuppressLint("WrongConstant")
private fun toggleEmojiLayout() {
if (emoticon_picker_view == null || emoticon_picker_view.visibility == View.GONE) {
showEmojiLayout()
// publish_emoji_iv.setImageResource(R.drawable.dynamic_edict_ico_key);
} else {
hideEmojiLayout()
showInputMethod(publish_trend_content_editext)
publish_emoji_iv.setImageResource(R.drawable.dynamic_edict_ico_emoji)
}
}
private val showEmojiRunnable =
Runnable { emoticon_picker_view.visibility = View.VISIBLE }
private val showTextRunnable = Runnable { showInputMethod(publish_trend_content_editext) }
// 隐藏表情布局
@SuppressLint("WrongConstant")
fun hideEmojiLayout() {
uiHandler?.removeCallbacks(showEmojiRunnable)
if (emoticon_picker_view != null) {
emoticon_picker_view.visibility = View.GONE
}
emojilayot_ishow = false
}
// 显示表情布局
@SuppressLint("WrongConstant")
private fun showEmojiLayout() {
hideInputMethod()
publish_trend_content_editext.requestFocus()
emoticon_picker_view.visibility = View.VISIBLE
emoticon_picker_view.show(this)
emojilayot_ishow = true
}
// 隐藏键盘布局
private fun hideInputMethod() {
isKeyboardShowed = false
uiHandler?.removeCallbacks(showTextRunnable)
@SuppressLint("WrongConstant") val imm =
this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(publish_trend_content_editext.windowToken, 0)
publish_trend_content_editext.clearFocus()
}
// 显示键盘布局
private fun showInputMethod(editTextMessage: EditText) {
editTextMessage.requestFocus()
//如果已经显示,则继续操作时不需要把光标定位到最后
if (!isKeyboardShowed) {
editTextMessage.setSelection(editTextMessage.text.length)
isKeyboardShowed = true
}
@SuppressLint("WrongConstant") val imm =
this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(editTextMessage, 0)
}
override fun onEmojiSelected(key: String?) {
val mEditable = publish_trend_content_editext.text
if (key == "/DEL") {
publish_trend_content_editext.dispatchKeyEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_DEL
)
)
} else {
var start = publish_trend_content_editext.selectionStart
var end = publish_trend_content_editext.selectionEnd
start = if (start < 0) 0 else start
end = if (start < 0) 0 else end
mEditable.replace(start, end, key)
}
}
override fun onStickerSelected(categoryName: String?, stickerName: String?) {
}
}
\ No newline at end of file
......@@ -8,10 +8,14 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AlertDialog;
......@@ -25,6 +29,7 @@ import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
......@@ -118,7 +123,8 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
private ImageView iv_fm;
private ImageView iv_to_expert;
private TextView publish_trend_ad_tv;
private ConstraintLayout trends_publish_question;
private LinearLayout ll_bottom_img_emoji;
RxFileTool fileUtils;
private String head_dir;//目录
private String head_path;//路径
......@@ -154,7 +160,6 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
protected Handler uiHandler;
private boolean isKeyboardShowed = true; // 是否显示键盘
//测试结果页(或者fm页面、文章页面)传过来的数据
private String Test_url;
private String Test_cover;
......@@ -168,8 +173,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
private static final String TITLE = "Test_title";
private View dialogContentView;
private Activity activity;
private int isCanlayout=0;
public static Fragment getInstance(String type) {
PublishQuestionAndTrendFragment fragment = new PublishQuestionAndTrendFragment();
fragment.type = type;
......@@ -193,6 +197,17 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onStop() {
super.onStop();
isCanlayout=0;
}
@Override
public void initDataAndEventLazy() {
rxPermissions = new RxPermissions(getActivity());
imgFiles = new ArrayList<File>();
......@@ -326,6 +341,8 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
}
private void initView() {
trends_publish_question=getRootView().findViewById(R.id.trends_publish_question);
ll_bottom_img_emoji=getRootView().findViewById(R.id.ll_bottom_img_emoji);
publish_trend_ad_rel = getRootView().findViewById(R.id.publish_trend_ad_rel);
iv_fm = getRootView().findViewById(R.id.iv_fm);
publish_trend_ad_iv = getRootView().findViewById(R.id.publish_trend_ad_iv);
......@@ -348,6 +365,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
publish_trend_title_editext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
isCanlayout=1;
if (hasFocus) {
// 此处为得到焦点时的处理内容
writeing_title = true;
......@@ -365,6 +383,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
}
});
publish_trend_content_editext.setOnTouchListener((v, event) -> {
isCanlayout=1;
hideEmojiLayout();
publish_emoji_iv.setImageResource(R.drawable.dynamic_edict_ico_emoji);
return false;
......@@ -386,6 +405,18 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
"2、你想寻求哪方面的帮助\n" +
"这样更容易获得咨询师准确、专业的解答哦~");
}
trends_publish_question.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (isCanlayout!=0){
Rect rect=new Rect();
trends_publish_question.getWindowVisibleDisplayFrame(rect);
ll_bottom_img_emoji.layout(0, rect.height()-ll_bottom_img_emoji.getHeight()-96,ll_bottom_img_emoji.getWidth(),rect.height());
}
}
});
}
private void initEvent() {
......
package com.yidianling.dynamic.trendsHome;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseFragment;
import com.ydl.ydlcommon.utils.BuryPointUtils;
import com.ydl.ydlcommon.utils.LogUtil;
import com.ydl.ydlcommon.utils.ScreenUtil;
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils;
import com.yidianling.common.tools.RxDeviceTool;
import com.yidianling.common.tools.RxImageTool;
import com.yidianling.dynamic.R;
import com.yidianling.dynamic.R2;
import com.yidianling.dynamic.bean.DynamicConstants;
import com.yidianling.dynamic.common.view.LooperTextView;
import com.yidianling.dynamic.dialog.CancelFocusDialog;
import com.yidianling.dynamic.dialog.TrendsAndQuestionDialog;
import com.yidianling.dynamic.dialog.listener.TrendsQuestionListener;
import com.yidianling.dynamic.model.TopicListDataBean;
import com.yidianling.dynamic.model.TrendsListBean;
import com.yidianling.dynamic.publishTrend.PublishTrendActivity;
import com.yidianling.dynamic.publishTrend.PublishTrendActivityTrends;
import com.yidianling.dynamic.router.DynamicIn;
import com.yidianling.dynamic.topic.AllTopicActivity;
import com.yidianling.dynamic.topic.topicDetail.TopicDetailActivity;
import com.yidianling.dynamic.trendsHome.content.TrendsContentListFragment;
import com.yidianling.dynamic.trendsHome.view.TrendsHomeBannerView;
import java.util.List;
import butterknife.BindView;
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.
* 首页问答fragment
*/
@Route(path = "/dynamic/dynamic")
public class TrendsHomeFragment extends BaseFragment implements ITrendHomeView, SwipeRefreshLayout.OnRefreshListener {
@BindView(R2.id.trend_home_swl)
SwipeRefreshLayout swl;
@BindView(R2.id.vp_content)
ViewPager vpContent;
@BindView(R2.id.trends_topic_iv1)
ImageView topicRoundIv1;
@BindView(R2.id.trends_topic_iv2)
ImageView topicRoundIv2;
@BindView(R2.id.trends_topic_iv3)
ImageView topicRoundIv3;
@BindView(R2.id.trends_home_csl)
ConstraintLayout mConstraintLayout;
@BindView(R2.id.trends_tv_mind_group)
TextView tvMindGroup;
@BindView(R2.id.trends_tv_mind_more)
TextView tvMindMore;
@BindView(R2.id.frl_topic_iv3)
FrameLayout frlTopicIv3;
@BindView(R2.id.frl_topic_iv2)
FrameLayout frlTopicIv2;
@BindView(R2.id.frl_topic_iv1)
FrameLayout frlTopicIv1;
@BindView(R2.id.trends_home_appBar)
AppBarLayout mAppBarLayout;
@BindView(R2.id.item_recommend_tv)
TextView mItemRecommendTv;
@BindView(R2.id.item_hot_tv)
TextView mItemHotTv;
@BindView(R2.id.item_focus_tv)
TextView mItemFocusTv;
@BindView(R2.id.trends_topic_tv3)
TextView trendsTopicTv3;
@BindView(R2.id.trends_topic_tv2)
TextView trendsTopicTv2;
@BindView(R2.id.trends_topic_tv1)
TextView trendsTopicTv1;
@BindView(R2.id.publish_trend_btn)
FloatingActionButton mPublishTrendButton;
@BindView(R2.id.ternd_loop_tv)
LooperTextView mLooperTextView;
@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;
private TrendsAndQuestionDialog trendsAndQuestionDialog = null;
public TrendsHomeFragment setTab(String tab) {
this.tab = tab;
return this;
}
public static TrendsHomeFragment newInstance() {
return new TrendsHomeFragment();
}
@Override
public int layoutResId() {
return R.layout.dynamic_fragment_moments;
}
@Override
public void initDataAndEvent() {
mUnbinder = ButterKnife.bind(this, getView());
initViews();
initDatas();
}
@Override
public void initDataAndEventLazy() {
// initDatas();
}
private void initViews() {
initBannerView();
swl.setOnRefreshListener(this);
swl.setColorSchemeResources(R.color.platform_main_theme);
mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
swl.setEnabled(true);
} else {
swl.setEnabled(false);
}
if (verticalOffset <= -appBarLayout.getTotalScrollRange() + mToolBarTv.getHeight()) {
mToolBarTv.setAlpha(1f);
} else {
mToolBarTv.setAlpha(0f);
}
}
});
initStatus();
}
private void initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
int statusBarHeight = ScreenUtil.getStatusBarHeight(getActivity());
CollapsingToolbarLayout.LayoutParams layoutParams = (CollapsingToolbarLayout.LayoutParams) mToolBarTv.getLayoutParams();
layoutParams.height = (int) (getResources().getDimension(R.dimen.title_bar_height) + statusBarHeight);
mToolBarTv.setPadding(0, statusBarHeight, 0, 0);
mToolBarTv.setLayoutParams(layoutParams);
}
}
private void initDatas() {
mPresenter = new TrendsHomePresenter();
mPresenter.callBack = this;
mPresenter.fetchDats();
}
private void initBannerView() {
int screenSize = RxDeviceTool.getScreenWidth(getActivity());
int topicRoundIv1Width = (screenSize - RxImageTool.dip2px(31)) * 2 / 3;
int topicRoundIv23Width = (screenSize - RxImageTool.dip2px(31)) / 3;
int topicRoundIv1Height = (int) (topicRoundIv1Width / 1.5f);
int topicRoundIv23Height = (int) ((topicRoundIv1Height - RxImageTool.dip2px(1)) / 2f);
ConstraintLayout.LayoutParams params1 = new ConstraintLayout.LayoutParams(topicRoundIv1Width, topicRoundIv1Height);
params1.topMargin = RxImageTool.dp2px(10);
params1.leftMargin = RxImageTool.dp2px(15);
params1.leftToRight = mConstraintLayout.getId();
params1.topToBottom = tvMindGroup.getId();
frlTopicIv1.setLayoutParams(params1);
ConstraintLayout.LayoutParams params2 = new ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height);
params2.topMargin = RxImageTool.dp2px(10);
params2.leftMargin = RxImageTool.dp2px(1);
params2.leftToRight = frlTopicIv1.getId();
params2.topToBottom = tvMindGroup.getId();
frlTopicIv2.setLayoutParams(params2);
ConstraintLayout.LayoutParams params3 = new ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height);
params3.topMargin = RxImageTool.dp2px(1);
params3.leftMargin = RxImageTool.dp2px(1);
params3.leftToRight = frlTopicIv1.getId();
params3.topToBottom = frlTopicIv2.getId();
frlTopicIv3.setLayoutParams(params3);
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser && isResumed()) {
startTime = System.currentTimeMillis();
ActionCountUtils.Companion.count(YDL_USER_ASK_PAGE_VISIT);
} else {
if (startTime != 0L) {
endTime = System.currentTimeMillis();
ActionCountUtils.Companion.count(YDL_USER_ASK_PAGE_STAY_VISIT, String.valueOf(endTime - startTime));
}
}
if (isVisibleToUser && isResumed()) {
onResume();
}
}
private void initViewPager() {
vpAdapter = new TrendsHomeVpAdapter(getChildFragmentManager(), mFragments);
vpContent.setAdapter(vpAdapter);
vpContent.setOffscreenPageLimit(1);
vpContent.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (position == currentPostion) {
return;
}
currentPostion = position;
if (position >= 1) {
vpContent.setOffscreenPageLimit(2);
}
switchTab(position);
switch (position) {
case 0:
BuryPointUtils.getInstance().createMap()
.put("toptab_name", "推荐")
.burryPoint("topTabClick");
BuryPointUtils.getInstance().trackViewScreen(getActivity(), "动态-推荐", "com.cxzapp.yidianling.trends.trendList.TrendsListFragment");
break;
case 1:
BuryPointUtils.getInstance().createMap()
.put("toptab_name", "最新")
.burryPoint("topTabClick");
BuryPointUtils.getInstance().trackViewScreen(getActivity(), "动态-最新", "com.cxzapp.yidianling.trends.trendList.TrendsListFragment");
break;
case 2:
BuryPointUtils.getInstance().createMap()
.put("toptab_name", "关注")
.burryPoint("topTabClick");
if (!DynamicIn.INSTANCE.loginByOneKeyLogin(getActivity(), true)) {
return;
}
BuryPointUtils.getInstance().trackViewScreen(getActivity(), "动态-关注", "com.cxzapp.yidianling.trends.trendList.TrendsListFragment");
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
if ("hot".equals(tab)) {
vpContent.setCurrentItem(1);
switchTab(1);
} else if ("new".equals(tab)) {
vpContent.setCurrentItem(0);
switchTab(0);
} else {
vpContent.setCurrentItem(0);
switchTab(0);
}
}
private void switchTab(int index) {
switch (index) {
case 0:
mItemRecommendTv.setSelected(false);
mItemRecommendTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666));
mItemFocusTv.setSelected(false);
mItemFocusTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666));
mItemHotTv.setSelected(true);
mItemHotTv.setTextColor(getResources().getColor(R.color.platform_but_text_color));
break;
case 1:
mItemRecommendTv.setSelected(true);
mItemRecommendTv.setTextColor(getResources().getColor(R.color.platform_but_text_color));
mItemFocusTv.setSelected(false);
mItemFocusTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666));
mItemHotTv.setSelected(false);
mItemHotTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666));
break;
case 2:
mItemRecommendTv.setSelected(false);
mItemRecommendTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666));
mItemFocusTv.setSelected(true);
mItemFocusTv.setTextColor(getResources().getColor(R.color.platform_but_text_color));
mItemHotTv.setSelected(false);
mItemHotTv.setTextColor(getResources().getColor(R.color.dynamic_text_666666));
break;
}
}
@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})
public void doClick(View view) {
if (view.getId() == R.id.item_recommend_tv) {
ActionCountUtils.Companion.count(YDL_USER_ASK_TYPE_CLICK, "推荐");
vpContent.setCurrentItem(1);
} else if (view.getId() == R.id.item_hot_tv) {
ActionCountUtils.Companion.count(YDL_USER_ASK_TYPE_CLICK, "最新");
vpContent.setCurrentItem(0);
} else if (view.getId() == R.id.item_focus_tv) {
ActionCountUtils.Companion.count(YDL_USER_ASK_TYPE_CLICK, "关注");
vpContent.setCurrentItem(2);
} else if (view.getId() == R.id.publish_trend_btn) {
ActionCountUtils.Companion.count(YDL_USER_ASK_QUESTIONS_BUTTON_CLICK);
trendsAndQuestionDialog = new TrendsAndQuestionDialog(requireContext(), new TrendsQuestionListener() {
@Override
public void publishTrends() {
//发布动态
if (DynamicIn.INSTANCE.loginByOneKeyLogin(getActivity(), true)) {
Intent intent = new Intent(getActivity().getApplicationContext(), PublishTrendActivity.class);
//默认改为今日打卡
Bundle bundle = new Bundle();
bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish");
bundle.putString("topic_id", "44");
bundle.putString("topic_title", "今日打卡");
intent.putExtra("bundle", bundle);
startActivity(intent);
// PublishTrendActivityTrends.Companion.start(requireContext(),"44","今日打卡");
}
}
@Override
public void publishQuestion() {
//发布问题
if (DynamicIn.INSTANCE.loginByOneKeyLogin(getActivity(), true)) {
Intent intent = new Intent(getActivity().getApplicationContext(), PublishTrendActivity.class);
//默认改为今日打卡
Bundle bundle = new Bundle();
bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish");
bundle.putString("topic_id", "44");
bundle.putString("topic_title", "今日打卡");
intent.putExtra("bundle", bundle);
startActivity(intent);
}
}
});
trendsAndQuestionDialog.show();
} else if (view.getId() == R.id.trends_tv_mind_more) {
ActionCountUtils.Companion.count(YDL_USER_THOUGHTS_GROUP_MORE_CLICK);
Intent intent = new Intent(getActivity(), AllTopicActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
// else if (view.getId() == R.id.iv_background) {
// YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_FM_LIST);
// }
}
@Override
public void onFetchedDatas(Fragment[] fragments) {
mFragments = fragments;
initViewPager();
}
public void setBannerData(List<TrendsListBean.Banner> list) {
v_banner.initData(list);
}
@Override
public void onFetchedDataFailed() {
}
public void displayShowCase() {
}
@Override
public void onDestroyView() {
super.onDestroyView();
mUnbinder.unbind();
}
@Override
public void onRefresh() {
swl.setRefreshing(true);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
((TrendsContentListFragment) mFragments[vpContent.getCurrentItem()]).onRefresh();
swl.setRefreshing(false);
}
}, 300);
}
public void showMindsGroup(TopicListDataBean topicListDatas) {
if (topicListDatas.list == null || topicListDatas.list.size() <= 0) {
return;
}
for (int i = 0; i < 3 && i < topicListDatas.list.size(); i++) {
switch (i) {
case 0:
GlideApp.with(this)
.load(topicListDatas.list.get(i).getImg_bg_url())
.centerCrop()
.transform(new RoundedCornersTransformation(20, 0, RoundedCornersTransformation.CornerType.LEFT))
.into(topicRoundIv1);
trendsTopicTv1.setText(topicListDatas.list.get(i).getTopic_title());
frlTopicIv1.setOnClickListener(view -> {
mindTopicClick(topicListDatas.list.get(0).getTopic_title(), topicListDatas.list.get(0).getTopic_id(), trendsTopicTv1.getText().toString());
});
break;
case 1:
GlideApp.with(this)
.load(topicListDatas.list.get(i).getImg_bg_url())
.centerCrop()
.transform(new RoundedCornersTransformation(20, 0, RoundedCornersTransformation.CornerType.TOP_RIGHT))
.into(topicRoundIv2);
trendsTopicTv2.setText(topicListDatas.list.get(i).getTopic_title());
frlTopicIv2.setOnClickListener(view -> {
mindTopicClick(topicListDatas.list.get(1).getTopic_title(), topicListDatas.list.get(1).getTopic_id(), trendsTopicTv2.getText().toString());
});
break;
case 2:
GlideApp.with(this)
.load(topicListDatas.list.get(i).getImg_bg_url())
.centerCrop()
.transform(new RoundedCornersTransformation(20, 0, RoundedCornersTransformation.CornerType.BOTTOM_RIGHT))
.into(topicRoundIv3);
trendsTopicTv3.setText(topicListDatas.list.get(i).getTopic_title());
frlTopicIv3.setOnClickListener(view -> {
mindTopicClick(topicListDatas.list.get(2).getTopic_title(), topicListDatas.list.get(2).getTopic_id(), trendsTopicTv3.getText().toString());
});
break;
}
}
}
private void mindTopicClick(String title, String id, String imgName) {
BuryPointUtils.getInstance().createMap()
.put("theme_name", title)
.put("theme_ID", id)
.burryPoint("Theme_click");
ActionCountUtils.Companion.count(YDL_USER_THOUGHTS_GROUP_TYPE_CLICK, imgName);
Intent intent = new Intent();
intent.setClass(getActivity(), TopicDetailActivity.class);
intent.putExtra("topic_id", id);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().startActivity(intent);
}
public void showTopTrend(List<TrendsListBean.ExtData> extDatas) {
mLooperTextView.setTipList(extDatas);
}
public void setGoneLooperTextView() {
mLooperTextView.setVisibility(View.GONE);
}
}
package com.yidianling.dynamic.trendsHome
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.Toolbar
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.viewpager.widget.ViewPager
import butterknife.BindView
import butterknife.ButterKnife
import butterknife.OnClick
import butterknife.Unbinder
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.base.BaseFragment
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.ScreenUtil
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils.Companion.count
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.dynamic.R
import com.yidianling.dynamic.R2
import com.yidianling.dynamic.bean.DynamicConstants
import com.yidianling.dynamic.common.view.LooperTextView
import com.yidianling.dynamic.model.TopicListDataBean
import com.yidianling.dynamic.model.TrendsListBean
import com.yidianling.dynamic.model.TrendsListBean.ExtData
import com.yidianling.dynamic.publishTrend.PublishTrendActivity
import com.yidianling.dynamic.router.DynamicIn.loginByOneKeyLogin
import com.yidianling.dynamic.topic.AllTopicActivity
import com.yidianling.dynamic.topic.topicDetail.TopicDetailActivity
import com.yidianling.dynamic.trendsHome.content.TrendsContentListFragment
import com.yidianling.dynamic.trendsHome.view.TrendsHomeBannerView
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
/**
* Created by Jim on 2017/9/22 0022.
* 首页问答fragment
*/
@Route(path = "/dynamic/dynamic")
class TrendsHomeFragment : BaseFragment(), ITrendHomeView, SwipeRefreshLayout.OnRefreshListener {
@JvmField
@BindView(R2.id.trend_home_swl)
var swl: SwipeRefreshLayout? = null
@JvmField
@BindView(R2.id.vp_content)
var vpContent: ViewPager? = null
@JvmField
@BindView(R2.id.trends_topic_iv1)
var topicRoundIv1: ImageView? = null
@JvmField
@BindView(R2.id.trends_topic_iv2)
var topicRoundIv2: ImageView? = null
@JvmField
@BindView(R2.id.trends_topic_iv3)
var topicRoundIv3: ImageView? = null
@JvmField
@BindView(R2.id.trends_home_csl)
var mConstraintLayout: ConstraintLayout? = null
@JvmField
@BindView(R2.id.trends_tv_mind_group)
var tvMindGroup: TextView? = null
@JvmField
@BindView(R2.id.trends_tv_mind_more)
var tvMindMore: TextView? = null
@JvmField
@BindView(R2.id.frl_topic_iv3)
var frlTopicIv3: FrameLayout? = null
@JvmField
@BindView(R2.id.frl_topic_iv2)
var frlTopicIv2: FrameLayout? = null
@JvmField
@BindView(R2.id.frl_topic_iv1)
var frlTopicIv1: FrameLayout? = null
@JvmField
@BindView(R2.id.trends_home_appBar)
var mAppBarLayout: AppBarLayout? = null
@JvmField
@BindView(R2.id.item_recommend_tv)
var mItemRecommendTv: TextView? = null
@JvmField
@BindView(R2.id.item_hot_tv)
var mItemHotTv: TextView? = null
@JvmField
@BindView(R2.id.item_focus_tv)
var mItemFocusTv: TextView? = null
@JvmField
@BindView(R2.id.trends_topic_tv3)
var trendsTopicTv3: TextView? = null
@JvmField
@BindView(R2.id.trends_topic_tv2)
var trendsTopicTv2: TextView? = null
@JvmField
@BindView(R2.id.trends_topic_tv1)
var trendsTopicTv1: TextView? = null
@JvmField
@BindView(R2.id.publish_trend_btn)
var mPublishTrendButton: FloatingActionButton? = null
@JvmField
@BindView(R2.id.ternd_loop_tv)
var mLooperTextView: LooperTextView? = null
@JvmField
@BindView(R2.id.toolbar_tv)
var mToolBarTv: Toolbar? = null
@JvmField
@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 {
return R.layout.dynamic_fragment_moments
}
override fun initDataAndEvent() {
mUnbinder = ButterKnife.bind(this, requireView())
initViews()
initDatas()
}
override fun initDataAndEventLazy() {
// initDatas();
}
private fun initViews() {
initBannerView()
swl!!.setOnRefreshListener(this)
swl!!.setColorSchemeResources(R.color.platform_main_theme)
mAppBarLayout!!.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
if (verticalOffset == 0) {
swl!!.isEnabled = true
} else {
swl!!.isEnabled = false
}
if (verticalOffset <= -appBarLayout.totalScrollRange + mToolBarTv!!.height) {
mToolBarTv!!.alpha = 1f
} else {
mToolBarTv!!.alpha = 0f
}
})
initStatus()
}
private fun initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //4.4以下不支持状态栏变色
val statusBarHeight = ScreenUtil.getStatusBarHeight(activity)
val layoutParams = mToolBarTv!!.layoutParams as CollapsingToolbarLayout.LayoutParams
layoutParams.height =
(resources.getDimension(R.dimen.title_bar_height) + statusBarHeight).toInt()
mToolBarTv!!.setPadding(0, statusBarHeight, 0, 0)
mToolBarTv!!.layoutParams = layoutParams
}
}
private fun initDatas() {
mPresenter = TrendsHomePresenter()
mPresenter!!.callBack = this
mPresenter!!.fetchDats()
}
private fun initBannerView() {
val screenSize = RxDeviceTool.getScreenWidth(activity)
val topicRoundIv1Width = (screenSize - RxImageTool.dip2px(31f)) * 2 / 3
val topicRoundIv23Width = (screenSize - RxImageTool.dip2px(31f)) / 3
val topicRoundIv1Height = (topicRoundIv1Width / 1.5f).toInt()
val topicRoundIv23Height = ((topicRoundIv1Height - RxImageTool.dip2px(1f)) / 2f).toInt()
val params1 = ConstraintLayout.LayoutParams(topicRoundIv1Width, topicRoundIv1Height)
params1.topMargin = RxImageTool.dp2px(10f)
params1.leftMargin = RxImageTool.dp2px(15f)
params1.leftToRight = mConstraintLayout!!.id
params1.topToBottom = tvMindGroup!!.id
frlTopicIv1!!.layoutParams = params1
val params2 = ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height)
params2.topMargin = RxImageTool.dp2px(10f)
params2.leftMargin = RxImageTool.dp2px(1f)
params2.leftToRight = frlTopicIv1!!.id
params2.topToBottom = tvMindGroup!!.id
frlTopicIv2!!.layoutParams = params2
val params3 = ConstraintLayout.LayoutParams(topicRoundIv23Width, topicRoundIv23Height)
params3.topMargin = RxImageTool.dp2px(1f)
params3.leftMargin = RxImageTool.dp2px(1f)
params3.leftToRight = frlTopicIv1!!.id
params3.topToBottom = frlTopicIv2!!.id
frlTopicIv3!!.layoutParams = params3
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
if (isVisibleToUser && isResumed) {
startTime = System.currentTimeMillis()
count(DynamicConstants.YDL_USER_ASK_PAGE_VISIT)
} else {
if (startTime != 0L) {
endTime = System.currentTimeMillis()
count(
DynamicConstants.YDL_USER_ASK_PAGE_STAY_VISIT,
(endTime - startTime).toString()
)
}
}
if (isVisibleToUser && isResumed) {
onResume()
}
}
private fun initViewPager() {
vpAdapter = TrendsHomeVpAdapter(childFragmentManager, mFragments)
vpContent!!.adapter = vpAdapter
vpContent!!.offscreenPageLimit = 1
vpContent!!.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) {
if (position == currentPostion) {
return
}
currentPostion = position
if (position >= 1) {
vpContent!!.offscreenPageLimit = 2
}
switchTab(position)
when (position) {
0 -> {
BuryPointUtils.getInstance().createMap()
.put("toptab_name", "推荐")
.burryPoint("topTabClick")
BuryPointUtils.getInstance().trackViewScreen(
activity,
"动态-推荐",
"com.cxzapp.yidianling.trends.trendList.TrendsListFragment"
)
}
1 -> {
BuryPointUtils.getInstance().createMap()
.put("toptab_name", "最新")
.burryPoint("topTabClick")
BuryPointUtils.getInstance().trackViewScreen(
activity,
"动态-最新",
"com.cxzapp.yidianling.trends.trendList.TrendsListFragment"
)
}
2 -> {
BuryPointUtils.getInstance().createMap()
.put("toptab_name", "关注")
.burryPoint("topTabClick")
if (!loginByOneKeyLogin(activity!!, true)) {
return
}
BuryPointUtils.getInstance().trackViewScreen(
activity,
"动态-关注",
"com.cxzapp.yidianling.trends.trendList.TrendsListFragment"
)
}
}
}
override fun onPageScrollStateChanged(state: Int) {}
})
if ("hot" == tab) {
vpContent!!.currentItem = 1
switchTab(1)
} else if ("new" == tab) {
vpContent!!.currentItem = 0
switchTab(0)
} else {
vpContent!!.currentItem = 0
switchTab(0)
}
}
private fun switchTab(index: Int) {
when (index) {
0 -> {
mItemRecommendTv!!.isSelected = false
mItemRecommendTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemFocusTv!!.isSelected = false
mItemFocusTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemHotTv!!.isSelected = true
mItemHotTv!!.setTextColor(resources.getColor(R.color.platform_but_text_color))
}
1 -> {
mItemRecommendTv!!.isSelected = true
mItemRecommendTv!!.setTextColor(resources.getColor(R.color.platform_but_text_color))
mItemFocusTv!!.isSelected = false
mItemFocusTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemHotTv!!.isSelected = false
mItemHotTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
}
2 -> {
mItemRecommendTv!!.isSelected = false
mItemRecommendTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
mItemFocusTv!!.isSelected = true
mItemFocusTv!!.setTextColor(resources.getColor(R.color.platform_but_text_color))
mItemHotTv!!.isSelected = false
mItemHotTv!!.setTextColor(resources.getColor(R.color.dynamic_text_666666))
}
}
}
@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
)
fun doClick(view: View) {
if (view.id == R.id.item_recommend_tv) {
count(DynamicConstants.YDL_USER_ASK_TYPE_CLICK, "推荐")
vpContent!!.currentItem = 1
} else if (view.id == R.id.item_hot_tv) {
count(DynamicConstants.YDL_USER_ASK_TYPE_CLICK, "最新")
vpContent!!.currentItem = 0
} else if (view.id == R.id.item_focus_tv) {
count(DynamicConstants.YDL_USER_ASK_TYPE_CLICK, "关注")
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)
//默认改为今日打卡
val bundle = Bundle()
bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish")
bundle.putString("topic_id", "44")
bundle.putString("topic_title", "今日打卡")
intent.putExtra("bundle", bundle)
startActivity(intent)
}
} else if (view.id == R.id.trends_tv_mind_more) {
count(DynamicConstants.YDL_USER_THOUGHTS_GROUP_MORE_CLICK)
val intent = Intent(activity, AllTopicActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
}
// else if (view.getId() == R.id.iv_background) {
// YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_FM_LIST);
// }
}
override fun onFetchedDatas(fragments: Array<Fragment>) {
mFragments = fragments
initViewPager()
}
fun setBannerData(list: List<TrendsListBean.Banner>) {
v_banner!!.initData(list)
}
override fun onFetchedDataFailed() {}
fun displayShowCase() {}
override fun onDestroyView() {
super.onDestroyView()
mUnbinder!!.unbind()
}
override fun onRefresh() {
swl!!.isRefreshing = true
Handler().postDelayed({
(mFragments[vpContent!!.currentItem] as TrendsContentListFragment).onRefresh()
swl!!.isRefreshing = false
}, 300)
}
fun showMindsGroup(topicListDatas: TopicListDataBean) {
if (topicListDatas.list == null || topicListDatas.list.size <= 0) {
return
}
var i = 0
while (i < 3 && i < topicListDatas.list.size) {
when (i) {
0 -> {
GlideApp.with(this)
.load(topicListDatas.list[i].img_bg_url)
.centerCrop()
.transform(
RoundedCornersTransformation(
20,
0,
RoundedCornersTransformation.CornerType.LEFT
)
)
.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)
.load(topicListDatas.list[i].img_bg_url)
.centerCrop()
.transform(
RoundedCornersTransformation(
20,
0,
RoundedCornersTransformation.CornerType.TOP_RIGHT
)
)
.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)
.load(topicListDatas.list[i].img_bg_url)
.centerCrop()
.transform(
RoundedCornersTransformation(
20,
0,
RoundedCornersTransformation.CornerType.BOTTOM_RIGHT
)
)
.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 fun mindTopicClick(title: String, id: String, imgName: String) {
BuryPointUtils.getInstance().createMap()
.put("theme_name", title)
.put("theme_ID", id)
.burryPoint("Theme_click")
count(DynamicConstants.YDL_USER_THOUGHTS_GROUP_TYPE_CLICK, imgName)
val intent = Intent()
intent.setClass(activity, TopicDetailActivity::class.java)
intent.putExtra("topic_id", id)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
requireActivity().startActivity(intent)
}
fun showTopTrend(extDatas: List<ExtData?>?) {
mLooperTextView!!.setTipList(extDatas)
}
fun setGoneLooperTextView() {
mLooperTextView!!.visibility = View.GONE
}
companion object {
fun newInstance(): TrendsHomeFragment {
return TrendsHomeFragment()
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<LinearLayout
android:id="@+id/publish_trend_title_rel"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/dynamic_background_publish_trend_top"
>
<RelativeLayout
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="48dp"
>
<ImageView
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:paddingLeft="15dp"
android:paddingRight="@dimen/platform_dp_15"
android:src="@drawable/platform_common_back" />
<com.flyco.tablayout.CommonTabLayout
android:id="@+id/tab_layout"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginBottom="6dp"
app:tl_indicator_anim_enable="false"
app:tl_indicator_height="0dp"
app:tl_tab_space_equal="true"
app:tl_textSelectColor="@color/platform_color_242424"
app:tl_textUnselectColor="@color/platform_white"
app:tl_textsize="17sp" />
<TextView
android:id="@+id/publish_trend_sure_tv"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="15dp"
android:background="@drawable/dynamic_bg_publish_button"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="发布"
android:textColor="@color/platform_but_text_color_selected"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/dynamic_white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/publish_trend_content_editext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dynamic_white"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="left|top"
android:hint="1、清晰描述事情的背景及经过\n2、你想寻求哪方面的帮助\n这样更容易获得咨询师准确、专业的解答哦~"
android:includeFontPadding="false"
android:minLines="6"
android:padding="15dp"
android:paddingLeft="15dp"
android:textColor="@color/dynamic_text_trend_title_black"
android:textColorHint="@color/dynamic_text_trend_defult"
android:textSize="15sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/publish_trend_img_rcv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/publish_trend_content_editext"
android:layout_marginTop="16dp"
android:paddingLeft="-5dp"
android:paddingRight="-5dp"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/publish_trend_img_rcv"
android:layout_margin="15dp">
<TextView
android:id="@+id/publish_trend_bottom_topic_tv"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:background="@drawable/dynamic_bg_topic"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="# 选择话题"
android:textColor="@color/platform_color_666666"
android:textSize="11sp" />
<TextView
android:id="@+id/publish_trend_content_num_tv"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:text="0/1000"
android:textColor="#FF757575"
android:textSize="11sp" />
<View
android:id="@+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/publish_trend_content_num_tv"
android:layout_marginTop="15dp"
android:background="@color/platform_new_divide_color" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/line"
android:layout_marginLeft="1dp"
android:layout_marginTop="15dp"
android:layout_marginRight="1dp"
android:layout_marginBottom="@dimen/platform_dp_1"
android:elevation="1dp"
app:cardCornerRadius="6dp">
<RelativeLayout
android:id="@+id/publish_trend_ad_rel"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/platform_color_F7F7F7"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/publish_trend_ad_iv"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:scaleType="fitXY"
android:src="@drawable/dynamic_default_img" />
<ImageView
android:id="@+id/iv_fm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="18dp"
android:src="@drawable/dynamic_img_trend_fm_play"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/publish_trend_ad_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_toRightOf="@+id/publish_trend_ad_iv"
android:maxLines="2"
android:text="测测你的童年阴影"
android:textColor="#333"
android:textSize="15sp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<include layout="@layout/dynamic_layout_publish_trend_bottom" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:id="@+id/trends_publish_question"
android:focusableInTouchMode="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@color/dynamic_white">
<EditText
......@@ -30,17 +30,14 @@
android:paddingBottom="13dp"
android:textColor="@color/dynamic_text_trend_title_black"
android:textColorHint="@color/dynamic_text_trend_defult"
android:textSize="17sp"
android:textSize="24sp"
tools:text="标题:说说你的标题:说说你的标题:说说你的困惑标题:说说你的困标题:说说你的困惑标题:说说你的困惑困惑标题:说说你的困惑" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/publish_trend_title_editext">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/publish_trend_title_editext"
>
<EditText
android:id="@+id/publish_trend_content_editext"
......@@ -57,12 +54,20 @@
android:paddingLeft="15dp"
android:textColor="@color/dynamic_text_trend_title_black"
android:textColorHint="@color/dynamic_text_trend_defult"
android:textSize="15sp" />
<RelativeLayout
android:textSize="17sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/publish_trend_img_rcv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/publish_trend_content_editext"
android:layout_marginTop="16dp"
android:paddingLeft="@dimen/platform_dp_12"
android:paddingRight="@dimen/platform_dp_12"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/publish_trend_img_rcv"
android:layout_margin="15dp">
<TextView
......@@ -97,15 +102,7 @@
android:layout_marginTop="15dp"
android:background="@color/platform_new_divide_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/publish_trend_img_rcv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/line"
android:layout_marginTop="16dp"
android:paddingLeft="-5dp"
android:paddingRight="-5dp"
android:visibility="gone" />
<androidx.cardview.widget.CardView
......@@ -162,10 +159,16 @@
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
<include layout="@layout/dynamic_layout_publish_trend_bottom" />
</LinearLayout>
</RelativeLayout>
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/ll_bottom_img_emoji"
android:layout_alignParentBottom="true"
layout="@layout/dynamic_layout_publish_trend_bottom" />
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
......@@ -17,7 +18,8 @@
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:padding="3dp"
android:src="@drawable/dynamic_edit_img" />
android:src="@drawable/dynamic_edit_img"
/>
<ImageView
android:id="@+id/publish_emoji_iv"
......
......@@ -2,7 +2,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"
android:layout_height="wrap_content"
android:paddingBottom="66dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/dynamic_publish_trends_question_background">
......
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