Merge branch 'dev-4.7.0' of git.ghzs.com:halo/assistant-android into dev-4.7.0
This commit is contained in:
@ -25,6 +25,11 @@ object AdHelper {
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun getStartUpAd() {
|
||||
if (!NetworkUtils.isNetworkConnected(HaloApp.getInstance())) {
|
||||
startupAd.postValue(null)
|
||||
return
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance(HaloApp.getInstance())
|
||||
.api
|
||||
.getSplashAd(HaloApp.getInstance().channel)
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.LinearLayout
|
||||
@ -11,8 +10,8 @@ import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.OnLifecycleEvent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.AppExecutor
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
|
||||
class AutoScrollRecyclerViewContainerView(context: Context, @Nullable attrs: AttributeSet?)
|
||||
: LinearLayout(context, attrs), LifecycleObserver {
|
||||
@ -21,6 +20,7 @@ class AutoScrollRecyclerViewContainerView(context: Context, @Nullable attrs: Att
|
||||
|
||||
private var mIsScrolling = false
|
||||
private var mIsScrollable = false
|
||||
private var mLastScrollTime = 0L
|
||||
|
||||
private var mOnItemTouchListener: RecyclerView.OnItemTouchListener? = null
|
||||
|
||||
@ -59,16 +59,22 @@ class AutoScrollRecyclerViewContainerView(context: Context, @Nullable attrs: Att
|
||||
fun resumeScrolling() {
|
||||
if (mIsScrolling) return
|
||||
|
||||
if (mIsScrolling) pauseScrolling()
|
||||
mIsScrollable = true
|
||||
mIsScrolling = true
|
||||
postDelayed(autoScrollTask, AUTO_SCROLL_INTERVAL)
|
||||
|
||||
AppExecutor.lightWeightIoExecutor.execute {
|
||||
while (mIsScrolling && autoScrollTask != null) {
|
||||
if (System.currentTimeMillis() - mLastScrollTime >= AUTO_SCROLL_INTERVAL) {
|
||||
mLastScrollTime = System.currentTimeMillis()
|
||||
AppExecutor.uiExecutor.execute(autoScrollTask!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
fun pauseScrolling() {
|
||||
mIsScrolling = false
|
||||
removeCallbacks(autoScrollTask)
|
||||
}
|
||||
|
||||
fun setLifeCycleOwner(lifeCycleOwner: Lifecycle) {
|
||||
@ -76,12 +82,12 @@ class AutoScrollRecyclerViewContainerView(context: Context, @Nullable attrs: Att
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val AUTO_SCROLL_INTERVAL: Long = 10
|
||||
private const val AUTO_SCROLL_INTERVAL: Long = 16
|
||||
private const val SCROLL_SLOP = 1
|
||||
}
|
||||
|
||||
class AutoScrollTask(reference: AutoScrollRecyclerViewContainerView?) : Runnable {
|
||||
private val mReference: WeakReference<AutoScrollRecyclerViewContainerView?>?
|
||||
private val mScrollSlop = if (Build.MODEL.toLowerCase(Locale.getDefault()) == "mumu") 1 else 2
|
||||
|
||||
init {
|
||||
mReference = WeakReference(reference)
|
||||
@ -92,10 +98,9 @@ class AutoScrollRecyclerViewContainerView(context: Context, @Nullable attrs: Att
|
||||
if (containerView != null && containerView.mIsScrolling && containerView.mIsScrollable) {
|
||||
for (child in containerView.children) {
|
||||
if (child is RecyclerView) {
|
||||
child.scrollBy(mScrollSlop, mScrollSlop)
|
||||
child.scrollBy(SCROLL_SLOP, SCROLL_SLOP)
|
||||
}
|
||||
}
|
||||
containerView.postDelayed(containerView.autoScrollTask, AUTO_SCROLL_INTERVAL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,12 +331,16 @@ public class MainActivity extends BaseActivity {
|
||||
private void observeAd() {
|
||||
AdHelper.startupAd.observe(this, startupAdEntity -> {
|
||||
if (showAd) {
|
||||
showAd(startupAdEntity);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(true), 2000);
|
||||
if (startupAdEntity == null) {
|
||||
hideAd(true);
|
||||
} else {
|
||||
showAd(startupAdEntity);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(true), 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(false), 1000);
|
||||
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(false), 950);
|
||||
}
|
||||
|
||||
private void hideAd(boolean forceToHide) {
|
||||
|
||||
@ -38,7 +38,7 @@ class SpecialCatalogSubjectCollectionAdapter(context: Context,
|
||||
override fun onBindViewHolder(holder: CatalogSubjectCollectionListItemViewHolder, position: Int) {
|
||||
holder.binding.run {
|
||||
root.layoutParams = (root.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
leftMargin = if (position == 0) 12F.dip2px() else 0
|
||||
leftMargin = if (position == 0) 17F.dip2px() else 0
|
||||
}
|
||||
val entity = mList[position]
|
||||
ImageUtils.display(subjectCollectionImage, entity.image)
|
||||
|
||||
@ -41,7 +41,7 @@ class ColumnCollectionDetailActivity : ListActivity<LinkEntity, ColumnCollection
|
||||
mListRv.addItemDecoration(GridSpacingItemDecoration(mListViewModel.rowCount(), 16F.dip2px(), false))
|
||||
} else {
|
||||
mListRv.setPadding(16F.dip2px(), 8F.dip2px(), 16F.dip2px(), 0)
|
||||
mListRv.addItemDecoration(GridSpacingItemDecoration(mListViewModel.rowCount(), 8F.dip2px(), false))
|
||||
mListRv.addItemDecoration(GridSpacingItemDecoration(mListViewModel.rowCount(), 12F.dip2px(), false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,6 +304,9 @@ public class WebFragment extends NormalFragment implements IScrollable {
|
||||
settings.setUseWideViewPort(true);
|
||||
settings.setLoadWithOverviewMode(true);
|
||||
settings.setDomStorageEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
settings.setMediaPlaybackRequiresUserGesture(false);
|
||||
}
|
||||
|
||||
// 自适应屏幕
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
|
||||
Reference in New Issue
Block a user