diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index baad14b..e56bb21 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,12 +1,11 @@ - + - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 11b887a..dfa769f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { @@ -8,9 +7,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.4.0-alpha02' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files } } diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/base/page/BasePageActivity.java b/mvvmbase/src/main/java/com/bing/mvvmbase/base/page/BasePageActivity.java index 4509092..9ca7a24 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/base/page/BasePageActivity.java +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/base/page/BasePageActivity.java @@ -18,10 +18,7 @@ import com.scwang.smartrefresh.layout.header.ClassicsHeader; import com.scwang.smartrefresh.layout.listener.OnRefreshListener; -import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Locale; -import java.util.Random; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -43,6 +40,7 @@ public abstract class BasePageActivity extends BaseFragment { protected RecyclerView mRecyclerView; protected RefreshLayout mRefreshLayout; + protected ClassicsHeader mClassicsHeader; protected AD mAdapter; protected LoadService mLoadService; @@ -79,11 +77,8 @@ public void onRefresh(@NonNull RefreshLayout refreshLayout) { protected abstract void refresh(@NonNull RefreshLayout refreshLayout); protected void initRefreshHeader() { - int delta = new Random().nextInt(7 * 24 * 60 * 60 * 1000); - ClassicsHeader classicsHeader = (ClassicsHeader) mRefreshLayout.getRefreshHeader(); - classicsHeader.setLastUpdateTime(new Date(System.currentTimeMillis() - delta)); - classicsHeader.setTimeFormat(new SimpleDateFormat(getString(R.string.refresh_at) + " MM-dd HH:mm", Locale.getDefault())); - classicsHeader.setTimeFormat(new DynamicTimeFormat(getString(R.string.refresh_at) + " %s")); + mClassicsHeader = (ClassicsHeader) mRefreshLayout.getRefreshHeader(); + mClassicsHeader.setTimeFormat(new DynamicTimeFormat(getString(R.string.refresh_at) + " %s")); } protected void initRecycleView() { @@ -151,6 +146,7 @@ public void onChanged(@Nullable Status status) { public void onChanged(Status status) { if (status != Status.LOADING) { mRefreshLayout.finishRefresh(status == Status.SUCCESS); + mClassicsHeader.setLastUpdateTime(new Date(System.currentTimeMillis())); } } }); diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.java b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.java index f3e2159..dc65c89 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.java +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.java @@ -43,6 +43,7 @@ public abstract class BaseRecycleViewActivity list) { public void onChanged(Status status) { if (status != Status.LOADING) { mRefreshLayout.finishRefresh(status == Status.SUCCESS); + mClassicsHeader.setLastUpdateTime(new Date(System.currentTimeMillis())); } } }); diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/base/widget/CustomViewPager.java b/mvvmbase/src/main/java/com/bing/mvvmbase/base/widget/CustomViewPager.java index fe73e43..7ead568 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/base/widget/CustomViewPager.java +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/base/widget/CustomViewPager.java @@ -6,6 +6,9 @@ import androidx.viewpager.widget.ViewPager; +/** + * 可以开启关闭是否滑动 + */ public class CustomViewPager extends ViewPager { private boolean isCanScroll = false; diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/bindingadapter/BindingAdapters.java b/mvvmbase/src/main/java/com/bing/mvvmbase/bindingadapter/BindingAdapters.java index 65bec30..a98f333 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/bindingadapter/BindingAdapters.java +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/bindingadapter/BindingAdapters.java @@ -4,7 +4,6 @@ import android.widget.ImageView; import com.bing.mvvmbase.module.glide.GlideApp; -import com.bumptech.glide.load.engine.DiskCacheStrategy; import androidx.databinding.BindingAdapter; @@ -16,6 +15,6 @@ public static void showHide(View view, boolean show) { @BindingAdapter("img_url") public static void showImg(ImageView iv, String url) { - GlideApp.with(iv.getContext()).load(url).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(iv); + GlideApp.with(iv.getContext()).load(url).into(iv); } } diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/utils/DynamicTimeFormat.java b/mvvmbase/src/main/java/com/bing/mvvmbase/utils/DynamicTimeFormat.java index 2aefe4e..384c9dd 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/utils/DynamicTimeFormat.java +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/utils/DynamicTimeFormat.java @@ -11,7 +11,6 @@ /** * 动态时间格式化 */ - public class DynamicTimeFormat extends SimpleDateFormat { private static Locale locale = Locale.CHINA; diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/widget/ScaleScrollView.java b/mvvmbase/src/main/java/com/bing/mvvmbase/widget/ScaleNestedScrollView.java similarity index 92% rename from mvvmbase/src/main/java/com/bing/mvvmbase/widget/ScaleScrollView.java rename to mvvmbase/src/main/java/com/bing/mvvmbase/widget/ScaleNestedScrollView.java index e13a6cf..14f12e8 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/widget/ScaleScrollView.java +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/widget/ScaleNestedScrollView.java @@ -4,12 +4,12 @@ import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; -import android.widget.ScrollView; import androidx.core.view.ViewCompat; +import androidx.core.widget.NestedScrollView; -public class ScaleScrollView extends ScrollView { - public ScaleScrollView(Context context, AttributeSet attrs) { +public class ScaleNestedScrollView extends NestedScrollView { + public ScaleNestedScrollView(Context context, AttributeSet attrs) { super(context, attrs); }