Commit a663a955 by gao.chao

滑动置顶,加载更多,下拉刷新demo

parent 904f6c18
......@@ -8,6 +8,8 @@ android {
targetSdkVersion 28
versionCode 1
versionName "1.0"
// 2、启用Multidex
multiDexEnabled true
}
signingConfigs {
......@@ -57,4 +59,5 @@ dependencies {
api project(':fastDevelop')
api project(':web')
api project(':map')
implementation 'com.google.android.material:material:1.0.0'
}
......@@ -34,7 +34,7 @@
android:value="d78a6d571c700f3ad33f374d81fed6a2" />
<activity
android:name=".MainActivity"
android:name=".page.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -43,28 +43,29 @@
</intent-filter>
</activity>
<activity
android:name=".StartActivity"
android:name=".page.StartActivity"
android:theme="@style/AppThemeLaunch" />
<activity android:name=".ListLazyLoadingActivity2" />
<activity android:name=".ListLazyLoadingActivity" />
<activity android:name=".TestListLazyLoadingActivity" />
<activity android:name=".PlayerActivity" />
<activity android:name=".PlayerActivtiy2" />
<activity android:name=".FunctionActivity" />
<activity android:name=".OnMultiClickActivity" />
<activity android:name=".PermissionActivity" />
<activity android:name=".SmartRefreshLayoutActivity" />
<activity android:name=".LoadingPicturesActivity" />
<activity android:name=".BannerActivity" />
<activity android:name=".ViewActviity" />
<activity android:name=".QRActivity" />
<activity android:name=".TitleActivity" />
<activity android:name=".DownLoadAPKActivity" />
<activity android:name=".FragmentInteractiveActivity" />
<activity android:name=".FragmentInteractiveActivity2" />
<activity android:name=".PageActivity" />
<activity android:name=".MyScanActivity" />
<activity android:name=".page.SlidingRoofPlacementActivity" />
<activity android:name=".view.ListLazyLoadingActivity2" />
<activity android:name=".view.ListLazyLoadingActivity" />
<activity android:name=".view.TestListLazyLoadingActivity" />
<activity android:name=".function.PlayerActivity" />
<activity android:name=".function.PlayerActivtiy2" />
<activity android:name=".function.FunctionActivity" />
<activity android:name=".view.OnMultiClickActivity" />
<activity android:name=".function.PermissionActivity" />
<activity android:name=".view.SmartRefreshLayoutActivity" />
<activity android:name=".view.LoadingPicturesActivity" />
<activity android:name=".view.BannerActivity" />
<activity android:name=".view.ViewActviity" />
<activity android:name=".function.QRActivity" />
<activity android:name=".view.TitleActivity" />
<activity android:name=".function.DownLoadAPKActivity" />
<activity android:name=".page.FragmentInteractiveActivity" />
<activity android:name=".page.FragmentInteractiveActivity2" />
<activity android:name=".page.PageActivity" />
<activity android:name=".page.MyScanActivity" />
<activity android:name=".web.CallJavascriptActivity" />
<activity android:name=".web.JavascriptCallNativeActivity" />
<activity android:name=".web.WrokWithFlyioTestActivity" />
......
package com.mayi.demo;
package com.mayi.demo.function;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.bean.AppConfig;
import com.mayi.fastdevelop.commonpage.UpdateDownLoadAPKActvity;
......
package com.mayi.demo;
package com.mayi.demo.function;
import android.content.Intent;
import android.net.Uri;
......@@ -15,6 +15,9 @@ import com.gc.call.CallManage;
import com.gc.call.CallParticipationBean;
import com.gc.call.CallReturnBean;
import com.gc.call.CallReturnListener;
import com.mayi.demo.R;
import com.mayi.demo.page.FragmentInteractiveActivity;
import com.mayi.demo.page.FragmentInteractiveActivity2;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.bean.UserInfo;
import com.mayi.fastdevelop.comnon.Constant;
......
package com.mayi.demo;
package com.mayi.demo.function;
import android.os.Bundle;
import android.view.View;
......@@ -8,6 +8,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import com.alibaba.fastjson.JSON;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.PermissionUtil;
import com.mayi.fastdevelop.view.OnMultiClickListener;
......
package com.mayi.demo;
package com.mayi.demo.function;
import android.os.Bundle;
import android.view.View;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
......
package com.mayi.demo;
package com.mayi.demo.function;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.AppPlayerView;
......
package com.mayi.demo;
package com.mayi.demo.function;
import android.os.Bundle;
import android.view.View;
......@@ -9,6 +9,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.BitmapUtil;
import com.mayi.fastdevelop.util.QrUtil;
......
package com.mayi.demo;
package com.mayi.demo.page;
import android.os.Bundle;
import android.os.Handler;
......@@ -8,6 +8,8 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
import com.mayi.demo.MyFragment;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseFragment;
import com.mayi.fastdevelop.base.BaseFragmentActivity;
import com.mayi.fastdevelop.comnon.AppCallback;
......
package com.mayi.demo;
package com.mayi.demo.page;
import android.os.Bundle;
import android.os.Handler;
......@@ -8,6 +8,8 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import com.mayi.demo.MyFragment;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseFragment;
import com.mayi.fastdevelop.base.BaseFragmentActivity;
import com.mayi.fastdevelop.comnon.AppCallback;
......
package com.mayi.demo;
package com.mayi.demo.page;
import android.os.Bundle;
......@@ -10,6 +10,11 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mayi.demo.CutPicturesActivity;
import com.mayi.demo.function.FunctionActivity;
import com.mayi.demo.ItemBean;
import com.mayi.demo.R;
import com.mayi.demo.view.ViewActviity;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.DrawableUtils;
......
package com.mayi.demo;
package com.mayi.demo.page;
import com.mayi.fastdevelop.commonpage.zxing.BaseScanActivity;
......
package com.mayi.demo;
package com.mayi.demo.page;
import android.app.Activity;
import android.content.Intent;
......@@ -10,6 +10,7 @@ import androidx.annotation.Nullable;
import com.gc.call.CallConstant;
import com.gc.call.CallManage;
import com.gc.call.CallParticipationBean;
import com.mayi.demo.R;
import com.mayi.demo.web.MainActivity;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.comnon.Key;
......@@ -80,6 +81,12 @@ public class PageActivity extends BaseActivity {
CallManage.getInstance().handleTarget(bean);
}
});
findViewById(R.id.b8).setOnClickListener(new OnMultiClickListener() {
@Override
public void onMultiClick(View v) {
gotoActivity(SlidingRoofPlacementActivity.class);
}
});
}
@Override
......
package com.mayi.demo.page;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
//滑动置顶,加载更多,下拉刷新
public class SlidingRoofPlacementActivity extends BaseActivity {
private CoordinatorLayout coordinatorLayout;
private AppBarLayout appBarLayout;
private Handler handler;
private int size = 100;
private LinearLayoutManager manager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slidingroofplacement);
RecyclerView rvlist = findViewById(R.id.rv_list);
coordinatorLayout = findViewById(R.id.scrollView);
appBarLayout = findViewById(R.id.appBarLayout);
manager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
rvlist.setLayoutManager(manager);
rvlist.setAdapter(new RecyclerView.Adapter() {
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new RecyclerView.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_slidingroofplacement
, parent, false)) {
};
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
// Log.i("coordinatorLayout", " Adapter position=" + position);
((TextView) holder.itemView).setText("" + position);
}
@Override
public int getItemCount() {
return size;
}
});
handler = new Handler();
final SmartRefreshLayout layout = findViewById(R.id.layout);
layout.setEnableRefresh(true);
layout.setEnableLoadmore(false);
layout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
size = 100;
rvlist.getAdapter().notifyDataSetChanged();
layout.finishRefresh();//完成刷新
}
}, 1000);
}
});
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (rvlist.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
if (manager.findLastVisibleItemPosition() + 10 > size) {
Log.i("coordinatorLayout", " notifyDataSetChanged size=" + size);
size = size + 10;
rvlist.getAdapter().notifyDataSetChanged();
}
}
handler.postDelayed(this, 1000);
}
}, 1000);
}
}
package com.mayi.demo;
package com.mayi.demo.page;
import com.mayi.demo.view.ViewActviity;
import com.mayi.fastdevelop.commonpage.BaseStartActivity;
public class StartActivity extends BaseStartActivity<ViewActviity,ViewActviity,ViewActviity>{
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.PicassoImageLoader;
import com.youth.banner.Banner;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.os.Handler;
import com.mayi.demo.MyListLazyLoadingAdapter;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.lazyLoading.ListLazyLoadingView;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.os.Handler;
import com.mayi.demo.MyListLazyLoadingAdapter;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.lazyLoading.ListLazyLoadingView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.os.Environment;
......@@ -6,6 +6,7 @@ import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.LoadingPictures;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.view.View;
......@@ -6,6 +6,7 @@ import android.widget.Button;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.OnMultiClickListener;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.os.Handler;
......@@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
public class TestListLazyLoadingActivity extends BaseActivity {
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.ToastUtil;
import com.mayi.fastdevelop.view.CustomTitleBar;
......
package com.mayi.demo;
package com.mayi.demo.view;
import android.os.Bundle;
import android.os.Handler;
......@@ -6,6 +6,7 @@ import android.view.View;
import androidx.annotation.Nullable;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.DialogUtils;
import com.mayi.fastdevelop.util.ToastUtil;
......@@ -37,7 +38,6 @@ public class ViewActviity extends BaseActivity {
}).show();
}
});
findViewById(R.id.b2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -72,7 +72,6 @@ public class ViewActviity extends BaseActivity {
}).show();
}
});
findViewById(R.id.b5).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -89,7 +88,6 @@ public class ViewActviity extends BaseActivity {
});
}
});
findViewById(R.id.b6).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -106,7 +104,6 @@ public class ViewActviity extends BaseActivity {
});
}
});
findViewById(R.id.b7).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -118,7 +115,6 @@ public class ViewActviity extends BaseActivity {
});
}
});
findViewById(R.id.b8).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -130,14 +126,12 @@ public class ViewActviity extends BaseActivity {
});
}
});
findViewById(R.id.b9).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoActivity(TitleActivity.class);
}
});
findViewById(R.id.b10).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -150,7 +144,6 @@ public class ViewActviity extends BaseActivity {
gotoActivity(LoadingPicturesActivity.class);
}
});
findViewById(R.id.b12).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -163,14 +156,12 @@ public class ViewActviity extends BaseActivity {
gotoActivity(OnMultiClickActivity.class);
}
});
findViewById(R.id.b14).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoActivity(TestListLazyLoadingActivity.class);
}
});
findViewById(R.id.b15).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......
......@@ -4,5 +4,5 @@
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" />
tools:context=".page.MainActivity" />
......@@ -57,6 +57,12 @@
android:layout_height="wrap_content"
android:text="搜索地址页" />
<Button
android:id="@+id/b8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="滑动置顶,加载更多,下拉刷新" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 第一部分:CoordinatorLayout -->
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<!-- 第二部分:缩放控件AppBarLayout -->
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/collapsing_tool_bar_test_ctl"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<!-- layout_scrollFlags="scroll" 所有想滚动出屏幕的view都需要设置这个flag, 没有设置这个flag的view将被固定在屏幕顶部。-->
<RelativeLayout
android:id="@+id/userScroreRe"
android:layout_width="match_parent"
android:layout_height="240dp"
android:background="#f00">
</RelativeLayout>
</RelativeLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="@color/color_666666"
android:orientation="horizontal"
android:text="留在屏幕"
android:textColor="@color/white" />
<!-- 没有设置的则会停留在顶部 -->
</com.google.android.material.appbar.AppBarLayout>
<!-- 第三部分:Your Scroll View-->
<!-- 一开始不明白为什么一定要使用NestedScrollView为什么不用你管ScrollView -->
<!-- 简单的说,它是专门用于和CoordinatorLayout搭配的达成滑动 -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1"
android:textColor="@color/black" />
\ No newline at end of file
......@@ -47,6 +47,6 @@ dependencies {
// api project(':call')
api 'com.gc:call:1.0.0'
api 'com.google.android.exoplayer:exoplayer:2.10.5'
api 'androidx.multidex:multidex:2.0.0'
api 'com.tencent:mmkv:1.0.23'
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import androidx.multidex.MultiDexApplication;
import com.mayi.fastdevelop.util.ActivitysManager;
import com.mayi.fastdevelop.util.DateUtil;
import com.mayi.fastdevelop.util.FileUtil;
......@@ -33,7 +35,7 @@ import com.tencent.mmkv.MMKV;
import java.text.SimpleDateFormat;
import java.util.Date;
public abstract class BaseApplication extends Application {
public abstract class BaseApplication extends MultiDexApplication {
private static BaseApplication mInstance;
private int logSize = 5 * 1024 * 1024;//默认记录Log文件大小--5M
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment