Skip to content

Commit

Permalink
Merge branch 'v2' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
WrBug committed Sep 12, 2024
2 parents 65cef4c + 1e0adeb commit 98fd966
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/captures
.externalNativeBuild
sign.jks
signing.properties
signing.properties
lint-baseline.xml
3 changes: 1 addition & 2 deletions basecommon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ def lifecycle_version = "2.0.0"
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.7.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'com.google.android.material:material:1.12.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation project(':commonutil')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager

class ActResultRequest {
private lateinit var mFragment: OnActResultEventDispatcherFragment
private val mFragment: OnActResultEventDispatcherFragment

constructor(activity: AppCompatActivity) {
mFragment = getEventDispatchFragment(activity)
Expand All @@ -29,10 +29,12 @@ class ActResultRequest {
}

private fun addFragment(fragmentManager: FragmentManager): OnActResultEventDispatcherFragment {
var fragment: OnActResultEventDispatcherFragment? = this.findEventDispatchFragment(fragmentManager)
var fragment: OnActResultEventDispatcherFragment? =
this.findEventDispatchFragment(fragmentManager)
if (fragment == null) {
fragment = OnActResultEventDispatcherFragment()
fragmentManager.beginTransaction().add(fragment, "on_act_result_event_dispatcher").commitAllowingStateLoss()
fragmentManager.beginTransaction().add(fragment, "on_act_result_event_dispatcher")
.commitAllowingStateLoss()
fragmentManager.executePendingTransactions()
}

Expand Down
4 changes: 2 additions & 2 deletions basemoduleimport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ dependencies {
api 'androidx.appcompat:appcompat:1.7.0'
api 'androidx.constraintlayout:constraintlayout:2.1.4'
api 'androidx.legacy:legacy-support-v4:1.0.0'
api 'androidx.recyclerview:recyclerview:1.0.0'
api 'com.google.android.material:material:1.1.0-alpha02'
api 'androidx.recyclerview:recyclerview:1.3.2'
api 'com.google.android.material:material:1.12.0'
api project(':commonutil')
api project(':commonwidget')
api project(':mmkv')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ object UiUtils {
).toInt()
}

fun sp2px(context: Context = CommonUtils.application, spVal: Float): Int {
return TypedValue.applyDimension(2, spVal, context.resources?.displayMetrics).toInt()
}

fun px2dp(context: Context = CommonUtils.application, pxVal: Float): Float {
val scale = context.resources?.displayMetrics?.density!!
return pxVal / scale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.widget.TextView
import android.widget.Toast
import com.wrbug.developerhelper.commonutil.UiUtils
import com.wrbug.developerhelper.commonwidget.R
import com.wrbug.developerhelper.commonwidget.databinding.LayoutToastFlexibleBinding

class FlexibleToast private constructor(private val mContext: Context) {

Expand Down Expand Up @@ -52,11 +53,13 @@ class FlexibleToast private constructor(private val mContext: Context) {
0,
0
)

builder.mGravity == GRAVITY_TOP -> flexibleToast.setGravity(
Gravity.TOP or Gravity.CENTER_VERTICAL,
0,
UiUtils.dp2px(mContext, 20F)
)

else -> flexibleToast.setGravity(
Gravity.BOTTOM or Gravity.CENTER_VERTICAL,
0,
Expand All @@ -71,7 +74,7 @@ class FlexibleToast private constructor(private val mContext: Context) {
if (builder.hasCustomerView && builder.mCustomerView != null) {
flexibleToast.view = builder.mCustomerView
} else {
flexibleToast.view = builder.mDefaultView
flexibleToast.view = builder.binding.root
}
flexibleToast.show()
}
Expand All @@ -80,46 +83,31 @@ class FlexibleToast private constructor(private val mContext: Context) {
* 控制Toast的显示样式
*/
class Builder(context: Context) {
val mDefaultView: View = LayoutInflater.from(context)
.inflate(R.layout.layout_toast_flexible, null)
val binding = LayoutToastFlexibleBinding.inflate(LayoutInflater.from(context))
var mCustomerView: View? = null
private val mIvImage: ImageView
private val mTvFirst: TextView
private val mTvSecond: TextView

private val dividerFirst: View
private val dividerSecond: View

var mDuration = Toast.LENGTH_SHORT// 0 short, 1 long
var mGravity = 0
var hasCustomerView = false // 是否使用自定义layout


init {
mIvImage = mDefaultView.findViewById(R.id.imgIv)
mTvFirst = mDefaultView.findViewById(R.id.firstTv)
mTvSecond = mDefaultView.findViewById(R.id.secondTv)
dividerFirst = mDefaultView.findViewById(R.id.firstDividerView)
dividerSecond = mDefaultView.findViewById(R.id.secondDividerView)
}

fun setImageResource(resId: Int): Builder {
this.mIvImage.setImageResource(resId)
this.mIvImage.visibility = View.VISIBLE
this.dividerFirst.visibility = View.VISIBLE
binding.imgIv.setImageResource(resId)
binding.imgIv.visibility = View.VISIBLE
binding.firstDividerView.visibility = View.VISIBLE
return this
}

fun setFirstText(firstText: String): Builder {
this.mTvFirst.text = firstText
this.mTvFirst.visibility = View.VISIBLE
this.dividerSecond.visibility = View.VISIBLE
binding.firstTv.text = firstText
binding.firstTv.visibility = View.VISIBLE
binding.secondDividerView.visibility = View.VISIBLE
return this
}

fun setSecondText(secondText: String): Builder {
this.mTvSecond.text = secondText
this.mTvSecond.visibility = View.VISIBLE
binding.secondTv.text = secondText
binding.secondTv.visibility = View.VISIBLE
return this
}

Expand Down
1 change: 0 additions & 1 deletion ipc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':commonutil')
Expand Down
5 changes: 1 addition & 4 deletions mmkv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.tencent:mmkv:1.3.9'
implementation 'androidx.appcompat:appcompat:1.7.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.code.gson:gson:2.10'
}

0 comments on commit 98fd966

Please sign in to comment.