Skip to content

Commit

Permalink
1. addOnClickListener()
Browse files Browse the repository at this point in the history
  • Loading branch information
刘冰冰 committed Nov 10, 2018
1 parent 7d26a2d commit 75aa23f
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 37 deletions.
13 changes: 6 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>

<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,6 +40,7 @@ public abstract class BasePageActivity<DB extends ViewDataBinding, VM extends Ba
protected CompositeDisposable mCompositeDisposable = new CompositeDisposable();
protected RecyclerView mRecyclerView;
protected RefreshLayout mRefreshLayout;
protected ClassicsHeader mClassicsHeader;
protected AD mAdapter;
protected LoadService mLoadService;

Expand Down Expand Up @@ -89,11 +87,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() {
Expand Down Expand Up @@ -155,6 +150,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()));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,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;
Expand All @@ -39,6 +36,7 @@
public abstract class BasePageFragment<AD extends PagedListAdapter, T> extends BaseFragment {
protected RecyclerView mRecyclerView;
protected RefreshLayout mRefreshLayout;
protected ClassicsHeader mClassicsHeader;
protected AD mAdapter;
protected LoadService mLoadService;

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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()));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public abstract class BaseRecycleViewActivity<DB extends ViewDataBinding, VM ext
protected CompositeDisposable mCompositeDisposable = new CompositeDisposable();
protected RecyclerView mRecyclerView;
protected RefreshLayout mRefreshLayout;
protected ClassicsHeader mClassicsHeader;
protected AD mAdapter;
protected LoadService mLoadService;

Expand Down Expand Up @@ -89,8 +90,8 @@ public void onRefresh(@NonNull RefreshLayout refreshLayout) {
protected abstract void refresh(@NonNull RefreshLayout refreshLayout);

protected void initRefreshHeader() {
ClassicsHeader classicsHeader = (ClassicsHeader) mRefreshLayout.getRefreshHeader();
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() {
Expand Down Expand Up @@ -153,6 +154,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()));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import java.util.Date;
import java.util.List;

import androidx.annotation.NonNull;
Expand All @@ -43,6 +44,7 @@ public abstract class BaseRecycleViewFragment<DB extends ViewDataBinding, VM ext

protected RecyclerView mRecyclerView;
protected RefreshLayout mRefreshLayout;
protected ClassicsHeader mClassicsHeader;
protected AD mAdapter;
protected LoadService mLoadService;

Expand Down Expand Up @@ -102,8 +104,8 @@ public void onRefresh(@NonNull RefreshLayout refreshLayout) {
protected abstract void refresh(@NonNull RefreshLayout refreshLayout);

protected void initRefreshHeader() {
ClassicsHeader classicsHeader = (ClassicsHeader) mRefreshLayout.getRefreshHeader();
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() {
Expand Down Expand Up @@ -176,6 +178,7 @@ public void onChanged(List<T> list) {
public void onChanged(Status status) {
if (status != Status.LOADING) {
mRefreshLayout.finishRefresh(status == Status.SUCCESS);
mClassicsHeader.setLastUpdateTime(new Date(System.currentTimeMillis()));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import androidx.viewpager.widget.ViewPager;

/**
* 可以开启关闭是否滑动
*/
public class CustomViewPager extends ViewPager {
private boolean isCanScroll = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/**
* 动态时间格式化
*/

public class DynamicTimeFormat extends SimpleDateFormat {

private static Locale locale = Locale.CHINA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 75aa23f

Please sign in to comment.