perf: 更改用户界面 UI
This commit is contained in:
parent
434c6db363
commit
b391356e72
|
|
@ -42,6 +42,7 @@ abstract class BaseActivity : SwipeBackActivity(), ExtraRefreshable {
|
|||
var isActivityRunning = true
|
||||
private set
|
||||
private var customStatusColor = -1
|
||||
private var statusBarTinted = false
|
||||
|
||||
val appPreferences: AppPreferencesUtils
|
||||
get() = AppPreferencesUtils(this)
|
||||
|
|
@ -200,18 +201,21 @@ abstract class BaseActivity : SwipeBackActivity(), ExtraRefreshable {
|
|||
.transparentBar()
|
||||
.init()
|
||||
} else {
|
||||
val immersionBar = ImmersionBar.with(this)
|
||||
.fitsSystemWindowsInt(true, ThemeUtils.getColorByAttr(this, R.attr.colorBg))
|
||||
.navigationBarColorInt(ThemeUtils.getColorByAttr(this, R.attr.colorNavBar))
|
||||
.navigationBarDarkIcon(ThemeUtil.isNavigationBarFontDark(this))
|
||||
if (customStatusColor != -1) {
|
||||
immersionBar.statusBarColorInt(customStatusColor)
|
||||
.autoStatusBarDarkModeEnable(true)
|
||||
} else {
|
||||
immersionBar.statusBarColorInt(calcStatusBarColor(this, ThemeUtils.getColorByAttr(this, R.attr.colorToolbar)))
|
||||
.statusBarDarkFont(ThemeUtil.isStatusBarFontDark(this))
|
||||
}
|
||||
immersionBar.init()
|
||||
ImmersionBar.with(this).apply {
|
||||
if (customStatusColor != -1) {
|
||||
statusBarColorInt(customStatusColor)
|
||||
autoStatusBarDarkModeEnable(true)
|
||||
} else {
|
||||
statusBarColorInt(calcStatusBarColor(this@BaseActivity, ThemeUtils.getColorByAttr(this@BaseActivity, R.attr.colorToolbar)))
|
||||
statusBarDarkFont(ThemeUtil.isStatusBarFontDark(this@BaseActivity))
|
||||
}
|
||||
fitsSystemWindowsInt(true, ThemeUtils.getColorByAttr(this@BaseActivity, R.attr.colorBg))
|
||||
navigationBarColorInt(ThemeUtils.getColorByAttr(this@BaseActivity, R.attr.colorNavBar))
|
||||
navigationBarDarkIcon(ThemeUtil.isNavigationBarFontDark(this@BaseActivity))
|
||||
}.init()
|
||||
}
|
||||
if (!statusBarTinted) {
|
||||
statusBarTinted = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,6 +213,8 @@ class FloorActivity : BaseActivity() {
|
|||
const val EXTRA_POST_ID = "pid"
|
||||
const val EXTRA_SUB_POST_ID = "spid"
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun launch(
|
||||
context: Context,
|
||||
threadId: String,
|
||||
|
|
|
|||
|
|
@ -1,240 +1,244 @@
|
|||
package com.huanchengfly.tieba.post.activities;
|
||||
@file:SuppressLint("NonConstantResourceId")
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
package com.huanchengfly.tieba.post.activities
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import butterknife.BindView
|
||||
import butterknife.OnClick
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.adapters.FragmentTabViewPagerAdapter
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi.getInstance
|
||||
import com.huanchengfly.tieba.post.api.models.CommonResponse
|
||||
import com.huanchengfly.tieba.post.api.models.ProfileBean
|
||||
import com.huanchengfly.tieba.post.fragments.UserLikeForumFragment
|
||||
import com.huanchengfly.tieba.post.fragments.UserPostFragment
|
||||
import com.huanchengfly.tieba.post.models.PhotoViewBean
|
||||
import com.huanchengfly.tieba.post.models.database.Block
|
||||
import com.huanchengfly.tieba.post.utils.AccountUtil
|
||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||
import com.huanchengfly.tieba.post.utils.StatusBarUtil
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||
import com.huanchengfly.tieba.post.widgets.theme.TintMaterialButton
|
||||
import com.huanchengfly.tieba.post.widgets.theme.TintToolbar
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import kotlin.math.abs
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
import com.huanchengfly.tieba.post.adapters.FragmentTabViewPagerAdapter;
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi;
|
||||
import com.huanchengfly.tieba.post.api.models.CommonResponse;
|
||||
import com.huanchengfly.tieba.post.api.models.ProfileBean;
|
||||
import com.huanchengfly.tieba.post.fragments.UserLikeForumFragment;
|
||||
import com.huanchengfly.tieba.post.fragments.UserPostFragment;
|
||||
import com.huanchengfly.tieba.post.models.PhotoViewBean;
|
||||
import com.huanchengfly.tieba.post.models.database.Account;
|
||||
import com.huanchengfly.tieba.post.models.database.Block;
|
||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||
import com.huanchengfly.tieba.post.utils.AccountUtil;
|
||||
import com.huanchengfly.tieba.post.utils.ImageUtil;
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
||||
import com.huanchengfly.tieba.post.widgets.theme.TintMaterialButton;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
import static com.huanchengfly.tieba.post.utils.Util.changeAlpha;
|
||||
|
||||
public class UserActivity extends BaseActivity {
|
||||
public static final String TAG = "UserActivity";
|
||||
public static final String EXTRA_UID = "uid";
|
||||
public static final String EXTRA_TAB = "tab";
|
||||
public static final String EXTRA_AVATAR = "avatar";
|
||||
|
||||
public static final int TAB_THREAD = 0;
|
||||
public static final int TAB_REPLY = 1;
|
||||
public static final int TAB_LIKE_FORUM = 2;
|
||||
|
||||
class UserActivity : BaseActivity() {
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
lateinit var toolbar: TintToolbar
|
||||
|
||||
@BindView(R.id.appbar)
|
||||
lateinit var appbar: AppBarLayout
|
||||
|
||||
@BindView(R.id.user_center_avatar)
|
||||
ImageView avatarView;
|
||||
lateinit var avatarView: ImageView
|
||||
|
||||
@BindView(R.id.title_view)
|
||||
TextView titleView;
|
||||
lateinit var titleView: TextView
|
||||
|
||||
@BindView(R.id.user_center_slogan)
|
||||
lateinit var sloganView: TextView
|
||||
|
||||
@BindView(R.id.user_center_stat)
|
||||
TextView statView;
|
||||
lateinit var statView: TextView
|
||||
|
||||
@BindView(R.id.user_center_action_btn)
|
||||
TintMaterialButton actionBtn;
|
||||
lateinit var actionBtn: TintMaterialButton
|
||||
|
||||
@BindView(R.id.loading_view)
|
||||
View loadingView;
|
||||
lateinit var loadingView: View
|
||||
|
||||
private ProfileBean profileBean;
|
||||
@BindView(R.id.fake_status_bar)
|
||||
lateinit var fakeStatusBarView: View
|
||||
|
||||
private String uid;
|
||||
private int tab;
|
||||
@BindView(R.id.user_center_header)
|
||||
lateinit var headerView: View
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_user;
|
||||
@BindView(R.id.user_center_header_mask)
|
||||
lateinit var headerMaskView: View
|
||||
|
||||
private var profileBean: ProfileBean? = null
|
||||
private var uid: String? = null
|
||||
private var tab = 0
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_user
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeUtil.setTranslucentThemeBackground(findViewById(R.id.background));
|
||||
uid = getIntent().getStringExtra(EXTRA_UID);
|
||||
tab = getIntent().getIntExtra(EXTRA_TAB, TAB_THREAD);
|
||||
String avatar = getIntent().getStringExtra(EXTRA_AVATAR);
|
||||
override val isNeedImmersionBar: Boolean
|
||||
get() = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
StatusBarUtil.transparentStatusBar(this)
|
||||
(toolbar.layoutParams as CollapsingToolbarLayout.LayoutParams).topMargin = StatusBarUtil.getStatusBarHeight(this)
|
||||
fakeStatusBarView.minimumHeight = StatusBarUtil.getStatusBarHeight(this)
|
||||
ThemeUtil.setTranslucentThemeBackground(findViewById(R.id.background))
|
||||
uid = intent.getStringExtra(EXTRA_UID)
|
||||
tab = intent.getIntExtra(EXTRA_TAB, TAB_THREAD)
|
||||
val avatar = intent.getStringExtra(EXTRA_AVATAR)
|
||||
if (uid == null) {
|
||||
finish();
|
||||
return;
|
||||
finish()
|
||||
return
|
||||
}
|
||||
FragmentTabViewPagerAdapter adapter = new FragmentTabViewPagerAdapter(getSupportFragmentManager());
|
||||
ViewPager viewPager = (ViewPager) findViewById(R.id.user_center_vp);
|
||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.user_center_tab);
|
||||
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
|
||||
actionBtn.setVisibility(View.GONE);
|
||||
val adapter = FragmentTabViewPagerAdapter(supportFragmentManager)
|
||||
val viewPager = findViewById(R.id.user_center_vp) as ViewPager
|
||||
val tabLayout = findViewById(R.id.user_center_tab) as TabLayout
|
||||
actionBtn.visibility = View.GONE
|
||||
if (!TextUtils.isEmpty(avatar)) {
|
||||
loadingView.setVisibility(View.GONE);
|
||||
ImageUtil.load(avatarView, ImageUtil.LOAD_TYPE_AVATAR, avatar);
|
||||
ImageUtil.initImageView(avatarView, new PhotoViewBean(avatar));
|
||||
loadingView.visibility = View.GONE
|
||||
ImageUtil.load(avatarView, ImageUtil.LOAD_TYPE_ALWAYS_ROUND, avatar)
|
||||
ImageUtil.initImageView(avatarView, PhotoViewBean(avatar))
|
||||
}
|
||||
appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
|
||||
toolbar.setBackgroundColor(changeAlpha(ThemeUtils.getColorByAttr(this, R.attr.colorToolbar), Math.abs(verticalOffset * 1.0f) / appBarLayout1.getTotalScrollRange()));
|
||||
if (profileBean != null && profileBean.getUser() != null && Math.abs(verticalOffset) >= appBarLayout1.getTotalScrollRange()) {
|
||||
toolbar.setTitle(profileBean.getUser().getNameShow());
|
||||
appbar.addOnOffsetChangedListener(OnOffsetChangedListener { appBarLayout: AppBarLayout, verticalOffset: Int ->
|
||||
val percent = abs(verticalOffset * 1.0f) / appBarLayout.totalScrollRange
|
||||
headerView.alpha = 1f - percent
|
||||
headerMaskView.alpha = percent
|
||||
if (profileBean != null && profileBean!!.user != null && abs(verticalOffset) >= appBarLayout.totalScrollRange) {
|
||||
toolbar.title = profileBean!!.user!!.nameShow
|
||||
} else {
|
||||
toolbar.setTitle(null);
|
||||
toolbar.title = null
|
||||
}
|
||||
});
|
||||
setSupportActionBar(toolbar);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
TiebaApi.getInstance().profile(uid).enqueue(new Callback<ProfileBean>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Call<ProfileBean> call, @NotNull Response<ProfileBean> response) {
|
||||
ProfileBean data = response.body();
|
||||
actionBtn.setVisibility(View.VISIBLE);
|
||||
loadingView.setVisibility(View.GONE);
|
||||
View dividerView = findViewById(R.id.user_center_divider);
|
||||
if (ThemeUtils.getColorByAttr(UserActivity.this, R.attr.colorBg) == ThemeUtils.getColorByAttr(UserActivity.this, R.attr.colorToolbar)) {
|
||||
dividerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (ThemeUtils.getColorByAttr(UserActivity.this, R.attr.colorToolbar) == ThemeUtils.getColorByAttr(UserActivity.this, R.attr.colorAccent)) {
|
||||
actionBtn.setTextColor(ColorStateList.valueOf(Color.WHITE));
|
||||
actionBtn.setStrokeColor(ColorStateList.valueOf(Color.WHITE));
|
||||
}
|
||||
profileBean = data;
|
||||
refreshHeader();
|
||||
adapter.clear();
|
||||
adapter.addFragment(UserPostFragment.newInstance(uid, true), "贴子 " + data.getUser().getThreadNum());
|
||||
adapter.addFragment(UserPostFragment.newInstance(uid, false), "回复 " + data.getUser().getRepostNum());
|
||||
adapter.addFragment(UserLikeForumFragment.newInstance(uid), "关注吧 " + data.getUser().getMyLikeNum());
|
||||
viewPager.setCurrentItem(tab, false);
|
||||
})
|
||||
viewPager.adapter = adapter
|
||||
viewPager.offscreenPageLimit = 3
|
||||
tabLayout.setupWithViewPager(viewPager)
|
||||
setSupportActionBar(toolbar)
|
||||
val actionBar = supportActionBar
|
||||
actionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
getInstance().profile(uid!!).enqueue(object : Callback<ProfileBean?> {
|
||||
override fun onResponse(call: Call<ProfileBean?>, response: Response<ProfileBean?>) {
|
||||
val data = response.body()
|
||||
actionBtn.visibility = View.VISIBLE
|
||||
loadingView.visibility = View.GONE
|
||||
profileBean = data
|
||||
refreshHeader()
|
||||
adapter.clear()
|
||||
adapter.addFragment(UserPostFragment.newInstance(uid, true), "贴子 " + data!!.user!!.threadNum)
|
||||
adapter.addFragment(UserPostFragment.newInstance(uid, false), "回复 " + data.user!!.repostNum)
|
||||
adapter.addFragment(UserLikeForumFragment.newInstance(uid), "关注吧 " + data.user.myLikeNum)
|
||||
viewPager.setCurrentItem(tab, false)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Call<ProfileBean> call, @NotNull Throwable t) {
|
||||
}
|
||||
});
|
||||
override fun onFailure(call: Call<ProfileBean?>, t: Throwable) {}
|
||||
})
|
||||
}
|
||||
|
||||
public void refreshHeader() {
|
||||
titleView.setText(profileBean.getUser().getNameShow());
|
||||
statView.setText(getString(R.string.tip_stat, profileBean.getUser().getConcernNum(), profileBean.getUser().getFansNum()));
|
||||
if (avatarView.getTag() == null) {
|
||||
ImageUtil.load(avatarView, ImageUtil.LOAD_TYPE_AVATAR, "http://tb.himg.baidu.com/sys/portrait/item/" + profileBean.getUser().getPortrait());
|
||||
ImageUtil.initImageView(avatarView, new PhotoViewBean("http://tb.himg.baidu.com/sys/portrait/item/" + profileBean.getUser().getPortrait()));
|
||||
fun refreshHeader() {
|
||||
titleView.text = profileBean!!.user!!.nameShow
|
||||
sloganView.text = profileBean!!.user!!.intro
|
||||
statView.text = getString(R.string.tip_stat, profileBean!!.user!!.concernNum, profileBean!!.user!!.fansNum)
|
||||
if (avatarView.tag == null) {
|
||||
ImageUtil.load(avatarView, ImageUtil.LOAD_TYPE_ALWAYS_ROUND, "http://tb.himg.baidu.com/sys/portrait/item/" + profileBean!!.user!!.portrait)
|
||||
ImageUtil.initImageView(avatarView, PhotoViewBean("http://tb.himg.baidu.com/sys/portrait/item/" + profileBean!!.user!!.portrait))
|
||||
}
|
||||
if (TextUtils.equals(AccountUtil.getUid(this), profileBean.getUser().getId())) {
|
||||
actionBtn.setText(R.string.menu_edit_info);
|
||||
if (TextUtils.equals(AccountUtil.getUid(this), profileBean!!.user!!.id)) {
|
||||
actionBtn.setText(R.string.menu_edit_info)
|
||||
} else {
|
||||
if ("1".equals(profileBean.getUser().getHasConcerned())) {
|
||||
actionBtn.setText(R.string.button_unfollow);
|
||||
if ("1" == profileBean!!.user!!.hasConcerned) {
|
||||
actionBtn.setText(R.string.button_unfollow)
|
||||
} else {
|
||||
actionBtn.setText(R.string.button_follow);
|
||||
actionBtn.setText(R.string.button_follow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_user_space, menu);
|
||||
Account account = AccountUtil.getLoginInfo(this);
|
||||
if (account != null && TextUtils.equals(account.getUid(), uid)) {
|
||||
menu.findItem(R.id.menu_block).setVisible(false);
|
||||
menu.findItem(R.id.menu_edit_info).setVisible(true);
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_user_space, menu)
|
||||
val account = AccountUtil.getLoginInfo(this)
|
||||
if (account != null && TextUtils.equals(account.uid, uid)) {
|
||||
menu.findItem(R.id.menu_block).isVisible = false
|
||||
menu.findItem(R.id.menu_edit_info).isVisible = true
|
||||
} else {
|
||||
menu.findItem(R.id.menu_block).setVisible(true);
|
||||
menu.findItem(R.id.menu_edit_info).setVisible(false);
|
||||
menu.findItem(R.id.menu_block).isVisible = true
|
||||
menu.findItem(R.id.menu_edit_info).isVisible = false
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_block_black:
|
||||
case R.id.menu_block_white:
|
||||
int category = item.getItemId() == R.id.menu_block_black ? Block.CATEGORY_BLACK_LIST : Block.CATEGORY_WHITE_LIST;
|
||||
new Block()
|
||||
.setUid(profileBean.getUser().getId())
|
||||
.setUsername(profileBean.getUser().getName())
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.menu_block_black, R.id.menu_block_white -> {
|
||||
val category = if (item.itemId == R.id.menu_block_black) Block.CATEGORY_BLACK_LIST else Block.CATEGORY_WHITE_LIST
|
||||
Block()
|
||||
.setUid(profileBean!!.user!!.id)
|
||||
.setUsername(profileBean!!.user!!.name)
|
||||
.setType(Block.TYPE_USER)
|
||||
.setCategory(category)
|
||||
.saveAsync()
|
||||
.listen(success -> {
|
||||
.listen { success: Boolean ->
|
||||
if (success) {
|
||||
Toast.makeText(this, R.string.toast_add_success, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, R.string.toast_add_success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
});
|
||||
return true;
|
||||
case R.id.menu_edit_info:
|
||||
startActivity(WebViewActivity.newIntent(this, getString(R.string.url_edit_info)));
|
||||
return true;
|
||||
}
|
||||
return true
|
||||
}
|
||||
R.id.menu_edit_info -> {
|
||||
startActivity(WebViewActivity.newIntent(this, getString(R.string.url_edit_info)))
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@OnClick(R.id.user_center_action_btn)
|
||||
public void onActionBtnClick(View view) {
|
||||
if (TextUtils.equals(profileBean.getUser().getId(), AccountUtil.getUid(this))) {
|
||||
startActivity(WebViewActivity.newIntent(this, getString(R.string.url_edit_info)));
|
||||
return;
|
||||
fun onActionBtnClick(view: View?) {
|
||||
if (TextUtils.equals(profileBean!!.user!!.id, AccountUtil.getUid(this))) {
|
||||
startActivity(WebViewActivity.newIntent(this, getString(R.string.url_edit_info)))
|
||||
return
|
||||
}
|
||||
if ("1".equals(profileBean.getUser().getHasConcerned())) {
|
||||
TiebaApi.getInstance().unfollow(profileBean.getUser().getPortrait(), AccountUtil.getLoginInfo(this).getTbs()).enqueue(new Callback<CommonResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Call<CommonResponse> call, @NotNull Response<CommonResponse> response) {
|
||||
CommonResponse data = response.body();
|
||||
Toast.makeText(UserActivity.this, data.getErrorMsg(), Toast.LENGTH_SHORT).show();
|
||||
profileBean.getUser().setHasConcerned("0");
|
||||
refreshHeader();
|
||||
if ("1" == profileBean!!.user!!.hasConcerned) {
|
||||
getInstance().unfollow(profileBean!!.user!!.portrait!!, AccountUtil.getLoginInfo(this)!!.tbs).enqueue(object : Callback<CommonResponse?> {
|
||||
override fun onResponse(call: Call<CommonResponse?>, response: Response<CommonResponse?>) {
|
||||
val data = response.body()
|
||||
Toast.makeText(this@UserActivity, data!!.errorMsg, Toast.LENGTH_SHORT).show()
|
||||
profileBean!!.user!!.setHasConcerned("0")
|
||||
refreshHeader()
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Call<CommonResponse> call, @NotNull Throwable t) {
|
||||
Toast.makeText(UserActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
override fun onFailure(call: Call<CommonResponse?>, t: Throwable) {
|
||||
Toast.makeText(this@UserActivity, t.message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
TiebaApi.getInstance().follow(profileBean.getUser().getPortrait(), AccountUtil.getLoginInfo(this).getTbs()).enqueue(new Callback<CommonResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Call<CommonResponse> call, @NotNull Response<CommonResponse> response) {
|
||||
CommonResponse data = response.body();
|
||||
Toast.makeText(UserActivity.this, data.getErrorMsg(), Toast.LENGTH_SHORT).show();
|
||||
profileBean.getUser().setHasConcerned("1");
|
||||
refreshHeader();
|
||||
getInstance().follow(profileBean!!.user!!.portrait!!, AccountUtil.getLoginInfo(this)!!.tbs).enqueue(object : Callback<CommonResponse?> {
|
||||
override fun onResponse(call: Call<CommonResponse?>, response: Response<CommonResponse?>) {
|
||||
val data = response.body()
|
||||
Toast.makeText(this@UserActivity, data!!.errorMsg, Toast.LENGTH_SHORT).show()
|
||||
profileBean!!.user!!.setHasConcerned("1")
|
||||
refreshHeader()
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Call<CommonResponse> call, @NotNull Throwable t) {
|
||||
Toast.makeText(UserActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
override fun onFailure(call: Call<CommonResponse?>, t: Throwable) {
|
||||
Toast.makeText(this@UserActivity, t.message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "UserActivity"
|
||||
const val EXTRA_UID = "uid"
|
||||
const val EXTRA_TAB = "tab"
|
||||
const val EXTRA_AVATAR = "avatar"
|
||||
const val TAB_THREAD = 0
|
||||
const val TAB_REPLY = 1
|
||||
const val TAB_LIKE_FORUM = 2
|
||||
}
|
||||
}
|
||||
|
|
@ -5,41 +5,34 @@ import android.text.TextUtils;
|
|||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
import com.huanchengfly.tieba.post.activities.ThreadActivity;
|
||||
import com.huanchengfly.tieba.post.adapters.base.BaseMultiTypeDelegateAdapter;
|
||||
import com.huanchengfly.tieba.post.api.models.UserPostBean;
|
||||
import com.huanchengfly.tieba.post.components.MyViewHolder;
|
||||
import com.huanchengfly.tieba.post.utils.DateTimeUtils;
|
||||
import com.huanchengfly.tieba.post.utils.ImageUtil;
|
||||
import com.huanchengfly.tieba.post.utils.NavigationHelper;
|
||||
import com.huanchengfly.tieba.post.utils.StringUtil;
|
||||
import com.othershe.baseadapter.ViewHolder;
|
||||
import com.othershe.baseadapter.base.MultiBaseAdapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UserPostAdapter extends MultiBaseAdapter<UserPostBean.PostBean> {
|
||||
public class UserPostAdapter extends BaseMultiTypeDelegateAdapter<UserPostBean.PostBean> {
|
||||
public static final int TYPE_THREAD = 0;
|
||||
public static final int TYPE_REPLY = 1;
|
||||
|
||||
private NavigationHelper navigationHelper;
|
||||
|
||||
public UserPostAdapter(Context context) {
|
||||
super(context, null, true);
|
||||
navigationHelper = NavigationHelper.newInstance(mContext);
|
||||
super(context, new LinearLayoutHelper());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(ViewHolder viewHolder, UserPostBean.PostBean postBean, int position, int type) {
|
||||
protected void convert(@NotNull MyViewHolder viewHolder, UserPostBean.PostBean postBean, int position, int type) {
|
||||
if (type == TYPE_THREAD) {
|
||||
viewHolder.setText(R.id.forum_item_agree_count_text, postBean.getAgree() != null ? postBean.getAgree().getDiffAgreeNum() : null);
|
||||
viewHolder.setText(R.id.forum_item_comment_count_text, postBean.getReplyNum());
|
||||
viewHolder.setVisibility(R.id.forum_item_good_tip, View.GONE);
|
||||
viewHolder.setOnClickListener(R.id.forum_item, view -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("tid", postBean.getThreadId());
|
||||
navigationHelper.navigationByData(NavigationHelper.ACTION_THREAD, map);
|
||||
});
|
||||
if ("1".equals(postBean.getIsNoTitle())) {
|
||||
viewHolder.setOnClickListener(R.id.forum_item, view -> ThreadActivity.launch(getContext(), postBean.getThreadId()));
|
||||
if ("1".equals(postBean.isNoTitle())) {
|
||||
viewHolder.setVisibility(R.id.forum_item_title_holder, View.GONE);
|
||||
} else {
|
||||
viewHolder.setVisibility(R.id.forum_item_title_holder, View.VISIBLE);
|
||||
|
|
@ -62,15 +55,15 @@ public class UserPostAdapter extends MultiBaseAdapter<UserPostBean.PostBean> {
|
|||
textView.setText("");
|
||||
textView.setVisibility(View.GONE);
|
||||
}
|
||||
viewHolder.setText(R.id.forum_item_user_name, StringUtil.getUsernameString(mContext, postBean.getUserName(), postBean.getNameShow()));
|
||||
viewHolder.setText(R.id.forum_item_user_name, StringUtil.getUsernameString(getContext(), postBean.getUserName(), postBean.getNameShow()));
|
||||
TextView timeTextView = viewHolder.getView(R.id.forum_item_user_time);
|
||||
String relativeTime = DateTimeUtils.getRelativeTimeString(mContext, postBean.getCreateTime());
|
||||
String relativeTime = DateTimeUtils.getRelativeTimeString(getContext(), postBean.getCreateTime());
|
||||
if (!TextUtils.isEmpty(postBean.getForumName())) {
|
||||
timeTextView.setText(
|
||||
mContext.getString(
|
||||
getContext().getString(
|
||||
R.string.template_two_string,
|
||||
relativeTime,
|
||||
mContext.getString(R.string.text_forum_name, postBean.getForumName())
|
||||
getContext().getString(R.string.text_forum_name, postBean.getForumName())
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
|
@ -79,12 +72,12 @@ public class UserPostAdapter extends MultiBaseAdapter<UserPostBean.PostBean> {
|
|||
ImageUtil.load(viewHolder.getView(R.id.forum_item_user_avatar), ImageUtil.LOAD_TYPE_AVATAR, postBean.getUserPortrait());
|
||||
} else if (type == TYPE_REPLY) {
|
||||
ImageUtil.load(viewHolder.getView(R.id.message_list_item_user_avatar), ImageUtil.LOAD_TYPE_AVATAR, postBean.getUserPortrait());
|
||||
viewHolder.setText(R.id.message_list_item_user_name, StringUtil.getUsernameString(mContext, postBean.getUserName(), postBean.getNameShow()));
|
||||
viewHolder.setText(R.id.message_list_item_user_name, StringUtil.getUsernameString(getContext(), postBean.getUserName(), postBean.getNameShow()));
|
||||
viewHolder.setText(
|
||||
R.id.message_list_item_user_time,
|
||||
mContext.getString(R.string.template_two_string,
|
||||
DateTimeUtils.getRelativeTimeString(mContext, postBean.getCreateTime()),
|
||||
mContext.getString(R.string.text_forum_name, postBean.getForumName())
|
||||
getContext().getString(R.string.template_two_string,
|
||||
DateTimeUtils.getRelativeTimeString(getContext(), postBean.getCreateTime()),
|
||||
getContext().getString(R.string.text_forum_name, postBean.getForumName())
|
||||
)
|
||||
);
|
||||
TextView contentTextView = viewHolder.getView(R.id.message_list_item_content);
|
||||
|
|
@ -94,7 +87,7 @@ public class UserPostAdapter extends MultiBaseAdapter<UserPostBean.PostBean> {
|
|||
}
|
||||
contentTextView.setText(content);
|
||||
viewHolder.setText(R.id.message_list_item_quote, postBean.getTitle().replace("回复:", "原贴:"));
|
||||
viewHolder.setOnClickListener(R.id.message_list_item_quote, v -> ThreadActivity.launch(mContext, postBean.getThreadId()));
|
||||
viewHolder.setOnClickListener(R.id.message_list_item_quote, v -> ThreadActivity.launch(getContext(), postBean.getThreadId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +98,6 @@ public class UserPostAdapter extends MultiBaseAdapter<UserPostBean.PostBean> {
|
|||
|
||||
@Override
|
||||
protected int getViewType(int position, UserPostBean.PostBean postBean) {
|
||||
return "1".equals(postBean.getIsThread()) ? TYPE_THREAD : TYPE_REPLY;
|
||||
return "1".equals(postBean.isThread()) ? TYPE_THREAD : TYPE_REPLY;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,218 +1,153 @@
|
|||
package com.huanchengfly.tieba.post.api.models;
|
||||
package com.huanchengfly.tieba.post.api.models
|
||||
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.huanchengfly.tieba.post.api.adapters.PortraitAdapter;
|
||||
import com.huanchengfly.tieba.post.api.adapters.UserPostContentAdapter;
|
||||
import com.huanchengfly.tieba.post.models.BaseBean;
|
||||
import com.google.gson.annotations.JsonAdapter
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.huanchengfly.tieba.post.api.adapters.PortraitAdapter
|
||||
import com.huanchengfly.tieba.post.api.adapters.UserPostContentAdapter
|
||||
import com.huanchengfly.tieba.post.models.BaseBean
|
||||
import java.util.*
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserPostBean extends BaseBean {
|
||||
class UserPostBean : BaseBean() {
|
||||
@SerializedName("error_code")
|
||||
private String errorCode;
|
||||
val errorCode: String? = null
|
||||
|
||||
@SerializedName("error_msg")
|
||||
private String errorMsg;
|
||||
val errorMsg: String? = null
|
||||
|
||||
@SerializedName("hide_post")
|
||||
private String hidePost;
|
||||
val hidePost: String? = null
|
||||
|
||||
@SerializedName("post_list")
|
||||
private List<PostBean> postList;
|
||||
val postList: List<PostBean>? = null
|
||||
|
||||
class AgreeBean {
|
||||
@SerializedName("agree_num")
|
||||
val agreeNum: String? = null
|
||||
|
||||
@SerializedName("disagree_num")
|
||||
val disagreeNum: String? = null
|
||||
|
||||
@SerializedName("diff_agree_num")
|
||||
val diffAgreeNum: String? = null
|
||||
|
||||
@SerializedName("has_agree")
|
||||
val hasAgree: String? = null
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
class PostBean {
|
||||
val agree: AgreeBean? = null
|
||||
|
||||
public String getHidePost() {
|
||||
return hidePost;
|
||||
}
|
||||
|
||||
public List<PostBean> getPostList() {
|
||||
return postList;
|
||||
}
|
||||
|
||||
public static class PostBean {
|
||||
@SerializedName("forum_id")
|
||||
private String forumId;
|
||||
val forumId: String? = null
|
||||
|
||||
@SerializedName("thread_id")
|
||||
private String threadId;
|
||||
val threadId: String? = null
|
||||
|
||||
@SerializedName("post_id")
|
||||
private String postId;
|
||||
val postId: String? = null
|
||||
|
||||
@SerializedName("is_thread")
|
||||
private String isThread;
|
||||
val isThread: String? = null
|
||||
|
||||
@SerializedName("create_time")
|
||||
private String createTime;
|
||||
val createTime: String? = null
|
||||
|
||||
@SerializedName("is_ntitle")
|
||||
private String isNoTitle;
|
||||
val isNoTitle: String? = null
|
||||
|
||||
@SerializedName("forum_name")
|
||||
private String forumName;
|
||||
private String title;
|
||||
val forumName: String? = null
|
||||
val title: String? = null
|
||||
|
||||
@SerializedName("user_name")
|
||||
private String userName;
|
||||
val userName: String? = null
|
||||
|
||||
@SerializedName("is_post_deleted")
|
||||
private String isPostDeleted;
|
||||
val isPostDeleted: String? = null
|
||||
|
||||
@SerializedName("reply_num")
|
||||
private String replyNum;
|
||||
val replyNum: String? = null
|
||||
|
||||
@SerializedName("freq_num")
|
||||
private String freqNum;
|
||||
val freqNum: String? = null
|
||||
|
||||
@SerializedName("user_id")
|
||||
private String userId;
|
||||
val userId: String? = null
|
||||
|
||||
@SerializedName("name_show")
|
||||
private String nameShow;
|
||||
@JsonAdapter(PortraitAdapter.class)
|
||||
val nameShow: String? = null
|
||||
|
||||
@JsonAdapter(PortraitAdapter::class)
|
||||
@SerializedName("user_portrait")
|
||||
private String userPortrait;
|
||||
val userPortrait: String? = null
|
||||
|
||||
@SerializedName("post_type")
|
||||
private String postType;
|
||||
@JsonAdapter(UserPostContentAdapter.class)
|
||||
private List<ContentBean> content;
|
||||
val postType: String? = null
|
||||
|
||||
@JsonAdapter(UserPostContentAdapter::class)
|
||||
val content: List<ContentBean>? = null
|
||||
|
||||
@SerializedName("abstract")
|
||||
private List<PostContentBean> abstracts;
|
||||
|
||||
public List<PostContentBean> getAbstracts() {
|
||||
return abstracts;
|
||||
}
|
||||
|
||||
public String getPostType() {
|
||||
return postType;
|
||||
}
|
||||
|
||||
public String getIsNoTitle() {
|
||||
return isNoTitle;
|
||||
}
|
||||
|
||||
public List<ContentBean> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getForumId() {
|
||||
return forumId;
|
||||
}
|
||||
|
||||
public String getThreadId() {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public String getPostId() {
|
||||
return postId;
|
||||
}
|
||||
|
||||
public String getIsThread() {
|
||||
return isThread;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public String getForumName() {
|
||||
return forumName;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getIsPostDeleted() {
|
||||
return isPostDeleted;
|
||||
}
|
||||
|
||||
public String getReplyNum() {
|
||||
return replyNum;
|
||||
}
|
||||
|
||||
public String getFreqNum() {
|
||||
return freqNum;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getNameShow() {
|
||||
return nameShow;
|
||||
}
|
||||
|
||||
public String getUserPortrait() {
|
||||
return userPortrait;
|
||||
}
|
||||
val abstracts: List<PostContentBean>? = null
|
||||
}
|
||||
|
||||
public static class ContentBean {
|
||||
class ContentBean {
|
||||
@SerializedName("post_content")
|
||||
private List<PostContentBean> postContent;
|
||||
var postContent: List<PostContentBean>? = null
|
||||
private set
|
||||
|
||||
@SerializedName("create_time")
|
||||
private String createTime;
|
||||
var createTime: String? = null
|
||||
private set
|
||||
|
||||
@SerializedName("post_id")
|
||||
private String postId;
|
||||
var postId: String? = null
|
||||
private set
|
||||
|
||||
public static ContentBean createContentBean(String content) {
|
||||
List<PostContentBean> list = new ArrayList<>();
|
||||
list.add(new PostContentBean()
|
||||
.setType("0")
|
||||
.setText(content));
|
||||
return new ContentBean()
|
||||
.setPostContent(list)
|
||||
.setCreateTime(null)
|
||||
.setPostId(null);
|
||||
fun setCreateTime(createTime: String?): ContentBean {
|
||||
this.createTime = createTime
|
||||
return this
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
fun setPostId(postId: String?): ContentBean {
|
||||
this.postId = postId
|
||||
return this
|
||||
}
|
||||
|
||||
public ContentBean setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
fun setPostContent(postContent: List<PostContentBean>?): ContentBean {
|
||||
this.postContent = postContent
|
||||
return this
|
||||
}
|
||||
|
||||
public String getPostId() {
|
||||
return postId;
|
||||
}
|
||||
|
||||
public ContentBean setPostId(String postId) {
|
||||
this.postId = postId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<PostContentBean> getPostContent() {
|
||||
return postContent;
|
||||
}
|
||||
|
||||
public ContentBean setPostContent(List<PostContentBean> postContent) {
|
||||
this.postContent = postContent;
|
||||
return this;
|
||||
companion object {
|
||||
fun createContentBean(content: String?): ContentBean {
|
||||
val list: MutableList<PostContentBean> = ArrayList()
|
||||
list.add(PostContentBean()
|
||||
.setType("0")
|
||||
.setText(content))
|
||||
return ContentBean()
|
||||
.setPostContent(list)
|
||||
.setCreateTime(null)
|
||||
.setPostId(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PostContentBean {
|
||||
private String type;
|
||||
private String text;
|
||||
class PostContentBean {
|
||||
var type: String? = null
|
||||
private set
|
||||
var text: String? = null
|
||||
private set
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
fun setType(type: String?): PostContentBean {
|
||||
this.type = type
|
||||
return this
|
||||
}
|
||||
|
||||
public PostContentBean setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public PostContentBean setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
fun setText(text: String?): PostContentBean {
|
||||
this.text = text
|
||||
return this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,197 +1,179 @@
|
|||
package com.huanchengfly.tieba.post.fragments;
|
||||
package com.huanchengfly.tieba.post.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import butterknife.BindView
|
||||
import com.alibaba.android.vlayout.DelegateAdapter
|
||||
import com.alibaba.android.vlayout.VirtualLayoutManager
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.activities.FloorActivity.Companion.launch
|
||||
import com.huanchengfly.tieba.post.activities.ThreadActivity
|
||||
import com.huanchengfly.tieba.post.adapters.SingleLayoutDelegateAdapter
|
||||
import com.huanchengfly.tieba.post.adapters.UserPostAdapter
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi.getInstance
|
||||
import com.huanchengfly.tieba.post.api.models.UserPostBean
|
||||
import com.huanchengfly.tieba.post.components.MyViewHolder
|
||||
import com.huanchengfly.tieba.post.components.dividers.SpacesItemDecoration
|
||||
import com.huanchengfly.tieba.post.utils.DisplayUtil
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
class UserPostFragment : BaseFragment() {
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
@BindView(R.id.refresh)
|
||||
lateinit var refreshLayout: SmartRefreshLayout
|
||||
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
import com.huanchengfly.tieba.post.activities.FloorActivity;
|
||||
import com.huanchengfly.tieba.post.activities.ThreadActivity;
|
||||
import com.huanchengfly.tieba.post.adapters.UserPostAdapter;
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi;
|
||||
import com.huanchengfly.tieba.post.api.models.UserPostBean;
|
||||
import com.huanchengfly.tieba.post.components.MyLinearLayoutManager;
|
||||
import com.huanchengfly.tieba.post.components.dividers.CommonDivider;
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
||||
@BindView(R.id.user_post_reclcyer_view)
|
||||
lateinit var recyclerView: RecyclerView
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
private val virtualLayoutManager: VirtualLayoutManager by lazy { VirtualLayoutManager(attachContext) }
|
||||
private val delegateAdapter: DelegateAdapter by lazy { DelegateAdapter(virtualLayoutManager) }
|
||||
private val userPostAdapter: UserPostAdapter by lazy { UserPostAdapter(attachContext) }
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
private var userPostBean: UserPostBean? = null
|
||||
private var uid: String? = null
|
||||
private var isThread = false
|
||||
private var page = 0
|
||||
private var hidePost = false
|
||||
|
||||
public class UserPostFragment extends BaseFragment {
|
||||
public static final String PARAM_UID = "uid";
|
||||
public static final String PARAM_IS_THREAD = "is_thread";
|
||||
public static final String TAG = UserPostFragment.class.getSimpleName();
|
||||
|
||||
private SwipeRefreshLayout refreshLayout;
|
||||
private RecyclerView recyclerView;
|
||||
private UserPostAdapter userPostAdapter;
|
||||
|
||||
private View emptyView;
|
||||
private TextView emptyTipView;
|
||||
|
||||
private UserPostBean userPostBean;
|
||||
|
||||
private String uid;
|
||||
private boolean isThread;
|
||||
private int page;
|
||||
|
||||
public UserPostFragment() {
|
||||
}
|
||||
|
||||
public static UserPostFragment newInstance(String uid) {
|
||||
return newInstance(uid, true);
|
||||
}
|
||||
|
||||
public static UserPostFragment newInstance(String uid, boolean isThread) {
|
||||
UserPostFragment fragment = new UserPostFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PARAM_UID, uid);
|
||||
args.putBoolean(PARAM_IS_THREAD, isThread);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle args = getArguments();
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val args = arguments
|
||||
if (args != null) {
|
||||
uid = args.getString(PARAM_UID, null);
|
||||
isThread = args.getBoolean(PARAM_IS_THREAD, true);
|
||||
uid = args.getString(PARAM_UID, null)
|
||||
isThread = args.getBoolean(PARAM_IS_THREAD, true)
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
int getLayoutId() {
|
||||
return R.layout.fragment_user_post;
|
||||
public override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_user_post
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View contentView = super.onCreateView(inflater, container, savedInstanceState);
|
||||
refreshLayout = contentView.findViewById(R.id.refresh);
|
||||
refreshLayout.setNestedScrollingEnabled(true);
|
||||
ThemeUtil.setThemeForSwipeRefreshLayout(refreshLayout);
|
||||
refreshLayout.setOnRefreshListener(this::refresh);
|
||||
recyclerView = contentView.findViewById(R.id.user_post_reclcyer_view);
|
||||
recyclerView.addItemDecoration(new CommonDivider(getAttachContext(), MyLinearLayoutManager.VERTICAL, R.drawable.drawable_divider_8dp));
|
||||
userPostAdapter = new UserPostAdapter(getAttachContext());
|
||||
emptyView = View.inflate(getAttachContext(), R.layout.layout_empty_view, null);
|
||||
emptyTipView = emptyView.findViewById(R.id.empty_tip);
|
||||
userPostAdapter.setOnMultiItemClickListener((viewHolder, postBean, position, viewType) -> {
|
||||
switch (viewType) {
|
||||
case UserPostAdapter.TYPE_THREAD:
|
||||
getAttachContext().startActivity(new Intent(getAttachContext(), ThreadActivity.class)
|
||||
.putExtra("tid", postBean.getThreadId()));
|
||||
break;
|
||||
case UserPostAdapter.TYPE_REPLY:
|
||||
if ("0".equals(postBean.getPostType())) {
|
||||
getAttachContext().startActivity(new Intent(getAttachContext(), FloorActivity.class)
|
||||
.putExtra("tid", postBean.getThreadId())
|
||||
.putExtra("pid", postBean.getPostId()));
|
||||
} else {
|
||||
getAttachContext().startActivity(new Intent(getAttachContext(), FloorActivity.class)
|
||||
.putExtra("tid", postBean.getThreadId())
|
||||
.putExtra("spid", postBean.getPostId()));
|
||||
}
|
||||
break;
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
refreshLayout.isNestedScrollingEnabled = true
|
||||
ThemeUtil.setThemeForSmartRefreshLayout(refreshLayout)
|
||||
refreshLayout.setOnRefreshLoadMoreListener(object : OnRefreshLoadMoreListener {
|
||||
override fun onRefresh(refreshLayout: RefreshLayout) {
|
||||
refresh()
|
||||
}
|
||||
});
|
||||
userPostAdapter.setLoadingView(R.layout.layout_footer_loading);
|
||||
userPostAdapter.setEmptyView(emptyView);
|
||||
userPostAdapter.setLoadEndView(R.layout.layout_footer_loadend);
|
||||
userPostAdapter.setLoadFailedView(R.layout.layout_footer_load_failed);
|
||||
userPostAdapter.setOnLoadMoreListener(this::load);
|
||||
recyclerView.setLayoutManager(new MyLinearLayoutManager(getAttachContext()));
|
||||
recyclerView.setAdapter(userPostAdapter);
|
||||
return contentView;
|
||||
}
|
||||
|
||||
public void load(boolean isReload) {
|
||||
if (!isReload) {
|
||||
page += 1;
|
||||
override fun onLoadMore(refreshLayout: RefreshLayout) {
|
||||
load()
|
||||
}
|
||||
})
|
||||
recyclerView.addItemDecoration(SpacesItemDecoration(0, 0, 0, DisplayUtil.dp2px(attachContext, 12f)))
|
||||
recyclerView.layoutManager = virtualLayoutManager
|
||||
recyclerView.adapter = delegateAdapter
|
||||
userPostAdapter.setOnItemClickListener { _, postBean, _ ->
|
||||
if ("1" == postBean.isThread) {
|
||||
ThreadActivity.launch(attachContext, postBean.threadId!!)
|
||||
} else {
|
||||
if ("0" == postBean.postType) {
|
||||
launch(attachContext, postBean.threadId!!, postBean.threadId)
|
||||
} else {
|
||||
launch(attachContext, postBean.threadId!!, null, postBean.threadId)
|
||||
}
|
||||
}
|
||||
}
|
||||
TiebaApi.getInstance()
|
||||
.userPost(uid, page, isThread)
|
||||
.enqueue(new Callback<UserPostBean>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Call<UserPostBean> call, @NotNull Response<UserPostBean> response) {
|
||||
UserPostBean data = response.body();
|
||||
userPostBean = data;
|
||||
if ("0".equals(data.getHidePost())) {
|
||||
userPostAdapter.setLoadMoreData(data.getPostList());
|
||||
if (data.getPostList().size() <= 0) {
|
||||
emptyTipView.setText(R.string.tip_empty);
|
||||
userPostAdapter.loadEnd();
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshAdapter() {
|
||||
delegateAdapter.clear()
|
||||
if (hidePost || userPostAdapter.itemCount == 0) {
|
||||
delegateAdapter.addAdapter(object : SingleLayoutDelegateAdapter(attachContext, R.layout.layout_empty_view) {
|
||||
override fun convert(viewHolder: MyViewHolder, itemView: View) {
|
||||
viewHolder.setText(
|
||||
R.id.empty_tip,
|
||||
if (hidePost) R.string.tip_user_hide else R.string.tip_empty
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
delegateAdapter.addAdapter(userPostAdapter)
|
||||
}
|
||||
delegateAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun load() {
|
||||
getInstance()
|
||||
.userPost(uid!!, page + 1, isThread)
|
||||
.enqueue(object : Callback<UserPostBean> {
|
||||
override fun onResponse(call: Call<UserPostBean>, response: Response<UserPostBean>) {
|
||||
page += 1
|
||||
val data = response.body()
|
||||
userPostBean = data
|
||||
refreshLayout.finishLoadMore()
|
||||
if (data!!.postList.isNullOrEmpty()) {
|
||||
refreshLayout.setNoMoreData(true)
|
||||
} else {
|
||||
emptyTipView.setText(R.string.tip_user_hide);
|
||||
userPostAdapter.loadEnd();
|
||||
userPostAdapter.insert(data.postList!!)
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Call<UserPostBean> call, @NotNull Throwable t) {
|
||||
Toast.makeText(getAttachContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
userPostAdapter.loadFailed();
|
||||
override fun onFailure(call: Call<UserPostBean>, t: Throwable) {
|
||||
Toast.makeText(attachContext, t.message, Toast.LENGTH_SHORT).show()
|
||||
refreshLayout.finishLoadMore(false)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
page = 1;
|
||||
userPostAdapter.reset();
|
||||
refreshLayout.setRefreshing(true);
|
||||
TiebaApi.getInstance()
|
||||
.userPost(uid, page, isThread)
|
||||
.enqueue(new Callback<UserPostBean>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Call<UserPostBean> call, @NotNull Response<UserPostBean> response) {
|
||||
UserPostBean data = response.body();
|
||||
userPostBean = data;
|
||||
if ("0".equals(data.getHidePost())) {
|
||||
userPostAdapter.setNewData(data.getPostList());
|
||||
if (data.getPostList().size() <= 0) {
|
||||
emptyTipView.setText(R.string.tip_empty);
|
||||
}
|
||||
fun refresh() {
|
||||
page = 1
|
||||
userPostAdapter.reset()
|
||||
getInstance()
|
||||
.userPost(uid!!, page, isThread)
|
||||
.enqueue(object : Callback<UserPostBean> {
|
||||
override fun onResponse(call: Call<UserPostBean>, response: Response<UserPostBean>) {
|
||||
val data = response.body()
|
||||
userPostBean = data
|
||||
hidePost = "1" == data!!.hidePost
|
||||
if (!hidePost) {
|
||||
userPostAdapter.setData(data.postList)
|
||||
} else {
|
||||
emptyTipView.setText(R.string.tip_user_hide);
|
||||
userPostAdapter.loadEnd();
|
||||
refreshLayout.setNoMoreData(true)
|
||||
}
|
||||
refreshLayout.setRefreshing(false);
|
||||
refreshLayout.finishRefresh()
|
||||
refreshAdapter()
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Call<UserPostBean> call, @NotNull Throwable t) {
|
||||
Toast.makeText(getAttachContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
refreshLayout.setRefreshing(false);
|
||||
override fun onFailure(call: Call<UserPostBean>, t: Throwable) {
|
||||
Toast.makeText(attachContext, t.message, Toast.LENGTH_SHORT).show()
|
||||
refreshLayout.finishRefresh(false)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFragmentFirstVisible() {
|
||||
refresh();
|
||||
override fun onFragmentFirstVisible() {
|
||||
refreshLayout.autoRefresh()
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFragmentVisibleChange(boolean isVisible) {
|
||||
override fun onFragmentVisibleChange(isVisible: Boolean) {
|
||||
if (isVisible && userPostBean == null) {
|
||||
refresh();
|
||||
refreshLayout.autoRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PARAM_UID = "uid"
|
||||
const val PARAM_IS_THREAD = "is_thread"
|
||||
val TAG = UserPostFragment::class.java.simpleName
|
||||
|
||||
@JvmOverloads
|
||||
fun newInstance(uid: String?, isThread: Boolean = true): UserPostFragment {
|
||||
val fragment = UserPostFragment()
|
||||
val args = Bundle()
|
||||
args.putString(PARAM_UID, uid)
|
||||
args.putBoolean(PARAM_IS_THREAD, isThread)
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ public class TintToolbar extends Toolbar implements Tintable {
|
|||
return;
|
||||
}
|
||||
if (attrs == null) {
|
||||
mBackgroundTintResId = R.color.default_color_toolbar;
|
||||
mBackgroundTintResId = 0;
|
||||
mItemTintResId = R.color.default_color_toolbar_item;
|
||||
mSecondaryItemTintResId = R.color.default_color_toolbar_item_secondary;
|
||||
mActiveItemTintResId = R.color.default_color_toolbar_item_active;
|
||||
|
|
@ -47,7 +47,7 @@ public class TintToolbar extends Toolbar implements Tintable {
|
|||
return;
|
||||
}
|
||||
TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.TintToolbar, defStyleAttr, 0);
|
||||
mBackgroundTintResId = array.getResourceId(R.styleable.TintToolbar_toolbarBackgroundTint, R.color.default_color_toolbar);
|
||||
mBackgroundTintResId = array.getResourceId(R.styleable.TintToolbar_toolbarBackgroundTint, 0);
|
||||
mItemTintResId = array.getResourceId(R.styleable.TintToolbar_itemTint, R.color.default_color_toolbar_item);
|
||||
mSecondaryItemTintResId = array.getResourceId(R.styleable.TintToolbar_secondaryItemTint, R.color.default_color_toolbar_item_secondary);
|
||||
mActiveItemTintResId = array.getResourceId(R.styleable.TintToolbar_activeItemTint, R.color.default_color_toolbar_item_active);
|
||||
|
|
@ -74,9 +74,6 @@ public class TintToolbar extends Toolbar implements Tintable {
|
|||
}
|
||||
|
||||
private void fixColor() {
|
||||
if (mBackgroundTintResId == 0) {
|
||||
mBackgroundTintResId = R.color.default_color_toolbar;
|
||||
}
|
||||
if (mItemTintResId == 0) {
|
||||
mItemTintResId = R.color.default_color_toolbar_item;
|
||||
}
|
||||
|
|
@ -89,10 +86,12 @@ public class TintToolbar extends Toolbar implements Tintable {
|
|||
}
|
||||
|
||||
private void tintBackground() {
|
||||
if (getBackground() == null) {
|
||||
setBackgroundColor(ThemeUtils.getColorById(getContext(), mBackgroundTintResId));
|
||||
} else {
|
||||
setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.getColorById(getContext(), mBackgroundTintResId)));
|
||||
if (mBackgroundTintResId != 0) {
|
||||
if (getBackground() == null) {
|
||||
setBackgroundColor(ThemeUtils.getColorById(getContext(), mBackgroundTintResId));
|
||||
} else {
|
||||
setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.getColorById(getContext(), mBackgroundTintResId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 170 KiB |
|
|
@ -1,115 +1,179 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
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:id="@+id/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activities.UserActivity">
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintCoordinatorLayout
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintCoordinatorLayout 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:id="@+id/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintAppBarLayout
|
||||
android:layout_height="match_parent"
|
||||
app:backgroundTint="@color/default_color_window_background"
|
||||
tools:context=".activities.UserActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
app:backgroundTint="@color/default_color_toolbar"
|
||||
android:background="@color/transparent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stateListAnimator="@animator/appbar_elevation">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:fitsSystemWindows="true"
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:titleEnabled="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<RelativeLayout
|
||||
android:padding="24dp"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/user_center_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.huanchengfly.tieba.post.widgets.MyImageView
|
||||
android:transitionName="avatar"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/user_center_avatar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp" />
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/user_header"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignBottom="@id/user_center_header" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/user_center_header"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_marginTop="?actionBarSize">
|
||||
|
||||
<View
|
||||
tools:minHeight="@android:dimen/status_bar_height"
|
||||
android:id="@+id/fake_status_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_toEndOf="@id/user_center_avatar"
|
||||
android:layout_toStartOf="@id/user_center_action_btn"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="56dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:textSize="18sp"
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.MyImageView
|
||||
android:id="@+id/user_center_avatar"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:transitionName="avatar" />
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintMaterialButton
|
||||
android:layout_alignParentEnd="true"
|
||||
android:id="@+id/user_center_action_btn"
|
||||
android:minHeight="32dp"
|
||||
android:minWidth="0dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp"
|
||||
app:backgroundTint="@color/user_center_action_btn_color"
|
||||
app:cornerRadius="100dp"
|
||||
app:buttonTextColor="@color/white"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
app:tint="@color/default_color_toolbar_item"
|
||||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_alignStart="@id/title_view"
|
||||
android:layout_below="@id/title_view"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:tint="@color/default_color_toolbar_item_secondary"
|
||||
android:id="@+id/user_center_stat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_centerVertical="true"
|
||||
tools:text="编辑资料"
|
||||
tools:ignore="RelativeOverlap" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintMaterialButton
|
||||
android:textStyle="bold"
|
||||
app:strokeWidth="1.5dp"
|
||||
style="@style/Widget.Button.Outlined"
|
||||
android:id="@+id/user_center_action_btn"
|
||||
android:layout_width="wrap_content"
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:layout_marginTop="24dp"
|
||||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="关注" />
|
||||
</RelativeLayout>
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/user_center_divider"
|
||||
app:backgroundTint="@color/default_color_divider"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:tint="@color/color_text_translucent_light" />
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:id="@+id/user_center_slogan"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="12sp"
|
||||
app:tint="@color/color_text_secondary_translucent_light" />
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:id="@+id/user_center_stat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="34dp"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:tint="@color/color_text_translucent_light" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
tools:visibility="gone"
|
||||
android:id="@+id/user_center_header_mask"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp" />
|
||||
</LinearLayout>
|
||||
android:layout_height="0dp"
|
||||
android:alpha="0"
|
||||
android:background="@color/user_center_header_mask"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignBottom="@id/user_center_header" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintToolbar
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="?attr/actionOverflowMenuStyle"
|
||||
app:toolbarBackgroundTint="@color/default_color_toolbar"
|
||||
app:itemTint="@color/default_color_toolbar_item"
|
||||
app:secondaryItemTint="@color/default_color_toolbar_item_secondary"
|
||||
app:activeItemTint="@color/default_color_toolbar_item_active"
|
||||
app:titleTextAppearance="@style/Toolbar.Title"
|
||||
app:subtitleTextAppearance="@style/Toolbar.Subtitle"
|
||||
app:itemTint="@color/theme_color_toolbar_item_translucent_light"
|
||||
app:secondaryItemTint="@color/theme_color_toolbar_item_secondary_translucent_light"
|
||||
app:activeItemTint="@color/theme_color_toolbar_item_active_translucent_light"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTabLayout
|
||||
android:id="@+id/user_center_tab"
|
||||
style="@style/Widget.TabLayout.Fixed"
|
||||
android:background="@drawable/bg_round"
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintFrameLayout
|
||||
android:id="@+id/user_center_tab_container"
|
||||
android:layout_marginTop="-10dp"
|
||||
app:backgroundTint="@color/default_color_toolbar"
|
||||
android:background="@drawable/bg_top_radius_10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintAppBarLayout>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintFrameLayout
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/bg_radius_8dp"
|
||||
app:backgroundTint="@color/default_color_toolbar_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTabLayout
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
style="@style/Widget.TabLayout.Toolbar.Fixed"
|
||||
android:id="@+id/user_center_tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintFrameLayout>
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintFrameLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:overScrollMode="ifContentScrolls"
|
||||
android:id="@+id/user_center_vp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintCoordinatorLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/loading_view"
|
||||
layout="@layout/layout_loading_view" />
|
||||
</FrameLayout>
|
||||
<include
|
||||
android:id="@+id/loading_view"
|
||||
layout="@layout/layout_loading_view" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintCoordinatorLayout>
|
||||
|
|
@ -1,12 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintSwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout 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"
|
||||
app:srlDragRate="0.8"
|
||||
app:srlEnableNestedScrolling="true"
|
||||
app:srlEnableOverScrollBounce="true"
|
||||
app:srlEnableOverScrollDrag="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/refresh"
|
||||
tools:context=".fragments.UserPostFragment">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintMaterialHeader
|
||||
android:id="@+id/refresh_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:paddingTop="@dimen/card_margin"
|
||||
android:paddingStart="@dimen/card_margin"
|
||||
android:paddingEnd="@dimen/card_margin"
|
||||
android:clipToPadding="false"
|
||||
android:id="@+id/user_post_reclcyer_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintSwipeRefreshLayout>
|
||||
|
||||
<com.huanchengfly.tieba.post.components.LoadMoreFooter
|
||||
app:footerSpinnerStyle="scale"
|
||||
app:backgroundTint="@color/transparent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:materialCardBackgroundTint="@color/default_color_card"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="@color/default_color_card"
|
||||
android:background="@drawable/bg_radius_10dp"
|
||||
android:paddingStart="@dimen/padding_start_default"
|
||||
android:paddingEnd="@dimen/padding_end_default"
|
||||
android:paddingTop="12dp"
|
||||
|
|
|
|||
|
|
@ -182,4 +182,6 @@
|
|||
<color name="icon_blue">#FF3373EE</color>
|
||||
<color name="icon_purple">#FF8E6DCA</color>
|
||||
<color name="black_trans">#50000000</color>
|
||||
<color name="user_center_action_btn_color">#50FFFFFF</color>
|
||||
<color name="user_center_header_mask">#90000000</color>
|
||||
</resources>
|
||||
|
|
@ -368,7 +368,7 @@
|
|||
<string name="text_load_failed">加载失败</string>
|
||||
<string name="text_pull_up_to_load">上拉加载更多</string>
|
||||
<string name="text_release_to_load">释放开始加载</string>
|
||||
<string name="template_two_string">%1$s·%2$s</string>
|
||||
<string name="template_two_string">%1$s · %2$s</string>
|
||||
<string name="title_search_forum">搜吧</string>
|
||||
<string name="title_search_thread">搜贴</string>
|
||||
<string name="title_search_user">搜人</string>
|
||||
|
|
@ -426,4 +426,5 @@
|
|||
<string name="title_oksign_slow_mode">慢速模式</string>
|
||||
<string name="summary_oksign_slow_mode">开启后,一键签到时签到每个吧的时间间隔将会更长</string>
|
||||
<string name="summary_oksign_slow_mode_on">一键签到时签到每个吧的时间间隔将会更长</string>
|
||||
<string name="title_user_threads">全部贴子(%1$s)</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue