feat:初步完成发红包弹窗UI
This commit is contained in:
@@ -341,7 +341,9 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
* @param optAdapter
|
||||
*/
|
||||
private void addRedPacketAction(OptAdapter optAdapter) {
|
||||
if (AvRoomDataManager.get().isRedEnvelopeOpen()) {
|
||||
// TODO 临时打开
|
||||
// if (AvRoomDataManager.get().isRedEnvelopeOpen()) {
|
||||
if (true) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) {
|
||||
return;
|
||||
|
@@ -0,0 +1,121 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
import android.graphics.Color
|
||||
import androidx.core.view.isVisible
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseBindingFragment
|
||||
import com.yizhuan.erban.databinding.RedPackagePrivateFragmentBinding
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.ColorDecoration
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 12:14
|
||||
* Desc:
|
||||
**/
|
||||
@ActLayoutRes(R.layout.red_package_private_fragment)
|
||||
class PrivateRedPackageEditorFragment : BaseBindingFragment<RedPackagePrivateFragmentBinding>() {
|
||||
override fun initiate() {
|
||||
initTypeView()
|
||||
updateTimeView(true)
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
super.onSetListener()
|
||||
mBinding.tvNow.setOnClickListener {
|
||||
updateTimeView(true)
|
||||
}
|
||||
mBinding.tvDelay.setOnClickListener {
|
||||
updateTimeView(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initTypeView() {
|
||||
mBinding.recyclerView.addItemDecoration(
|
||||
ColorDecoration(
|
||||
Color.TRANSPARENT, UIUtil.dip2px(context, 6.0), 0, false
|
||||
)
|
||||
)
|
||||
val list = ArrayList<RedPackageTypeItemAdapter.ItemData>()
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
"UNLIMITED",
|
||||
R.string.red_package_type_unlimited_name,
|
||||
R.string.red_package_type_unlimited_tips
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
"FOLLOW",
|
||||
R.string.red_package_type_follow_name,
|
||||
R.string.red_package_type_follow_tips
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
"SHARE",
|
||||
R.string.red_package_type_share_name,
|
||||
R.string.red_package_type_share_tips
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
"MSG",
|
||||
R.string.red_package_type_msg_name,
|
||||
R.string.red_package_type_msg_tips
|
||||
)
|
||||
)
|
||||
val adapter = RedPackageTypeItemAdapter(list)
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
adapter.select(position)
|
||||
updateTypeView(adapter.getSelect()?.type)
|
||||
}
|
||||
mBinding.recyclerView.adapter = adapter
|
||||
// 默认选择第一个
|
||||
adapter.select(0)
|
||||
updateTypeView(adapter.getSelect()?.type)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新红包类型对应的视图
|
||||
*/
|
||||
private fun updateTypeView(type: String?) {
|
||||
when (type) {
|
||||
"UNLIMITED" -> {
|
||||
mBinding.tvNow.isVisible = true
|
||||
mBinding.tvDelay.isVisible = true
|
||||
mBinding.etText.isVisible = false
|
||||
}
|
||||
|
||||
"MSG" -> {
|
||||
mBinding.tvNow.isVisible = false
|
||||
mBinding.tvDelay.isVisible = false
|
||||
mBinding.etText.isVisible = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
mBinding.tvNow.isVisible = false
|
||||
mBinding.tvDelay.isVisible = false
|
||||
mBinding.etText.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间选项
|
||||
*/
|
||||
private fun updateTimeView(nowOrDelay: Boolean) {
|
||||
if (nowOrDelay) {
|
||||
mBinding.tvNow.setBackgroundResource(R.drawable.red_package_bg_type_selected)
|
||||
mBinding.tvDelay.setBackgroundResource(R.drawable.shape_f8f8fa_8)
|
||||
mBinding.tvNow.setTextColor(mBinding.root.context.getColorById(R.color.color_FF285C))
|
||||
mBinding.tvDelay.setTextColor(mBinding.root.context.getColorById(R.color.color_767585))
|
||||
} else {
|
||||
mBinding.tvNow.setBackgroundResource(R.drawable.shape_f8f8fa_8)
|
||||
mBinding.tvDelay.setBackgroundResource(R.drawable.red_package_bg_type_selected)
|
||||
mBinding.tvNow.setTextColor(mBinding.root.context.getColorById(R.color.color_767585))
|
||||
mBinding.tvDelay.setTextColor(mBinding.root.context.getColorById(R.color.color_FF285C))
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseBindingFragment
|
||||
import com.yizhuan.erban.databinding.RedPackagePrivateFragmentBinding
|
||||
import com.yizhuan.erban.databinding.RedPackagePublicFragmentBinding
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 12:14
|
||||
* Desc:
|
||||
**/
|
||||
@ActLayoutRes(R.layout.red_package_public_fragment)
|
||||
class PublicRedPackageEditorFragment : BaseBindingFragment<RedPackagePublicFragmentBinding>() {
|
||||
override fun initiate() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageEvent
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.common.ViewPagerAdapter
|
||||
import com.yizhuan.erban.databinding.DialogRedPackageSend2Binding
|
||||
import com.yizhuan.erban.home.adapter.ContactsIndicatorAdapter
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
@ActLayoutRes(R.layout.dialog_red_package_send2)
|
||||
class RedPackageSendDialog2 : BaseDialog<DialogRedPackageSend2Binding>() {
|
||||
|
||||
override fun onStart() {
|
||||
gravity = Gravity.BOTTOM
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun init() {
|
||||
EventBus.getDefault().register(this)
|
||||
val tabTitles = arrayListOf("厅内红包", "全服红包")
|
||||
val topMagicIndicatorAdapter = ContactsIndicatorAdapter(context, tabTitles, 1)
|
||||
topMagicIndicatorAdapter.setOnItemSelectListener {
|
||||
binding.viewPager.currentItem = it
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.isAdjustMode = true
|
||||
commonNavigator.adapter = topMagicIndicatorAdapter
|
||||
binding.tabLayout.navigator = commonNavigator
|
||||
val fragments =
|
||||
arrayListOf(PrivateRedPackageEditorFragment(), PublicRedPackageEditorFragment())
|
||||
binding.viewPager.adapter = ViewPagerAdapter(
|
||||
childFragmentManager,
|
||||
fragments.toList(),
|
||||
null
|
||||
)
|
||||
ViewPagerHelper.bind(binding.tabLayout, binding.viewPager)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun handleRedPackageDialog(event: RedPackageEvent?) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.yizhuan.erban.R
|
||||
import io.realm.internal.Keep
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 18:02
|
||||
* Desc:
|
||||
**/
|
||||
class RedPackageTypeItemAdapter(list: List<ItemData>) :
|
||||
BaseQuickAdapter<RedPackageTypeItemAdapter.ItemData, BaseViewHolder>(
|
||||
R.layout.red_package_private_item_type,
|
||||
list
|
||||
) {
|
||||
|
||||
private var selectPosition = -1
|
||||
|
||||
@Keep
|
||||
data class ItemData(val type: String, val name: Int, val tips: Int)
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: ItemData) {
|
||||
helper.setText(R.id.tv_name, item.name)
|
||||
helper.setText(R.id.tv_tips, item.tips)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: ItemData,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
private fun convertState(helper: BaseViewHolder, item: ItemData) {
|
||||
if (helper.bindingAdapterPosition == selectPosition) {
|
||||
helper.setBackgroundRes(R.id.layout_root, R.drawable.red_package_bg_type_selected)
|
||||
helper.setTextColor(
|
||||
R.id.tv_name,
|
||||
helper.itemView.context.getColorById(R.color.color_FF285C)
|
||||
)
|
||||
helper.setTextColor(
|
||||
R.id.tv_tips,
|
||||
helper.itemView.context.getColorById(R.color.color_FF285C)
|
||||
)
|
||||
} else {
|
||||
helper.setBackgroundRes(R.id.layout_root, R.drawable.shape_f8f8fa_8)
|
||||
helper.setTextColor(
|
||||
R.id.tv_name,
|
||||
helper.itemView.context.getColorById(R.color.color_767585)
|
||||
)
|
||||
helper.setTextColor(
|
||||
R.id.tv_tips,
|
||||
helper.itemView.context.getColorById(R.color.color_94959C)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(position: Int) {
|
||||
this.selectPosition = position
|
||||
notifyItemRangeChanged(0, itemCount, true)
|
||||
}
|
||||
|
||||
fun getSelect(): ItemData? {
|
||||
return data.getOrNull(selectPosition)
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description
|
||||
* @Date 2018/11/1
|
||||
*/
|
||||
public class TabIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private List<String> mTitleList;
|
||||
private Context mContext;
|
||||
private int mBottomMargin;
|
||||
|
||||
public TabIndicatorAdapter(Context mContext, List<String> mTitleList, int bottomMargin) {
|
||||
this.mTitleList = mTitleList;
|
||||
this.mContext = mContext;
|
||||
mBottomMargin = bottomMargin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, int index) {
|
||||
ContactsPagerTitleView categoryPagerTitleView = new ContactsPagerTitleView(context, mTitleList.get(index));
|
||||
categoryPagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (null != mOnItemSelectListener) {
|
||||
mOnItemSelectListener.onItemSelect(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
return categoryPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 9));
|
||||
indicator.setColors(context.getResources().getColor(R.color.app_248cfe));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position);
|
||||
}
|
||||
|
||||
class ContactsPagerTitleView extends AppCompatTextView implements IPagerTitleView {
|
||||
|
||||
|
||||
public ContactsPagerTitleView(Context context, String tabInfo) {
|
||||
super(context);
|
||||
setHeight(Utils.dip2px(getContext(), 30));
|
||||
setTextSize(16);
|
||||
setText(tabInfo);
|
||||
setGravity(Gravity.CENTER);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelected(int index, int totalCount) {
|
||||
// setBackgroundResource(R.drawable.shape_bg_contact_indicator_item);
|
||||
setTextColor(getResources().getColor(R.color.color_333333));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeselected(int index, int totalCount) {
|
||||
// setBackgroundDrawable(null);
|
||||
setTextColor(getResources().getColor(R.color.color_666666));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -57,10 +57,10 @@ public class ContactsIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 9));
|
||||
indicator.setColors(context.getResources().getColor(R.color.app_248cfe));
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 12));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_FF285C));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
@@ -82,8 +82,8 @@ public class ContactsIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
|
||||
public ContactsPagerTitleView(Context context, String tabInfo) {
|
||||
super(context);
|
||||
setHeight(Utils.dip2px(getContext(), 30));
|
||||
setTextSize(16);
|
||||
setHeight(Utils.dip2px(getContext(), 25));
|
||||
setTextSize(18);
|
||||
setText(tabInfo);
|
||||
setGravity(Gravity.CENTER);
|
||||
|
||||
|
@@ -8,8 +8,10 @@ import android.text.SpannableString
|
||||
import android.view.View
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import com.tongdaxing.erban.upgrade.AppUpgradeHelper
|
||||
import com.yizhuan.erban.BuildConfig
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.UIHelper
|
||||
import com.yizhuan.erban.avroom.redpackage.send.RedPackageSendDialog2
|
||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager.OkCancelDialogListener
|
||||
import com.yizhuan.erban.databinding.ActivitySettingBinding
|
||||
@@ -74,6 +76,12 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
binding.tvShieldManager.setOnClickListener(this)
|
||||
binding.rlyPermission.setOnClickListener(this)
|
||||
binding.rlyCheck.setOnClickListener(this)
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
binding.titleBar.setOnTitleClickListener {
|
||||
RedPackageSendDialog2().show(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.yizhuan.erban.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
|
||||
/**
|
||||
* Created by Max on 2022/10/10 15:30
|
||||
* 高度自适应(采用最大的子页面高度)-ViewPager
|
||||
*/
|
||||
class WrapHeightViewPager : ViewPager {
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
var height = 0
|
||||
for (i in 0 until childCount) {
|
||||
val child: View = getChildAt(i)
|
||||
child.measure(
|
||||
widthMeasureSpec,
|
||||
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
|
||||
)
|
||||
val h = child.measuredHeight
|
||||
if (h > height) {
|
||||
height = h
|
||||
}
|
||||
}
|
||||
super.onMeasure(
|
||||
widthMeasureSpec, MeasureSpec.makeMeasureSpec(
|
||||
height,
|
||||
MeasureSpec.EXACTLY
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
11
app/src/main/res/drawable/red_package_bg_balance.xml
Normal file
11
app/src/main/res/drawable/red_package_bg_balance.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="26dp"
|
||||
android:topLeftRadius="26dp" />
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="#FF225C"
|
||||
android:startColor="#FF6060" />
|
||||
</shape>
|
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="8dp" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#FF285C" />
|
||||
<solid android:color="#0FFF285C" />
|
||||
</shape>
|
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="26dp" />
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="#FF225C"
|
||||
android:startColor="#FF6060" />
|
||||
</shape>
|
231
app/src/main/res/layout/red_package_private_fragment.xml
Normal file
231
app/src/main/res/layout/red_package_private_fragment.xml
Normal file
@@ -0,0 +1,231 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_money"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="end|center_vertical"
|
||||
android:hint="0"
|
||||
android:inputType="number"
|
||||
android:paddingEnd="59dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textColorHint="@color/color_B3B3C3"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_money"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="9dp"
|
||||
android:src="@drawable/red_package_ic"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintStart_toStartOf="@id/et_money"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:text="红包金额"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_money"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_money_unit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="钻"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintEnd_toEndOf="@id/et_money"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:background="@color/color_EBEEF5"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_money_unit"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_num"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="end|center_vertical"
|
||||
android:hint="0"
|
||||
android:inputType="number"
|
||||
android:paddingEnd="59dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textColorHint="@color/color_B3B3C3"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_money" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="红包数量"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
app:layout_constraintStart_toStartOf="@id/et_num"
|
||||
app:layout_constraintTop_toTopOf="@id/et_num" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_num_unit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="个"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
app:layout_constraintEnd_toEndOf="@id/et_num"
|
||||
app:layout_constraintTop_toTopOf="@id/et_num" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:background="@color/color_EBEEF5"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_num_unit"
|
||||
app:layout_constraintTop_toTopOf="@id/et_num" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="抢红包条件"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_num" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="62dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="6dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_type" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/layout_parameter"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginTop="12dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/recyclerView">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_now"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:text="立即生效"
|
||||
android:textColor="@color/color_FF285C"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_delay"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_delay"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="19dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:text="即时生效"
|
||||
android:textColor="@color/color_FF285C"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_now"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_now" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:hint="輸入指定彈幕內容(最多10個字符)"
|
||||
android:maxLength="10"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textColorHint="@color/color_B3B3C3"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrier_send_top"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="et_text,tv_now,tv_delay" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_send"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginHorizontal="40dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:background="@drawable/shape_g_ff6060_ff225c_26_lr"
|
||||
android:gravity="center"
|
||||
android:text="发红包"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/layout_parameter" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="未搶完的紅包將在12小時後返還你的錢包"
|
||||
android:textColor="@color/color_94959C"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_send" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
@@ -703,5 +703,9 @@
|
||||
<color name="color_1E686868">#1E686868</color>
|
||||
<color name="color_9E9EA8">#9E9EA8</color>
|
||||
<color name="color_001338">#001338</color>
|
||||
<color name="color_FF285C">#FF285C</color>
|
||||
<color name="color_322F4D">#322F4D</color>
|
||||
<color name="color_EBEEF5">#EBEEF5</color>
|
||||
<color name="color_94959C">#94959C</color>
|
||||
|
||||
</resources>
|
||||
|
@@ -5143,4 +5143,13 @@
|
||||
<string name="room_album_type_no_need_unlocked_gift_tips">當前無需選擇解鎖禮物</string>
|
||||
<string name="room_album_type_choose_unlocked_gift_tips">選擇解鎖禮物</string>
|
||||
|
||||
<string name="red_package_type_unlimited_name">無門檻紅包</string>
|
||||
<string name="red_package_type_unlimited_tips">所有人均可參與</string>
|
||||
<string name="red_package_type_follow_name">關註紅包</string>
|
||||
<string name="red_package_type_follow_tips">關註主播可參與</string>
|
||||
<string name="red_package_type_share_name">分享紅包</string>
|
||||
<string name="red_package_type_share_tips">分享房間可參與</string>
|
||||
<string name="red_package_type_msg_name">發彈幕紅包</string>
|
||||
<string name="red_package_type_msg_tips">發指定彈幕內容</string>
|
||||
|
||||
</resources>
|
Binary file not shown.
After Width: | Height: | Size: 112 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="16">
|
||||
<path
|
||||
android:pathData="M8,3C8.491,3 8.889,3.398 8.889,3.889L8.888,7.111L12.111,7.111C12.602,7.111 13,7.509 13,8C13,8.491 12.602,8.889 12.111,8.889L8.888,8.888L8.889,12.111C8.889,12.602 8.491,13 8,13C7.509,13 7.111,12.602 7.111,12.111L7.111,8.888L3.889,8.889C3.398,8.889 3,8.491 3,8C3,7.509 3.398,7.111 3.889,7.111L7.111,7.111L7.111,3.889C7.111,3.398 7.509,3 8,3Z"
|
||||
android:strokeWidth="0.5"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
@@ -0,0 +1,22 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12.171,6.342C11.02,6.342 10.118,6.669 9.464,7.338C8.811,7.991 8.484,8.878 8.484,10.013L10.118,10.013C10.118,9.329 10.258,8.8 10.538,8.427C10.849,7.976 11.362,7.758 12.062,7.758C12.622,7.758 13.073,7.913 13.384,8.224C13.68,8.536 13.836,8.956 13.836,9.5C13.836,9.904 13.68,10.278 13.4,10.636L13.136,10.931C12.171,11.787 11.58,12.424 11.378,12.86C11.16,13.264 11.067,13.762 11.067,14.338L11.067,14.602L12.731,14.602L12.731,14.338C12.731,13.964 12.809,13.622 12.98,13.311C13.12,13.031 13.338,12.751 13.633,12.502C14.364,11.864 14.8,11.46 14.94,11.289C15.329,10.791 15.531,10.153 15.531,9.391C15.531,8.458 15.22,7.711 14.598,7.167C13.976,6.607 13.167,6.342 12.171,6.342ZM11.891,15.442C11.58,15.442 11.3,15.536 11.082,15.753C10.864,15.956 10.756,16.22 10.756,16.547C10.756,16.858 10.864,17.122 11.082,17.34C11.3,17.558 11.58,17.667 11.891,17.667C12.202,17.667 12.482,17.558 12.7,17.356C12.918,17.138 13.042,16.873 13.042,16.547C13.042,16.22 12.933,15.956 12.716,15.753C12.498,15.536 12.218,15.442 11.891,15.442Z"
|
||||
android:strokeAlpha="0.90000004"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="0.90000004"/>
|
||||
<path
|
||||
android:pathData="M12,12m-9.333,0a9.333,9.333 0,1 1,18.667 0a9.333,9.333 0,1 1,-18.667 0"
|
||||
android:strokeAlpha="0.90000004"
|
||||
android:strokeWidth="1.33333333"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:fillAlpha="0.90000004"/>
|
||||
</vector>
|
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="8dp"/>
|
||||
<solid android:color="#F8F8FA"/>
|
||||
</shape>
|
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout 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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:background="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="@id/viewPager"
|
||||
app:layout_constraintTop_toTopOf="@id/viewPager" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/red_package_bg"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginTop="170dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_top" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginTop="71dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/red_package_ic_help"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_top" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_balance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/red_package_bg_balance"
|
||||
android:gravity="center"
|
||||
android:paddingStart="25dp"
|
||||
android:paddingEnd="23dp"
|
||||
android:text="0"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/tab_layout"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/red_package_ic_add"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_balance"
|
||||
app:layout_constraintEnd_toEndOf="@id/tv_balance"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_balance" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/red_package_ic_diamond"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_balance"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_balance"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_balance" />
|
||||
|
||||
<com.yizhuan.erban.view.WrapHeightViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/tab_layout" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout 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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/layout_root"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:layout_width="94dp"
|
||||
android:layout_height="62dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_tips"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tips"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_94959C"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_name"
|
||||
tools:text="Tips" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
@@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_money"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="end|center_vertical"
|
||||
android:hint="0"
|
||||
android:inputType="number"
|
||||
android:paddingEnd="59dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textColorHint="@color/color_B3B3C3"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_money"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="9dp"
|
||||
android:src="@drawable/red_package_ic"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintStart_toStartOf="@id/et_money"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:text="红包金额"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_money"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_money_unit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="钻"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintEnd_toEndOf="@id/et_money"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:background="@color/color_EBEEF5"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_money_unit"
|
||||
app:layout_constraintTop_toTopOf="@id/et_money" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_num"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="end|center_vertical"
|
||||
android:hint="0"
|
||||
android:inputType="number"
|
||||
android:paddingEnd="59dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textColorHint="@color/color_B3B3C3"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_money" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="红包数量"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
app:layout_constraintStart_toStartOf="@id/et_num"
|
||||
app:layout_constraintTop_toTopOf="@id/et_num" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_num_unit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="个"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
app:layout_constraintEnd_toEndOf="@id/et_num"
|
||||
app:layout_constraintTop_toTopOf="@id/et_num" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:background="@color/color_EBEEF5"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_num_unit"
|
||||
app:layout_constraintTop_toTopOf="@id/et_num" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="76dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:maxLength="20"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:text="恭喜發財,大吉大利!"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_num" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_text_langth"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="0/20"
|
||||
android:textColor="@color/color_94959C"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_text"
|
||||
app:layout_constraintEnd_toEndOf="@id/et_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_send"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginHorizontal="40dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_g_ff6060_ff225c_26_lr"
|
||||
android:text="发红包"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_text" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="未搶完的紅包將在12小時後返還你的錢包"
|
||||
android:textColor="@color/color_94959C"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_send" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
@@ -35,6 +35,7 @@ android {
|
||||
'src/module_luban/java',
|
||||
'src/module_easyphoto/java',
|
||||
'src/module_common/java',
|
||||
'src/module_utils/java',
|
||||
|
||||
]
|
||||
|
||||
@@ -43,6 +44,7 @@ android {
|
||||
'src/module_easypermission/res',
|
||||
'src/module_easyphoto/res',
|
||||
'src/module_common/res',
|
||||
'src/module_utils/res',
|
||||
|
||||
]
|
||||
|
||||
@@ -144,6 +146,9 @@ dependencies {
|
||||
api 'com.facebook.android:facebook-android-sdk:16.2.0'
|
||||
api 'com.facebook.android:facebook-login:16.2.0'
|
||||
|
||||
// 网络请求chrome数据调试
|
||||
implementation 'com.facebook.stetho:stetho:1.5.1'
|
||||
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.stetho.okhttp3.StethoInterceptor;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.yizhuan.xchat_android_library.BuildConfig;
|
||||
@@ -70,6 +71,8 @@ public final class RxNetManager {
|
||||
});
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
mBuilder.addInterceptor(loggingInterceptor);
|
||||
|
||||
mBuilder.addNetworkInterceptor(new StethoInterceptor());
|
||||
}
|
||||
|
||||
for (Interceptor interceptor : interceptors) {
|
||||
|
@@ -26,6 +26,7 @@ public abstract class BaseApp extends Application{
|
||||
|
||||
public static void init(Application application) {
|
||||
gContext = application;
|
||||
com.chuhai.utils.AppUtils.init(application);
|
||||
}
|
||||
|
||||
/**
|
||||
|
403
library/src/module_utils/java/com/chuhai/utils/AppUtils.java
Normal file
403
library/src/module_utils/java/com/chuhai/utils/AppUtils.java
Normal file
@@ -0,0 +1,403 @@
|
||||
package com.chuhai.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* author:
|
||||
* ___ ___ ___ ___
|
||||
* _____ / /\ /__/\ /__/| / /\
|
||||
* / /::\ / /::\ \ \:\ | |:| / /:/
|
||||
* / /:/\:\ ___ ___ / /:/\:\ \ \:\ | |:| /__/::\
|
||||
* / /:/~/::\ /__/\ / /\ / /:/~/::\ _____\__\:\ __| |:| \__\/\:\
|
||||
* /__/:/ /:/\:| \ \:\ / /:/ /__/:/ /:/\:\ /__/::::::::\ /__/\_|:|____ \ \:\
|
||||
* \ \:\/:/~/:/ \ \:\ /:/ \ \:\/:/__\/ \ \:\~~\~~\/ \ \:\/:::::/ \__\:\
|
||||
* \ \::/ /:/ \ \:\/:/ \ \::/ \ \:\ ~~~ \ \::/~~~~ / /:/
|
||||
* \ \:\/:/ \ \::/ \ \:\ \ \:\ \ \:\ /__/:/
|
||||
* \ \::/ \__\/ \ \:\ \ \:\ \ \:\ \__\/
|
||||
* \__\/ \__\/ \__\/ \__\/
|
||||
* blog : http://blankj.com
|
||||
* time : 16/12/08
|
||||
* desc : utils about initialization
|
||||
* </pre>
|
||||
*/
|
||||
public final class AppUtils {
|
||||
|
||||
private static final ExecutorService UTIL_POOL = Executors.newFixedThreadPool(3);
|
||||
private static final Handler UTIL_HANDLER = new Handler(Looper.getMainLooper());
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Application sApplication;
|
||||
|
||||
|
||||
private AppUtils() {
|
||||
throw new UnsupportedOperationException("u can't instantiate me...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Init utils.
|
||||
* <p>Init it in the class of Application.</p>
|
||||
*
|
||||
* @param context context
|
||||
*/
|
||||
public static void init(final Context context) {
|
||||
if (context == null) {
|
||||
init(getApplicationByReflect());
|
||||
return;
|
||||
}
|
||||
init((Application) context.getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Init utils.
|
||||
* <p>Init it in the class of Application.</p>
|
||||
*
|
||||
* @param app application
|
||||
*/
|
||||
public static void init(final Application app) {
|
||||
if (sApplication == null) {
|
||||
if (app == null) {
|
||||
sApplication = getApplicationByReflect();
|
||||
} else {
|
||||
sApplication = app;
|
||||
}
|
||||
} else {
|
||||
sApplication = app;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the context of Application object.
|
||||
*
|
||||
* @return the context of Application object
|
||||
*/
|
||||
public static Application getApp() {
|
||||
if (sApplication != null) return sApplication;
|
||||
Application app = getApplicationByReflect();
|
||||
init(app);
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
public static String getPackageName(Context context) {
|
||||
return context.getPackageName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版本名
|
||||
*
|
||||
* @param noSuffix 是否去掉后缀 (如:-debug、-test)
|
||||
*/
|
||||
public static String getVersionName(boolean noSuffix) {
|
||||
PackageInfo packageInfo = getPackageInfo(getApp());
|
||||
if (packageInfo != null) {
|
||||
String versionName = packageInfo.versionName;
|
||||
if (noSuffix && versionName != null) {
|
||||
int index = versionName.indexOf("-");
|
||||
if (index >= 0) {
|
||||
return versionName.substring(0, index);
|
||||
}
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//版本号
|
||||
public static int getVersionCode() {
|
||||
PackageInfo packageInfo = getPackageInfo(getApp());
|
||||
if (packageInfo != null) {
|
||||
return packageInfo.versionCode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较版本
|
||||
* 1 = 大于当前版本
|
||||
* 0 = 版本一样
|
||||
* -1 = 当前版本大于更新版本
|
||||
*/
|
||||
public static int compareVersionNames(String newVersionName) {
|
||||
try {
|
||||
if (TextUtils.isEmpty(newVersionName)) {
|
||||
return -1;
|
||||
}
|
||||
int res = 0;
|
||||
String currentVersionName = getVersionName(true);
|
||||
if (currentVersionName.equals(newVersionName)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String[] oldNumbers = currentVersionName.split("\\.");
|
||||
String[] newNumbers = newVersionName.split("\\.");
|
||||
|
||||
// To avoid IndexOutOfBounds
|
||||
int minIndex = Math.min(oldNumbers.length, newNumbers.length);
|
||||
|
||||
for (int i = 0; i < minIndex; i++) {
|
||||
int oldVersionPart = Integer.parseInt(oldNumbers[i]);
|
||||
int newVersionPart = Integer.parseInt(newNumbers[i]);
|
||||
|
||||
if (oldVersionPart < newVersionPart) {
|
||||
res = 1;
|
||||
break;
|
||||
} else if (oldVersionPart > newVersionPart) {
|
||||
res = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If versions are the same so far, but they have different length...
|
||||
if (res == 0 && oldNumbers.length != newNumbers.length) {
|
||||
res = (oldNumbers.length > newNumbers.length) ? -1 : 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static PackageInfo getPackageInfo(Context context) {
|
||||
PackageInfo packageInfo;
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS);
|
||||
return packageInfo;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static <T> Task<T> doAsync(final Task<T> task) {
|
||||
UTIL_POOL.execute(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
public static void runOnUiThread(final Runnable runnable) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
AppUtils.UTIL_HANDLER.post(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
public static void runOnUiThreadDelayed(final Runnable runnable, long delayMillis) {
|
||||
AppUtils.UTIL_HANDLER.postDelayed(runnable, delayMillis);
|
||||
}
|
||||
|
||||
static String getCurrentProcessName() {
|
||||
String name = getCurrentProcessNameByFile();
|
||||
if (!TextUtils.isEmpty(name)) return name;
|
||||
name = getCurrentProcessNameByAms();
|
||||
if (!TextUtils.isEmpty(name)) return name;
|
||||
name = getCurrentProcessNameByReflect();
|
||||
return name;
|
||||
}
|
||||
|
||||
static void fixSoftInputLeaks(final Window window) {
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) AppUtils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm == null) return;
|
||||
String[] leakViews = new String[]{"mLastSrvView", "mCurRootView", "mServedView", "mNextServedView"};
|
||||
for (String leakView : leakViews) {
|
||||
try {
|
||||
Field leakViewField = InputMethodManager.class.getDeclaredField(leakView);
|
||||
if (leakViewField == null) continue;
|
||||
if (!leakViewField.isAccessible()) {
|
||||
leakViewField.setAccessible(true);
|
||||
}
|
||||
Object obj = leakViewField.get(imm);
|
||||
if (!(obj instanceof View)) continue;
|
||||
View view = (View) obj;
|
||||
if (view.getRootView() == window.getDecorView().getRootView()) {
|
||||
leakViewField.set(imm, null);
|
||||
}
|
||||
} catch (Throwable ignore) {/**/}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// private method
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static String getCurrentProcessNameByFile() {
|
||||
try {
|
||||
File file = new File("/proc/" + android.os.Process.myPid() + "/" + "cmdline");
|
||||
BufferedReader mBufferedReader = new BufferedReader(new FileReader(file));
|
||||
String processName = mBufferedReader.readLine().trim();
|
||||
mBufferedReader.close();
|
||||
return processName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCurrentProcessNameByAms() {
|
||||
ActivityManager am = (ActivityManager) AppUtils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
if (am == null) return "";
|
||||
List<ActivityManager.RunningAppProcessInfo> info = am.getRunningAppProcesses();
|
||||
if (info == null || info.size() == 0) return "";
|
||||
int pid = android.os.Process.myPid();
|
||||
for (ActivityManager.RunningAppProcessInfo aInfo : info) {
|
||||
if (aInfo.pid == pid) {
|
||||
if (aInfo.processName != null) {
|
||||
return aInfo.processName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getCurrentProcessNameByReflect() {
|
||||
String processName = "";
|
||||
try {
|
||||
Application app = AppUtils.getApp();
|
||||
Field loadedApkField = app.getClass().getField("mLoadedApk");
|
||||
loadedApkField.setAccessible(true);
|
||||
Object loadedApk = loadedApkField.get(app);
|
||||
|
||||
Field activityThreadField = loadedApk.getClass().getDeclaredField("mActivityThread");
|
||||
activityThreadField.setAccessible(true);
|
||||
Object activityThread = activityThreadField.get(loadedApk);
|
||||
|
||||
Method getProcessName = activityThread.getClass().getDeclaredMethod("getProcessName");
|
||||
processName = (String) getProcessName.invoke(activityThread);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return processName;
|
||||
}
|
||||
|
||||
private static Application getApplicationByReflect() {
|
||||
try {
|
||||
@SuppressLint("PrivateApi")
|
||||
Class<?> activityThread = Class.forName("android.app.ActivityThread");
|
||||
Object thread = activityThread.getMethod("currentActivityThread").invoke(null);
|
||||
Object app = activityThread.getMethod("getApplication").invoke(thread);
|
||||
if (app == null) {
|
||||
throw new NullPointerException("u should init first");
|
||||
}
|
||||
return (Application) app;
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new NullPointerException("u should init first");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// interface
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public abstract static class Task<Result> implements Runnable {
|
||||
|
||||
private static final int NEW = 0;
|
||||
private static final int COMPLETING = 1;
|
||||
private static final int CANCELLED = 2;
|
||||
private static final int EXCEPTIONAL = 3;
|
||||
|
||||
private volatile int state = NEW;
|
||||
|
||||
abstract Result doInBackground();
|
||||
|
||||
private final Callback<Result> mCallback;
|
||||
|
||||
public Task(final Callback<Result> callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final Result t = doInBackground();
|
||||
|
||||
if (state != NEW) return;
|
||||
state = COMPLETING;
|
||||
UTIL_HANDLER.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mCallback.onCall(t);
|
||||
}
|
||||
});
|
||||
} catch (Throwable th) {
|
||||
if (state != NEW) return;
|
||||
state = EXCEPTIONAL;
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
state = CANCELLED;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return state != NEW;
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return state == CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Callback<T> {
|
||||
void onCall(T data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否打开定位
|
||||
*/
|
||||
public static boolean getGpsStatus(Context ctx) {
|
||||
//从系统服务中获取定位管理器
|
||||
LocationManager locationManager
|
||||
= (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE);
|
||||
// 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)
|
||||
boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
// 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)
|
||||
boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
if (gps || network) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开系统定位界面
|
||||
*/
|
||||
public static void goToOpenGps(Context ctx) {
|
||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
ctx.startActivity(intent);
|
||||
}
|
||||
}
|
@@ -0,0 +1,195 @@
|
||||
package com.chuhai.utils.ktx
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.TypedValue
|
||||
import androidx.annotation.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.chuhai.utils.AppUtils
|
||||
|
||||
/**
|
||||
* 资源工具类
|
||||
* @author Max
|
||||
* @date 2019-11-26.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 获取颜色
|
||||
*/
|
||||
fun Fragment.getColorById(@ColorRes colorResId: Int): Int {
|
||||
return ContextCompat.getColor(context!!, colorResId)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取图片
|
||||
*/
|
||||
fun Fragment.getDrawableById(@DrawableRes drawableRedId: Int): Drawable? {
|
||||
return ContextCompat.getDrawable(context!!, drawableRedId)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取颜色
|
||||
*/
|
||||
fun Activity.getColorById(@ColorRes colorResId: Int): Int {
|
||||
return ContextCompat.getColor(this, colorResId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片
|
||||
*/
|
||||
fun Activity.getDrawableById(@DrawableRes drawableRedId: Int): Drawable? {
|
||||
return ContextCompat.getDrawable(this, drawableRedId)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取颜色
|
||||
*/
|
||||
fun Context.getColorById(@ColorRes colorResId: Int): Int {
|
||||
return ContextCompat.getColor(this, colorResId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片
|
||||
*/
|
||||
fun Context.getDrawableById(@DrawableRes drawableRedId: Int): Drawable? {
|
||||
return ContextCompat.getDrawable(this, drawableRedId)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字符串资源
|
||||
*/
|
||||
fun Any.getStringById(@StringRes stringResId: Int): String {
|
||||
return AppUtils.getApp().getString(stringResId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串资源
|
||||
*/
|
||||
fun Int.toStringRes(): String {
|
||||
return AppUtils.getApp().getString(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源drawable
|
||||
* */
|
||||
fun Int.toDrawableRes(): Drawable? {
|
||||
return ContextCompat.getDrawable(AppUtils.getApp(), this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源color
|
||||
* */
|
||||
fun Int.toColorRes(): Int {
|
||||
return ContextCompat.getColor(AppUtils.getApp(), this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义属性-获取DrawableRes
|
||||
*/
|
||||
@DrawableRes
|
||||
fun Context.getDrawableResFromAttr(
|
||||
@AttrRes attrResId: Int,
|
||||
typedValue: TypedValue = TypedValue(),
|
||||
resolveRefs: Boolean = true
|
||||
): Int? {
|
||||
return try {
|
||||
theme.resolveAttribute(attrResId, typedValue, resolveRefs)
|
||||
return typedValue.resourceId
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义属性-获取Drawable
|
||||
*/
|
||||
fun Context.getDrawableFromAttr(@AttrRes attrId: Int): Drawable? {
|
||||
return try {
|
||||
val drawableRes = getDrawableResFromAttr(attrId) ?: return null
|
||||
ResourcesCompat.getDrawable(resources, drawableRes, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义属性-获取ColorRes
|
||||
*/
|
||||
@ColorRes
|
||||
fun Context.getColorResFromAttr(
|
||||
@AttrRes attrResId: Int,
|
||||
typedValue: TypedValue = TypedValue(),
|
||||
resolveRefs: Boolean = true
|
||||
): Int? {
|
||||
return try {
|
||||
theme.resolveAttribute(attrResId, typedValue, resolveRefs)
|
||||
return typedValue.resourceId
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义属性-获取Color
|
||||
*/
|
||||
@ColorRes
|
||||
fun Context.getColorFromAttr(
|
||||
@AttrRes attrResId: Int
|
||||
): Int? {
|
||||
return try {
|
||||
val colorRes = getColorFromAttr(attrResId) ?: return null
|
||||
ResourcesCompat.getColor(resources, colorRes, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义属性-获取LayoutRes
|
||||
*/
|
||||
@LayoutRes
|
||||
fun Context.getLayoutResFromAttr(
|
||||
@AttrRes attrResId: Int,
|
||||
typedValue: TypedValue = TypedValue(),
|
||||
resolveRefs: Boolean = true
|
||||
): Int? {
|
||||
return try {
|
||||
theme.resolveAttribute(attrResId, typedValue, resolveRefs)
|
||||
return typedValue.resourceId
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义属性-获取Boolean
|
||||
*/
|
||||
fun Context.getBooleanResFromAttr(
|
||||
@AttrRes attrResId: Int,
|
||||
defValue: Boolean = false
|
||||
): Boolean {
|
||||
var attrs: TypedArray? = null
|
||||
try {
|
||||
attrs = obtainStyledAttributes(null, intArrayOf(attrResId))
|
||||
return attrs.getBoolean(0, defValue)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
attrs?.recycle()
|
||||
}
|
||||
return defValue
|
||||
}
|
5
library/src/module_utils/res/values/ids.xml
Normal file
5
library/src/module_utils/res/values/ids.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
|
||||
</resources>
|
3
library/src/module_utils/res/values/strings.xml
Normal file
3
library/src/module_utils/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
|
||||
</resources>
|
Reference in New Issue
Block a user