├── LICENSE ├── README.md ├── common-utils ├── .gitignore ├── build.gradle ├── common-utils.iml ├── common-view │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── draghelper_study │ │ │ └── heaven7 │ │ │ └── com │ │ │ └── common_view │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── org │ │ │ │ └── heaven7 │ │ │ │ └── core │ │ │ │ └── view │ │ │ │ ├── AutoResizeGridView.java │ │ │ │ ├── AutoResizeListView.java │ │ │ │ ├── BadgeView.java │ │ │ │ ├── EasyProgress.java │ │ │ │ ├── ExpandScrollView.java │ │ │ │ ├── FlowLayout.java │ │ │ │ ├── PasswordInputView.java │ │ │ │ ├── SlidingTabLayout.java │ │ │ │ └── SlidingTabStrip.java │ │ └── res │ │ │ └── values │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── draghelper_study │ │ └── heaven7 │ │ └── com │ │ └── common_view │ │ └── ExampleUnitTest.java ├── commonutil-extra │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── study │ │ │ └── heaven7 │ │ │ └── com │ │ │ └── commonutil_extra │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── study │ │ └── heaven7 │ │ └── com │ │ └── commonutil_extra │ │ └── ExampleUnitTest.java ├── commonutil │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── commonutil.iml │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── org │ │ │ └── heaven7 │ │ │ └── core │ │ │ └── ApplicationTest.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── heaven7 │ │ │ └── core │ │ │ ├── adapter │ │ │ ├── AdapterManager.java │ │ │ ├── BaseAdapterHelper.java │ │ │ ├── BaseFragmentPagerAdapter.java │ │ │ ├── BaseQuickAdapter.java │ │ │ ├── BaseSelector.java │ │ │ ├── BaseSwipeAdapterHelper.java │ │ │ ├── HeaderFooterHelper.java │ │ │ ├── ISelectable.java │ │ │ ├── ISwipeMultiItemTypeSupport.java │ │ │ ├── MultiItemTypeSupport.java │ │ │ ├── NetworkImagePagerAdapter.java │ │ │ ├── QuickAdapter.java │ │ │ ├── QuickExpandListAdapter.java │ │ │ ├── QuickRecycleViewAdapter.java │ │ │ ├── QuickRecycleViewSwipeAdapter.java │ │ │ ├── QuickSwipeAdapter.java │ │ │ ├── ResizeHeightPostCallback.java │ │ │ ├── SelectHelper.java │ │ │ ├── SimpleFragmentPagerAdapter.java │ │ │ ├── SimpleSwipeStateChangeListener.java │ │ │ └── SwipeHelper.java │ │ │ ├── anno │ │ │ └── Hide.java │ │ │ ├── helper │ │ │ └── BundleHelper.java │ │ │ ├── item │ │ │ └── decoration │ │ │ │ ├── AbstractDividerItemDecoration.java │ │ │ │ ├── DividerGridItemDecoration.java │ │ │ │ ├── DividerItemDecoration.java │ │ │ │ ├── DividerManagerImpl.java │ │ │ │ └── IDividerManager.java │ │ │ ├── layoutmanager │ │ │ ├── ExStaggeredGridLayoutManager.java │ │ │ ├── FullyGridLayoutManager.java │ │ │ └── FullyLinearLayoutManager.java │ │ │ ├── save_state │ │ │ ├── BundleSupportType.java │ │ │ ├── BundleSupportTypeFlag.java │ │ │ ├── SaveFieldInfo.java │ │ │ ├── SaveStateField.java │ │ │ ├── SaveStateHelper.java │ │ │ └── SaveStateUtil.java │ │ │ ├── util │ │ │ ├── CalendarUtils.java │ │ │ ├── DialogHelper.java │ │ │ ├── ImageParser.java │ │ │ ├── Logger.java │ │ │ ├── MD5Util.java │ │ │ ├── MainWorker.java │ │ │ ├── PackageUtil.java │ │ │ ├── ResourceUtil.java │ │ │ ├── SPHelper.java │ │ │ ├── TextWatcherAdapter.java │ │ │ ├── Toaster.java │ │ │ ├── ViewCompatUtil.java │ │ │ ├── VolleyUtil.java │ │ │ └── WeakHandler.java │ │ │ └── viewhelper │ │ │ ├── ViewHelper.java │ │ │ └── ViewHelperImpl.java │ │ └── res │ │ └── values │ │ └── strings.xml ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── log.txt ├── pulltorefresh-swipe │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── study │ │ │ └── heaven7 │ │ │ └── com │ │ │ └── pulltorefresh_swipe │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── heaven7 │ │ │ │ └── pulltorefresh │ │ │ │ └── swipe │ │ │ │ ├── PullToRefreshListFooter.java │ │ │ │ ├── PullToRefreshListHeader.java │ │ │ │ ├── PullToRefreshSwipeMenuListView.java │ │ │ │ ├── RefreshTime.java │ │ │ │ ├── SwipeMenu.java │ │ │ │ ├── SwipeMenuAdapter.java │ │ │ │ ├── SwipeMenuCreator.java │ │ │ │ ├── SwipeMenuItem.java │ │ │ │ ├── SwipeMenuLayout.java │ │ │ │ └── SwipeMenuView.java │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── heaven7_xlistview_arrow.png │ │ │ ├── layout │ │ │ ├── heaven7_xlistview_footer.xml │ │ │ └── heaven7_xlistview_header.xml │ │ │ └── values │ │ │ ├── ids.xml │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── study │ │ └── heaven7 │ │ └── com │ │ └── pulltorefresh_swipe │ │ └── ExampleUnitTest.java ├── sample │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ ├── sample.iml │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── org │ │ │ └── heaven7 │ │ │ └── demo │ │ │ └── ApplicationTest.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── org │ │ │ └── heaven7 │ │ │ └── demo │ │ │ ├── BaseActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── PulltorefreshSwipeTest.java │ │ │ ├── QuickRecycleViewTestActivity.java │ │ │ ├── QuickSwipeListViewAdapterTestActivity.java │ │ │ ├── QuickSwipeRecycleAdapterTestActivity.java │ │ │ ├── RecyclerViewDecorationTestActivity.java │ │ │ ├── Test.java │ │ │ ├── TestApplication.java │ │ │ ├── third_sdk │ │ │ ├── LoginShareDemo.java │ │ │ └── PayDemoActivity.java │ │ │ └── wxapi │ │ │ ├── WXEntryActivity.java │ │ │ └── WXPayEntryActivity.java │ │ └── res │ │ ├── drawable-xhdpi │ │ ├── ic_delete.png │ │ └── ic_launcher.png │ │ ├── drawable │ │ ├── divider_bg.xml │ │ └── test_progressbar.xml │ │ ├── layout │ │ ├── activity_list_view.xml │ │ ├── activity_main.xml │ │ ├── activity_pay.xml │ │ ├── activity_pulltofresh_swipe.xml │ │ ├── activity_recycle.xml │ │ ├── activity_recycle2.xml │ │ ├── footer_item.xml │ │ ├── item_image.xml │ │ ├── item_image_narrow.xml │ │ ├── item_list_app.xml │ │ ├── item_menu.xml │ │ ├── item_swipe.xml │ │ └── test_1.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── style_theme.xml ├── settings.gradle ├── swipelistview │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── study │ │ │ └── heaven7 │ │ │ └── com │ │ │ └── swipelistview │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── xyczero │ │ │ │ └── customswipelistview │ │ │ │ ├── CustomSwipeBaseAdapter.java │ │ │ │ ├── CustomSwipeListView.java │ │ │ │ ├── CustomSwipeUndoDialog.java │ │ │ │ ├── CustomSwipeUtils.java │ │ │ │ └── OnUndoActionListener.java │ │ └── res │ │ │ ├── anim │ │ │ ├── swipe_listview_undodialog_enter.xml │ │ │ ├── swipe_listview_undodialog_exit.xml │ │ │ └── swipe_listview_undodialog_push_right_in.xml │ │ │ ├── drawable-hdpi │ │ │ └── swipe_listview_ic_action_undo.jpg │ │ │ ├── drawable │ │ │ └── swipe_listview__undodialog_shape.xml │ │ │ ├── layout │ │ │ └── customswipe_undodialog_view.xml │ │ │ ├── values-zh │ │ │ └── strings.xml │ │ │ └── values │ │ │ ├── color.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── study │ │ └── heaven7 │ │ └── com │ │ └── swipelistview │ │ └── ExampleUnitTest.java ├── third_sdks │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── libs │ │ ├── alipaySDK-20150818.jar │ │ ├── json_heaven7.jar │ │ ├── libammsdk.jar │ │ └── qq_open_sdk_r5276.jar │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── study │ │ │ └── heaven7 │ │ │ └── com │ │ │ └── third_sdks │ │ │ └── ApplicationTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── heaven7 │ │ │ │ └── third │ │ │ │ ├── core │ │ │ │ ├── AsyncTask2.java │ │ │ │ ├── IResetable.java │ │ │ │ ├── ITaskManager.java │ │ │ │ ├── ImageParser.java │ │ │ │ ├── SdkFactory.java │ │ │ │ └── internal │ │ │ │ │ ├── SdkConfig.java │ │ │ │ │ └── TaskManagerImpl.java │ │ │ │ ├── pay │ │ │ │ ├── Base64.java │ │ │ │ ├── BaseWeixinPayActivity.java │ │ │ │ ├── ByteStreams.java │ │ │ │ ├── IoUtil.java │ │ │ │ ├── Util.java │ │ │ │ ├── WeixinPayHelper.java │ │ │ │ ├── WeixinUtil.java │ │ │ │ └── ZhifubaoHelper.java │ │ │ │ └── share │ │ │ │ ├── BaseWeixinActivity.java │ │ │ │ ├── QQHelper.java │ │ │ │ ├── QQUtil.java │ │ │ │ ├── Util.java │ │ │ │ ├── WeixinHelper.java │ │ │ │ └── weixin │ │ │ │ ├── AccessTokenResult.java │ │ │ │ ├── UserInfoResult.java │ │ │ │ └── ValidateAccessTokenResult.java │ │ └── res │ │ │ ├── layout │ │ │ └── activity_wx_entry.xml │ │ │ └── values │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── study │ │ └── heaven7 │ │ └── com │ │ └── third_sdks │ │ └── ExampleUnitTest.java └── volley_with_extra │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ ├── androidTest │ └── java │ │ └── study │ │ └── heaven7 │ │ └── com │ │ └── volley_with_extra │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── android │ │ │ └── volley │ │ │ ├── AuthFailureError.java │ │ │ ├── Cache.java │ │ │ ├── CacheDispatcher.java │ │ │ ├── DefaultRetryPolicy.java │ │ │ ├── ExecutorDelivery.java │ │ │ ├── Network.java │ │ │ ├── NetworkDispatcher.java │ │ │ ├── NetworkError.java │ │ │ ├── NetworkResponse.java │ │ │ ├── NoConnectionError.java │ │ │ ├── ParseError.java │ │ │ ├── Request.java │ │ │ ├── RequestQueue.java │ │ │ ├── Response.java │ │ │ ├── ResponseDelivery.java │ │ │ ├── RetryPolicy.java │ │ │ ├── ServerError.java │ │ │ ├── TimeoutError.java │ │ │ ├── VolleyError.java │ │ │ ├── VolleyLog.java │ │ │ ├── data │ │ │ ├── ApiParams.java │ │ │ ├── BitmapLruCache.java │ │ │ ├── LruCache.java │ │ │ └── RequestManager.java │ │ │ ├── extra │ │ │ ├── ColorInt.java │ │ │ ├── Corner.java │ │ │ ├── ExpandNetworkImageView.java │ │ │ ├── ImageParam.java │ │ │ ├── IntDef.java │ │ │ ├── MultipartEntity.java │ │ │ ├── MultipartRequest.java │ │ │ ├── NonNull.java │ │ │ ├── RoundedBitmapBuilder.java │ │ │ ├── RoundedDrawable.java │ │ │ ├── Util.java │ │ │ └── util │ │ │ │ ├── Method.java │ │ │ │ ├── MethodDef.java │ │ │ │ ├── Pairs.java │ │ │ │ ├── RestfulHelper.java │ │ │ │ └── VolleyUtil.java │ │ │ └── toolbox │ │ │ ├── AndroidAuthenticator.java │ │ │ ├── Authenticator.java │ │ │ ├── BasicNetwork.java │ │ │ ├── ByteArrayPool.java │ │ │ ├── ClearCacheRequest.java │ │ │ ├── DiskBasedCache.java │ │ │ ├── HttpClientStack.java │ │ │ ├── HttpHeaderParser.java │ │ │ ├── HttpStack.java │ │ │ ├── HurlStack.java │ │ │ ├── ImageLoader.java │ │ │ ├── ImageRequest.java │ │ │ ├── JsonArrayRequest.java │ │ │ ├── JsonObjectRequest.java │ │ │ ├── JsonRequest.java │ │ │ ├── NetworkImageView.java │ │ │ ├── NoCache.java │ │ │ ├── PoolingByteArrayOutputStream.java │ │ │ ├── RequestFuture.java │ │ │ ├── StringRequest.java │ │ │ └── Volley.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── study │ └── heaven7 │ └── com │ └── volley_with_extra │ └── ExampleUnitTest.java └── images └── swipe_adapter_1.gif /common-utils/.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Android Studio 23 | .idea/ 24 | .gradle 25 | /*/local.properties 26 | /*/out 27 | build 28 | /*/*/production 29 | *.iml 30 | *.iws 31 | *.ipr 32 | *~ 33 | *.swp 34 | -------------------------------------------------------------------------------- /common-utils/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:1.5.0' 9 | //jcenter 10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | jcenter() 21 | } 22 | //解决生成javadoc失败导致的上传不了bintray, so Disable javadoc check for Bintray upload 23 | tasks.withType(Javadoc) { 24 | options.addStringOption('Xdoclint:none', '-quiet') 25 | options.addStringOption('encoding', 'UTF-8') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common-utils/common-utils.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /common-utils/common-view/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /common-utils/common-view/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 23 10 | versionCode 122 11 | versionName "1.2.2" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | // testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:23.1.1' 25 | } 26 | 27 | apply from: "bintrayUpload.gradle" 28 | -------------------------------------------------------------------------------- /common-utils/common-view/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 I:\android\sdk2/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 | -------------------------------------------------------------------------------- /common-utils/common-view/project.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/common-view/project.properties -------------------------------------------------------------------------------- /common-utils/common-view/src/androidTest/java/draghelper_study/heaven7/com/common_view/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package draghelper_study.heaven7.com.common_view; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/java/org/heaven7/core/view/AutoResizeGridView.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.GridView; 6 | 7 | public class AutoResizeGridView extends GridView { 8 | 9 | public AutoResizeGridView(Context context, AttributeSet attrs) { 10 | super(context, attrs); 11 | } 12 | 13 | public AutoResizeGridView(Context context) { 14 | super(context); 15 | } 16 | 17 | public AutoResizeGridView(Context context, AttributeSet attrs, int defStyle) { 18 | super(context, attrs, defStyle); 19 | } 20 | 21 | @Override //disable scroll 22 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 23 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 24 | super.onMeasure(widthMeasureSpec, expandSpec); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/java/org/heaven7/core/view/AutoResizeListView.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.view; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | import android.widget.ListView; 7 | 8 | /** 9 | * Created by heaven7 on 2015/8/24. 10 | */ 11 | public class AutoResizeListView extends ListView { 12 | public AutoResizeListView(Context context) { 13 | super(context); 14 | } 15 | 16 | public AutoResizeListView(Context context, AttributeSet attrs) { 17 | super(context, attrs); 18 | } 19 | 20 | public AutoResizeListView(Context context, AttributeSet attrs, int defStyleAttr) { 21 | super(context, attrs, defStyleAttr); 22 | } 23 | 24 | @TargetApi(21) 25 | public AutoResizeListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 26 | super(context, attrs, defStyleAttr, defStyleRes); 27 | } 28 | 29 | @Override //disable scroll 30 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 31 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 32 | super.onMeasure(widthMeasureSpec, expandSpec); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/java/org/heaven7/core/view/ExpandScrollView.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.MotionEvent; 6 | import android.view.ViewConfiguration; 7 | import android.widget.ScrollView; 8 | 9 | /** 10 | * 能够兼容ViewPager and 竖直recyclerview 的 ScrollView 11 | * 解决了ViewPager在ScrollView中的滑动反弹问题 12 | */ 13 | public class ExpandScrollView extends ScrollView { 14 | // 滑动距离及坐标 15 | private float xDistance, yDistance, xLast, yLast; 16 | private final int mTouchSlop; 17 | 18 | public ExpandScrollView(Context context, AttributeSet attrs) { 19 | super(context, attrs); 20 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); 21 | } 22 | 23 | @Override 24 | public boolean onInterceptTouchEvent(MotionEvent ev) { 25 | switch (ev.getAction()) { 26 | case MotionEvent.ACTION_DOWN: 27 | xDistance = yDistance = 0f; 28 | xLast = ev.getX(); 29 | yLast = ev.getY(); 30 | break; 31 | case MotionEvent.ACTION_MOVE: 32 | final float curX = ev.getX(); 33 | final float curY = ev.getY(); 34 | 35 | xDistance += Math.abs(curX - xLast); 36 | yDistance += Math.abs(curY - yLast); 37 | xLast = curX; 38 | yLast = curY; 39 | 40 | if(xDistance > yDistance){ 41 | return false; 42 | } 43 | //解决scrollView嵌套 recyclerview 后 recyclerview 惯性滑动消失的问题. 即拦截child的点击事件 44 | if(yDistance > mTouchSlop){ 45 | return true; 46 | } 47 | 48 | } 49 | return super.onInterceptTouchEvent(ev); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common-utils/common-view/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 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | #CCCCCC 19 | #CCCCCC 20 | 21 | 22 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1dp 7 | 1dp 8 | 10dp 9 | 1dp 10 | 6 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /common-utils/common-view/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | common-view 3 | 4 | -------------------------------------------------------------------------------- /common-utils/common-view/src/test/java/draghelper_study/heaven7/com/common_view/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package draghelper_study.heaven7.com.common_view; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:23.1.1' 25 | } 26 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/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 I:\android\sdk2/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 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/src/androidTest/java/study/heaven7/com/commonutil_extra/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package study.heaven7.com.commonutil_extra; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Commonutil-extra 3 | 4 | -------------------------------------------------------------------------------- /common-utils/commonutil-extra/src/test/java/study/heaven7/com/commonutil_extra/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package study.heaven7.com.commonutil_extra; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common-utils/commonutil/.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Android Studio 23 | .idea/ 24 | .gradle 25 | /*/local.properties 26 | /*/out 27 | build 28 | /build 29 | /*/*/production 30 | *.iml 31 | *.iws 32 | *.ipr 33 | *~ 34 | *.swp 35 | -------------------------------------------------------------------------------- /common-utils/commonutil/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 11 9 | targetSdkVersion 22 10 | versionCode 21 11 | versionName "1.8.2" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:22.1.0' 24 | compile "com.android.support:gridlayout-v7:22.1.0" 25 | compile 'com.android.support:recyclerview-v7:22.1.0' 26 | compile 'com.heaven7.volley:volley_with_extra:1.0.1' 27 | } 28 | 29 | //apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle" 30 | apply from: "bintrayUpload.gradle" 31 | -------------------------------------------------------------------------------- /common-utils/commonutil/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 I:\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 | -------------------------------------------------------------------------------- /common-utils/commonutil/project.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/commonutil/project.properties -------------------------------------------------------------------------------- /common-utils/commonutil/src/androidTest/java/org/heaven7/core/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/BaseAdapterHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 3 | * heaven7(donshine723@gmail.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.heaven7.core.adapter; 18 | 19 | import android.content.Context; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | 24 | import org.heaven7.core.viewhelper.ViewHelper; 25 | 26 | /** 27 | * base adapter helper. write this based on Joan Zapata's 'base-adapter-helper' 28 | * and change something for easily use. use can see the source of his in github. 29 | * @author heaven7 30 | * 31 | */ 32 | /*public*/ class BaseAdapterHelper { 33 | 34 | public int position; 35 | private int layoutId; 36 | private ViewHelper mViewHelper; 37 | 38 | public BaseAdapterHelper(ViewGroup parent, int layoutId,int mPosition) { 39 | super(); 40 | Context context = parent.getContext(); 41 | this.position = mPosition; 42 | this.layoutId = layoutId; 43 | View root = LayoutInflater.from(context).inflate(layoutId, parent, false); 44 | root.setTag(this); 45 | mViewHelper = new ViewHelper(root); 46 | } 47 | public BaseAdapterHelper(View item,int mPosition) { 48 | super(); 49 | this.position = mPosition; 50 | item.setTag(this); 51 | mViewHelper = new ViewHelper(item); 52 | } 53 | 54 | public Context getContext(){ 55 | return mViewHelper.getContext(); 56 | } 57 | public int getPosition(){ 58 | return position; 59 | } 60 | public int getLayoutId(){ 61 | return layoutId; 62 | } 63 | 64 | /** 65 | * @since 1.8.0 66 | */ 67 | public int getMenuLayoutId(){ 68 | return 0; 69 | } 70 | 71 | public ViewHelper getViewHelper(){ 72 | return mViewHelper; 73 | } 74 | 75 | // ================================================== // 76 | 77 | public static BaseAdapterHelper get(View convertView, 78 | ViewGroup parent, int layoutId){ 79 | return get(convertView, parent, layoutId, -1); 80 | } 81 | 82 | public static BaseAdapterHelper get(View convertView, 83 | ViewGroup parent, int layoutId, int position) { 84 | if (convertView == null) { 85 | return new BaseAdapterHelper(parent, layoutId, position); 86 | } 87 | 88 | // Retrieve the existing helper and update its position 89 | BaseAdapterHelper existingHelper = (BaseAdapterHelper) convertView 90 | .getTag(); 91 | 92 | if (existingHelper.layoutId != layoutId) { 93 | return new BaseAdapterHelper(parent, layoutId, position); 94 | } 95 | // RatingBar 96 | existingHelper.position = position; 97 | return existingHelper; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/BaseSelector.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | /** 4 | * this class just implements the interface ISelectable . not the state selector of android resource . 5 | * Created by heaven7 on 2016/1/9. 6 | */ 7 | public class BaseSelector implements ISelectable { 8 | 9 | private boolean selected; 10 | 11 | @Override 12 | public void setSelected(boolean selected) { 13 | this.selected = selected; 14 | } 15 | 16 | @Override 17 | public boolean isSelected() { 18 | return selected; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/BaseSwipeAdapterHelper.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | import android.support.annotation.LayoutRes; 4 | import android.view.ViewGroup; 5 | 6 | /** 7 | * Created by heaven7 on 2016/1/29. 8 | * @since 1.8.0 9 | */ 10 | /*public*/ class BaseSwipeAdapterHelper extends BaseAdapterHelper { 11 | 12 | private final SwipeHelper mSwiperHelper; 13 | 14 | public BaseSwipeAdapterHelper(ViewGroup parent,@LayoutRes int mainLayoutId, 15 | @LayoutRes int menuLayoutId, int mTrackingEdges, 16 | int position, SwipeHelper.OnSwipeStateChangeListener l){ 17 | this(new SwipeHelper(parent, mainLayoutId, menuLayoutId, mTrackingEdges), position); 18 | mSwiperHelper.setOnSwipeStateChangeListener(l); 19 | } 20 | 21 | private BaseSwipeAdapterHelper(SwipeHelper sh, int mPosition) { 22 | super(sh.getItemView(), mPosition); 23 | this.mSwiperHelper = sh; 24 | } 25 | 26 | @Override 27 | public int getLayoutId() { 28 | return mSwiperHelper.getMainLayoutId(); 29 | } 30 | 31 | @Override 32 | public int getMenuLayoutId() { 33 | return mSwiperHelper.getMenuLayoutId(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/ISelectable.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | /** 4 | * Created by heaven7 on 2015/9/2. 5 | */ 6 | public interface ISelectable { 7 | 8 | int SELECT_MODE_SINGLE = 1; 9 | int SELECT_MODE_MULTI = 2; 10 | 11 | int INVALID_POSITION = -1; 12 | 13 | void setSelected(boolean selected); 14 | boolean isSelected(); 15 | } 16 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/ISwipeMultiItemTypeSupport.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | /** 4 | * for base adapter support swipe. this is a expand class of {@link MultiItemTypeSupport} 5 | * Created by heaven7 on 2016/1/29. 6 | * @since 1.8.0 7 | */ 8 | public interface ISwipeMultiItemTypeSupport extends MultiItemTypeSupport{ 9 | 10 | /** 11 | * get the menu layout id 12 | * @param position the position 13 | * @param mainLayoutId the layout id of main item 14 | * @param t the T 15 | */ 16 | int getMenuLayoutId(int position, int mainLayoutId, T t); 17 | } 18 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/MultiItemTypeSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 3 | * heaven7(donshine723@gmail.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.heaven7.core.adapter; 18 | 19 | import android.support.annotation.LayoutRes; 20 | 21 | /** 22 | * used to multi item support. such as: Listview contains two items 23 | * @author heaven7 24 | * 25 | * @param 26 | */ 27 | public interface MultiItemTypeSupport { 28 | 29 | @LayoutRes int getLayoutId(int position, T t); 30 | 31 | int getViewTypeCount(); 32 | 33 | int getItemViewType(int postion, T t); 34 | } 35 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/NetworkImagePagerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.DrawableRes; 5 | import android.support.v4.view.PagerAdapter; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | 10 | import com.android.volley.extra.ExpandNetworkImageView; 11 | import com.android.volley.extra.RoundedBitmapBuilder; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | /** 17 | * this is a troll image pager adapter . 18 | * Created by heaven7 on 2016/2/1. 19 | * @since 1.8.1 20 | */ 21 | public class NetworkImagePagerAdapter 22 | extends PagerAdapter { 23 | 24 | private List datas; 25 | private List mImageViews; 26 | private final int mPlaceHolder; 27 | private final int mErrorRes; 28 | 29 | public NetworkImagePagerAdapter(Context context, List datas, 30 | @DrawableRes int placeHolderRes){ 31 | this(context,datas,placeHolderRes,placeHolderRes); 32 | } 33 | 34 | public NetworkImagePagerAdapter(Context context, List datas, 35 | @DrawableRes int placeHolderRes,@DrawableRes int errorRes) { 36 | this.mPlaceHolder = placeHolderRes; 37 | this.mErrorRes = errorRes; 38 | this.datas = datas; 39 | this.mImageViews = new ArrayList<>(); 40 | for(int i=0,size = datas.size() ; i 28 | * Using the provided BaseAdapterHelper, your code is minimalist. 29 | * 30 | * @param 31 | * The type of the items in the list. 32 | */ 33 | public abstract class QuickAdapter extends 34 | BaseQuickAdapter { 35 | 36 | /** 37 | * Same as QuickAdapter#QuickAdapter(Context,int) but with some 38 | * initialization data. 39 | * 40 | * @param layoutResId 41 | * The layout resource id of each item. 42 | * @param data 43 | * A new list is created out of this one to avoid mutable list 44 | */ 45 | public QuickAdapter(int layoutResId, List data) { 46 | this(layoutResId, data, ISelectable.SELECT_MODE_SINGLE); 47 | } 48 | public QuickAdapter(int layoutResId, List data,int selectMode) { 49 | super(layoutResId, data, selectMode); 50 | } 51 | 52 | /** 53 | * default select mode is {@link ISelectable#SELECT_MODE_SINGLE} 54 | * @param data the data to populate 55 | * @param multiItemSupport the multi itemsupport 56 | */ 57 | public QuickAdapter(ArrayList data, 58 | MultiItemTypeSupport multiItemSupport) { 59 | this(data, multiItemSupport, ISelectable.SELECT_MODE_SINGLE); 60 | } 61 | 62 | /** 63 | * @param data the data to populate 64 | * @param multiItemSupport the multi itemsupport 65 | * @param selectMode the select mode ,{@link ISelectable#SELECT_MODE_SINGLE} or {@link ISelectable#SELECT_MODE_MULTI} 66 | */ 67 | public QuickAdapter(ArrayList data, 68 | MultiItemTypeSupport multiItemSupport,int selectMode) { 69 | super(data, multiItemSupport, selectMode); 70 | } 71 | 72 | @Override 73 | protected BaseAdapterHelper getAdapterHelper(int position, 74 | View convertView, ViewGroup parent) { 75 | 76 | if (mMultiItemSupport != null) { 77 | return BaseAdapterHelper.get( 78 | convertView, 79 | parent, 80 | mMultiItemSupport.getLayoutId(position, getAdapterManager().getItems().get(position)), 81 | position); 82 | } else { 83 | return BaseAdapterHelper.get(convertView, parent, layoutResId, position); 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/ResizeHeightPostCallback.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | import android.support.v7.widget.GridLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.support.v7.widget.StaggeredGridLayoutManager; 6 | import android.util.SparseIntArray; 7 | 8 | import org.heaven7.core.viewhelper.ViewHelper; 9 | 10 | import java.lang.ref.WeakReference; 11 | 12 | /** 13 | *

14 | * this callback help you resize the height of RecyclerView. this is useful while ScrollView nested 15 | * RecyclerView with GridLayoutManager or StaggeredGridLayoutManager. but in layout xml you should define 16 | * a opportune height to RecyclerView, not wrap_content. 17 | *

18 | * Created by heaven7 on 2016/1/14. 19 | * @since 1.7.5 20 | */ 21 | public class ResizeHeightPostCallback implements AdapterManager.IPostRunnableCallback{ 22 | 23 | private final SparseIntArray mSizeMap = new SparseIntArray(); 24 | private final WeakReference mWeakRecyclerView; 25 | 26 | public ResizeHeightPostCallback(RecyclerView rv){ 27 | mWeakRecyclerView = new WeakReference(rv); 28 | } 29 | 30 | 31 | @Override 32 | public void onPostCallback(int position, T item, int itemLayoutId, ViewHelper helper) { 33 | RecyclerView rv ; 34 | if( ( rv = mWeakRecyclerView.get()) == null){ 35 | return; 36 | } 37 | mSizeMap.put(position,rv.getLayoutManager().getDecoratedMeasuredHeight(helper.getRootView())); 38 | rv.getLayoutParams().height = calculateHeight(rv.getLayoutManager(),mSizeMap); 39 | rv.requestLayout(); 40 | } 41 | 42 | /** 43 | * @param lm the LayoutManager of LayoutManager 44 | * @param heightMap the height map , key is position,value is the height of position 45 | * @return the new height of RecyclerView 46 | */ 47 | protected int calculateHeight(RecyclerView.LayoutManager lm, SparseIntArray heightMap){ 48 | int spanCount = 1; 49 | if(lm instanceof GridLayoutManager){ 50 | spanCount = ((GridLayoutManager) lm).getSpanCount(); 51 | }else if(lm instanceof StaggeredGridLayoutManager){ 52 | spanCount = ((StaggeredGridLayoutManager) lm).getSpanCount(); 53 | } 54 | final int mapSize = heightMap.size(); 55 | int total = 0; 56 | for(int i = 0 ,size = mapSize % spanCount == 0 ? mapSize / spanCount: 57 | mapSize /spanCount + 1; i < size ; i++){ 58 | total = total + heightMap.valueAt(i); 59 | } 60 | return total; 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/SimpleFragmentPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by heaven7 on 2015/12/31. 11 | */ 12 | public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter { 13 | 14 | final List mFragments; 15 | 16 | public SimpleFragmentPagerAdapter(FragmentManager fm, List fragmentList) { 17 | super(fm); 18 | this.mFragments = fragmentList; 19 | } 20 | 21 | @Override 22 | public Fragment getItem(int position) { 23 | return mFragments.get(position); 24 | } 25 | 26 | @Override 27 | public int getCount() { 28 | return mFragments.size(); 29 | } 30 | 31 | @Override 32 | public int getItemPosition(Object object) { 33 | return POSITION_NONE; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/adapter/SimpleSwipeStateChangeListener.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.adapter; 2 | 3 | /** this class help to make single swipe operation. 4 | * Created by heaven7 on 2016/1/29. 5 | * @since 1.8.0 6 | */ 7 | /*public*/ class SimpleSwipeStateChangeListener implements SwipeHelper.OnSwipeStateChangeListener { 8 | 9 | private SwipeHelper.ISwipeManager mLastSm; 10 | 11 | public SimpleSwipeStateChangeListener() { 12 | } 13 | 14 | @Override 15 | public void onSwipeStateChange(SwipeHelper.ISwipeManager swipeManager, int swipeState) { 16 | switch (swipeState){ 17 | case SwipeHelper.STATE_CLOSE: 18 | //ignore 19 | break; 20 | 21 | case SwipeHelper.STATE_OPNE: 22 | //close previous 23 | if(mLastSm != null){ 24 | mLastSm.close(); 25 | } 26 | mLastSm = swipeManager; 27 | break; 28 | 29 | default: 30 | throw new RuntimeException("can't reach here"); 31 | } 32 | } 33 | 34 | /** 35 | * return true when try to close the opened swipe item success . */ 36 | public boolean closeSwipeIfNeed(){ 37 | if(mLastSm != null){ 38 | mLastSm.close(); 39 | mLastSm = null; 40 | return true; 41 | } 42 | return false; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/anno/Hide.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * this indicate the class/method/filed called by system or other framework. 10 | * so user should not call it. 11 | * Created by heaven7 on 2016/1/8. 12 | */ 13 | @Target( { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,ElementType.CONSTRUCTOR }) 14 | @Retention( RetentionPolicy.CLASS ) 15 | public @interface Hide { 16 | } 17 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/helper/BundleHelper.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.helper; 2 | 3 | import android.os.Bundle; 4 | import android.os.Parcelable; 5 | import android.support.v4.app.Fragment; 6 | 7 | import java.io.Serializable; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by heaven7 on 2015/10/10. 13 | */ 14 | public class BundleHelper { 15 | 16 | private final Bundle b = new Bundle(); 17 | 18 | public BundleHelper putInt(String key,int val){ 19 | b.putInt(key,val); 20 | return this; 21 | } 22 | public BundleHelper putString(String key,String val){ 23 | b.putString(key, val); 24 | return this; 25 | } 26 | public BundleHelper putFloat(String key,float val){ 27 | b.putFloat(key, val); 28 | return this; 29 | } 30 | public BundleHelper putLong(String key,long val){ 31 | b.putLong(key, val); 32 | return this; 33 | } 34 | public BundleHelper putDouble(String key,double val){ 35 | b.putDouble(key, val); 36 | return this; 37 | } 38 | 39 | public BundleHelper putSerializable(String key,Serializable data){ 40 | b.putSerializable(key, data); 41 | return this; 42 | } 43 | public BundleHelper putParcelable(String key,Parcelable data){ 44 | b.putParcelable(key, data); 45 | return this; 46 | } 47 | 48 | public Bundle getBundle(){ 49 | return b; 50 | } 51 | 52 | public T into(T fragment){ 53 | fragment.setArguments(getBundle()); 54 | return fragment; 55 | } 56 | public T into(T fragment){ 57 | fragment.setArguments(getBundle()); 58 | return fragment; 59 | } 60 | 61 | public BundleHelper putStringArrayList(String key,List imageUrls) { 62 | b.putStringArrayList(key, imageUrls != null && imageUrls.size() > 0 63 | ? new ArrayList<>(imageUrls) : null); 64 | return this; 65 | } 66 | 67 | public BundleHelper putBoolean(String key , boolean value) { 68 | b.putBoolean(key ,value); 69 | return this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/item/decoration/AbstractDividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.item.decoration; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | /** 6 | * Created by heaven7 on 2016/1/6. 7 | */ 8 | public abstract class AbstractDividerItemDecoration extends RecyclerView.ItemDecoration{ 9 | 10 | private final IDividerManager mDividerManager; 11 | 12 | public AbstractDividerItemDecoration() { 13 | mDividerManager = new DividerManagerImpl(); 14 | } 15 | 16 | public IDividerManager getDividerManager() { 17 | return mDividerManager; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/item/decoration/DividerManagerImpl.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.item.decoration; 2 | 3 | import android.graphics.drawable.ColorDrawable; 4 | import android.graphics.drawable.Drawable; 5 | 6 | /** 7 | * this is the devider helper , help you manage it. 8 | * Created by heaven7 on 2016/1/6. 9 | */ 10 | /*public*/ class DividerManagerImpl implements IDividerManager { 11 | 12 | private Drawable mDivider; 13 | 14 | private int mDivideWidth ; 15 | private int mDivideHeight; 16 | 17 | @Override 18 | public void setDivider(Drawable divider){ 19 | this.mDivider = divider; 20 | this.mDivideWidth = divider.getIntrinsicWidth(); 21 | this.mDivideHeight = divider.getIntrinsicHeight(); 22 | } 23 | 24 | @Override 25 | public void setDivider(int color, int widthInVertical, int heightInHorizontal){ 26 | if(widthInVertical <0 || heightInHorizontal < 0 ) 27 | throw new IllegalArgumentException(); 28 | this.mDivider = new ColorDrawable(color); 29 | this.mDivideWidth = widthInVertical; 30 | this.mDivideHeight = heightInHorizontal; 31 | } 32 | 33 | @Override 34 | public Drawable getDivider(){ 35 | return mDivider; 36 | } 37 | 38 | @Override 39 | public int getDividerWidth(){ 40 | return mDivideWidth; 41 | } 42 | @Override 43 | public int getDividerHeight(){ 44 | return mDivideHeight; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/item/decoration/IDividerManager.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.item.decoration; 2 | 3 | import android.graphics.drawable.Drawable; 4 | 5 | /** 6 | * Created by heaven7 on 2016/1/6. 7 | */ 8 | public interface IDividerManager { 9 | 10 | /** 11 | * set the divider 12 | */ 13 | void setDivider(Drawable divider); 14 | 15 | /** 16 | * set the divider 17 | * @param color the divider color 18 | * @param widthInVertical divider width in vertical layout 19 | * @param heightInHorizontal divider height in horizontal layout 20 | */ 21 | void setDivider(int color, int widthInVertical, int heightInHorizontal); 22 | 23 | Drawable getDivider(); 24 | 25 | int getDividerWidth(); 26 | 27 | int getDividerHeight(); 28 | } 29 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/save_state/BundleSupportType.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.save_state; 2 | 3 | /** 4 | * constant 5 | */ 6 | public interface BundleSupportType { 7 | int IBINDER = 1; // must >= api-18 8 | int BUNDLE = 2; 9 | 10 | int BYTE = 3; 11 | int BYTE_ARRAY = 4; 12 | int FLOAT = 5; 13 | int FLOAT_ARRAY = 6; 14 | int INT = 7; 15 | int INT_ARRAY = 8; 16 | int SHORT = 9; 17 | int SHORT_ARRAY = 10; 18 | int CHAR = 11; 19 | int CHAR_ARRAY = 12; 20 | int LONG = 13; 21 | int LONG_ARRAY = 14; 22 | int BOOLEAN = 16; 23 | int BOOLEAN_ARRAY = 17; 24 | int DOUBLE = 18; 25 | int DOUBLE_ARRAY = 19; 26 | 27 | int INTEGER_ARRAY_lIST = 15; 28 | 29 | int STRING = 20; 30 | int STRING_ARRAY = 21; 31 | int STRING_ARRAY_LIST = 22; 32 | 33 | int CHAR_SEQUENCE = 31; 34 | int CHAR_SEQUENCE_ARRAY = 32; 35 | int CHAR_SEQUENCE_ARRAY_LIST = 33; 36 | 37 | int PARCELABLE = 34; 38 | int PARCELABLE_ARRAY_LIST = 35; 39 | int PARCELABLE_LIST = 36; 40 | int PARCELABLE_ARRAY = 37; 41 | 42 | int SERIALIZABLE = 38; 43 | int SPARSE_PARCELABLE_ARRAY = 39; 44 | } 45 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/save_state/BundleSupportTypeFlag.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.save_state; 2 | 3 | import android.support.annotation.IntDef; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | @IntDef(value = { 9 | BundleSupportType.BYTE, 10 | BundleSupportType.BYTE_ARRAY, 11 | BundleSupportType.FLOAT, 12 | BundleSupportType.FLOAT_ARRAY, 13 | BundleSupportType.INT, 14 | BundleSupportType.INT_ARRAY, 15 | BundleSupportType.LONG, 16 | BundleSupportType.LONG_ARRAY, 17 | BundleSupportType.SHORT, 18 | BundleSupportType.SHORT_ARRAY, 19 | BundleSupportType.CHAR, 20 | BundleSupportType.CHAR_ARRAY, 21 | BundleSupportType.BOOLEAN, 22 | BundleSupportType.BOOLEAN_ARRAY, 23 | BundleSupportType.DOUBLE, 24 | BundleSupportType.DOUBLE_ARRAY, 25 | 26 | BundleSupportType.STRING, 27 | BundleSupportType.STRING_ARRAY, 28 | BundleSupportType.CHAR_SEQUENCE, 29 | BundleSupportType.CHAR_SEQUENCE_ARRAY, 30 | BundleSupportType.PARCELABLE, 31 | BundleSupportType.PARCELABLE_ARRAY, 32 | 33 | BundleSupportType.IBINDER, 34 | BundleSupportType.BUNDLE, 35 | BundleSupportType.SERIALIZABLE, 36 | BundleSupportType.SPARSE_PARCELABLE_ARRAY, 37 | 38 | BundleSupportType.INTEGER_ARRAY_lIST, 39 | BundleSupportType.STRING_ARRAY_LIST, 40 | BundleSupportType.PARCELABLE_ARRAY_LIST, 41 | BundleSupportType.PARCELABLE_LIST, 42 | BundleSupportType.CHAR_SEQUENCE_ARRAY_LIST, 43 | }) 44 | @Retention(RetentionPolicy.CLASS) 45 | public @interface BundleSupportTypeFlag { 46 | } 47 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/save_state/SaveFieldInfo.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.save_state; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | /*public*/ class SaveFieldInfo { 6 | Field field; 7 | SaveStateField saveField; 8 | int type; 9 | 10 | public SaveFieldInfo(Field f, SaveStateField saveField, int type) { 11 | this.field = f; 12 | this.saveField = saveField; 13 | this.type = type; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/save_state/SaveStateField.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.save_state; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /*** 9 | * useful to quick save state and restore it from bundle 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.FIELD) 13 | public @interface SaveStateField { 14 | /** 15 | * the key used to save data into bundle or restore data from bundle. 16 | */ 17 | String value(); 18 | 19 | /** 20 | * the flag indicate the value type 21 | */ 22 | @BundleSupportTypeFlag int flag() default BundleSupportType.STRING; 23 | } 24 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/save_state/SaveStateHelper.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.save_state; 2 | 3 | import android.os.Bundle; 4 | 5 | import java.lang.reflect.Field; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class SaveStateHelper { 10 | 11 | private final List mSaveInfos; 12 | private final Object mHolder; 13 | 14 | /** 15 | * @param holder may be activity or fragment 16 | */ 17 | public SaveStateHelper(Object holder) { 18 | this.mHolder = holder; 19 | mSaveInfos = new ArrayList<>(); 20 | init(holder); 21 | } 22 | 23 | private void init(Object holder) { 24 | Field[] fields = holder.getClass().getDeclaredFields(); 25 | if (fields == null || fields.length == 0) 26 | return; 27 | List infos = this.mSaveInfos; 28 | SaveStateField sf; 29 | for (int i = 0, size = fields.length; i < size; i++) { 30 | Field f = fields[i]; 31 | f.setAccessible(true); 32 | sf = f.getAnnotation(SaveStateField.class); 33 | if (sf == null) 34 | continue; 35 | infos.add(new SaveFieldInfo(f, sf, SaveStateUtil.getFlag(f, sf.flag()))); 36 | } 37 | } 38 | 39 | public void onSaveInstanceState(Bundle outState) { 40 | List mSaveInfos = this.mSaveInfos; 41 | SaveFieldInfo info; 42 | Object holder = this.mHolder; 43 | for (int i = 0, size = mSaveInfos.size(); i < size; i++) { 44 | info = mSaveInfos.get(i); 45 | SaveStateUtil.doSaveState(outState, info, holder); 46 | } 47 | } 48 | 49 | public void onRestoreInstanceState(Bundle savedInstanceState) { 50 | if (savedInstanceState == null) 51 | return; 52 | List mSaveInfos = this.mSaveInfos; 53 | SaveFieldInfo info; 54 | Object holder = this.mHolder; 55 | for (int i = 0, size = mSaveInfos.size(); i < size; i++) { 56 | info = mSaveInfos.get(i); 57 | SaveStateUtil.doRestoreState(savedInstanceState, info, holder); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/DialogHelper.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.util; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.Context; 6 | import android.content.DialogInterface; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.widget.TextView; 10 | 11 | import org.heaven7.core.viewhelper.ViewHelper; 12 | 13 | 14 | /** 15 | * Created by heaven7 on 2015/8/31. 16 | */ 17 | public class DialogHelper { 18 | 19 | private AlertDialog mDialog; 20 | private ViewHelper mViewHelper; 21 | 22 | public DialogHelper createFrom(Context ctx,int layoutId){ 23 | final View view = LayoutInflater.from(ctx).inflate(layoutId, null); 24 | mViewHelper = new ViewHelper(view); 25 | mDialog = new AlertDialog.Builder(ctx,AlertDialog.THEME_HOLO_LIGHT) 26 | .setView(view).setCancelable(true).create(); 27 | mDialog.setCanceledOnTouchOutside(true); 28 | return this; 29 | } 30 | 31 | public DialogHelper setOnClickListener(int viewId, View.OnClickListener l){ 32 | mViewHelper.setOnClickListener(viewId, l); 33 | return this; 34 | } 35 | 36 | public String getTextById(int textId){ 37 | return ((TextView)mViewHelper.getView(textId)).getText().toString(); 38 | } 39 | 40 | public ViewHelper getViewHelper(){ 41 | return mViewHelper; 42 | } 43 | 44 | public AlertDialog show(){ 45 | mDialog.show(); 46 | return mDialog; 47 | } 48 | 49 | public boolean isShowing(){ 50 | return mDialog!=null && mDialog.isShowing(); 51 | } 52 | 53 | public void dismiss(){ 54 | if(mDialog!=null && mDialog.isShowing()){ 55 | mDialog.dismiss(); 56 | mDialog = null; 57 | } 58 | } 59 | 60 | public T getView(int viewId) { 61 | return mViewHelper.getView(viewId); 62 | } 63 | 64 | public DialogHelper setCancelable(boolean cancelable) { 65 | if(mDialog!=null){ 66 | mDialog.setCancelable(cancelable); 67 | } 68 | return this; 69 | } 70 | public DialogHelper setCanceledOnTouchOutside(boolean cancel) { 71 | if(mDialog!=null){ 72 | mDialog.setCanceledOnTouchOutside(cancel); 73 | } 74 | return this; 75 | } 76 | public DialogHelper setOnCancelListener(DialogInterface.OnCancelListener l) { 77 | if(mDialog!=null){ 78 | mDialog.setOnCancelListener(l); 79 | } 80 | return this; 81 | } 82 | 83 | public static void dismissDialog(Dialog d){ 84 | if(d!=null && d.isShowing()){ 85 | d.dismiss(); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.util; 2 | 3 | import android.annotation.SuppressLint; 4 | 5 | import java.security.MessageDigest; 6 | import java.security.NoSuchAlgorithmException; 7 | 8 | public class MD5Util { 9 | 10 | private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 11 | 'A', 'B', 'C', 'D', 'E', 'F' }; 12 | public static String toHexString(byte[] b) { 13 | StringBuilder sb = new StringBuilder(b.length * 2); 14 | for (int i = 0; i < b.length; i++) { 15 | sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]); 16 | sb.append(HEX_DIGITS[b[i] & 0x0f]); 17 | } 18 | return sb.toString(); 19 | } 20 | 21 | /** 22 | * MD5加密 23 | * @param message 要加密的字符串 24 | */ 25 | @SuppressLint("DefaultLocale") 26 | public static String encode(String message){ 27 | MessageDigest md5 = null; 28 | try { 29 | md5 = MessageDigest.getInstance("MD5"); 30 | } catch (NoSuchAlgorithmException e) { 31 | e.printStackTrace(); 32 | return ""; 33 | } 34 | byte[] result = md5.digest(message.getBytes()); 35 | return toHexString(result).toLowerCase(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/MainWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 3 | * heaven7(donshine723@gmail.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.heaven7.core.util; 18 | 19 | import android.os.Handler; 20 | import android.os.Looper; 21 | 22 | /**the all post runnables will run on main thread. 23 | * @author heaven7 24 | */ 25 | public class MainWorker { 26 | 27 | public static final Handler MainHandler = new Handler(Looper.getMainLooper()); 28 | 29 | public static void post(Runnable r){ 30 | if(currentIsMainThread()){ 31 | r.run(); 32 | }else{ 33 | MainHandler.post(r); 34 | } 35 | } 36 | public static void postAtfront(Runnable r){ 37 | MainHandler.postAtFrontOfQueue(r); 38 | } 39 | 40 | public static boolean currentIsMainThread(){ 41 | return Thread.currentThread() == Looper.getMainLooper().getThread(); 42 | } 43 | 44 | public static void remove(Runnable r){ 45 | MainHandler.removeCallbacks(r); 46 | } 47 | 48 | public static void postDelay(long delay,Runnable r){ 49 | MainHandler.postDelayed(r, delay); 50 | } 51 | 52 | public static void removePreviousAndPost(Runnable r){ 53 | MainHandler.removeCallbacks(r); 54 | MainHandler.post(r); 55 | } 56 | public static void removePreviousAndPostDelay(long delayMills,Runnable r){ 57 | MainHandler.removeCallbacks(r); 58 | MainHandler.postDelayed(r,delayMills); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/ResourceUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 3 | * heaven7(donshine723@gmail.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.heaven7.core.util; 18 | 19 | import android.content.Context; 20 | 21 | public class ResourceUtil { 22 | 23 | /** if you use shard uid(eg: android:sharedUserId="com.heaven7.skin"), 24 | * package name must be target package name*/ 25 | public static int getRemoteResId(Context ctx,String packageName,String resName,ResourceType type){ 26 | return ctx.getResources().getIdentifier(resName, type.name,packageName); 27 | } 28 | public static int getResId(Context ctx,String resName,ResourceType type){ 29 | return ctx.getResources().getIdentifier(resName, type.name,ctx.getPackageName()); 30 | } 31 | 32 | public enum ResourceType{ 33 | Layout("layout"),Id("id"),Style("style"),String("string"), 34 | Drawable("drawable"),Color("color"),Dimen("dimen"), 35 | Raw("raw"),StringArray("array"),Anim("anim"),Menu("menu"), 36 | Animator("animator"),Interpolator("interpolator"),Xml("xml"), 37 | Transition("transition") 38 | ; 39 | 40 | public final String name; 41 | ResourceType(String name) { 42 | this.name = name; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/TextWatcherAdapter.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.util; 2 | 3 | import android.text.Editable; 4 | import android.text.TextWatcher; 5 | 6 | /** 7 | * Created by heaven7 on 2015/9/2. 8 | */ 9 | public abstract class TextWatcherAdapter implements TextWatcher { 10 | @Override 11 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 12 | } 13 | 14 | @Override 15 | public void onTextChanged(CharSequence s, int start, int before, int count) { 16 | } 17 | 18 | @Override 19 | public void afterTextChanged(Editable s) { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/ViewCompatUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 3 | * heaven7(donshine723@gmail.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.heaven7.core.util; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.graphics.drawable.Drawable; 21 | import android.os.Build; 22 | import android.view.View; 23 | import android.view.animation.AlphaAnimation; 24 | 25 | public class ViewCompatUtil { 26 | 27 | @SuppressWarnings("deprecation") 28 | @SuppressLint("NewApi") 29 | public static void setBackgroundCompatible(View v, Drawable d) { 30 | if (Build.VERSION.SDK_INT >= 16) 31 | v.setBackground(d); 32 | else 33 | v.setBackgroundDrawable(d); 34 | } 35 | 36 | public static void setAlpha(View v, float value) { 37 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 38 | v.setAlpha(value); 39 | } else { 40 | // Pre-honeycomb hack to set Alpha value 41 | AlphaAnimation alpha = new AlphaAnimation(value, value); 42 | alpha.setDuration(0); 43 | alpha.setFillAfter(true); 44 | v.startAnimation(alpha); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/java/org/heaven7/core/util/WeakHandler.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.core.util; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | import java.lang.ref.WeakReference; 7 | 8 | /** 9 | * Created by heaven7 on 2016/1/26. 10 | */ 11 | public abstract class WeakHandler extends Handler { 12 | 13 | private final WeakReference mWeakRef; 14 | 15 | public WeakHandler(T t) { 16 | this.mWeakRef = new WeakReference(t); 17 | } 18 | 19 | public WeakHandler(Looper looper,T t) { 20 | super(looper); 21 | this.mWeakRef = new WeakReference(t); 22 | } 23 | 24 | public T get(){ 25 | return mWeakRef.get(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /common-utils/commonutil/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CommonUtil 3 | 4 | -------------------------------------------------------------------------------- /common-utils/gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/gradle.properties -------------------------------------------------------------------------------- /common-utils/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /common-utils/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 02 17:29:45 CST 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.4-all.zip 7 | -------------------------------------------------------------------------------- /common-utils/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 | -------------------------------------------------------------------------------- /common-utils/log.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1, swipelistview have bugs . so it is Deprecated. 4 | 5 | 2. com.baidu.location.a that does't come with an associated enclosingMethod attribute 有重复的jar 6 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 23 10 | versionCode 2 11 | versionName "1.0.1" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:23.1.1' 25 | } 26 | 27 | apply from: "bintrayUpload.gradle" 28 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/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 I:\android\sdk2/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 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/project.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/pulltorefresh-swipe/project.properties -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/androidTest/java/study/heaven7/com/pulltorefresh_swipe/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package study.heaven7.com.pulltorefresh_swipe; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/java/com/heaven7/pulltorefresh/swipe/RefreshTime.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.pulltorefresh.swipe; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.content.SharedPreferences.Editor; 6 | 7 | public class RefreshTime { 8 | final static String PRE_NAME = "heaven7_swipe_refresh_time"; 9 | final static String SET_FRESHTIME = "heaven7_swipe_set_refresh_time"; 10 | 11 | public static String getRefreshTime(Context context) { 12 | SharedPreferences preferences = context.getSharedPreferences(PRE_NAME, Context.MODE_APPEND); 13 | return preferences.getString(SET_FRESHTIME, ""); 14 | } 15 | 16 | public static void setRefreshTime(Context context, String newPasswd) { 17 | SharedPreferences preferences = context.getSharedPreferences(PRE_NAME, Context.MODE_APPEND); 18 | Editor editor = preferences.edit(); 19 | editor.putString(SET_FRESHTIME, newPasswd); 20 | editor.commit(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/java/com/heaven7/pulltorefresh/swipe/SwipeMenu.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.pulltorefresh.swipe; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import android.content.Context; 7 | 8 | public class SwipeMenu { 9 | 10 | private Context mContext; 11 | private List mItems; 12 | private int mViewType; 13 | 14 | public SwipeMenu(Context context) { 15 | mContext = context; 16 | mItems = new ArrayList(); 17 | } 18 | 19 | public Context getContext() { 20 | return mContext; 21 | } 22 | 23 | public void addMenuItem(SwipeMenuItem item) { 24 | mItems.add(item); 25 | } 26 | 27 | public void removeMenuItem(SwipeMenuItem item) { 28 | mItems.remove(item); 29 | } 30 | 31 | public List getMenuItems() { 32 | return mItems; 33 | } 34 | 35 | public SwipeMenuItem getMenuItem(int index) { 36 | return mItems.get(index); 37 | } 38 | 39 | public int getViewType() { 40 | return mViewType; 41 | } 42 | 43 | public void setViewType(int viewType) { 44 | this.mViewType = viewType; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/java/com/heaven7/pulltorefresh/swipe/SwipeMenuCreator.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.pulltorefresh.swipe; 2 | 3 | public interface SwipeMenuCreator { 4 | 5 | void create(SwipeMenu menu); 6 | } 7 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/java/com/heaven7/pulltorefresh/swipe/SwipeMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.pulltorefresh.swipe; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | 6 | public class SwipeMenuItem { 7 | 8 | private int id; 9 | private Context mContext; 10 | private String title; 11 | private Drawable icon; 12 | private Drawable background; 13 | private int titleColor; 14 | private int titleSize; 15 | private int width; 16 | 17 | public SwipeMenuItem(Context context) { 18 | mContext = context; 19 | } 20 | 21 | public int getId() { 22 | return id; 23 | } 24 | 25 | public void setId(int id) { 26 | this.id = id; 27 | } 28 | 29 | public int getTitleColor() { 30 | return titleColor; 31 | } 32 | 33 | public int getTitleSize() { 34 | return titleSize; 35 | } 36 | 37 | public void setTitleSize(int titleSize) { 38 | this.titleSize = titleSize; 39 | } 40 | 41 | public void setTitleColor(int titleColor) { 42 | this.titleColor = titleColor; 43 | } 44 | 45 | public String getTitle() { 46 | return title; 47 | } 48 | 49 | public void setTitle(String title) { 50 | this.title = title; 51 | } 52 | 53 | public void setTitle(int resId) { 54 | setTitle(mContext.getString(resId)); 55 | } 56 | 57 | public Drawable getIcon() { 58 | return icon; 59 | } 60 | 61 | public void setIcon(Drawable icon) { 62 | this.icon = icon; 63 | } 64 | 65 | public void setIcon(int resId) { 66 | this.icon = mContext.getResources().getDrawable(resId); 67 | } 68 | 69 | public Drawable getBackground() { 70 | return background; 71 | } 72 | 73 | public void setBackground(Drawable background) { 74 | this.background = background; 75 | } 76 | 77 | public void setBackground(int resId) { 78 | this.background = mContext.getResources().getDrawable(resId); 79 | } 80 | 81 | public int getWidth() { 82 | return width; 83 | } 84 | 85 | public void setWidth(int width) { 86 | this.width = width; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/java/com/heaven7/pulltorefresh/swipe/SwipeMenuView.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.pulltorefresh.swipe; 2 | 3 | import android.text.TextUtils; 4 | import android.view.Gravity; 5 | import android.view.View; 6 | import android.view.View.OnClickListener; 7 | import android.widget.ImageView; 8 | import android.widget.LinearLayout; 9 | import android.widget.TextView; 10 | 11 | import java.util.List; 12 | 13 | public class SwipeMenuView extends LinearLayout implements OnClickListener { 14 | 15 | private PullToRefreshSwipeMenuListView mListView; 16 | private SwipeMenuLayout mLayout; 17 | private SwipeMenu mMenu; 18 | private OnSwipeItemClickListener onItemClickListener; 19 | private int position; 20 | 21 | public int getPosition() { 22 | return position; 23 | } 24 | 25 | public void setPosition(int position) { 26 | this.position = position; 27 | } 28 | 29 | public SwipeMenuView(SwipeMenu menu, PullToRefreshSwipeMenuListView listView) { 30 | super(menu.getContext()); 31 | mListView = listView; 32 | mMenu = menu; 33 | List items = menu.getMenuItems(); 34 | int id = 0; 35 | for (SwipeMenuItem item : items) { 36 | addItem(item, id++); 37 | } 38 | } 39 | 40 | private void addItem(SwipeMenuItem item, int id) { 41 | LayoutParams params = new LayoutParams(item.getWidth(), LayoutParams.MATCH_PARENT); 42 | LinearLayout parent = new LinearLayout(getContext()); 43 | parent.setId(id); 44 | parent.setGravity(Gravity.CENTER); 45 | parent.setOrientation(LinearLayout.VERTICAL); 46 | parent.setLayoutParams(params); 47 | parent.setBackgroundDrawable(item.getBackground()); 48 | parent.setOnClickListener(this); 49 | addView(parent); 50 | 51 | if (item.getIcon() != null) { 52 | parent.addView(createIcon(item)); 53 | } 54 | if (!TextUtils.isEmpty(item.getTitle())) { 55 | parent.addView(createTitle(item)); 56 | } 57 | 58 | } 59 | 60 | private ImageView createIcon(SwipeMenuItem item) { 61 | ImageView iv = new ImageView(getContext()); 62 | iv.setImageDrawable(item.getIcon()); 63 | return iv; 64 | } 65 | 66 | private TextView createTitle(SwipeMenuItem item) { 67 | TextView tv = new TextView(getContext()); 68 | tv.setText(item.getTitle()); 69 | tv.setGravity(Gravity.CENTER); 70 | tv.setTextSize(item.getTitleSize()); 71 | tv.setTextColor(item.getTitleColor()); 72 | return tv; 73 | } 74 | 75 | @Override 76 | public void onClick(View v) { 77 | if (onItemClickListener != null && mLayout.isOpen()) { 78 | onItemClickListener.onItemClick(this, mMenu, v.getId()); 79 | } 80 | } 81 | 82 | public OnSwipeItemClickListener getOnSwipeItemClickListener() { 83 | return onItemClickListener; 84 | } 85 | 86 | public void setOnSwipeItemClickListener(OnSwipeItemClickListener onItemClickListener) { 87 | this.onItemClickListener = onItemClickListener; 88 | } 89 | 90 | public void setLayout(SwipeMenuLayout mLayout) { 91 | this.mLayout = mLayout; 92 | } 93 | 94 | public static interface OnSwipeItemClickListener { 95 | void onItemClick(SwipeMenuView view, SwipeMenu menu, int index); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/res/drawable-hdpi/heaven7_xlistview_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/pulltorefresh-swipe/src/main/res/drawable-hdpi/heaven7_xlistview_arrow.png -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/res/layout/heaven7_xlistview_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 18 | 19 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/res/layout/heaven7_xlistview_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 19 | 20 | 25 | 26 | 30 | 31 | 36 | 37 | 42 | 43 | 44 | 45 | 53 | 54 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PullToRefreshSwipeMenuListView 3 | 下拉刷新 4 | 松开刷新数据 5 | 正在加载... 6 | 上次更新时间: 7 | 查看更多 8 | 松开载入更多 9 | 10 | -------------------------------------------------------------------------------- /common-utils/pulltorefresh-swipe/src/test/java/study/heaven7/com/pulltorefresh_swipe/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package study.heaven7.com.pulltorefresh_swipe; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common-utils/sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /common-utils/sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:23.1.1' 24 | compile project(':commonutil') 25 | compile project(':pulltorefresh-swipe') 26 | compile project(':third_sdks') 27 | // compile 'org.heaven7.core.view:common-view:1.0.0' 28 | } 29 | -------------------------------------------------------------------------------- /common-utils/sample/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 I:\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 | -------------------------------------------------------------------------------- /common-utils/sample/src/androidTest/java/org/heaven7/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 34 | 35 | 38 | 39 | 42 | 43 | 46 | 47 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/java/org/heaven7/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.demo; 2 | 3 | import android.app.ListActivity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.ArrayAdapter; 8 | import android.widget.ListView; 9 | 10 | public class MainActivity extends ListActivity { 11 | 12 | public static final String[] options = { 13 | "QuickRecycleAdapterTest", 14 | "RecyclerViewDecorationTest", 15 | "PulltofreshSwipeTest", 16 | "QuickRecycleSwipeAdapterTest", 17 | "QuickListViewSwipeAdapterTest", 18 | }; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, options)); 24 | } 25 | 26 | @Override 27 | protected void onListItemClick(ListView l, View v, int position, long id) { 28 | Intent intent; 29 | 30 | switch (position) { 31 | case 0: 32 | intent = new Intent(this, QuickRecycleViewTestActivity.class); 33 | break; 34 | case 1: 35 | intent = new Intent(this, RecyclerViewDecorationTestActivity.class); 36 | break; 37 | case 2: 38 | intent = new Intent(this, PulltorefreshSwipeTest.class); 39 | break; 40 | case 3: 41 | intent = new Intent(this, QuickSwipeRecycleAdapterTestActivity.class); 42 | break; 43 | case 4: 44 | intent = new Intent(this, QuickSwipeListViewAdapterTestActivity.class); 45 | break; 46 | default: 47 | throw new UnsupportedOperationException(); 48 | } 49 | startActivity(intent); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/java/org/heaven7/demo/Test.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.demo; 2 | 3 | /** 4 | * Created by heaven7 on 2015/8/27. 5 | */ 6 | public interface Test { 7 | 8 | String [] URLS = { 9 | "http://img1.imgtn.bdimg.com/it/u=3351576580,2426190115&fm=21&gp=0.jpg" , 10 | "http://img5.imgtn.bdimg.com/it/u=860944204,3685287977&fm=21&gp=0.jpg" , 11 | "http://image.tianjimedia.com/uploadImages/2012/236/VBG8009Y8A27_1000x500.jpg", 12 | "http://img8.zol.com.cn/postbbs/225/a224909_s.jpg", 13 | "http://b.zol-img.com.cn/sjbizhi/images/6/320x510/1394523258256.jpg" , 14 | "http://img1.imgtn.bdimg.com/it/u=3882844624,1404148837&fm=21&gp=0.jpg" 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/java/org/heaven7/demo/TestApplication.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.demo; 2 | 3 | import android.app.Application; 4 | 5 | import com.android.volley.data.RequestManager; 6 | 7 | /** 8 | * Created by heaven7 on 2015/9/2. 9 | */ 10 | public class TestApplication extends Application { 11 | 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | RequestManager.init(this); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/java/org/heaven7/demo/wxapi/WXEntryActivity.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.demo.wxapi; 2 | 3 | import com.heaven7.third.share.BaseWeixinActivity; 4 | 5 | /** 6 | * Created by heaven7 on 2016/2/4. 7 | */ 8 | public class WXEntryActivity extends BaseWeixinActivity { 9 | } 10 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/java/org/heaven7/demo/wxapi/WXPayEntryActivity.java: -------------------------------------------------------------------------------- 1 | package org.heaven7.demo.wxapi; 2 | 3 | import com.heaven7.third.pay.BaseWeixinPayActivity; 4 | 5 | /** 6 | * Created by heaven7 on 2016/2/4. 7 | */ 8 | public class WXPayEntryActivity extends BaseWeixinPayActivity { 9 | } 10 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/drawable-xhdpi/ic_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/sample/src/main/res/drawable-xhdpi/ic_delete.png -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-common-utils/9fd5de650e547b6b67420fe289950fc4531af027/common-utils/sample/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/drawable/divider_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/drawable/test_progressbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/layout/activity_list_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /common-utils/sample/src/main/res/layout/activity_pay.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 |