├── .DS_Store ├── LockTableViewProject ├── .gitignore ├── .idea │ ├── caches │ │ └── build_file_checksums.ser │ ├── codeStyles │ │ └── Project.xml │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── rmondjone │ │ │ └── locktableviewproject │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── rmondjone │ │ │ │ └── locktableviewproject │ │ │ │ └── MainActivity.java │ │ └── res │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ ├── colors.xml │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── rmondjone │ │ └── locktableviewproject │ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── locktableview │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── rmondjone │ │ │ └── locktableview │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── rmondjone │ │ │ │ ├── locktableview │ │ │ │ ├── CustomHorizontalScrollView.java │ │ │ │ ├── DisplayUtil.java │ │ │ │ ├── LockColumnAdapter.java │ │ │ │ ├── LockTableView.java │ │ │ │ ├── TableViewAdapter.java │ │ │ │ └── UnLockColumnAdapter.java │ │ │ │ └── xrecyclerview │ │ │ │ ├── AppBarStateChangeListener.java │ │ │ │ ├── ArrowRefreshHeader.java │ │ │ │ ├── BaseRefreshHeader.java │ │ │ │ ├── ItemTouchHelperAdapter.java │ │ │ │ ├── JellyView.java │ │ │ │ ├── LoadingMoreFooter.java │ │ │ │ ├── ProgressStyle.java │ │ │ │ ├── SimpleItemTouchHelperCallback.java │ │ │ │ ├── SimpleViewSwitcher.java │ │ │ │ ├── XRecyclerView.java │ │ │ │ └── progressindicator │ │ │ │ ├── AVLoadingIndicatorView.java │ │ │ │ └── indicator │ │ │ │ ├── BallBeatIndicator.java │ │ │ │ ├── BallClipRotateIndicator.java │ │ │ │ ├── BallClipRotateMultipleIndicator.java │ │ │ │ ├── BallClipRotatePulseIndicator.java │ │ │ │ ├── BallGridBeatIndicator.java │ │ │ │ ├── BallGridPulseIndicator.java │ │ │ │ ├── BallPulseIndicator.java │ │ │ │ ├── BallPulseRiseIndicator.java │ │ │ │ ├── BallPulseSyncIndicator.java │ │ │ │ ├── BallRotateIndicator.java │ │ │ │ ├── BallScaleIndicator.java │ │ │ │ ├── BallScaleMultipleIndicator.java │ │ │ │ ├── BallScaleRippleIndicator.java │ │ │ │ ├── BallScaleRippleMultipleIndicator.java │ │ │ │ ├── BallSpinFadeLoaderIndicator.java │ │ │ │ ├── BallTrianglePathIndicator.java │ │ │ │ ├── BallZigZagDeflectIndicator.java │ │ │ │ ├── BallZigZagIndicator.java │ │ │ │ ├── BaseIndicatorController.java │ │ │ │ ├── CubeTransitionIndicator.java │ │ │ │ ├── LineScaleIndicator.java │ │ │ │ ├── LineScalePartyIndicator.java │ │ │ │ ├── LineScalePulseOutIndicator.java │ │ │ │ ├── LineScalePulseOutRapidIndicator.java │ │ │ │ ├── LineSpinFadeLoaderIndicator.java │ │ │ │ ├── PacmanIndicator.java │ │ │ │ ├── SemiCircleSpinIndicator.java │ │ │ │ ├── SquareSpinIndicator.java │ │ │ │ └── TriangleSkewSpinIndicator.java │ │ └── res │ │ │ ├── drawable │ │ │ ├── ic_loading_rotate.png │ │ │ ├── ic_pulltorefresh_arrow.png │ │ │ ├── iconfont_downgrey.png │ │ │ ├── loading_01.png │ │ │ ├── loading_02.png │ │ │ ├── loading_03.png │ │ │ ├── loading_04.png │ │ │ ├── loading_05.png │ │ │ ├── loading_06.png │ │ │ ├── loading_07.png │ │ │ ├── loading_08.png │ │ │ ├── loading_09.png │ │ │ ├── loading_10.png │ │ │ ├── loading_11.png │ │ │ ├── loading_12.png │ │ │ ├── progressbar.xml │ │ │ └── progressloading.xml │ │ │ ├── layout │ │ │ ├── listview_footer.xml │ │ │ ├── listview_header.xml │ │ │ ├── lock_item.xml │ │ │ ├── locktablecontentview.xml │ │ │ ├── locktableview.xml │ │ │ ├── pull_to_refresh_head.xml │ │ │ └── unlock_item.xml │ │ │ ├── values-zh │ │ │ └── strings.xml │ │ │ └── values │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── rmondjone │ │ └── locktableview │ │ └── ExampleUnitTest.java └── settings.gradle ├── README.md └── show.gif /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/.DS_Store -------------------------------------------------------------------------------- /LockTableViewProject/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /LockTableViewProject/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Class structureJava 36 | 37 | 38 | Code maturity issuesJava 39 | 40 | 41 | Java 42 | 43 | 44 | Java language level migration aidsJava 45 | 46 | 47 | Javadoc issuesJava 48 | 49 | 50 | Performance issuesJava 51 | 52 | 53 | TestNGJava 54 | 55 | 56 | Threading issuesJava 57 | 58 | 59 | 60 | 61 | Android 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 73 | 74 | 75 | 76 | 77 | Android API 23 Platform 78 | 79 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /LockTableViewProject/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LockTableViewProject/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /LockTableViewProject/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | defaultConfig { 7 | multiDexEnabled true //dex优化 8 | applicationId "com.rmondjone.locktableviewproject" 9 | minSdkVersion 19 10 | targetSdkVersion 25 11 | versionCode 12 12 | versionName "1.1.2" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | dexOptions { 16 | javaMaxHeapSize "4g" //修改堆栈内存大小 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | repositories { 27 | maven { 28 | url "https://jitpack.io" 29 | } 30 | } 31 | 32 | dependencies { 33 | compile fileTree(include: ['*.jar'], dir: 'libs') 34 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 35 | exclude group: 'com.android.support', module: 'support-annotations' 36 | }) 37 | compile 'com.android.support:appcompat-v7:25.0.0' 38 | testCompile 'junit:junit:4.12' 39 | // compile project(':locktableview') 40 | compile 'com.github.RmondJone:LockTableView:1.1.2' 41 | } 42 | -------------------------------------------------------------------------------- /LockTableViewProject/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ghl/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/androidTest/java/com/rmondjone/locktableviewproject/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableviewproject; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.rmondjone.locktableviewproject", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/java/com/rmondjone/locktableviewproject/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableviewproject; 2 | 3 | import android.os.Handler; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.DisplayMetrics; 8 | import android.util.Log; 9 | import android.view.View; 10 | import android.widget.HorizontalScrollView; 11 | import android.widget.LinearLayout; 12 | import android.widget.Toast; 13 | 14 | import com.rmondjone.locktableview.DisplayUtil; 15 | import com.rmondjone.locktableview.LockTableView; 16 | import com.rmondjone.xrecyclerview.ProgressStyle; 17 | import com.rmondjone.xrecyclerview.XRecyclerView; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | public class MainActivity extends AppCompatActivity { 23 | 24 | private LinearLayout mContentView; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | mContentView = (LinearLayout) findViewById(R.id.contentView); 31 | initDisplayOpinion(); 32 | 33 | //构造假数据 34 | ArrayList> mTableDatas = new ArrayList>(); 35 | ArrayList mfristData = new ArrayList(); 36 | mfristData.add("标题"); 37 | for (int i = 0; i < 10; i++) { 38 | mfristData.add("标题" + i); 39 | } 40 | mTableDatas.add(mfristData); 41 | for (int i = 0; i < 20; i++) { 42 | ArrayList mRowDatas = new ArrayList(); 43 | mRowDatas.add("标题" + i); 44 | for (int j = 0; j < 10; j++) { 45 | mRowDatas.add("数据" + j); 46 | } 47 | mTableDatas.add(mRowDatas); 48 | } 49 | final LockTableView mLockTableView = new LockTableView(this, mContentView, mTableDatas); 50 | Log.e("表格加载开始", "当前线程:" + Thread.currentThread()); 51 | mLockTableView.setLockFristColumn(true) //是否锁定第一列 52 | .setLockFristRow(true) //是否锁定第一行 53 | .setMaxColumnWidth(100) //列最大宽度 54 | .setMinColumnWidth(60) //列最小宽度 55 | .setColumnWidth(1,30) //设置指定列文本宽度 56 | .setColumnWidth(2,20) 57 | .setMinRowHeight(20)//行最小高度 58 | .setMaxRowHeight(60)//行最大高度 59 | .setTextViewSize(16) //单元格字体大小 60 | .setFristRowBackGroudColor(R.color.table_head)//表头背景色 61 | .setTableHeadTextColor(R.color.beijin)//表头字体颜色 62 | .setTableContentTextColor(R.color.border_color)//单元格字体颜色 63 | .setCellPadding(15)//设置单元格内边距(dp) 64 | .setNullableString("N/A") //空值替换值 65 | .setTableViewListener(new LockTableView.OnTableViewListener() { 66 | @Override 67 | public void onTableViewScrollChange(int x, int y) { 68 | // Log.e("滚动值","["+x+"]"+"["+y+"]"); 69 | } 70 | })//设置横向滚动回调监听 71 | .setTableViewRangeListener(new LockTableView.OnTableViewRangeListener() { 72 | @Override 73 | public void onLeft(HorizontalScrollView view) { 74 | Log.e("滚动边界","滚动到最左边"); 75 | } 76 | 77 | @Override 78 | public void onRight(HorizontalScrollView view) { 79 | Log.e("滚动边界","滚动到最右边"); 80 | } 81 | })//设置横向滚动边界监听 82 | .setOnLoadingListener(new LockTableView.OnLoadingListener() { 83 | @Override 84 | public void onRefresh(final XRecyclerView mXRecyclerView, final ArrayList> mTableDatas) { 85 | Log.e("onRefresh",Thread.currentThread().toString()); 86 | Handler handler = new Handler(); 87 | handler.postDelayed(new Runnable() { 88 | @Override 89 | public void run() { 90 | // Log.e("现有表格数据", mTableDatas.toString()); 91 | //构造假数据 92 | ArrayList> mTableDatas = new ArrayList>(); 93 | ArrayList mfristData = new ArrayList(); 94 | mfristData.add("标题"); 95 | for (int i = 0; i < 10; i++) { 96 | mfristData.add("标题" + i); 97 | } 98 | mTableDatas.add(mfristData); 99 | for (int i = 0; i < 20; i++) { 100 | ArrayList mRowDatas = new ArrayList(); 101 | mRowDatas.add("标题" + i); 102 | for (int j = 0; j < 10; j++) { 103 | mRowDatas.add("数据" + j); 104 | } 105 | mTableDatas.add(mRowDatas); 106 | } 107 | mLockTableView.setTableDatas(mTableDatas); 108 | mXRecyclerView.refreshComplete(); 109 | } 110 | }, 1000); 111 | } 112 | 113 | @Override 114 | public void onLoadMore(final XRecyclerView mXRecyclerView, final ArrayList> mTableDatas) { 115 | Log.e("onLoadMore",Thread.currentThread().toString()); 116 | Handler handler = new Handler(); 117 | handler.postDelayed(new Runnable() { 118 | @Override 119 | public void run() { 120 | if (mTableDatas.size() <= 60) { 121 | for (int i = 0; i < 10; i++) { 122 | ArrayList mRowDatas = new ArrayList(); 123 | mRowDatas.add("标题" + (mTableDatas.size() - 1)); 124 | for (int j = 0; j < 10; j++) { 125 | mRowDatas.add("数据" + j); 126 | } 127 | mTableDatas.add(mRowDatas); 128 | } 129 | mLockTableView.setTableDatas(mTableDatas); 130 | } else { 131 | mXRecyclerView.setNoMore(true); 132 | } 133 | mXRecyclerView.loadMoreComplete(); 134 | } 135 | }, 1000); 136 | } 137 | }) 138 | .setOnItemClickListenter(new LockTableView.OnItemClickListenter() { 139 | @Override 140 | public void onItemClick(View item, int position) { 141 | Log.e("点击事件",position+""); 142 | } 143 | }) 144 | .setOnItemLongClickListenter(new LockTableView.OnItemLongClickListenter() { 145 | @Override 146 | public void onItemLongClick(View item, int position) { 147 | Log.e("长按事件",position+""); 148 | } 149 | }) 150 | .setOnItemSeletor(R.color.dashline_color)//设置Item被选中颜色 151 | .show(); //显示表格,此方法必须调用 152 | mLockTableView.getTableScrollView().setPullRefreshEnabled(true); 153 | mLockTableView.getTableScrollView().setLoadingMoreEnabled(true); 154 | mLockTableView.getTableScrollView().setRefreshProgressStyle(ProgressStyle.SquareSpin); 155 | //属性值获取 156 | Log.e("每列最大宽度(dp)", mLockTableView.getColumnMaxWidths().toString()); 157 | Log.e("每行最大高度(dp)", mLockTableView.getRowMaxHeights().toString()); 158 | Log.e("表格所有的滚动视图", mLockTableView.getScrollViews().toString()); 159 | Log.e("表格头部固定视图(锁列)", mLockTableView.getLockHeadView().toString()); 160 | Log.e("表格头部固定视图(不锁列)", mLockTableView.getUnLockHeadView().toString()); 161 | } 162 | 163 | private void initDisplayOpinion() { 164 | DisplayMetrics dm = getResources().getDisplayMetrics(); 165 | DisplayUtil.density = dm.density; 166 | DisplayUtil.densityDPI = dm.densityDpi; 167 | DisplayUtil.screenWidthPx = dm.widthPixels; 168 | DisplayUtil.screenhightPx = dm.heightPixels; 169 | DisplayUtil.screenWidthDip = DisplayUtil.px2dip(getApplicationContext(), dm.widthPixels); 170 | DisplayUtil.screenHightDip = DisplayUtil.px2dip(getApplicationContext(), dm.heightPixels); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/values-w820dp/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #00000000 6 | #334E6C 7 | #E5EFFE 8 | #FF000000 9 | #FFFFFFFF 10 | #e6e6e6 11 | #fafafa 12 | #555555 13 | #FF0033 14 | #ADD8E6 15 | #817F80 16 | #0000ff 17 | #00000000 18 | #0F0 19 | #FF0000 20 | #DDDDDD 21 | #b8b8b8 22 | #0cb9f5 23 | #2c8fd3 24 | #ffa500 25 | #000000 26 | #e3eef4 27 | #b1dce2ff 28 | #faedda 29 | #ff6bd697 30 | #c0c0c0 31 | #FFf3feff 32 | #FFfff1f2 33 | #603b07 34 | #00000000 35 | #31abfe 36 | #76c120 37 | #ffffffff 38 | #EE4000 39 | #fff2f9ec 40 | #EDEDE4 41 | #E8E8E8 42 | #ff434343 43 | #FAFAFA 44 | #3C70A6 45 | #C3C4C9 46 | #262B31 47 | #CED7DF 48 | #7B7B7B 49 | #949494 50 | #1989E0 51 | #CFEDF9 52 | #FFFFFF 53 | #F7F8F9 54 | #C2C0C2 55 | 56 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LockTableViewProject 3 | 4 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LockTableViewProject/app/src/test/java/com/rmondjone/locktableviewproject/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableviewproject; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /LockTableViewProject/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /LockTableViewProject/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /LockTableViewProject/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /LockTableViewProject/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /LockTableViewProject/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /LockTableViewProject/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group='com.github.RmondJone' 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.0" 7 | 8 | defaultConfig { 9 | minSdkVersion 11 10 | targetSdkVersion 25 11 | versionCode 12 12 | versionName "1.1.2" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | compile 'com.android.support:appcompat-v7:25.0.0' 31 | compile 'com.android.support:recyclerview-v7:25.0.0' 32 | compile 'com.android.support:design:25.0.0' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ghl/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/androidTest/java/com/rmondjone/locktableview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableview; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.rmondjone.locktableview.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/locktableview/CustomHorizontalScrollView.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableview; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.MotionEvent; 6 | import android.widget.HorizontalScrollView; 7 | 8 | /** 9 | * 说明 自定义水平滚动视图,解决ScrollView在API23以下没有滚动监听事件问题 10 | * 作者 郭翰林 11 | * 创建时间 2017/3/31. 12 | */ 13 | 14 | public class CustomHorizontalScrollView extends HorizontalScrollView { 15 | //触摸前的点 16 | private float x; 17 | 18 | //手势抬起之后的点 19 | private float x1; 20 | 21 | private onScrollChangeListener onScrollChangeListener; 22 | 23 | public CustomHorizontalScrollView(Context context) { 24 | super(context); 25 | } 26 | 27 | public CustomHorizontalScrollView(Context context, AttributeSet attrs) { 28 | super(context, attrs); 29 | } 30 | 31 | public CustomHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) { 32 | super(context, attrs, defStyleAttr); 33 | } 34 | 35 | public interface onScrollChangeListener { 36 | /** 37 | * 滚动监听 38 | * 39 | * @param scrollView 40 | * @param x 41 | * @param y 42 | */ 43 | void onScrollChanged(HorizontalScrollView scrollView, int x, int y); 44 | 45 | /** 46 | * 滑动到最左侧 47 | * 48 | * @param scrollView 49 | */ 50 | void onScrollFarLeft(HorizontalScrollView scrollView); 51 | 52 | /** 53 | * 滑动到最右侧 54 | * 55 | * @param scrollView 56 | */ 57 | void onScrollFarRight(HorizontalScrollView scrollView); 58 | } 59 | 60 | @Override 61 | public boolean onTouchEvent(MotionEvent ev) { 62 | switch (ev.getAction()) { 63 | case MotionEvent.ACTION_DOWN: 64 | x = ev.getX(); 65 | break; 66 | case MotionEvent.ACTION_UP: 67 | x1 = ev.getX(); 68 | if (computeHorizontalScrollOffset() == 0 && x-x1<0) { 69 | //滑动最左边 70 | if (onScrollChangeListener != null) { 71 | onScrollChangeListener.onScrollFarLeft(this); 72 | } 73 | } else if (computeHorizontalScrollRange() - computeHorizontalScrollOffset() 74 | <= computeHorizontalScrollExtent() && x-x1>0) { 75 | //滑动最右边 76 | if (onScrollChangeListener != null) { 77 | onScrollChangeListener.onScrollFarRight(this); 78 | } 79 | } 80 | break; 81 | default: 82 | break; 83 | } 84 | return super.onTouchEvent(ev); 85 | } 86 | 87 | /** 88 | * 设置监听 89 | * 90 | * @param onScrollChangeListener 91 | */ 92 | public void setOnScrollChangeListener(CustomHorizontalScrollView.onScrollChangeListener onScrollChangeListener) { 93 | this.onScrollChangeListener = onScrollChangeListener; 94 | } 95 | 96 | 97 | @Override 98 | protected void onScrollChanged(int l, int t, int oldl, int oldt) { 99 | super.onScrollChanged(l, t, oldl, oldt); 100 | //回调 101 | if (onScrollChangeListener != null) { 102 | onScrollChangeListener.onScrollChanged(this, l, t); 103 | } 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/locktableview/DisplayUtil.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableview; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by aaron on 16/8/3. 7 | */ 8 | public class DisplayUtil 9 | { 10 | 11 | public static int screenWidthPx; //屏幕宽 px 12 | public static int screenhightPx; //屏幕高 px 13 | public static float density;//屏幕密度 14 | public static int densityDPI;//屏幕密度 15 | public static float screenWidthDip;// dp单位 16 | public static float screenHightDip;// dp单位 17 | 18 | 19 | 20 | /** 21 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) 22 | */ 23 | public static int dip2px(Context context, float dpValue) { 24 | final float scale = context.getResources().getDisplayMetrics().density; 25 | return (int) (dpValue * scale + 0.5f); 26 | } 27 | 28 | /** 29 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp 30 | */ 31 | public static int px2dip(Context context, float pxValue) { 32 | final float scale = context.getResources().getDisplayMetrics().density; 33 | return (int) (pxValue / scale + 0.5f); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/locktableview/LockColumnAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.v4.content.ContextCompat; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.LinearLayout; 11 | import android.widget.NumberPicker; 12 | import android.widget.TextView; 13 | 14 | import java.util.ArrayList; 15 | 16 | /** 17 | * 说明 18 | * 作者 郭翰林 19 | * 创建时间 2017/9/17. 20 | */ 21 | 22 | public class LockColumnAdapter extends RecyclerView.Adapter { 23 | /** 24 | * 上下文 25 | */ 26 | private Context mContext; 27 | /** 28 | * 第一列数据 29 | */ 30 | private ArrayList mLockColumnDatas; 31 | /** 32 | * 第一行背景颜色 33 | */ 34 | private int mFristRowBackGroudColor; 35 | /** 36 | * 表格头部字体颜色 37 | */ 38 | private int mTableHeadTextColor; 39 | /** 40 | * 表格内容字体颜色 41 | */ 42 | private int mTableContentTextColor; 43 | /** 44 | * 是否锁定首行 45 | */ 46 | private boolean isLockFristRow = true; 47 | /** 48 | * 记录每列最大宽度 49 | */ 50 | private ArrayList mColumnMaxWidths = new ArrayList(); 51 | /** 52 | * 记录每行最大高度 53 | */ 54 | private ArrayList mRowMaxHeights = new ArrayList(); 55 | 56 | /** 57 | * 单元格字体大小 58 | */ 59 | private int mTextViewSize; 60 | /** 61 | * 单元格内边距 62 | */ 63 | private int mCellPadding; 64 | 65 | /** 66 | * Item点击事件 67 | */ 68 | private LockTableView.OnItemClickListenter mOnItemClickListenter; 69 | 70 | /** 71 | * Item长按事件 72 | */ 73 | private LockTableView.OnItemLongClickListenter mOnItemLongClickListenter; 74 | 75 | /** 76 | * Item项被选中监听(处理被选中的效果) 77 | */ 78 | private TableViewAdapter.OnItemSelectedListenter mOnItemSelectedListenter; 79 | 80 | 81 | public LockColumnAdapter(Context mContext, ArrayList mLockColumnDatas) { 82 | this.mContext = mContext; 83 | this.mLockColumnDatas = mLockColumnDatas; 84 | } 85 | 86 | 87 | @Override 88 | public LockViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 89 | LockViewHolder holder = new LockViewHolder(LayoutInflater.from(mContext).inflate(R.layout.lock_item, null)); 90 | return holder; 91 | } 92 | 93 | @Override 94 | public void onBindViewHolder(LockViewHolder holder, final int position) { 95 | //设置布局 96 | holder.mTextView.setText(mLockColumnDatas.get(position)); 97 | holder.mTextView.setTextSize(mTextViewSize); 98 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) holder.mTextView.getLayoutParams(); 99 | layoutParams.width = DisplayUtil.dip2px(mContext, mColumnMaxWidths.get(0)); 100 | if (isLockFristRow) { 101 | layoutParams.height = DisplayUtil.dip2px(mContext, mRowMaxHeights.get(position + 1)); 102 | } else { 103 | layoutParams.height = DisplayUtil.dip2px(mContext, mRowMaxHeights.get(position)); 104 | } 105 | layoutParams.setMargins(mCellPadding, mCellPadding, mCellPadding, mCellPadding); 106 | holder.mTextView.setLayoutParams(layoutParams); 107 | //设置颜色 108 | if (!isLockFristRow) { 109 | if (position == 0) { 110 | holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(mContext, mFristRowBackGroudColor)); 111 | holder.mTextView.setTextColor(ContextCompat.getColor(mContext, mTableHeadTextColor)); 112 | } else { 113 | holder.mTextView.setTextColor(ContextCompat.getColor(mContext, mTableContentTextColor)); 114 | } 115 | } else { 116 | holder.mTextView.setTextColor(ContextCompat.getColor(mContext, mTableContentTextColor)); 117 | } 118 | //添加事件 119 | if(mOnItemClickListenter!=null){ 120 | holder.mLinearLayout.setOnClickListener(new View.OnClickListener() { 121 | @Override 122 | public void onClick(View v) { 123 | if(mOnItemSelectedListenter!=null){ 124 | mOnItemSelectedListenter.onItemSelected(v,position); 125 | } 126 | if(isLockFristRow){ 127 | mOnItemClickListenter.onItemClick(v,position+1); 128 | }else{ 129 | if(position!=0){ 130 | mOnItemClickListenter.onItemClick(v,position); 131 | } 132 | } 133 | } 134 | }); 135 | } 136 | if(mOnItemLongClickListenter!=null){ 137 | holder.mLinearLayout.setOnLongClickListener(new View.OnLongClickListener() { 138 | @Override 139 | public boolean onLongClick(View v) { 140 | if(mOnItemSelectedListenter!=null){ 141 | mOnItemSelectedListenter.onItemSelected(v,position); 142 | } 143 | if (isLockFristRow){ 144 | mOnItemLongClickListenter.onItemLongClick(v,position+1); 145 | }else{ 146 | if(position!=0){ 147 | mOnItemLongClickListenter.onItemLongClick(v,position); 148 | } 149 | } 150 | return true; 151 | } 152 | }); 153 | } 154 | //如果没有设置点击事件和长按事件 155 | if(mOnItemClickListenter==null&&mOnItemLongClickListenter==null){ 156 | holder.mLinearLayout.setOnClickListener(new View.OnClickListener() { 157 | @Override 158 | public void onClick(View v) { 159 | if(mOnItemSelectedListenter!=null){ 160 | mOnItemSelectedListenter.onItemSelected(v,position); 161 | } 162 | } 163 | }); 164 | holder.mLinearLayout.setOnLongClickListener(new View.OnLongClickListener() { 165 | @Override 166 | public boolean onLongClick(View v) { 167 | if(mOnItemSelectedListenter!=null){ 168 | mOnItemSelectedListenter.onItemSelected(v,position); 169 | } 170 | return true; 171 | } 172 | }); 173 | } 174 | } 175 | 176 | @Override 177 | public int getItemCount() { 178 | return mLockColumnDatas.size(); 179 | } 180 | 181 | @Override 182 | public int getItemViewType(int position) { 183 | return position; 184 | } 185 | 186 | class LockViewHolder extends RecyclerView.ViewHolder { 187 | TextView mTextView; 188 | LinearLayout mLinearLayout; 189 | 190 | public LockViewHolder(View itemView) { 191 | super(itemView); 192 | mTextView = (TextView) itemView.findViewById(R.id.lock_text); 193 | mLinearLayout = (LinearLayout) itemView.findViewById(R.id.lock_linearlayout); 194 | } 195 | } 196 | 197 | 198 | //取得每行每列应用高宽 199 | public void setColumnMaxWidths(ArrayList mColumnMaxWidths) { 200 | this.mColumnMaxWidths = mColumnMaxWidths; 201 | } 202 | 203 | public void setRowMaxHeights(ArrayList mRowMaxHeights) { 204 | this.mRowMaxHeights = mRowMaxHeights; 205 | } 206 | 207 | public void setTextViewSize(int mTextViewSize) { 208 | this.mTextViewSize = mTextViewSize; 209 | } 210 | 211 | public void setLockFristRow(boolean lockFristRow) { 212 | isLockFristRow = lockFristRow; 213 | } 214 | 215 | public void setCellPadding(int mCellPadding) { 216 | this.mCellPadding = mCellPadding; 217 | } 218 | 219 | public void setFristRowBackGroudColor(int mFristRowBackGroudColor) { 220 | this.mFristRowBackGroudColor = mFristRowBackGroudColor; 221 | } 222 | 223 | public void setTableHeadTextColor(int mTableHeadTextColor) { 224 | this.mTableHeadTextColor = mTableHeadTextColor; 225 | } 226 | 227 | public void setTableContentTextColor(int mTableContentTextColor) { 228 | this.mTableContentTextColor = mTableContentTextColor; 229 | } 230 | 231 | public void setOnItemClickListenter(LockTableView.OnItemClickListenter mOnItemClickListenter) { 232 | this.mOnItemClickListenter = mOnItemClickListenter; 233 | } 234 | 235 | public void setOnItemLongClickListenter(LockTableView.OnItemLongClickListenter mOnItemLongClickListenter) { 236 | this.mOnItemLongClickListenter = mOnItemLongClickListenter; 237 | } 238 | 239 | public void setOnItemSelectedListenter(TableViewAdapter.OnItemSelectedListenter mOnItemSelectedListenter) { 240 | this.mOnItemSelectedListenter = mOnItemSelectedListenter; 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/locktableview/UnLockColumnAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.v4.content.ContextCompat; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.TypedValue; 8 | import android.view.Gravity; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.HorizontalScrollView; 13 | import android.widget.LinearLayout; 14 | import android.widget.TextView; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * 说明 21 | * 作者 郭翰林 22 | * 创建时间 2017/9/17. 23 | */ 24 | 25 | public class UnLockColumnAdapter extends RecyclerView.Adapter { 26 | /** 27 | * 上下文 28 | */ 29 | private Context mContext; 30 | /** 31 | * 表格数据 32 | */ 33 | private ArrayList> mTableDatas; 34 | /** 35 | * 第一行背景颜色 36 | */ 37 | private int mFristRowBackGroudColor; 38 | /** 39 | * 表格头部字体颜色 40 | */ 41 | private int mTableHeadTextColor; 42 | /** 43 | * 表格内容字体颜色 44 | */ 45 | private int mTableContentTextColor; 46 | /** 47 | * 记录每列最大宽度 48 | */ 49 | private ArrayList mColumnMaxWidths = new ArrayList(); 50 | /** 51 | * 记录每行最大高度 52 | */ 53 | private ArrayList mRowMaxHeights = new ArrayList(); 54 | /** 55 | * 单元格字体大小 56 | */ 57 | private int mTextViewSize; 58 | /** 59 | * 是否锁定首行 60 | */ 61 | private boolean isLockFristRow = true; 62 | /** 63 | * 是否锁定首列 64 | */ 65 | private boolean isLockFristColumn = true; 66 | 67 | /** 68 | * 单元格内边距 69 | */ 70 | private int mCellPadding; 71 | 72 | /** 73 | * Item点击事件 74 | */ 75 | private LockTableView.OnItemClickListenter mOnItemClickListenter; 76 | 77 | /** 78 | * Item长按事件 79 | */ 80 | private LockTableView.OnItemLongClickListenter mOnItemLongClickListenter; 81 | 82 | /** 83 | * Item项被选中监听(处理被选中的效果) 84 | */ 85 | private TableViewAdapter.OnItemSelectedListenter mOnItemSelectedListenter; 86 | 87 | /** 88 | * 构造方法 89 | * 90 | * @param mContext 91 | * @param mTableDatas 92 | */ 93 | public UnLockColumnAdapter(Context mContext, ArrayList> mTableDatas) { 94 | this.mContext = mContext; 95 | this.mTableDatas = mTableDatas; 96 | } 97 | 98 | 99 | @Override 100 | public int getItemCount() { 101 | return mTableDatas.size(); 102 | } 103 | 104 | @Override 105 | public UnLockViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 106 | UnLockViewHolder holder = new UnLockViewHolder(LayoutInflater.from(mContext).inflate(R.layout.unlock_item, null)); 107 | return holder; 108 | } 109 | 110 | @Override 111 | public void onBindViewHolder(UnLockViewHolder holder, final int position) { 112 | ArrayList datas = mTableDatas.get(position); 113 | if (isLockFristRow) { 114 | //第一行是锁定的 115 | createRowView(holder.mLinearLayout, datas, false, mRowMaxHeights.get(position + 1)); 116 | } else { 117 | if (position == 0) { 118 | holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(mContext, mFristRowBackGroudColor)); 119 | createRowView(holder.mLinearLayout, datas, true, mRowMaxHeights.get(position)); 120 | } else { 121 | createRowView(holder.mLinearLayout, datas, false, mRowMaxHeights.get(position)); 122 | } 123 | } 124 | //添加事件 125 | if(mOnItemClickListenter!=null){ 126 | holder.mLinearLayout.setOnClickListener(new View.OnClickListener() { 127 | @Override 128 | public void onClick(View v) { 129 | if(mOnItemSelectedListenter!=null){ 130 | mOnItemSelectedListenter.onItemSelected(v,position); 131 | } 132 | if(isLockFristRow){ 133 | mOnItemClickListenter.onItemClick(v,position+1); 134 | }else{ 135 | if(position!=0){ 136 | mOnItemClickListenter.onItemClick(v,position); 137 | } 138 | } 139 | } 140 | }); 141 | } 142 | if(mOnItemLongClickListenter!=null){ 143 | holder.mLinearLayout.setOnLongClickListener(new View.OnLongClickListener() { 144 | @Override 145 | public boolean onLongClick(View v) { 146 | if(mOnItemSelectedListenter!=null){ 147 | mOnItemSelectedListenter.onItemSelected(v,position); 148 | } 149 | if (isLockFristRow){ 150 | mOnItemLongClickListenter.onItemLongClick(v,position+1); 151 | }else{ 152 | if(position!=0){ 153 | mOnItemLongClickListenter.onItemLongClick(v,position); 154 | } 155 | } 156 | return true; 157 | } 158 | }); 159 | } 160 | //如果没有设置点击事件和长按事件 161 | if(mOnItemClickListenter==null&&mOnItemLongClickListenter==null){ 162 | holder.mLinearLayout.setOnClickListener(new View.OnClickListener() { 163 | @Override 164 | public void onClick(View v) { 165 | if(mOnItemSelectedListenter!=null){ 166 | mOnItemSelectedListenter.onItemSelected(v,position); 167 | } 168 | } 169 | }); 170 | holder.mLinearLayout.setOnLongClickListener(new View.OnLongClickListener() { 171 | @Override 172 | public boolean onLongClick(View v) { 173 | if(mOnItemSelectedListenter!=null){ 174 | mOnItemSelectedListenter.onItemSelected(v,position); 175 | } 176 | return true; 177 | } 178 | }); 179 | } 180 | } 181 | 182 | @Override 183 | public int getItemViewType(int position) { 184 | return position; 185 | } 186 | 187 | 188 | //取得每行每列应用高宽 189 | public void setColumnMaxWidths(ArrayList mColumnMaxWidths) { 190 | this.mColumnMaxWidths = mColumnMaxWidths; 191 | } 192 | 193 | public void setRowMaxHeights(ArrayList mRowMaxHeights) { 194 | this.mRowMaxHeights = mRowMaxHeights; 195 | } 196 | 197 | public void setTextViewSize(int mTextViewSize) { 198 | this.mTextViewSize = mTextViewSize; 199 | } 200 | 201 | public void setLockFristRow(boolean lockFristRow) { 202 | isLockFristRow = lockFristRow; 203 | } 204 | 205 | public void setFristRowBackGroudColor(int mFristRowBackGroudColor) { 206 | this.mFristRowBackGroudColor = mFristRowBackGroudColor; 207 | } 208 | 209 | public void setTableHeadTextColor(int mTableHeadTextColor) { 210 | this.mTableHeadTextColor = mTableHeadTextColor; 211 | } 212 | 213 | public void setTableContentTextColor(int mTableContentTextColor) { 214 | this.mTableContentTextColor = mTableContentTextColor; 215 | } 216 | 217 | public void setLockFristColumn(boolean lockFristColumn) { 218 | isLockFristColumn = lockFristColumn; 219 | } 220 | 221 | public void setOnItemClickListenter(LockTableView.OnItemClickListenter mOnItemClickListenter) { 222 | this.mOnItemClickListenter = mOnItemClickListenter; 223 | } 224 | 225 | public void setOnItemLongClickListenter(LockTableView.OnItemLongClickListenter mOnItemLongClickListenter) { 226 | this.mOnItemLongClickListenter = mOnItemLongClickListenter; 227 | } 228 | 229 | public void setOnItemSelectedListenter(TableViewAdapter.OnItemSelectedListenter mOnItemSelectedListenter) { 230 | this.mOnItemSelectedListenter = mOnItemSelectedListenter; 231 | } 232 | 233 | public void setCellPadding(int mCellPadding) { 234 | this.mCellPadding = mCellPadding; 235 | } 236 | 237 | class UnLockViewHolder extends RecyclerView.ViewHolder { 238 | LinearLayout mLinearLayout; 239 | 240 | public UnLockViewHolder(View itemView) { 241 | super(itemView); 242 | mLinearLayout = (LinearLayout) itemView.findViewById(R.id.unlock_linearlayout); 243 | } 244 | } 245 | 246 | /** 247 | * 构造每行数据视图 248 | * 249 | * @param linearLayout 250 | * @param datas 251 | * @param isFristRow 是否是第一行 252 | */ 253 | private void createRowView(LinearLayout linearLayout, List datas, boolean isFristRow, int mMaxHeight) { 254 | //设置LinearLayout 255 | linearLayout.removeAllViews();//首先清空LinearLayout,复用会造成重复绘制,使内容超出预期长度 256 | for (int i = 0; i < datas.size(); i++) { 257 | //构造单元格 258 | TextView textView = new TextView(mContext); 259 | if (isFristRow) { 260 | textView.setTextColor(ContextCompat.getColor(mContext, mTableHeadTextColor)); 261 | } else { 262 | textView.setTextColor(ContextCompat.getColor(mContext, mTableContentTextColor)); 263 | } 264 | textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextViewSize); 265 | textView.setGravity(Gravity.CENTER); 266 | textView.setText(datas.get(i)); 267 | //设置布局 268 | LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, 269 | LinearLayout.LayoutParams.WRAP_CONTENT); 270 | textViewParams.setMargins(mCellPadding, mCellPadding, mCellPadding, mCellPadding); 271 | textViewParams.height = DisplayUtil.dip2px(mContext, mMaxHeight); 272 | if (isLockFristColumn) { 273 | textViewParams.width = DisplayUtil.dip2px(mContext, mColumnMaxWidths.get(i+1)); 274 | } else { 275 | textViewParams.width = DisplayUtil.dip2px(mContext, mColumnMaxWidths.get(i)); 276 | } 277 | textView.setLayoutParams(textViewParams); 278 | linearLayout.addView(textView); 279 | //画分隔线 280 | if (i != datas.size() - 1) { 281 | View splitView = new View(mContext); 282 | ViewGroup.LayoutParams splitViewParmas = new ViewGroup.LayoutParams(DisplayUtil.dip2px(mContext, 1), 283 | ViewGroup.LayoutParams.MATCH_PARENT); 284 | splitView.setLayoutParams(splitViewParmas); 285 | if (isFristRow) { 286 | splitView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.white)); 287 | } else { 288 | splitView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.light_gray)); 289 | } 290 | linearLayout.addView(splitView); 291 | } 292 | } 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/AppBarStateChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | import android.support.design.widget.AppBarLayout; 4 | 5 | /** 6 | * Created by jianghejie on 16/6/19. 7 | */ 8 | 9 | public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { 10 | 11 | public enum State { 12 | EXPANDED, 13 | COLLAPSED, 14 | IDLE 15 | } 16 | 17 | private State mCurrentState = State.IDLE; 18 | 19 | @Override 20 | public final void onOffsetChanged(AppBarLayout appBarLayout, int i) { 21 | if (i == 0) { 22 | if (mCurrentState != State.EXPANDED) { 23 | onStateChanged(appBarLayout, State.EXPANDED); 24 | } 25 | mCurrentState = State.EXPANDED; 26 | } else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) { 27 | if (mCurrentState != State.COLLAPSED) { 28 | onStateChanged(appBarLayout, State.COLLAPSED); 29 | } 30 | mCurrentState = State.COLLAPSED; 31 | } else { 32 | if (mCurrentState != State.IDLE) { 33 | onStateChanged(appBarLayout, State.IDLE); 34 | } 35 | mCurrentState = State.IDLE; 36 | } 37 | } 38 | public abstract void onStateChanged(AppBarLayout appBarLayout, State state); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/ArrowRefreshHeader.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.content.Context; 5 | import android.os.Handler; 6 | import android.util.AttributeSet; 7 | import android.view.Gravity; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.view.animation.Animation; 12 | import android.view.animation.RotateAnimation; 13 | import android.widget.ImageView; 14 | import android.widget.LinearLayout; 15 | import android.widget.ProgressBar; 16 | import android.widget.TextView; 17 | 18 | import com.rmondjone.xrecyclerview.progressindicator.AVLoadingIndicatorView; 19 | import com.rmondjone.locktableview.R; 20 | 21 | import java.util.Date; 22 | 23 | public class ArrowRefreshHeader extends LinearLayout implements BaseRefreshHeader { 24 | 25 | private LinearLayout mContainer; 26 | private ImageView mArrowImageView; 27 | private SimpleViewSwitcher mProgressBar; 28 | private TextView mStatusTextView; 29 | private int mState = STATE_NORMAL; 30 | 31 | private TextView mHeaderTimeView; 32 | 33 | private Animation mRotateUpAnim; 34 | private Animation mRotateDownAnim; 35 | 36 | private static final int ROTATE_ANIM_DURATION = 180; 37 | 38 | public int mMeasuredHeight; 39 | 40 | public ArrowRefreshHeader(Context context) { 41 | super(context); 42 | initView(); 43 | } 44 | 45 | /** 46 | * @param context 47 | * @param attrs 48 | */ 49 | public ArrowRefreshHeader(Context context, AttributeSet attrs) { 50 | super(context, attrs); 51 | initView(); 52 | } 53 | 54 | private void initView() { 55 | // 初始情况,设置下拉刷新view高度为0 56 | mContainer = (LinearLayout) LayoutInflater.from(getContext()).inflate( 57 | R.layout.listview_header, null); 58 | LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 59 | lp.setMargins(0, 0, 0, 0); 60 | this.setLayoutParams(lp); 61 | this.setPadding(0, 0, 0, 0); 62 | 63 | addView(mContainer, new LayoutParams(LayoutParams.MATCH_PARENT, 0)); 64 | setGravity(Gravity.BOTTOM); 65 | 66 | mArrowImageView = (ImageView)findViewById(R.id.listview_header_arrow); 67 | mStatusTextView = (TextView)findViewById(R.id.refresh_status_textview); 68 | 69 | //init the progress view 70 | mProgressBar = (SimpleViewSwitcher)findViewById(R.id.listview_header_progressbar); 71 | AVLoadingIndicatorView progressView = new AVLoadingIndicatorView(getContext()); 72 | progressView.setIndicatorColor(0xffB5B5B5); 73 | progressView.setIndicatorId(ProgressStyle.BallSpinFadeLoader); 74 | mProgressBar.setView(progressView); 75 | 76 | 77 | mRotateUpAnim = new RotateAnimation(0.0f, -180.0f, 78 | Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 79 | mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); 80 | mRotateUpAnim.setFillAfter(true); 81 | mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f, 82 | Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 83 | mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); 84 | mRotateDownAnim.setFillAfter(true); 85 | 86 | mHeaderTimeView = (TextView)findViewById(R.id.last_refresh_time); 87 | measure(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); 88 | mMeasuredHeight = getMeasuredHeight(); 89 | } 90 | 91 | public void setProgressStyle(int style) { 92 | if(style == ProgressStyle.SysProgress){ 93 | mProgressBar.setView(new ProgressBar(getContext(), null, android.R.attr.progressBarStyle)); 94 | }else{ 95 | AVLoadingIndicatorView progressView = new AVLoadingIndicatorView(this.getContext()); 96 | progressView.setIndicatorColor(0xffB5B5B5); 97 | progressView.setIndicatorId(style); 98 | mProgressBar.setView(progressView); 99 | } 100 | } 101 | 102 | public void setArrowImageView(int resid){ 103 | mArrowImageView.setImageResource(resid); 104 | } 105 | 106 | public void setState(int state) { 107 | if (state == mState) return ; 108 | 109 | if (state == STATE_REFRESHING) { // 显示进度 110 | mArrowImageView.clearAnimation(); 111 | mArrowImageView.setVisibility(View.INVISIBLE); 112 | mProgressBar.setVisibility(View.VISIBLE); 113 | smoothScrollTo(mMeasuredHeight); 114 | } else if(state == STATE_DONE) { 115 | mArrowImageView.setVisibility(View.INVISIBLE); 116 | mProgressBar.setVisibility(View.INVISIBLE); 117 | } else { // 显示箭头图片 118 | mArrowImageView.setVisibility(View.VISIBLE); 119 | mProgressBar.setVisibility(View.INVISIBLE); 120 | } 121 | 122 | switch(state){ 123 | case STATE_NORMAL: 124 | if (mState == STATE_RELEASE_TO_REFRESH) { 125 | mArrowImageView.startAnimation(mRotateDownAnim); 126 | } 127 | if (mState == STATE_REFRESHING) { 128 | mArrowImageView.clearAnimation(); 129 | } 130 | mStatusTextView.setText(R.string.listview_header_hint_normal); 131 | break; 132 | case STATE_RELEASE_TO_REFRESH: 133 | if (mState != STATE_RELEASE_TO_REFRESH) { 134 | mArrowImageView.clearAnimation(); 135 | mArrowImageView.startAnimation(mRotateUpAnim); 136 | mStatusTextView.setText(R.string.listview_header_hint_release); 137 | } 138 | break; 139 | case STATE_REFRESHING: 140 | mStatusTextView.setText(R.string.refreshing); 141 | break; 142 | case STATE_DONE: 143 | mStatusTextView.setText(R.string.refresh_done); 144 | break; 145 | default: 146 | } 147 | 148 | mState = state; 149 | } 150 | 151 | public int getState() { 152 | return mState; 153 | } 154 | 155 | @Override 156 | public void refreshComplete(){ 157 | mHeaderTimeView.setText(friendlyTime(new Date())); 158 | setState(STATE_DONE); 159 | new Handler().postDelayed(new Runnable(){ 160 | public void run() { 161 | reset(); 162 | } 163 | }, 200); 164 | } 165 | 166 | public void setVisibleHeight(int height) { 167 | if (height < 0) height = 0; 168 | LayoutParams lp = (LayoutParams) mContainer .getLayoutParams(); 169 | lp.height = height; 170 | mContainer.setLayoutParams(lp); 171 | } 172 | 173 | public int getVisibleHeight() { 174 | LayoutParams lp = (LayoutParams) mContainer.getLayoutParams(); 175 | return lp.height; 176 | } 177 | 178 | @Override 179 | public void onMove(float delta) { 180 | if(getVisibleHeight() > 0 || delta > 0) { 181 | setVisibleHeight((int) delta + getVisibleHeight()); 182 | if (mState <= STATE_RELEASE_TO_REFRESH) { // 未处于刷新状态,更新箭头 183 | if (getVisibleHeight() > mMeasuredHeight) { 184 | setState(STATE_RELEASE_TO_REFRESH); 185 | }else { 186 | setState(STATE_NORMAL); 187 | } 188 | } 189 | } 190 | } 191 | 192 | @Override 193 | public boolean releaseAction() { 194 | boolean isOnRefresh = false; 195 | int height = getVisibleHeight(); 196 | if (height == 0) // not visible. 197 | isOnRefresh = false; 198 | 199 | if(getVisibleHeight() > mMeasuredHeight && mState < STATE_REFRESHING){ 200 | setState(STATE_REFRESHING); 201 | isOnRefresh = true; 202 | } 203 | // refreshing and header isn't shown fully. do nothing. 204 | if (mState == STATE_REFRESHING && height <= mMeasuredHeight) { 205 | // return false; 206 | } 207 | if (mState != STATE_REFRESHING) { 208 | smoothScrollTo(0); 209 | } 210 | 211 | if (mState == STATE_REFRESHING) { 212 | int destHeight = mMeasuredHeight; 213 | smoothScrollTo(destHeight); 214 | } 215 | 216 | return isOnRefresh; 217 | } 218 | 219 | public void reset() { 220 | smoothScrollTo(0); 221 | new Handler().postDelayed(new Runnable() { 222 | public void run() { 223 | setState(STATE_NORMAL); 224 | } 225 | }, 500); 226 | } 227 | 228 | private void smoothScrollTo(int destHeight) { 229 | ValueAnimator animator = ValueAnimator.ofInt(getVisibleHeight(), destHeight); 230 | animator.setDuration(300).start(); 231 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 232 | @Override 233 | public void onAnimationUpdate(ValueAnimator animation) 234 | { 235 | setVisibleHeight((int) animation.getAnimatedValue()); 236 | } 237 | }); 238 | animator.start(); 239 | } 240 | 241 | public static String friendlyTime(Date time) { 242 | //获取time距离当前的秒数 243 | int ct = (int)((System.currentTimeMillis() - time.getTime())/1000); 244 | 245 | if(ct == 0) { 246 | return "刚刚"; 247 | } 248 | 249 | if(ct > 0 && ct < 60) { 250 | return ct + "秒前"; 251 | } 252 | 253 | if(ct >= 60 && ct < 3600) { 254 | return Math.max(ct / 60,1) + "分钟前"; 255 | } 256 | if(ct >= 3600 && ct < 86400) 257 | return ct / 3600 + "小时前"; 258 | if(ct >= 86400 && ct < 2592000){ //86400 * 30 259 | int day = ct / 86400 ; 260 | return day + "天前"; 261 | } 262 | if(ct >= 2592000 && ct < 31104000) { //86400 * 30 263 | return ct / 2592000 + "月前"; 264 | } 265 | return ct / 31104000 + "年前"; 266 | } 267 | 268 | } 269 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/BaseRefreshHeader.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | /** 4 | * Created by jianghejie on 15/11/22. 5 | */ 6 | interface BaseRefreshHeader { 7 | 8 | int STATE_NORMAL = 0; 9 | int STATE_RELEASE_TO_REFRESH = 1; 10 | int STATE_REFRESHING = 2; 11 | int STATE_DONE = 3; 12 | 13 | void onMove(float delta); 14 | 15 | boolean releaseAction(); 16 | 17 | void refreshComplete(); 18 | 19 | } -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/ItemTouchHelperAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | /** 6 | * Created by jianghejie on 16/6/20. 7 | */ 8 | 9 | public interface ItemTouchHelperAdapter { 10 | 11 | /** 12 | * Called when an item has been dragged far enough to trigger a move. This is called every time 13 | * an item is shifted, and not at the end of a "drop" event.
14 | *
15 | * Implementations should call {@link RecyclerView.Adapter#notifyItemMoved(int, int)} after 16 | * adjusting the underlying data to reflect this move. 17 | * 18 | * @param fromPosition The start position of the moved item. 19 | * @param toPosition Then resolved position of the moved item. 20 | * 21 | * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) 22 | * @see RecyclerView.ViewHolder#getAdapterPosition() 23 | */ 24 | void onItemMove(int fromPosition, int toPosition); 25 | 26 | 27 | /** 28 | * Called when an item has been dismissed by a swipe.
29 | *
30 | * Implementations should call {@link RecyclerView.Adapter#notifyItemRemoved(int)} after 31 | * adjusting the underlying data to reflect this removal. 32 | * 33 | * @param position The position of the item dismissed. 34 | * 35 | * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) 36 | * @see RecyclerView.ViewHolder#getAdapterPosition() 37 | */ 38 | void onItemDismiss(int position); 39 | } 40 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/JellyView.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | /** 4 | * Created by jianghejie on 15/11/22. 5 | */ 6 | 7 | import android.annotation.TargetApi; 8 | import android.content.Context; 9 | import android.graphics.Canvas; 10 | import android.graphics.Paint; 11 | import android.graphics.Path; 12 | import android.os.Build; 13 | import android.util.AttributeSet; 14 | import android.util.Log; 15 | import android.view.View; 16 | 17 | 18 | public class JellyView extends View implements BaseRefreshHeader{ 19 | Path path; 20 | 21 | Paint paint; 22 | 23 | private int minimumHeight = 0; 24 | 25 | private int jellyHeight =0; 26 | 27 | public JellyView(Context context) { 28 | super(context); 29 | init(); 30 | } 31 | 32 | public JellyView(Context context, AttributeSet attrs) { 33 | super(context, attrs); 34 | init(); 35 | } 36 | 37 | public JellyView(Context context, AttributeSet attrs, int defStyleAttr) { 38 | super(context, attrs, defStyleAttr); 39 | init(); 40 | } 41 | 42 | @SuppressWarnings("unused") 43 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 44 | public JellyView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 45 | super(context, attrs, defStyleAttr, defStyleRes); 46 | init(); 47 | } 48 | 49 | private void init() { 50 | if (isInEditMode()) { 51 | return; 52 | } 53 | path = new Path(); 54 | paint = new Paint(); 55 | paint.setColor(getContext().getResources().getColor(android.R.color.holo_blue_bright)); 56 | paint.setAntiAlias(true); 57 | } 58 | 59 | public void setJellyColor(int jellyColor) { 60 | paint.setColor(jellyColor); 61 | } 62 | 63 | @Override 64 | protected void onDraw(Canvas canvas) { 65 | super.onDraw(canvas); 66 | path.reset(); 67 | path.lineTo(0, minimumHeight); 68 | path.quadTo(getMeasuredWidth() / 2, minimumHeight + jellyHeight, getMeasuredWidth(), minimumHeight); 69 | path.lineTo(getMeasuredWidth(), 0); 70 | canvas.drawPath(path, paint); 71 | } 72 | 73 | @Override 74 | public void setMinimumHeight(int minimumHeight) { 75 | this.minimumHeight = minimumHeight; 76 | } 77 | 78 | public void setJellyHeight(int ribbonHeight) { 79 | this.jellyHeight = ribbonHeight; 80 | } 81 | 82 | @Override 83 | public int getMinimumHeight() { 84 | return minimumHeight; 85 | } 86 | 87 | public int getJellyHeight() { 88 | return jellyHeight; 89 | } 90 | 91 | 92 | @Override 93 | public void refreshComplete(){ 94 | 95 | } 96 | 97 | @Override 98 | public void onMove(float delta) { 99 | jellyHeight = jellyHeight + (int)delta; 100 | Log.i("jellyHeight", "delta = " + delta); 101 | this.invalidate(); 102 | } 103 | 104 | @Override 105 | public boolean releaseAction() { 106 | return false; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/LoadingMoreFooter.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.AttributeSet; 6 | import android.view.Gravity; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.LinearLayout; 10 | import android.widget.ProgressBar; 11 | import android.widget.TextView; 12 | 13 | import com.rmondjone.xrecyclerview.progressindicator.AVLoadingIndicatorView; 14 | import com.rmondjone.locktableview.R; 15 | 16 | public class LoadingMoreFooter extends LinearLayout { 17 | 18 | private SimpleViewSwitcher progressCon; 19 | public final static int STATE_LOADING = 0; 20 | public final static int STATE_COMPLETE = 1; 21 | public final static int STATE_NOMORE = 2; 22 | private TextView mText; 23 | private String loadingHint; 24 | private String noMoreHint; 25 | private String loadingDoneHint; 26 | 27 | public LoadingMoreFooter(Context context) { 28 | super(context); 29 | initView(); 30 | } 31 | 32 | /** 33 | * @param context 34 | * @param attrs 35 | */ 36 | public LoadingMoreFooter(Context context, AttributeSet attrs) { 37 | super(context, attrs); 38 | initView(); 39 | } 40 | 41 | public void setLoadingHint(String hint) { 42 | loadingHint = hint; 43 | } 44 | 45 | public void setNoMoreHint(String hint) { 46 | noMoreHint = hint; 47 | } 48 | 49 | public void setLoadingDoneHint(String hint) { 50 | loadingDoneHint = hint; 51 | } 52 | 53 | public void initView(){ 54 | setGravity(Gravity.CENTER); 55 | setLayoutParams(new RecyclerView.LayoutParams( 56 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 57 | progressCon = new SimpleViewSwitcher(getContext()); 58 | progressCon.setLayoutParams(new ViewGroup.LayoutParams( 59 | ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 60 | 61 | AVLoadingIndicatorView progressView = new AVLoadingIndicatorView(this.getContext()); 62 | progressView.setIndicatorColor(0xffB5B5B5); 63 | progressView.setIndicatorId(ProgressStyle.BallSpinFadeLoader); 64 | progressCon.setView(progressView); 65 | 66 | addView(progressCon); 67 | mText = new TextView(getContext()); 68 | mText.setText("正在加载..."); 69 | loadingHint = (String)getContext().getText(R.string.listview_loading); 70 | noMoreHint = (String)getContext().getText(R.string.nomore_loading); 71 | loadingDoneHint = (String)getContext().getText(R.string.loading_done); 72 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 73 | layoutParams.setMargins( (int)getResources().getDimension(R.dimen.textandiconmargin),0,0,0 ); 74 | 75 | mText.setLayoutParams(layoutParams); 76 | addView(mText); 77 | } 78 | 79 | public void setProgressStyle(int style) { 80 | if(style == ProgressStyle.SysProgress){ 81 | progressCon.setView(new ProgressBar(getContext(), null, android.R.attr.progressBarStyle)); 82 | }else{ 83 | AVLoadingIndicatorView progressView = new AVLoadingIndicatorView(this.getContext()); 84 | progressView.setIndicatorColor(0xffB5B5B5); 85 | progressView.setIndicatorId(style); 86 | progressCon.setView(progressView); 87 | } 88 | } 89 | 90 | public void setState(int state) { 91 | switch(state) { 92 | case STATE_LOADING: 93 | progressCon.setVisibility(View.VISIBLE); 94 | mText.setText(loadingHint); 95 | this.setVisibility(View.VISIBLE); 96 | break; 97 | case STATE_COMPLETE: 98 | mText.setText(loadingDoneHint); 99 | this.setVisibility(View.GONE); 100 | break; 101 | case STATE_NOMORE: 102 | mText.setText(noMoreHint); 103 | progressCon.setVisibility(View.GONE); 104 | this.setVisibility(View.VISIBLE); 105 | break; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/ProgressStyle.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | /** 4 | * Created by jianghejie on 15/11/23. 5 | */ 6 | public class ProgressStyle { 7 | public static final int SysProgress=-1; 8 | public static final int BallPulse=0; 9 | public static final int BallGridPulse=1; 10 | public static final int BallClipRotate=2; 11 | public static final int BallClipRotatePulse=3; 12 | public static final int SquareSpin=4; 13 | public static final int BallClipRotateMultiple=5; 14 | public static final int BallPulseRise=6; 15 | public static final int BallRotate=7; 16 | public static final int CubeTransition=8; 17 | public static final int BallZigZag=9; 18 | public static final int BallZigZagDeflect=10; 19 | public static final int BallTrianglePath=11; 20 | public static final int BallScale=12; 21 | public static final int LineScale=13; 22 | public static final int LineScaleParty=14; 23 | public static final int BallScaleMultiple=15; 24 | public static final int BallPulseSync=16; 25 | public static final int BallBeat=17; 26 | public static final int LineScalePulseOut=18; 27 | public static final int LineScalePulseOutRapid=19; 28 | public static final int BallScaleRipple=20; 29 | public static final int BallScaleRippleMultiple=21; 30 | public static final int BallSpinFadeLoader=22; 31 | public static final int LineSpinFadeLoader=23; 32 | public static final int TriangleSkewSpin=24; 33 | public static final int Pacman=25; 34 | public static final int BallGridBeat=26; 35 | public static final int SemiCircleSpin=27; 36 | } 37 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/SimpleItemTouchHelperCallback.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Color; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.support.v7.widget.helper.ItemTouchHelper; 7 | import android.view.View; 8 | 9 | /** 10 | * Created by jianghejie on 16/6/20. 11 | */ 12 | 13 | public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { 14 | 15 | public static final float ALPHA_FULL = 1.0f; 16 | 17 | private final ItemTouchHelperAdapter mAdapter; 18 | private XRecyclerView mXrecyclerView; 19 | 20 | public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter, XRecyclerView recyclerView) { 21 | mAdapter = adapter; 22 | this.mXrecyclerView = recyclerView; 23 | } 24 | 25 | @Override 26 | public boolean isLongPressDragEnabled() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public boolean isItemViewSwipeEnabled() { 32 | return true; 33 | } 34 | 35 | @Override 36 | public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { 37 | // Enable drag and swipe in both directions 38 | final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; 39 | final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; 40 | return makeMovementFlags(dragFlags, swipeFlags); 41 | } 42 | 43 | @Override 44 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { 45 | if (source.getItemViewType() != target.getItemViewType()) { 46 | return false; 47 | } 48 | // Notify the adapter of the move 49 | mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); 50 | return true; 51 | } 52 | 53 | @Override 54 | public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { 55 | // Notify the adapter of the dismissal 56 | mAdapter.onItemDismiss(viewHolder.getAdapterPosition()); 57 | } 58 | 59 | @Override 60 | public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { 61 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); 62 | 63 | // Fade out the view as it is swiped out of the parent's bounds 64 | if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { 65 | View itemView = viewHolder.itemView; 66 | final float alpha = ALPHA_FULL - Math.abs(dX) / (float) itemView.getWidth(); 67 | itemView.setAlpha(alpha); 68 | } 69 | } 70 | 71 | @Override 72 | public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { 73 | if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { 74 | // Let the view holder know that this item is being moved or dragged 75 | viewHolder.itemView.setBackgroundColor(Color.LTGRAY); 76 | } 77 | 78 | super.onSelectedChanged(viewHolder, actionState); 79 | } 80 | 81 | @Override 82 | public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { 83 | super.clearView(recyclerView, viewHolder); 84 | viewHolder.itemView.setAlpha(ALPHA_FULL); 85 | viewHolder.itemView.setBackgroundColor(0); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/SimpleViewSwitcher.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | /** 9 | * Created by jianghejie on 15/11/22. 10 | */ 11 | public class SimpleViewSwitcher extends ViewGroup { 12 | 13 | public SimpleViewSwitcher(Context context) { 14 | super(context); 15 | } 16 | 17 | public SimpleViewSwitcher(Context context, AttributeSet attrs) { 18 | this(context, attrs, 0); 19 | } 20 | 21 | public SimpleViewSwitcher(Context context, AttributeSet attrs, int defStyle) { 22 | super(context, attrs, defStyle); 23 | } 24 | 25 | @Override 26 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 27 | int childCount = this.getChildCount(); 28 | int maxHeight = 0; 29 | int maxWidth = 0; 30 | for (int i = 0; i < childCount; i++) { 31 | View child = this.getChildAt(i); 32 | this.measureChild(child, widthMeasureSpec, heightMeasureSpec); 33 | int cw = child.getMeasuredWidth(); 34 | // int ch = child.getMeasuredHeight(); 35 | maxWidth = child.getMeasuredWidth(); 36 | maxHeight = child.getMeasuredHeight(); 37 | } 38 | setMeasuredDimension(maxWidth, maxHeight); 39 | } 40 | 41 | @Override 42 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 43 | final int count = getChildCount(); 44 | for (int i = 0; i < count; i++) { 45 | final View child = getChildAt(i); 46 | if (child.getVisibility() != View.GONE) { 47 | child.layout(0, 0, r - l, b - t); 48 | 49 | } 50 | } 51 | } 52 | 53 | public void setView(View view) { 54 | if (this.getChildCount() != 0){ 55 | this.removeViewAt(0); 56 | } 57 | this.addView(view,0); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallBeatIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Jack on 2015/10/19. 13 | */ 14 | public class BallBeatIndicator extends com.rmondjone.xrecyclerview.progressindicator.indicator.BaseIndicatorController { 15 | 16 | public static final float SCALE=1.0f; 17 | 18 | public static final int ALPHA=255; 19 | 20 | private float[] scaleFloats=new float[]{SCALE, 21 | SCALE, 22 | SCALE}; 23 | 24 | int[] alphas=new int[]{ALPHA, 25 | ALPHA, 26 | ALPHA,}; 27 | 28 | @Override 29 | public void draw(Canvas canvas, Paint paint) { 30 | float circleSpacing=4; 31 | float radius=(getWidth()-circleSpacing*2)/6; 32 | float x = getWidth()/ 2-(radius*2+circleSpacing); 33 | float y=getHeight() / 2; 34 | for (int i = 0; i < 3; i++) { 35 | canvas.save(); 36 | float translateX=x+(radius*2)*i+circleSpacing*i; 37 | canvas.translate(translateX, y); 38 | canvas.scale(scaleFloats[i], scaleFloats[i]); 39 | paint.setAlpha(alphas[i]); 40 | canvas.drawCircle(0, 0, radius, paint); 41 | canvas.restore(); 42 | } 43 | } 44 | 45 | @Override 46 | public List createAnimation() { 47 | List animators=new ArrayList<>(); 48 | int[] delays=new int[]{350,0,350}; 49 | for (int i = 0; i < 3; i++) { 50 | final int index=i; 51 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.75f,1); 52 | scaleAnim.setDuration(700); 53 | scaleAnim.setRepeatCount(-1); 54 | scaleAnim.setStartDelay(delays[i]); 55 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 56 | @Override 57 | public void onAnimationUpdate(ValueAnimator animation) { 58 | scaleFloats[index] = (float) animation.getAnimatedValue(); 59 | postInvalidate(); 60 | } 61 | }); 62 | scaleAnim.start(); 63 | 64 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255,51,255); 65 | alphaAnim.setDuration(700); 66 | alphaAnim.setRepeatCount(-1); 67 | alphaAnim.setStartDelay(delays[i]); 68 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 69 | @Override 70 | public void onAnimationUpdate(ValueAnimator animation) { 71 | alphas[index] = (int) animation.getAnimatedValue(); 72 | postInvalidate(); 73 | } 74 | }); 75 | alphaAnim.start(); 76 | animators.add(scaleAnim); 77 | animators.add(alphaAnim); 78 | } 79 | return animators; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallClipRotateIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/16. 14 | */ 15 | public class BallClipRotateIndicator extends BaseIndicatorController { 16 | 17 | float scaleFloat=1,degrees; 18 | 19 | @Override 20 | public void draw(Canvas canvas, Paint paint) { 21 | paint.setStyle(Paint.Style.STROKE); 22 | paint.setStrokeWidth(3); 23 | 24 | float circleSpacing=12; 25 | float x = (getWidth()) / 2; 26 | float y=(getHeight()) / 2; 27 | canvas.translate(x, y); 28 | canvas.scale(scaleFloat, scaleFloat); 29 | canvas.rotate(degrees); 30 | RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,0+x-circleSpacing,0+y-circleSpacing); 31 | canvas.drawArc(rectF, -45, 270, false, paint); 32 | } 33 | 34 | @Override 35 | public List createAnimation() { 36 | List animators=new ArrayList<>(); 37 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.6f,0.5f,1); 38 | scaleAnim.setDuration(750); 39 | scaleAnim.setRepeatCount(-1); 40 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 41 | @Override 42 | public void onAnimationUpdate(ValueAnimator animation) { 43 | scaleFloat = (float) animation.getAnimatedValue(); 44 | postInvalidate(); 45 | } 46 | }); 47 | scaleAnim.start(); 48 | 49 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360); 50 | rotateAnim.setDuration(750); 51 | rotateAnim.setRepeatCount(-1); 52 | rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 53 | @Override 54 | public void onAnimationUpdate(ValueAnimator animation) { 55 | degrees = (float) animation.getAnimatedValue(); 56 | postInvalidate(); 57 | } 58 | }); 59 | rotateAnim.start(); 60 | animators.add(scaleAnim); 61 | animators.add(rotateAnim); 62 | return animators; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallClipRotateMultipleIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/17. 14 | */ 15 | public class BallClipRotateMultipleIndicator extends BaseIndicatorController{ 16 | 17 | float scaleFloat=1,degrees; 18 | 19 | 20 | @Override 21 | public void draw(Canvas canvas, Paint paint) { 22 | paint.setStrokeWidth(3); 23 | paint.setStyle(Paint.Style.STROKE); 24 | 25 | float circleSpacing=12; 26 | float x=getWidth()/2; 27 | float y=getHeight()/2; 28 | 29 | canvas.save(); 30 | 31 | canvas.translate(x, y); 32 | canvas.scale(scaleFloat, scaleFloat); 33 | canvas.rotate(degrees); 34 | 35 | //draw two big arc 36 | float[] bStartAngles=new float[]{135,-45}; 37 | for (int i = 0; i < 2; i++) { 38 | RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing); 39 | canvas.drawArc(rectF, bStartAngles[i], 90, false, paint); 40 | } 41 | 42 | canvas.restore(); 43 | canvas.translate(x, y); 44 | canvas.scale(scaleFloat, scaleFloat); 45 | canvas.rotate(-degrees); 46 | //draw two small arc 47 | float[] sStartAngles=new float[]{225,45}; 48 | for (int i = 0; i < 2; i++) { 49 | RectF rectF=new RectF(-x/1.8f+circleSpacing,-y/1.8f+circleSpacing,x/1.8f-circleSpacing,y/1.8f-circleSpacing); 50 | canvas.drawArc(rectF, sStartAngles[i], 90, false, paint); 51 | } 52 | } 53 | 54 | @Override 55 | public List createAnimation() { 56 | List animators=new ArrayList<>(); 57 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.6f,1); 58 | scaleAnim.setDuration(1000); 59 | scaleAnim.setRepeatCount(-1); 60 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 61 | @Override 62 | public void onAnimationUpdate(ValueAnimator animation) { 63 | scaleFloat = (float) animation.getAnimatedValue(); 64 | postInvalidate(); 65 | } 66 | }); 67 | scaleAnim.start(); 68 | 69 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0, 180,360); 70 | rotateAnim.setDuration(1000); 71 | rotateAnim.setRepeatCount(-1); 72 | rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 73 | @Override 74 | public void onAnimationUpdate(ValueAnimator animation) { 75 | degrees = (float) animation.getAnimatedValue(); 76 | postInvalidate(); 77 | } 78 | }); 79 | rotateAnim.start(); 80 | animators.add(scaleAnim); 81 | animators.add(rotateAnim); 82 | return animators; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallClipRotatePulseIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/16. 14 | */ 15 | public class BallClipRotatePulseIndicator extends BaseIndicatorController { 16 | 17 | float scaleFloat1,scaleFloat2,degrees; 18 | 19 | 20 | @Override 21 | public void draw(Canvas canvas, Paint paint) { 22 | float circleSpacing=12; 23 | float x=getWidth()/2; 24 | float y=getHeight()/2; 25 | 26 | //draw fill circle 27 | canvas.save(); 28 | canvas.translate(x, y); 29 | canvas.scale(scaleFloat1, scaleFloat1); 30 | paint.setStyle(Paint.Style.FILL); 31 | canvas.drawCircle(0, 0, x / 2.5f, paint); 32 | 33 | canvas.restore(); 34 | 35 | canvas.translate(x, y); 36 | canvas.scale(scaleFloat2, scaleFloat2); 37 | canvas.rotate(degrees); 38 | 39 | paint.setStrokeWidth(3); 40 | paint.setStyle(Paint.Style.STROKE); 41 | 42 | //draw two arc 43 | float[] startAngles=new float[]{225,45}; 44 | for (int i = 0; i < 2; i++) { 45 | RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing); 46 | canvas.drawArc(rectF, startAngles[i], 90, false, paint); 47 | } 48 | } 49 | 50 | @Override 51 | public List createAnimation() { 52 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1); 53 | scaleAnim.setDuration(1000); 54 | scaleAnim.setRepeatCount(-1); 55 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 56 | @Override 57 | public void onAnimationUpdate(ValueAnimator animation) { 58 | scaleFloat1 = (float) animation.getAnimatedValue(); 59 | postInvalidate(); 60 | } 61 | }); 62 | scaleAnim.start(); 63 | 64 | ValueAnimator scaleAnim2=ValueAnimator.ofFloat(1,0.6f,1); 65 | scaleAnim2.setDuration(1000); 66 | scaleAnim2.setRepeatCount(-1); 67 | scaleAnim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 68 | @Override 69 | public void onAnimationUpdate(ValueAnimator animation) { 70 | scaleFloat2 = (float) animation.getAnimatedValue(); 71 | postInvalidate(); 72 | } 73 | }); 74 | scaleAnim2.start(); 75 | 76 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0, 180,360); 77 | rotateAnim.setDuration(1000); 78 | rotateAnim.setRepeatCount(-1); 79 | rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 80 | @Override 81 | public void onAnimationUpdate(ValueAnimator animation) { 82 | degrees = (float) animation.getAnimatedValue(); 83 | postInvalidate(); 84 | } 85 | }); 86 | rotateAnim.start(); 87 | List animators=new ArrayList<>(); 88 | animators.add(scaleAnim); 89 | animators.add(scaleAnim2); 90 | animators.add(rotateAnim); 91 | return animators; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallGridBeatIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Jack on 2015/10/20. 13 | */ 14 | public class BallGridBeatIndicator extends BaseIndicatorController { 15 | 16 | public static final int ALPHA=255; 17 | 18 | int[] alphas=new int[]{ALPHA, 19 | ALPHA, 20 | ALPHA, 21 | ALPHA, 22 | ALPHA, 23 | ALPHA, 24 | ALPHA, 25 | ALPHA, 26 | ALPHA}; 27 | 28 | @Override 29 | public void draw(Canvas canvas, Paint paint) { 30 | float circleSpacing=4; 31 | float radius=(getWidth()-circleSpacing*4)/6; 32 | float x = getWidth()/ 2-(radius*2+circleSpacing); 33 | float y = getWidth()/ 2-(radius*2+circleSpacing); 34 | 35 | for (int i = 0; i < 3; i++) { 36 | for (int j = 0; j < 3; j++) { 37 | canvas.save(); 38 | float translateX=x+(radius*2)*j+circleSpacing*j; 39 | float translateY=y+(radius*2)*i+circleSpacing*i; 40 | canvas.translate(translateX, translateY); 41 | paint.setAlpha(alphas[3 * i + j]); 42 | canvas.drawCircle(0, 0, radius, paint); 43 | canvas.restore(); 44 | } 45 | } 46 | } 47 | 48 | @Override 49 | public List createAnimation() { 50 | List animators=new ArrayList<>(); 51 | 52 | int[] durations={960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190}; 53 | int[] delays= {360, 400, 680, 410, 710, -150, -120, 10, 320}; 54 | 55 | for (int i = 0; i < 9; i++) { 56 | final int index=i; 57 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 168,255); 58 | alphaAnim.setDuration(durations[i]); 59 | alphaAnim.setRepeatCount(-1); 60 | alphaAnim.setStartDelay(delays[i]); 61 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 62 | @Override 63 | public void onAnimationUpdate(ValueAnimator animation) { 64 | alphas[index] = (int) animation.getAnimatedValue(); 65 | postInvalidate(); 66 | } 67 | }); 68 | alphaAnim.start(); 69 | animators.add(alphaAnim); 70 | } 71 | return animators; 72 | } 73 | 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallGridPulseIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Jack on 2015/10/16. 13 | */ 14 | public class BallGridPulseIndicator extends BaseIndicatorController{ 15 | 16 | public static final int ALPHA=255; 17 | 18 | public static final float SCALE=1.0f; 19 | 20 | int[] alphas=new int[]{ALPHA, 21 | ALPHA, 22 | ALPHA, 23 | ALPHA, 24 | ALPHA, 25 | ALPHA, 26 | ALPHA, 27 | ALPHA, 28 | ALPHA}; 29 | 30 | float[] scaleFloats=new float[]{SCALE, 31 | SCALE, 32 | SCALE, 33 | SCALE, 34 | SCALE, 35 | SCALE, 36 | SCALE, 37 | SCALE, 38 | SCALE}; 39 | 40 | 41 | 42 | @Override 43 | public void draw(Canvas canvas, Paint paint) { 44 | float circleSpacing=4; 45 | float radius=(getWidth()-circleSpacing*4)/6; 46 | float x = getWidth()/ 2-(radius*2+circleSpacing); 47 | float y = getWidth()/ 2-(radius*2+circleSpacing); 48 | 49 | for (int i = 0; i < 3; i++) { 50 | for (int j = 0; j < 3; j++) { 51 | canvas.save(); 52 | float translateX=x+(radius*2)*j+circleSpacing*j; 53 | float translateY=y+(radius*2)*i+circleSpacing*i; 54 | canvas.translate(translateX, translateY); 55 | canvas.scale(scaleFloats[3 * i + j], scaleFloats[3 * i + j]); 56 | paint.setAlpha(alphas[3 * i + j]); 57 | canvas.drawCircle(0, 0, radius, paint); 58 | canvas.restore(); 59 | } 60 | } 61 | } 62 | 63 | @Override 64 | public List createAnimation() { 65 | List animators=new ArrayList<>(); 66 | int[] durations={720, 1020, 1280, 1420, 1450, 1180, 870, 1450, 1060}; 67 | int[] delays= {-60, 250, -170, 480, 310, 30, 460, 780, 450}; 68 | 69 | for (int i = 0; i < 9; i++) { 70 | final int index=i; 71 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.5f,1); 72 | scaleAnim.setDuration(durations[i]); 73 | scaleAnim.setRepeatCount(-1); 74 | scaleAnim.setStartDelay(delays[i]); 75 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 76 | @Override 77 | public void onAnimationUpdate(ValueAnimator animation) { 78 | scaleFloats[index] = (float) animation.getAnimatedValue(); 79 | postInvalidate(); 80 | } 81 | }); 82 | scaleAnim.start(); 83 | 84 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 210, 122, 255); 85 | alphaAnim.setDuration(durations[i]); 86 | alphaAnim.setRepeatCount(-1); 87 | alphaAnim.setStartDelay(delays[i]); 88 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 89 | @Override 90 | public void onAnimationUpdate(ValueAnimator animation) { 91 | alphas[index] = (int) animation.getAnimatedValue(); 92 | postInvalidate(); 93 | } 94 | }); 95 | alphaAnim.start(); 96 | animators.add(scaleAnim); 97 | animators.add(alphaAnim); 98 | } 99 | return animators; 100 | } 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallPulseIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Jack on 2015/10/16. 13 | */ 14 | public class BallPulseIndicator extends BaseIndicatorController{ 15 | 16 | public static final float SCALE=1.0f; 17 | 18 | //scale x ,y 19 | private float[] scaleFloats=new float[]{SCALE, 20 | SCALE, 21 | SCALE}; 22 | 23 | 24 | 25 | @Override 26 | public void draw(Canvas canvas, Paint paint) { 27 | float circleSpacing=4; 28 | float radius=(Math.min(getWidth(),getHeight())-circleSpacing*2)/6; 29 | float x = getWidth()/ 2-(radius*2+circleSpacing); 30 | float y=getHeight() / 2; 31 | for (int i = 0; i < 3; i++) { 32 | canvas.save(); 33 | float translateX=x+(radius*2)*i+circleSpacing*i; 34 | canvas.translate(translateX, y); 35 | canvas.scale(scaleFloats[i], scaleFloats[i]); 36 | canvas.drawCircle(0, 0, radius, paint); 37 | canvas.restore(); 38 | } 39 | } 40 | 41 | @Override 42 | public List createAnimation() { 43 | List animators=new ArrayList<>(); 44 | int[] delays=new int[]{120,240,360}; 45 | for (int i = 0; i < 3; i++) { 46 | final int index=i; 47 | 48 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1); 49 | 50 | scaleAnim.setDuration(750); 51 | scaleAnim.setRepeatCount(-1); 52 | scaleAnim.setStartDelay(delays[i]); 53 | 54 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 55 | @Override 56 | public void onAnimationUpdate(ValueAnimator animation) { 57 | scaleFloats[index] = (float) animation.getAnimatedValue(); 58 | postInvalidate(); 59 | 60 | } 61 | }); 62 | scaleAnim.start(); 63 | animators.add(scaleAnim); 64 | } 65 | return animators; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallPulseRiseIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.PropertyValuesHolder; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.view.animation.LinearInterpolator; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by Jack on 2015/10/17. 15 | */ 16 | public class BallPulseRiseIndicator extends BaseIndicatorController{ 17 | 18 | @Override 19 | public void draw(Canvas canvas, Paint paint) { 20 | float radius=getWidth()/10; 21 | canvas.drawCircle(getWidth()/4,radius*2,radius,paint); 22 | canvas.drawCircle(getWidth()*3/4,radius*2,radius,paint); 23 | 24 | canvas.drawCircle(radius,getHeight()-2*radius,radius,paint); 25 | canvas.drawCircle(getWidth()/2,getHeight()-2*radius,radius,paint); 26 | canvas.drawCircle(getWidth()-radius,getHeight()-2*radius,radius,paint); 27 | } 28 | 29 | @Override 30 | public List createAnimation() { 31 | PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationX",0,360); 32 | ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6); 33 | animator.setInterpolator(new LinearInterpolator()); 34 | animator.setRepeatCount(-1); 35 | animator.setDuration(1500); 36 | animator.start(); 37 | List animators=new ArrayList<>(); 38 | animators.add(animator); 39 | return animators; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallPulseSyncIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Jack on 2015/10/19. 13 | */ 14 | public class BallPulseSyncIndicator extends BaseIndicatorController { 15 | 16 | float[] translateYFloats=new float[3]; 17 | 18 | @Override 19 | public void draw(Canvas canvas, Paint paint) { 20 | float circleSpacing=4; 21 | float radius=(getWidth()-circleSpacing*2)/6; 22 | float x = getWidth()/ 2-(radius*2+circleSpacing); 23 | for (int i = 0; i < 3; i++) { 24 | canvas.save(); 25 | float translateX=x+(radius*2)*i+circleSpacing*i; 26 | canvas.translate(translateX, translateYFloats[i]); 27 | canvas.drawCircle(0, 0, radius, paint); 28 | canvas.restore(); 29 | } 30 | } 31 | 32 | @Override 33 | public List createAnimation() { 34 | List animators=new ArrayList<>(); 35 | float circleSpacing=4; 36 | float radius=(getWidth()-circleSpacing*2)/6; 37 | int[] delays=new int[]{70,140,210}; 38 | for (int i = 0; i < 3; i++) { 39 | final int index=i; 40 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(getHeight()/2,getHeight()/2-radius*2,getHeight()/2); 41 | scaleAnim.setDuration(600); 42 | scaleAnim.setRepeatCount(-1); 43 | scaleAnim.setStartDelay(delays[i]); 44 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 45 | @Override 46 | public void onAnimationUpdate(ValueAnimator animation) { 47 | translateYFloats[index] = (float) animation.getAnimatedValue(); 48 | postInvalidate(); 49 | } 50 | }); 51 | scaleAnim.start(); 52 | animators.add(scaleAnim); 53 | } 54 | return animators; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallRotateIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/17. 14 | */ 15 | public class BallRotateIndicator extends BaseIndicatorController{ 16 | 17 | float scaleFloat=0.5f; 18 | 19 | 20 | @Override 21 | public void draw(Canvas canvas, Paint paint) { 22 | float radius=getWidth()/10; 23 | float x = getWidth()/ 2; 24 | float y=getHeight()/2; 25 | 26 | canvas.save(); 27 | canvas.translate(x - radius * 2 - radius, y); 28 | canvas.scale(scaleFloat, scaleFloat); 29 | canvas.drawCircle(0, 0, radius, paint); 30 | canvas.restore(); 31 | 32 | canvas.save(); 33 | canvas.translate(x, y); 34 | canvas.scale(scaleFloat, scaleFloat); 35 | canvas.drawCircle(0, 0, radius, paint); 36 | canvas.restore(); 37 | 38 | canvas.save(); 39 | canvas.translate(x + radius * 2 + radius, y); 40 | canvas.scale(scaleFloat, scaleFloat); 41 | canvas.drawCircle(0,0,radius, paint); 42 | canvas.restore(); 43 | } 44 | 45 | @Override 46 | public List createAnimation() { 47 | List animators=new ArrayList<>(); 48 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0.5f,1,0.5f); 49 | scaleAnim.setDuration(1000); 50 | scaleAnim.setRepeatCount(-1); 51 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 52 | @Override 53 | public void onAnimationUpdate(ValueAnimator animation) { 54 | scaleFloat = (float) animation.getAnimatedValue(); 55 | postInvalidate(); 56 | } 57 | }); 58 | scaleAnim.start(); 59 | 60 | ObjectAnimator rotateAnim=ObjectAnimator.ofFloat(getTarget(),"rotation",0,180,360); 61 | rotateAnim.setDuration(1000); 62 | rotateAnim.setRepeatCount(-1); 63 | rotateAnim.start(); 64 | 65 | animators.add(scaleAnim); 66 | animators.add(rotateAnim); 67 | return animators; 68 | } 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallScaleIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.view.animation.LinearInterpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class BallScaleIndicator extends BaseIndicatorController { 16 | 17 | float scale=1; 18 | int alpha=255; 19 | 20 | @Override 21 | public void draw(Canvas canvas, Paint paint) { 22 | float circleSpacing=4; 23 | paint.setAlpha(alpha); 24 | canvas.scale(scale,scale,getWidth()/2,getHeight()/2); 25 | paint.setAlpha(alpha); 26 | canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint); 27 | } 28 | 29 | @Override 30 | public List createAnimation() { 31 | List animators=new ArrayList<>(); 32 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1); 33 | scaleAnim.setInterpolator(new LinearInterpolator()); 34 | scaleAnim.setDuration(1000); 35 | scaleAnim.setRepeatCount(-1); 36 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 37 | @Override 38 | public void onAnimationUpdate(ValueAnimator animation) { 39 | scale = (float) animation.getAnimatedValue(); 40 | postInvalidate(); 41 | } 42 | }); 43 | scaleAnim.start(); 44 | 45 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 0); 46 | alphaAnim.setInterpolator(new LinearInterpolator()); 47 | alphaAnim.setDuration(1000); 48 | alphaAnim.setRepeatCount(-1); 49 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 50 | @Override 51 | public void onAnimationUpdate(ValueAnimator animation) { 52 | alpha = (int) animation.getAnimatedValue(); 53 | postInvalidate(); 54 | } 55 | }); 56 | alphaAnim.start(); 57 | animators.add(scaleAnim); 58 | animators.add(alphaAnim); 59 | return animators; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallScaleMultipleIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.view.animation.LinearInterpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class BallScaleMultipleIndicator extends BaseIndicatorController { 16 | 17 | float[] scaleFloats=new float[]{1,1,1}; 18 | int[] alphaInts=new int[]{255,255,255}; 19 | 20 | @Override 21 | public void draw(Canvas canvas, Paint paint) { 22 | float circleSpacing=4; 23 | for (int i = 0; i < 3; i++) { 24 | paint.setAlpha(alphaInts[i]); 25 | canvas.scale(scaleFloats[i],scaleFloats[i],getWidth()/2,getHeight()/2); 26 | canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint); 27 | } 28 | } 29 | 30 | @Override 31 | public List createAnimation() { 32 | List animators=new ArrayList<>(); 33 | long[] delays=new long[]{0, 200, 400}; 34 | for (int i = 0; i < 3; i++) { 35 | final int index=i; 36 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1); 37 | scaleAnim.setInterpolator(new LinearInterpolator()); 38 | scaleAnim.setDuration(1000); 39 | scaleAnim.setRepeatCount(-1); 40 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 41 | @Override 42 | public void onAnimationUpdate(ValueAnimator animation) { 43 | scaleFloats[index] = (float) animation.getAnimatedValue(); 44 | postInvalidate(); 45 | } 46 | }); 47 | scaleAnim.setStartDelay(delays[i]); 48 | scaleAnim.start(); 49 | 50 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255,0); 51 | alphaAnim.setInterpolator(new LinearInterpolator()); 52 | alphaAnim.setDuration(1000); 53 | alphaAnim.setRepeatCount(-1); 54 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 55 | @Override 56 | public void onAnimationUpdate(ValueAnimator animation) { 57 | alphaInts[index] = (int) animation.getAnimatedValue(); 58 | postInvalidate(); 59 | } 60 | }); 61 | scaleAnim.setStartDelay(delays[i]); 62 | alphaAnim.start(); 63 | 64 | animators.add(scaleAnim); 65 | animators.add(alphaAnim); 66 | } 67 | return animators; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallScaleRippleIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.view.animation.LinearInterpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class BallScaleRippleIndicator extends BallScaleIndicator { 16 | 17 | 18 | @Override 19 | public void draw(Canvas canvas, Paint paint) { 20 | paint.setStyle(Paint.Style.STROKE); 21 | paint.setStrokeWidth(3); 22 | super.draw(canvas, paint); 23 | } 24 | 25 | @Override 26 | public List createAnimation() { 27 | List animators=new ArrayList<>(); 28 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1); 29 | scaleAnim.setInterpolator(new LinearInterpolator()); 30 | scaleAnim.setDuration(1000); 31 | scaleAnim.setRepeatCount(-1); 32 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 33 | @Override 34 | public void onAnimationUpdate(ValueAnimator animation) { 35 | scale = (float) animation.getAnimatedValue(); 36 | postInvalidate(); 37 | } 38 | }); 39 | scaleAnim.start(); 40 | 41 | ValueAnimator alphaAnim=ValueAnimator.ofInt(0, 255); 42 | alphaAnim.setInterpolator(new LinearInterpolator()); 43 | alphaAnim.setDuration(1000); 44 | alphaAnim.setRepeatCount(-1); 45 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 46 | @Override 47 | public void onAnimationUpdate(ValueAnimator animation) { 48 | alpha = (int) animation.getAnimatedValue(); 49 | postInvalidate(); 50 | } 51 | }); 52 | alphaAnim.start(); 53 | 54 | animators.add(scaleAnim); 55 | animators.add(alphaAnim); 56 | return animators; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallScaleRippleMultipleIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.view.animation.LinearInterpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class BallScaleRippleMultipleIndicator extends BallScaleMultipleIndicator{ 16 | 17 | 18 | @Override 19 | public void draw(Canvas canvas, Paint paint) { 20 | paint.setStyle(Paint.Style.STROKE); 21 | paint.setStrokeWidth(3); 22 | super.draw(canvas, paint); 23 | } 24 | 25 | @Override 26 | public List createAnimation() { 27 | List animators=new ArrayList<>(); 28 | long[] delays=new long[]{0, 200, 400}; 29 | for (int i = 0; i < 3; i++) { 30 | final int index=i; 31 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1); 32 | scaleAnim.setInterpolator(new LinearInterpolator()); 33 | scaleAnim.setDuration(1000); 34 | scaleAnim.setRepeatCount(-1); 35 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 36 | @Override 37 | public void onAnimationUpdate(ValueAnimator animation) { 38 | scaleFloats[index] = (float) animation.getAnimatedValue(); 39 | postInvalidate(); 40 | } 41 | }); 42 | scaleAnim.setStartDelay(delays[i]); 43 | scaleAnim.start(); 44 | 45 | ValueAnimator alphaAnim=ValueAnimator.ofInt(0,255); 46 | scaleAnim.setInterpolator(new LinearInterpolator()); 47 | alphaAnim.setDuration(1000); 48 | alphaAnim.setRepeatCount(-1); 49 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 50 | @Override 51 | public void onAnimationUpdate(ValueAnimator animation) { 52 | alphaInts[index] = (int) animation.getAnimatedValue(); 53 | postInvalidate(); 54 | } 55 | }); 56 | scaleAnim.setStartDelay(delays[i]); 57 | alphaAnim.start(); 58 | 59 | animators.add(scaleAnim); 60 | animators.add(alphaAnim); 61 | } 62 | return animators; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallSpinFadeLoaderIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by Jack on 2015/10/20. 13 | */ 14 | public class BallSpinFadeLoaderIndicator extends BaseIndicatorController { 15 | 16 | public static final float SCALE=1.0f; 17 | 18 | public static final int ALPHA=255; 19 | 20 | float[] scaleFloats=new float[]{SCALE, 21 | SCALE, 22 | SCALE, 23 | SCALE, 24 | SCALE, 25 | SCALE, 26 | SCALE, 27 | SCALE}; 28 | 29 | int[] alphas=new int[]{ALPHA, 30 | ALPHA, 31 | ALPHA, 32 | ALPHA, 33 | ALPHA, 34 | ALPHA, 35 | ALPHA, 36 | ALPHA}; 37 | 38 | 39 | @Override 40 | public void draw(Canvas canvas, Paint paint) { 41 | float radius=getWidth()/10; 42 | for (int i = 0; i < 8; i++) { 43 | canvas.save(); 44 | Point point=circleAt(getWidth(),getHeight(),getWidth()/2-radius,i*(Math.PI/4)); 45 | canvas.translate(point.x,point.y); 46 | canvas.scale(scaleFloats[i],scaleFloats[i]); 47 | paint.setAlpha(alphas[i]); 48 | canvas.drawCircle(0,0,radius,paint); 49 | canvas.restore(); 50 | } 51 | } 52 | 53 | /** 54 | * 圆O的圆心为(a,b),半径为R,点A与到X轴的为角α. 55 | *则点A的坐标为(a+R*cosα,b+R*sinα) 56 | * @param width 57 | * @param height 58 | * @param radius 59 | * @param angle 60 | * @return 61 | */ 62 | Point circleAt(int width,int height,float radius,double angle){ 63 | float x= (float) (width/2+radius*(Math.cos(angle))); 64 | float y= (float) (height/2+radius*(Math.sin(angle))); 65 | return new Point(x,y); 66 | } 67 | 68 | @Override 69 | public List createAnimation() { 70 | List animators=new ArrayList<>(); 71 | int[] delays= {0, 120, 240, 360, 480, 600, 720, 780, 840}; 72 | for (int i = 0; i < 8; i++) { 73 | final int index=i; 74 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1); 75 | scaleAnim.setDuration(1000); 76 | scaleAnim.setRepeatCount(-1); 77 | scaleAnim.setStartDelay(delays[i]); 78 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 79 | @Override 80 | public void onAnimationUpdate(ValueAnimator animation) { 81 | scaleFloats[index] = (float) animation.getAnimatedValue(); 82 | postInvalidate(); 83 | } 84 | }); 85 | scaleAnim.start(); 86 | 87 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 77, 255); 88 | alphaAnim.setDuration(1000); 89 | alphaAnim.setRepeatCount(-1); 90 | alphaAnim.setStartDelay(delays[i]); 91 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 92 | @Override 93 | public void onAnimationUpdate(ValueAnimator animation) { 94 | alphas[index] = (int) animation.getAnimatedValue(); 95 | postInvalidate(); 96 | } 97 | }); 98 | alphaAnim.start(); 99 | animators.add(scaleAnim); 100 | animators.add(alphaAnim); 101 | } 102 | return animators; 103 | } 104 | 105 | final class Point{ 106 | public float x; 107 | public float y; 108 | 109 | public Point(float x, float y){ 110 | this.x=x; 111 | this.y=y; 112 | } 113 | } 114 | 115 | 116 | } 117 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallTrianglePathIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.view.animation.LinearInterpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class BallTrianglePathIndicator extends BaseIndicatorController { 16 | 17 | float[] translateX=new float[3],translateY=new float[3]; 18 | 19 | @Override 20 | public void draw(Canvas canvas, Paint paint) { 21 | paint.setStrokeWidth(3); 22 | paint.setStyle(Paint.Style.STROKE); 23 | for (int i = 0; i < 3; i++) { 24 | canvas.save(); 25 | canvas.translate(translateX[i], translateY[i]); 26 | canvas.drawCircle(0, 0, getWidth() / 10, paint); 27 | canvas.restore(); 28 | } 29 | } 30 | 31 | @Override 32 | public List createAnimation() { 33 | List animators=new ArrayList<>(); 34 | float startX=getWidth()/5; 35 | float startY=getWidth()/5; 36 | for (int i = 0; i < 3; i++) { 37 | final int index=i; 38 | ValueAnimator translateXAnim=ValueAnimator.ofFloat(getWidth()/2,getWidth()-startX,startX,getWidth()/2); 39 | if (i==1){ 40 | translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()/2,getWidth()-startX); 41 | }else if (i==2){ 42 | translateXAnim=ValueAnimator.ofFloat(startX,getWidth()/2,getWidth()-startX,startX); 43 | } 44 | ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,getHeight()-startY,getHeight()-startY,startY); 45 | if (i==1){ 46 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,getHeight()-startY); 47 | }else if (i==2){ 48 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,startY,getHeight()-startY,getHeight()-startY); 49 | } 50 | 51 | translateXAnim.setDuration(2000); 52 | translateXAnim.setInterpolator(new LinearInterpolator()); 53 | translateXAnim.setRepeatCount(-1); 54 | translateXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 55 | @Override 56 | public void onAnimationUpdate(ValueAnimator animation) { 57 | translateX [index]= (float) animation.getAnimatedValue(); 58 | postInvalidate(); 59 | } 60 | }); 61 | translateXAnim.start(); 62 | 63 | translateYAnim.setDuration(2000); 64 | translateYAnim.setInterpolator(new LinearInterpolator()); 65 | translateYAnim.setRepeatCount(-1); 66 | translateYAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 67 | @Override 68 | public void onAnimationUpdate(ValueAnimator animation) { 69 | translateY [index]= (float) animation.getAnimatedValue(); 70 | postInvalidate(); 71 | } 72 | }); 73 | translateYAnim.start(); 74 | 75 | animators.add(translateXAnim); 76 | animators.add(translateYAnim); 77 | } 78 | return animators; 79 | } 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallZigZagDeflectIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | 4 | import android.animation.Animator; 5 | import android.animation.ValueAnimator; 6 | import android.view.animation.LinearInterpolator; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by Jack on 2015/10/19. 12 | */ 13 | public class BallZigZagDeflectIndicator extends BallZigZagIndicator { 14 | 15 | 16 | 17 | 18 | @Override 19 | public List createAnimation() { 20 | List animators=new ArrayList<>(); 21 | float startX=getWidth()/6; 22 | float startY=getWidth()/6; 23 | for (int i = 0; i < 2; i++) { 24 | final int index=i; 25 | ValueAnimator translateXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,startX,getWidth()-startX,startX); 26 | if (i==1){ 27 | translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()-startX,startX,getWidth()-startX); 28 | } 29 | ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()-startY,getHeight()-startY,startY); 30 | if (i==1){ 31 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,startY,getHeight()-startY); 32 | } 33 | 34 | translateXAnim.setDuration(2000); 35 | translateXAnim.setInterpolator(new LinearInterpolator()); 36 | translateXAnim.setRepeatCount(-1); 37 | translateXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 38 | @Override 39 | public void onAnimationUpdate(ValueAnimator animation) { 40 | translateX [index]= (float) animation.getAnimatedValue(); 41 | postInvalidate(); 42 | } 43 | }); 44 | translateXAnim.start(); 45 | 46 | translateYAnim.setDuration(2000); 47 | translateYAnim.setInterpolator(new LinearInterpolator()); 48 | translateYAnim.setRepeatCount(-1); 49 | translateYAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 50 | @Override 51 | public void onAnimationUpdate(ValueAnimator animation) { 52 | translateY [index]= (float) animation.getAnimatedValue(); 53 | postInvalidate(); 54 | } 55 | }); 56 | translateYAnim.start(); 57 | 58 | animators.add(translateXAnim); 59 | animators.add(translateYAnim); 60 | } 61 | return animators; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BallZigZagIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.view.animation.LinearInterpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class BallZigZagIndicator extends BaseIndicatorController { 16 | 17 | float[] translateX=new float[2],translateY=new float[2]; 18 | 19 | 20 | @Override 21 | public void draw(Canvas canvas, Paint paint) { 22 | for (int i = 0; i < 2; i++) { 23 | canvas.save(); 24 | canvas.translate(translateX[i], translateY[i]); 25 | canvas.drawCircle(0, 0, getWidth() / 10, paint); 26 | canvas.restore(); 27 | } 28 | } 29 | 30 | @Override 31 | public List createAnimation() { 32 | List animators=new ArrayList<>(); 33 | float startX=getWidth()/6; 34 | float startY=getWidth()/6; 35 | for (int i = 0; i < 2; i++) { 36 | final int index=i; 37 | ValueAnimator translateXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,getWidth()/2,startX); 38 | if (i==1){ 39 | translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()/2,getWidth()-startX); 40 | } 41 | ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()/2,startY); 42 | if (i==1){ 43 | translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,getHeight()/2,getHeight()-startY); 44 | } 45 | 46 | translateXAnim.setDuration(1000); 47 | translateXAnim.setInterpolator(new LinearInterpolator()); 48 | translateXAnim.setRepeatCount(-1); 49 | translateXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 50 | @Override 51 | public void onAnimationUpdate(ValueAnimator animation) { 52 | translateX[index] = (float) animation.getAnimatedValue(); 53 | postInvalidate(); 54 | } 55 | }); 56 | translateXAnim.start(); 57 | 58 | translateYAnim.setDuration(1000); 59 | translateYAnim.setInterpolator(new LinearInterpolator()); 60 | translateYAnim.setRepeatCount(-1); 61 | translateYAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 62 | @Override 63 | public void onAnimationUpdate(ValueAnimator animation) { 64 | translateY[index] = (float) animation.getAnimatedValue(); 65 | postInvalidate(); 66 | } 67 | }); 68 | translateYAnim.start(); 69 | animators.add(translateXAnim); 70 | animators.add(translateYAnim); 71 | } 72 | return animators; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/BaseIndicatorController.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.view.View; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Jack on 2015/10/15. 11 | */ 12 | public abstract class BaseIndicatorController { 13 | 14 | 15 | private View mTarget; 16 | 17 | private List mAnimators; 18 | 19 | 20 | public void setTarget(View target){ 21 | this.mTarget=target; 22 | } 23 | 24 | public View getTarget(){ 25 | return mTarget; 26 | } 27 | 28 | 29 | public int getWidth(){ 30 | return mTarget.getWidth(); 31 | } 32 | 33 | public int getHeight(){ 34 | return mTarget.getHeight(); 35 | } 36 | 37 | public void postInvalidate(){ 38 | mTarget.postInvalidate(); 39 | } 40 | 41 | /** 42 | * draw indicator 43 | * @param canvas 44 | * @param paint 45 | */ 46 | public abstract void draw(Canvas canvas,Paint paint); 47 | 48 | /** 49 | * create animation or animations 50 | */ 51 | public abstract List createAnimation(); 52 | 53 | public void initAnimation(){ 54 | mAnimators=createAnimation(); 55 | } 56 | 57 | /** 58 | * make animation to start or end when target 59 | * view was be Visible or Gone or Invisible. 60 | * make animation to cancel when target view 61 | * be onDetachedFromWindow. 62 | * @param animStatus 63 | */ 64 | public void setAnimationStatus(AnimStatus animStatus){ 65 | if (mAnimators==null){ 66 | return; 67 | } 68 | int count=mAnimators.size(); 69 | for (int i = 0; i < count; i++) { 70 | Animator animator=mAnimators.get(i); 71 | boolean isRunning=animator.isRunning(); 72 | switch (animStatus){ 73 | case START: 74 | if (!isRunning){ 75 | animator.start(); 76 | } 77 | break; 78 | case END: 79 | if (isRunning){ 80 | animator.end(); 81 | } 82 | break; 83 | case CANCEL: 84 | if (isRunning){ 85 | animator.cancel(); 86 | } 87 | break; 88 | } 89 | } 90 | } 91 | 92 | 93 | public enum AnimStatus{ 94 | START,END,CANCEL 95 | } 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/CubeTransitionIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | import android.view.animation.LinearInterpolator; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by Jack on 2015/10/18. 15 | */ 16 | public class CubeTransitionIndicator extends BaseIndicatorController { 17 | 18 | float[] translateX=new float[2],translateY=new float[2]; 19 | float degrees,scaleFloat=1.0f; 20 | 21 | @Override 22 | public void draw(Canvas canvas, Paint paint) { 23 | float rWidth=getWidth()/5; 24 | float rHeight=getHeight()/5; 25 | for (int i = 0; i < 2; i++) { 26 | canvas.save(); 27 | canvas.translate(translateX[i], translateY[i]); 28 | canvas.rotate(degrees); 29 | canvas.scale(scaleFloat,scaleFloat); 30 | RectF rectF=new RectF(-rWidth/2,-rHeight/2,rWidth/2,rHeight/2); 31 | canvas.drawRect(rectF,paint); 32 | canvas.restore(); 33 | } 34 | } 35 | 36 | @Override 37 | public List createAnimation() { 38 | List animators=new ArrayList<>(); 39 | float startX=getWidth()/5; 40 | float startY=getHeight()/5; 41 | for (int i = 0; i < 2; i++) { 42 | final int index=i; 43 | translateX[index]=startX; 44 | ValueAnimator translationXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,getWidth()-startX, startX,startX); 45 | if (i==1){ 46 | translationXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,startX, getWidth()-startX,getWidth()-startX); 47 | } 48 | translationXAnim.setInterpolator(new LinearInterpolator()); 49 | translationXAnim.setDuration(1600); 50 | translationXAnim.setRepeatCount(-1); 51 | translationXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 52 | @Override 53 | public void onAnimationUpdate(ValueAnimator animation) { 54 | translateX[index] = (float) animation.getAnimatedValue(); 55 | postInvalidate(); 56 | } 57 | }); 58 | translationXAnim.start(); 59 | translateY[index]=startY; 60 | ValueAnimator translationYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()-startY,getHeight()- startY,startY); 61 | if (i==1){ 62 | translationYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,startY,getHeight()-startY); 63 | } 64 | translationYAnim.setDuration(1600); 65 | translationYAnim.setInterpolator(new LinearInterpolator()); 66 | translationYAnim.setRepeatCount(-1); 67 | translationYAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 68 | @Override 69 | public void onAnimationUpdate(ValueAnimator animation) { 70 | translateY[index] = (float) animation.getAnimatedValue(); 71 | postInvalidate(); 72 | } 73 | }); 74 | translationYAnim.start(); 75 | 76 | animators.add(translationXAnim); 77 | animators.add(translationYAnim); 78 | } 79 | 80 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.5f,1,0.5f,1); 81 | scaleAnim.setDuration(1600); 82 | scaleAnim.setInterpolator(new LinearInterpolator()); 83 | scaleAnim.setRepeatCount(-1); 84 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 85 | @Override 86 | public void onAnimationUpdate(ValueAnimator animation) { 87 | scaleFloat = (float) animation.getAnimatedValue(); 88 | postInvalidate(); 89 | } 90 | }); 91 | scaleAnim.start(); 92 | 93 | ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360,1.5f*360,2*360); 94 | rotateAnim.setDuration(1600); 95 | rotateAnim.setInterpolator(new LinearInterpolator()); 96 | rotateAnim.setRepeatCount(-1); 97 | rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 98 | @Override 99 | public void onAnimationUpdate(ValueAnimator animation) { 100 | degrees = (float) animation.getAnimatedValue(); 101 | postInvalidate(); 102 | } 103 | }); 104 | rotateAnim.start(); 105 | 106 | animators.add(scaleAnim); 107 | animators.add(rotateAnim); 108 | return animators; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/LineScaleIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class LineScaleIndicator extends BaseIndicatorController { 16 | 17 | public static final float SCALE=1.0f; 18 | 19 | float[] scaleYFloats=new float[]{SCALE, 20 | SCALE, 21 | SCALE, 22 | SCALE, 23 | SCALE,}; 24 | 25 | @Override 26 | public void draw(Canvas canvas, Paint paint) { 27 | float translateX=getWidth()/11; 28 | float translateY=getHeight()/2; 29 | for (int i = 0; i < 5; i++) { 30 | canvas.save(); 31 | canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY); 32 | canvas.scale(SCALE, scaleYFloats[i]); 33 | RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f); 34 | canvas.drawRoundRect(rectF, 5, 5, paint); 35 | canvas.restore(); 36 | } 37 | } 38 | 39 | @Override 40 | public List createAnimation() { 41 | List animators=new ArrayList<>(); 42 | long[] delays=new long[]{100,200,300,400,500}; 43 | for (int i = 0; i < 5; i++) { 44 | final int index=i; 45 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1, 0.4f, 1); 46 | scaleAnim.setDuration(1000); 47 | scaleAnim.setRepeatCount(-1); 48 | scaleAnim.setStartDelay(delays[i]); 49 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 50 | @Override 51 | public void onAnimationUpdate(ValueAnimator animation) { 52 | scaleYFloats[index] = (float) animation.getAnimatedValue(); 53 | postInvalidate(); 54 | } 55 | }); 56 | scaleAnim.start(); 57 | animators.add(scaleAnim); 58 | } 59 | return animators; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/LineScalePartyIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/19. 14 | */ 15 | public class LineScalePartyIndicator extends BaseIndicatorController { 16 | 17 | public static final float SCALE=1.0f; 18 | 19 | float[] scaleFloats=new float[]{SCALE, 20 | SCALE, 21 | SCALE, 22 | SCALE, 23 | SCALE,}; 24 | 25 | @Override 26 | public void draw(Canvas canvas, Paint paint) { 27 | float translateX=getWidth()/9; 28 | float translateY=getHeight()/2; 29 | for (int i = 0; i < 4; i++) { 30 | canvas.save(); 31 | canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY); 32 | canvas.scale(scaleFloats[i], scaleFloats[i]); 33 | RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f); 34 | canvas.drawRoundRect(rectF,5,5,paint); 35 | canvas.restore(); 36 | } 37 | } 38 | 39 | @Override 40 | public List createAnimation() { 41 | List animators=new ArrayList<>(); 42 | long[] durations=new long[]{1260, 430, 1010, 730}; 43 | long[] delays=new long[]{770, 290, 280, 740}; 44 | for (int i = 0; i < 4; i++) { 45 | final int index=i; 46 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1); 47 | scaleAnim.setDuration(durations[i]); 48 | scaleAnim.setRepeatCount(-1); 49 | scaleAnim.setStartDelay(delays[i]); 50 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 51 | @Override 52 | public void onAnimationUpdate(ValueAnimator animation) { 53 | scaleFloats[index] = (float) animation.getAnimatedValue(); 54 | postInvalidate(); 55 | } 56 | }); 57 | scaleAnim.start(); 58 | animators.add(scaleAnim); 59 | } 60 | return animators; 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/LineScalePulseOutIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Jack on 2015/10/19. 11 | */ 12 | public class LineScalePulseOutIndicator extends LineScaleIndicator { 13 | 14 | @Override 15 | public List createAnimation() { 16 | List animators=new ArrayList<>(); 17 | long[] delays=new long[]{500,250,0,250,500}; 18 | for (int i = 0; i < 5; i++) { 19 | final int index=i; 20 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1); 21 | scaleAnim.setDuration(900); 22 | scaleAnim.setRepeatCount(-1); 23 | scaleAnim.setStartDelay(delays[i]); 24 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 25 | @Override 26 | public void onAnimationUpdate(ValueAnimator animation) { 27 | scaleYFloats[index] = (float) animation.getAnimatedValue(); 28 | postInvalidate(); 29 | } 30 | }); 31 | scaleAnim.start(); 32 | animators.add(scaleAnim); 33 | } 34 | return animators; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/LineScalePulseOutRapidIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Jack on 2015/10/19. 11 | */ 12 | public class LineScalePulseOutRapidIndicator extends LineScaleIndicator { 13 | 14 | @Override 15 | public List createAnimation() { 16 | List animators=new ArrayList<>(); 17 | long[] delays=new long[]{400,200,0,200,400}; 18 | for (int i = 0; i < 5; i++) { 19 | final int index=i; 20 | ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1); 21 | scaleAnim.setDuration(1000); 22 | scaleAnim.setRepeatCount(-1); 23 | scaleAnim.setStartDelay(delays[i]); 24 | scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 25 | @Override 26 | public void onAnimationUpdate(ValueAnimator animation) { 27 | scaleYFloats[index] = (float) animation.getAnimatedValue(); 28 | postInvalidate(); 29 | } 30 | }); 31 | scaleAnim.start(); 32 | animators.add(scaleAnim); 33 | } 34 | return animators; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/LineSpinFadeLoaderIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | import android.graphics.RectF; 6 | 7 | /** 8 | * Created by Jack on 2015/10/24. 9 | * Email:81813780@qq.com 10 | */ 11 | public class LineSpinFadeLoaderIndicator extends BallSpinFadeLoaderIndicator { 12 | 13 | 14 | @Override 15 | public void draw(Canvas canvas, Paint paint) { 16 | float radius=getWidth()/10; 17 | for (int i = 0; i < 8; i++) { 18 | canvas.save(); 19 | Point point=circleAt(getWidth(),getHeight(),getWidth()/2.5f-radius,i*(Math.PI/4)); 20 | canvas.translate(point.x, point.y); 21 | canvas.scale(scaleFloats[i], scaleFloats[i]); 22 | canvas.rotate(i*45); 23 | paint.setAlpha(alphas[i]); 24 | RectF rectF=new RectF(-radius,-radius/1.5f,1.5f*radius,radius/1.5f); 25 | canvas.drawRoundRect(rectF,5,5,paint); 26 | canvas.restore(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/PacmanIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | import android.view.animation.LinearInterpolator; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by Jack on 2015/10/16. 15 | */ 16 | public class PacmanIndicator extends BaseIndicatorController{ 17 | 18 | private float translateX; 19 | 20 | private int alpha; 21 | 22 | private float degrees1,degrees2; 23 | 24 | @Override 25 | public void draw(Canvas canvas, Paint paint) { 26 | drawPacman(canvas,paint); 27 | drawCircle(canvas,paint); 28 | } 29 | 30 | private void drawPacman(Canvas canvas,Paint paint){ 31 | float x=getWidth()/2; 32 | float y=getHeight()/2; 33 | 34 | canvas.save(); 35 | 36 | canvas.translate(x, y); 37 | canvas.rotate(degrees1); 38 | paint.setAlpha(255); 39 | RectF rectF1=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f); 40 | canvas.drawArc(rectF1, 0, 270, true, paint); 41 | 42 | canvas.restore(); 43 | 44 | canvas.save(); 45 | canvas.translate(x, y); 46 | canvas.rotate(degrees2); 47 | paint.setAlpha(255); 48 | RectF rectF2=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f); 49 | canvas.drawArc(rectF2,90,270,true,paint); 50 | canvas.restore(); 51 | } 52 | 53 | 54 | private void drawCircle(Canvas canvas, Paint paint) { 55 | float radius=getWidth()/11; 56 | paint.setAlpha(alpha); 57 | canvas.drawCircle(translateX, getHeight() / 2, radius, paint); 58 | } 59 | 60 | @Override 61 | public List createAnimation() { 62 | List animators=new ArrayList<>(); 63 | float startT=getWidth()/11; 64 | ValueAnimator translationAnim=ValueAnimator.ofFloat(getWidth()-startT,getWidth()/2); 65 | translationAnim.setDuration(650); 66 | translationAnim.setInterpolator(new LinearInterpolator()); 67 | translationAnim.setRepeatCount(-1); 68 | translationAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 69 | @Override 70 | public void onAnimationUpdate(ValueAnimator animation) { 71 | translateX = (float) animation.getAnimatedValue(); 72 | postInvalidate(); 73 | } 74 | }); 75 | translationAnim.start(); 76 | 77 | ValueAnimator alphaAnim=ValueAnimator.ofInt(255,122); 78 | alphaAnim.setDuration(650); 79 | alphaAnim.setRepeatCount(-1); 80 | alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 81 | @Override 82 | public void onAnimationUpdate(ValueAnimator animation) { 83 | alpha = (int) animation.getAnimatedValue(); 84 | postInvalidate(); 85 | } 86 | }); 87 | alphaAnim.start(); 88 | 89 | ValueAnimator rotateAnim1=ValueAnimator.ofFloat(0, 45, 0); 90 | rotateAnim1.setDuration(650); 91 | rotateAnim1.setRepeatCount(-1); 92 | rotateAnim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 93 | @Override 94 | public void onAnimationUpdate(ValueAnimator animation) { 95 | degrees1 = (float) animation.getAnimatedValue(); 96 | postInvalidate(); 97 | } 98 | }); 99 | rotateAnim1.start(); 100 | 101 | ValueAnimator rotateAnim2=ValueAnimator.ofFloat(0,-45,0); 102 | rotateAnim2.setDuration(650); 103 | rotateAnim2.setRepeatCount(-1); 104 | rotateAnim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 105 | @Override 106 | public void onAnimationUpdate(ValueAnimator animation) { 107 | degrees2 = (float) animation.getAnimatedValue(); 108 | postInvalidate(); 109 | } 110 | }); 111 | rotateAnim2.start(); 112 | 113 | animators.add(translationAnim); 114 | animators.add(alphaAnim); 115 | animators.add(rotateAnim1); 116 | animators.add(rotateAnim2); 117 | return animators; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/SemiCircleSpinIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.RectF; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Jack on 2015/10/20. 14 | */ 15 | public class SemiCircleSpinIndicator extends BaseIndicatorController { 16 | 17 | 18 | @Override 19 | public void draw(Canvas canvas, Paint paint) { 20 | RectF rectF=new RectF(0,0,getWidth(),getHeight()); 21 | canvas.drawArc(rectF,-60,120,false,paint); 22 | } 23 | 24 | @Override 25 | public List createAnimation() { 26 | List animators=new ArrayList<>(); 27 | ObjectAnimator rotateAnim=ObjectAnimator.ofFloat(getTarget(),"rotation",0,180,360); 28 | rotateAnim.setDuration(600); 29 | rotateAnim.setRepeatCount(-1); 30 | rotateAnim.start(); 31 | animators.add(rotateAnim); 32 | return animators; 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/SquareSpinIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.PropertyValuesHolder; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.view.animation.LinearInterpolator; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by Jack on 2015/10/16. 16 | */ 17 | public class SquareSpinIndicator extends BaseIndicatorController { 18 | 19 | @Override 20 | public void draw(Canvas canvas, Paint paint) { 21 | canvas.drawRect(new RectF(getWidth()/5,getHeight()/5,getWidth()*4/5,getHeight()*4/5),paint); 22 | } 23 | 24 | @Override 25 | public List createAnimation() { 26 | List animators=new ArrayList<>(); 27 | PropertyValuesHolder rotation5=PropertyValuesHolder.ofFloat("rotationX",0,180,180,0,0); 28 | PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationY",0,0,180,180,0); 29 | ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6,rotation5); 30 | animator.setInterpolator(new LinearInterpolator()); 31 | animator.setRepeatCount(-1); 32 | animator.setDuration(2500); 33 | animator.start(); 34 | animators.add(animator); 35 | return animators; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/java/com/rmondjone/xrecyclerview/progressindicator/indicator/TriangleSkewSpinIndicator.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.xrecyclerview.progressindicator.indicator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.PropertyValuesHolder; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.graphics.Path; 9 | import android.view.animation.LinearInterpolator; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by Jack on 2015/10/20. 16 | */ 17 | public class TriangleSkewSpinIndicator extends BaseIndicatorController { 18 | 19 | @Override 20 | public void draw(Canvas canvas, Paint paint) { 21 | Path path=new Path(); 22 | path.moveTo(getWidth()/5,getHeight()*4/5); 23 | path.lineTo(getWidth()*4/5, getHeight()*4/5); 24 | path.lineTo(getWidth()/2,getHeight()/5); 25 | path.close(); 26 | canvas.drawPath(path, paint); 27 | } 28 | 29 | @Override 30 | public List createAnimation() { 31 | List animators=new ArrayList<>(); 32 | PropertyValuesHolder rotation5=PropertyValuesHolder.ofFloat("rotationX",0,180,180,0,0); 33 | PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationY",0,0,180,180,0); 34 | 35 | ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6,rotation5); 36 | animator.setInterpolator(new LinearInterpolator()); 37 | animator.setRepeatCount(-1); 38 | animator.setDuration(2500); 39 | animator.start(); 40 | 41 | animators.add(animator); 42 | return animators; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/ic_loading_rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/ic_loading_rotate.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/ic_pulltorefresh_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/ic_pulltorefresh_arrow.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/iconfont_downgrey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/iconfont_downgrey.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_01.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_02.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_03.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_04.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_05.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_06.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_07.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_08.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_09.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_10.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_11.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/loading_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/LockTableViewProject/locktableview/src/main/res/drawable/loading_12.png -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/progressbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/drawable/progressloading.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/listview_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/listview_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 22 | 23 | 28 | 29 | 34 | 35 | 40 | 41 | 46 | 47 | 48 | 49 | 58 | 59 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/lock_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/locktablecontentview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 18 | 19 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/locktableview.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 22 | 23 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 45 | 46 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/pull_to_refresh_head.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 21 | 22 | 28 | 29 | 30 | 31 | 38 | 45 | 46 | 47 | 48 | 54 | 55 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/layout/unlock_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/values-zh/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 下拉刷新 3 | 释放立即刷新 4 | 正在加载... 5 | 数据已全部加载结束 6 | 正在刷新... 7 | 刷新完成 8 | 加载完成 9 | 上次更新时间: 10 | 11 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #00000000 6 | #334E6C 7 | #E5EFFE 8 | #FF000000 9 | #FFFFFFFF 10 | #e6e6e6 11 | #fafafa 12 | #555555 13 | #FF0033 14 | #ADD8E6 15 | #817F80 16 | #0000ff 17 | #00000000 18 | #0F0 19 | #FF0000 20 | #DDDDDD 21 | #b8b8b8 22 | #0cb9f5 23 | #2c8fd3 24 | #ffa500 25 | #000000 26 | #e3eef4 27 | #b1dce2ff 28 | #faedda 29 | #ff6bd697 30 | #c0c0c0 31 | #FFf3feff 32 | #FFfff1f2 33 | #603b07 34 | #00000000 35 | #31abfe 36 | #76c120 37 | #ffffffff 38 | #EE4000 39 | #fff2f9ec 40 | #EDEDE4 41 | #E8E8E8 42 | #ff434343 43 | #FAFAFA 44 | #3C70A6 45 | #C3C4C9 46 | #262B31 47 | #CED7DF 48 | #7B7B7B 49 | #949494 50 | #1989E0 51 | #CFEDF9 52 | #FFFFFF 53 | #F7F8F9 54 | #C2C0C2 55 | 56 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10dp 4 | 5 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | pull to refresh 3 | release to start refresh 4 | loading... 5 | no more to be loaded 6 | refreshing... 7 | refresh done 8 | loading done 9 | last update: 10 | 11 | -------------------------------------------------------------------------------- /LockTableViewProject/locktableview/src/test/java/com/rmondjone/locktableview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.rmondjone.locktableview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /LockTableViewProject/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':locktableview' 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LockTableView 2 | 自定义表格,可锁定双向表头,自适应列宽,自适应行高,下拉刷新,上拉加载,快速集成
3 | ## 效果展示 4 | 5 | ![image](https://github.com/RmondJone/LockTableView/blob/master/show.gif) 6 | 7 | ## 工程集成说明 8 | * 第一步 9 | ```java 10 | //在工程gradle文件里 11 | allprojects { 12 | repositories { 13 | ....... 14 | maven { url 'https://jitpack.io' } 15 | ...... 16 | } 17 | } 18 | ``` 19 | 20 | ```java 21 | //如果不在工程gradle文件里加入,也可以加入模块gradle文件中 22 | repositories { 23 | maven { 24 | url "https://jitpack.io" 25 | } 26 | } 27 | ``` 28 | 29 | * 第二步 30 | ```java 31 | dependencies { 32 | compile 'com.github.RmondJone:LockTableView:1.1.2' 33 | } 34 | ``` 35 | 36 | ## API使用说明 37 | 38 | ```java 39 | 40 | final LockTableView mLockTableView = new LockTableView(this, mContentView, mTableDatas); 41 | Log.e("表格加载开始", "当前线程:" + Thread.currentThread()); 42 | mLockTableView.setLockFristColumn(true) //是否锁定第一列 43 | .setLockFristRow(true) //是否锁定第一行 44 | .setMaxColumnWidth(100) //列最大宽度 45 | .setMinColumnWidth(60) //列最小宽度 46 | .setColumnWidth(1,60) //设置指定列文本宽度(从0开始计算,宽度单位dp) 47 | .setMinRowHeight(20)//行最小高度 48 | .setMaxRowHeight(60)//行最大高度 49 | .setTextViewSize(16) //单元格字体大小 50 | .setCellPadding(15)//设置单元格内边距(dp) 51 | .setFristRowBackGroudColor(R.color.table_head)//表头背景色 52 | .setTableHeadTextColor(R.color.beijin)//表头字体颜色 53 | .setTableContentTextColor(R.color.border_color)//单元格字体颜色 54 | .setNullableString("N/A") //空值替换值 55 | .setTableViewListener(new LockTableView.OnTableViewListener() { 56 | //设置横向滚动监听 57 | @Override 58 | public void onTableViewScrollChange(int x, int y) { 59 | Log.e("滚动值","["+x+"]"+"["+y+"]"); 60 | } 61 | }) 62 | .setTableViewRangeListener(new LockTableView.OnTableViewRangeListener() { 63 | //设置横向滚动边界监听 64 | @Override 65 | public void onLeft(HorizontalScrollView view) { 66 | Log.e("滚动边界","滚动到最左边"); 67 | } 68 | 69 | @Override 70 | public void onRight(HorizontalScrollView view) { 71 | Log.e("滚动边界","滚动到最右边"); 72 | } 73 | }) 74 | .setOnLoadingListener(new LockTableView.OnLoadingListener() { 75 | //下拉刷新、上拉加载监听 76 | @Override 77 | public void onRefresh(final XRecyclerView mXRecyclerView, final ArrayList> mTableDatas) { 78 | Log.e("表格主视图",mXRecyclerView); 79 | Log.e("表格所有数据",mTableDatas); 80 | //如需更新表格数据调用,部分刷新不会全部重绘 81 | mLockTableView.setTableDatas(mTableDatas); 82 | //停止刷新 83 | mXRecyclerView.refreshComplete(); 84 | } 85 | 86 | @Override 87 | public void onLoadMore(final XRecyclerView mXRecyclerView, final ArrayList> mTableDatas) { 88 | Log.e("表格主视图",mXRecyclerView); 89 | Log.e("表格所有数据",mTableDatas); 90 | //如需更新表格数据调用,部分刷新不会全部重绘 91 | mLockTableView.setTableDatas(mTableDatas); 92 | //停止刷新 93 | mXRecyclerView.loadMoreComplete(); 94 | //如果没有更多数据调用 95 | mXRecyclerView.setNoMore(true); 96 | } 97 | }) 98 | .setOnItemClickListenter(new LockTableView.OnItemClickListenter() { 99 | @Override 100 | public void onItemClick(View item, int position) { 101 | Log.e("点击事件",position+""); 102 | } 103 | }) 104 | .setOnItemLongClickListenter(new LockTableView.OnItemLongClickListenter() { 105 | @Override 106 | public void onItemLongClick(View item, int position) { 107 | Log.e("长按事件",position+""); 108 | } 109 | }) 110 | .setOnItemSeletor(R.color.dashline_color)//设置Item被选中颜色 111 | .show(); //显示表格,此方法必须调用 112 | mLockTableView.getTableScrollView().setPullRefreshEnabled(true); 113 | mLockTableView.getTableScrollView().setLoadingMoreEnabled(true); 114 | mLockTableView.getTableScrollView().setRefreshProgressStyle(ProgressStyle.SquareSpin); 115 | //属性值获取 116 | Log.e("每列最大宽度(dp)", mLockTableView.getColumnMaxWidths().toString()); 117 | Log.e("每行最大高度(dp)", mLockTableView.getRowMaxHeights().toString()); 118 | Log.e("表格所有的滚动视图", mLockTableView.getScrollViews().toString()); 119 | Log.e("表格头部固定视图(锁列)", mLockTableView.getLockHeadView().toString()); 120 | Log.e("表格头部固定视图(不锁列)", mLockTableView.getUnLockHeadView().toString()); 121 | 122 | /** 123 | * 构造方法 124 | * 125 | * @param mContext 上下文 126 | * @param mContentView 表格父视图 127 | * @param mTableDatas 表格数据 128 | */ 129 | public LockTableView(Context mContext, ViewGroup mContentView, ArrayList> mTableDatas) { 130 | this.mContext = mContext; 131 | this.mContentView = mContentView; 132 | this.mTableDatas = mTableDatas; 133 | initAttrs(); 134 | } 135 | 136 | ``` 137 | ## 目前支持可自定义属性 138 | 139 | ```java 140 | /** 141 | * 是否锁定首行 142 | */ 143 | private boolean isLockFristRow = true; 144 | /** 145 | * 是否锁定首列 146 | */ 147 | private boolean isLockFristColumn = true; 148 | /** 149 | * 最大列宽(dp) 150 | */ 151 | private int maxColumnWidth; 152 | /** 153 | * 最小列宽(dp) 154 | */ 155 | private int minColumnWidth; 156 | /** 157 | * 最大行高(dp) 158 | */ 159 | private int maxRowHeight; 160 | /** 161 | * 最小行高dp) 162 | */ 163 | private int minRowHeight; 164 | /** 165 | * 第一行背景颜色 166 | */ 167 | private int mFristRowBackGroudColor; 168 | /** 169 | * 数据为空时的缺省值 170 | */ 171 | private String mNullableString; 172 | /** 173 | * 单元格字体大小 174 | */ 175 | private int mTextViewSize; 176 | /** 177 | * 表格头部字体颜色 178 | */ 179 | private int mTableHeadTextColor; 180 | /** 181 | * 表格内容字体颜色 182 | */ 183 | private int mTableContentTextColor; 184 | /** 185 | * 表格横向滚动监听事件 186 | */ 187 | private OnTableViewListener mTableViewListener; 188 | /** 189 | * 表格横向滚动到边界监听事件 190 | */ 191 | private OnTableViewRangeListener mTableViewRangeListener; 192 | /** 193 | * 表格上拉刷新、下拉加载监听事件 194 | */ 195 | private OnLoadingListener mOnLoadingListener; 196 | /** 197 | * Item点击事件 198 | */ 199 | private OnItemClickListenter mOnItemClickListenter; 200 | /** 201 | * Item长按事件 202 | */ 203 | private OnItemLongClickListenter mOnItemLongClickListenter; 204 | /** 205 | * Item选中颜色 206 | */ 207 | private int mOnItemSeletor; 208 | /** 209 | * 单元格内边距 210 | */ 211 | private int mCellPadding; 212 | 213 | 214 | ``` 215 | 216 | ## 问题反馈 217 | * 技术交流群:QQ(264587303) 218 | * Demo作者:郭翰林 219 | * 注:有定制化需求自己下源码根据自己的需求改动,不要指望别人给你实现,这样永远没有成长! 220 | * 本控件实现没有难度,只要静心看代码都能看的懂。我只提供最基础的功能,尽量满足大部分的开发需求。 221 | * 此项目由于个人原因,已停止维护!望大家见谅!希望有更多热心人士可以Fork此项目进行改造升级! 222 | 223 | ## License 224 | ```java 225 | Copyright (c) 2018 Guohanlin 226 | 227 | Permission is hereby granted, free of charge, to any person obtaining a copy 228 | of this software and associated documentation files (the "Software"), to deal 229 | in the Software without restriction, including without limitation the rights 230 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 231 | copies of the Software, and to permit persons to whom the Software is 232 | furnished to do so, subject to the following conditions: 233 | 234 | The above copyright notice and this permission notice shall be included in all 235 | copies or substantial portions of the Software. 236 | 237 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 238 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 239 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 240 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 241 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 242 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 243 | SOFTWARE. 244 | ``` 245 | -------------------------------------------------------------------------------- /show.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RmondJone/LockTableView/cddbef96d38021579be21ab17c6280e40dc46a00/show.gif --------------------------------------------------------------------------------