[
  {
    "path": ".gitignore",
    "content": "# Built application files\n*.apk\n*.ap_\n\n# Files for the ART/Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\nout/\n\n# Gradle files\n.gradle/\nbuild/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n# Android Studio Navigation editor temp files\n.navigation/\n\n# Android Studio captures folder\ncaptures/\n\n# Intellij\n*.iml\n.idea/workspace.xml\n\n# Keystore files\n*.jks\n.idea/\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# PageStateManager/StatefulFrameLayout\n页面状态管理\n\n[![](https://jitpack.io/v/hss01248/PageStateManager.svg)](https://jitpack.io/#hss01248/PageStateManager)\n\n在张鸿洋的[LoadingAndRetryManager](https://github.com/hongyangAndroid/LoadingAndRetryManager)的基础上改写,修正一些bug,优化api,并提供使用时封装的例子\n\n# 特性\n* api超级简单\n* 可以在xml中使用StatefulFrameLayout\n* 也可以不改动xml,直接在代码里使用PageStateManager\n* 错误页面和空白页面均提供了点击事件的回调,直接实现即可\n* 不改动framlayout本身任何属性,依然可以添加多个子view\n\n\n\n# 更新:fragment的操作改变了\n\n由于fragment的生命周期引起的bug,已取消原先直接传入fragment对象的方式.\n\n请改成传入组成fragment的view,注意该view对象传入时,其parent不能为空,也就是,该view不能是xml的根view,可以自己随便包一层.\n\nps.\n\n其实fragment本质也是基于view包裹了一层api,搞点生命周期之类的,api难用得要死,还一大堆坑,还不如自己包装一个view,自己加点生命周期,高度可控,减少bug.我的项目中从来都不用fragment,都是自己把view包装成各种page.\n\n# API\n\n> 参考demo里的,自己封装一层(拷过去改一改)\n\n## 接口\n\n```\npublic interface IViewState {\n\n     void showLoading();\n     void showError(CharSequence msg);\n     void showContent();\n     void showEmpty();\n}\n```\n\n# 四个级别的配置\n\n### 库内默认\n\n自带Loading,Empty,Error的xml:\n\n```\npublic static int BASE_LOADING_LAYOUT_ID = R.layout.pager_loading;\npublic static int BASE_RETRY_LAYOUT_ID = R.layout.pager_error;\npublic static int BASE_EMPTY_LAYOUT_ID = R.layout.pager_empty;\n```\n\n## 使用时可全局配置\n\n在application的oncreate里调用:\n\n也就是修改上述的三个静态变量:\n\n```\nPageStateManager.initInAppOnCreate():\n```\n\n```\npublic static void initInApp(int layoutIdOfEmpty, int layoutIdOfLoading, int layoutIdOfError) {\n    if (layoutIdOfEmpty != 0) {\n        BASE_EMPTY_LAYOUT_ID = layoutIdOfEmpty;\n    }\n    if (layoutIdOfLoading != 0) {\n        BASE_LOADING_LAYOUT_ID = layoutIdOfLoading;\n    }\n    if (layoutIdOfError != 0) {\n        BASE_RETRY_LAYOUT_ID = layoutIdOfError;\n    }\n}\n```\n\n\n\n## 单个页面的配置:\n\n### 可配置的项目:\n\n// PageConfig为抽象类: \n\n仅一个必须实现的方法:\n\n\n    \n\n    public abstract class PageConfig {\n    \n    public abstract void onRetry(View retryView);//必须实现\n    \n    public void onEmtptyViewClicked(View emptyView) {\n        onRetry(emptyView);\n    }\n    \n    public boolean isFirstStateLoading(){\n        return true;\n    }\n    \n    public String emptyMsg(){\n        return \"\";\n    }\n    \n    public int customLoadingLayoutId() {\n        return PageStateManager.BASE_LOADING_LAYOUT_ID;\n    }\n    \n    public int customErrorLayoutId() {\n        return PageStateManager.BASE_RETRY_LAYOUT_ID;\n    }\n    \n    public int customEmptyLayoutId() {\n        return PageStateManager.BASE_EMPTY_LAYOUT_ID;\n    }\n### xml里使用statefulFrameLayout时:\n\n```\n<com.hss01248.pagestate.StatefulFrameLayout\n    android:id=\"@+id/pager\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n    <TextView\n        android:id=\"@+id/context\"\n        android:background=\"#ffff00\"\n        android:text=\"i am the content!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/>\n    <Button\n        android:layout_width=\"match_parent\"\n        android:id=\"@+id/btn\"\n        android:layout_marginTop=\"40dp\"\n        android:text=\"view2\"\n        android:layout_height=\"wrap_content\"/>\n</com.hss01248.pagestate.StatefulFrameLayout>\n```\n\n```\nstatefulFrameLayout.init(new PageConfig() {\n            @Override\n            public void onRetry(View retryView) {\n                doNet();\n            }\n        });\n        \n\n```\n\n### 或者使用PageStateManager:\n\n```\n\n /**\n     *\n     * @param container  必须为activity或者view.如果是view,则该view对象必须有parent\n     */\npageStateManager =   PageStateManager.initWhenUse(container,new MyPageConfig() {\n    @Override\n    protected void onReallyRetry() {\n        doNet();\n    }\n\n    @Override\n    public int customEmptyLayoutId() {\n        return R.layout.pager_empty_2;\n    }\n\n    @Override\n    public int customLoadingLayoutId() {\n        return R.layout.pager_loading_2;\n    }\n\n    @Override\n    public int customErrorLayoutId() {\n        return R.layout.pager_error_2;\n    }\n});\n```\n\n## 控制页面状态的api:\n\n```\npublic void showLoading()\npublic void showContent()\npublic void showEmpty()\npublic void showError(CharSequence errorMsg)\n```\n\n\n\n# demo中的默认的几个页面状态UI图\n\n \n\n ![loading](loading.jpg)\n\n![empty](empty.jpg)\n\n\n\n ![error](error.jpg)\n\n\n\n其中无网络时弹出dialog:\n\n ![error_dialog](error_dialog.jpg)\n\n无网络的对话框可以全局复写:\n\n```\nNoNetworkHelper.setShowDialogImpl(IShowDialog showDialog)\n\npublic interface IShowDialog{\n        void showNoNetWorkDlg(final Context context);\n    }\n    \n\n```\n\n# 使用\n\n## gradle\n\n**Step 1.** Add the JitPack repository to your build file\n\nAdd it in your root build.gradle at the end of repositories:\n\n```\n    allprojects {\n        repositories {\n            ...\n            maven { url \"https://jitpack.io\" }\n        }\n    }\n```\n\n**Step 2.** Add the dependency\n\n```\n    dependencies {\n            compile 'com.github.hss01248:PageStateManager:3.0.1'\n    }\n```\n\n\n\n## 示例代码(详见demo)\n\n## xml里不写StatefulFramelayout时:\n\n```\nprivate void initView() {\n        setContentView(R.layout.activity_main);\n        pageStateManager =   PageStateManager.initWhenUse(this,new PageConfig() {\n\n            @Override\n            public int customEmptyLayoutId() {\n                return R.layout.pager_empty_2;\n            }\n\n            @Override\n            public void onRetry(View retryView) {\n                doNet();\n            }\n\n            @Override\n            public int customLoadingLayoutId() {\n                return R.layout.pager_loading_2;\n            }\n\n            @Override\n            public int customErrorLayoutId() {\n                return R.layout.pager_error_2;\n            }\n        });\n\n    }\n\n    private void doNet() {\n        pageStateManager.showLoading();\n\n        new Handler().postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                int  state = new Random().nextInt(3);\n                switch (state){\n                    case 0:\n                        pageStateManager.showError(\"稍候重试\");\n                        break;\n                    case 1:\n                        pageStateManager.showEmpty();\n                        break;\n                    case 2:\n                        pageStateManager.showContent();\n                }\n\n            }\n        },2000);\n    }\n```\n\n## 在xml里直接写时:\n\n```\n......\nstatefulFrameLayout = (StatefulFrameLayout)findViewById(R.id.pager);\n    statefulFrameLayout.init(new PageConfig() {\n        @Override\n        public void onRetry(View retryView) {\n            doNet();\n        }\n    });\n    doNet();\n}\n\n\n\nprivate void doNet() {\n    statefulFrameLayout.showLoading();\n\n    new Handler().postDelayed(new Runnable() {\n        @Override\n        public void run() {\n            int  state = new Random().nextInt(3);\n            switch (state){\n                case 0:\n                    statefulFrameLayout.showError(\"稍候重试222222\");\n                    break;\n                case 1:\n                    statefulFrameLayout.showEmpty();\n                    break;\n                case 2:\n                    statefulFrameLayout.showContent();\n            }\n\n        }\n    },2000);\n}\n```\n\n# 注意事项\n\n1.给view对象设置状态时,该对象必须有parent\n\n2.\n\n\n\n\n\n# blog\n\n[介绍一下页面状态管理类PageStateManager,我实在看不下去你们直接用Layout](http://www.jianshu.com/p/665a69e9436b)\n"
  },
  {
    "path": "app/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "app/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 28\n\n    defaultConfig {\n        applicationId \"com.hss01248.pagestate.demo\"\n        minSdkVersion 15\n        targetSdkVersion 28\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    testCompile 'junit:junit:4.12'\n    compile 'androidx.appcompat:appcompat:1.1.0'\n    compile project(path: ':pagestate')\n    compile 'com.nineoldandroids:library:2.4.0'\n    //compile 'com.jakewharton:butterknife:10.2.1'\n    //annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'\n    //compile 'com.wuhenzhizao:titlebar:1.2.0'\n}\n"
  },
  {
    "path": "app/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in I:\\dev\\Android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "app/src/androidTest/java/com/hss01248/pagestate/demo/ApplicationTest.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n    public ApplicationTest() {\n        super(Application.class);\n    }\n}"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.hss01248.pagestate.demo\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n            android:name=\".BaseApp\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\".SplashActy\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity android:name=\".MainActivity\"/>\n        <activity android:name=\".CustomUIActy\"/>\n        <activity android:name=\".XmlActivity\" />\n    </application>\n\n</manifest>"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/BaseActivity.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.os.Bundle;\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.app.AppCompatActivity;\nimport android.view.View;\nimport android.widget.LinearLayout;\nimport android.widget.TextView;\n\nimport com.hss01248.pagestate.PageStateConfig;\nimport com.hss01248.pagestate.PageStateManager;\n\n/**\n * time:2020/4/26\n * author:hss\n * desription:\n */\npublic class BaseActivity extends AppCompatActivity {\n\n    BaseConfig config;\n    TextView titlebar;\n    LinearLayout linearLayout;\n    PageStateManager stateManager;\n\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.base_activity);\n        linearLayout = (LinearLayout) findViewById(R.id.ll_root);\n        titlebar = (TextView) findViewById(R.id.titlebar);\n        config = new BaseConfig();\n        configPage(config);\n\n        applyConfig(config);\n    }\n\n    protected void requestData(IRequestCallback callback){\n\n    }\n\n    private void applyConfig(BaseConfig config) {\n        if(config.hasPageStatus ){\n            stateManager = PageStateManager.initWhenUse(linearLayout, new PageStateConfig() {\n                @Override\n                public void onRetry(View retryView) {\n                    stateManager.showLoading();\n                    doNet();\n                }\n            });\n            doNet();\n        }\n    }\n\n    private void doNet() {\n        requestData(new IRequestCallback() {\n            @Override\n            public void onSuccess() {\n                stateManager.showContent();\n            }\n\n            @Override\n            public void onError(String msg) {\n                stateManager.showError(msg);\n            }\n\n            @Override\n            public void onEmpty() {\n                stateManager.showEmpty();\n            }\n        });\n    }\n\n    protected void configPage(BaseConfig config) {\n        config.hasPageStatus = true;\n    }\n\n    public static class BaseConfig{\n        boolean hasPageStatus = true;\n        boolean hasTitlebar = true;\n        PageStateConfig stateConfig;\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/BaseApp.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.app.Application;\n\nimport com.hss01248.pagestate.PageStateManager;\n\n\n/**\n * Created by huangshuisheng on 2017/10/16.\n */\n\npublic class BaseApp extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        PageStateManager.initInAppOnCreate(R.layout.pager_empty,R.layout.pager_loading,R.layout.pager_error);\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/CustomUIActy.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport androidx.annotation.Nullable;\nimport android.view.View;\n\nimport com.hss01248.pagestate.PageStateConfig;\nimport com.hss01248.pagestate.PageStateManager;\n\n\nimport java.util.Random;\n\n/**\n * Created by huangshuisheng on 2017/10/16.\n */\n\npublic class CustomUIActy extends Activity {\n\n    PageStateManager pageStateManager;\n\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        initView();\n        doNet();\n    }\n\n    private void initView() {\n        setContentView(R.layout.activity_main);\n        pageStateManager =   PageStateManager.initWhenUse(this,new PageStateConfig() {\n\n            @Override\n            public int customEmptyLayoutId() {\n                return R.layout.pager_empty_2;\n            }\n\n            @Override\n            public void onRetry(View retryView) {\n                doNet();\n            }\n\n            @Override\n            public int customLoadingLayoutId() {\n                return R.layout.pager_loading_2;\n            }\n\n            @Override\n            public int customErrorLayoutId() {\n                return R.layout.pager_error_2;\n            }\n        });\n\n    }\n\n    private void doNet() {\n        pageStateManager.showLoading();\n\n        new Handler().postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                int  state = new Random().nextInt(3);\n                switch (state){\n                    case 0:\n                        pageStateManager.showError(\"稍候重试\");\n                        break;\n                    case 1:\n                        pageStateManager.showEmpty();\n                        break;\n                    case 2:\n                        pageStateManager.showContent();\n                }\n\n            }\n        },2000);\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/IRequestCallback.java",
    "content": "package com.hss01248.pagestate.demo;\n\n/**\n * time:2020/4/26\n * author:hss\n * desription:\n */\npublic interface IRequestCallback {\n    void onSuccess();\n    void onError(String msg);\n    void onEmpty();\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/LoadingView.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.os.Build;\nimport android.text.TextUtils;\nimport android.util.AttributeSet;\nimport android.view.Gravity;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.view.animation.AccelerateInterpolator;\nimport android.view.animation.DecelerateInterpolator;\nimport android.widget.FrameLayout;\nimport android.widget.ImageView;\nimport android.widget.TextView;\n\nimport com.nineoldandroids.animation.Animator;\nimport com.nineoldandroids.animation.AnimatorSet;\nimport com.nineoldandroids.animation.ObjectAnimator;\n\n\n/**\n * Created by cy on 5/24/16.\n * <p/>\n * 功能描述:\n */\npublic class LoadingView extends FrameLayout {\n\n    private static final int ANIMATION_DURATION = 500;\n\n    private static float mDistance = 200;\n\n    private ShapeLoadingView mShapeLoadingView;\n\n    private ImageView mIndicationIm;\n\n    private TextView mLoadTextView;\n    private int mTextAppearance;\n\n    private String mLoadText;\n\n    private boolean mLoading = false;\n\n    public LoadingView(Context context) {\n        super(context);\n    }\n\n    public LoadingView(Context context, AttributeSet attrs) {\n        super(context, attrs, 0);\n        init(context, attrs);\n\n    }\n\n    private void init(Context context, AttributeSet attrs) {\n\n        TypedArray typedArray = context\n                .obtainStyledAttributes(attrs, R.styleable.LoadingView);\n        mLoadText = typedArray.getString(R.styleable.LoadingView_loadingText);\n        mTextAppearance = typedArray.getResourceId(R.styleable.LoadingView_loadingTextAppearance, -1);\n\n        typedArray.recycle();\n    }\n\n\n    public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        init(context, attrs);\n    }\n\n    @TargetApi(Build.VERSION_CODES.LOLLIPOP)\n    public LoadingView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n        super(context, attrs, defStyleAttr, defStyleRes);\n        init(context, attrs);\n    }\n\n    public int dip2px(float dipValue) {\n        final float scale = getContext().getResources().getDisplayMetrics().density;\n        return (int) (dipValue * scale + 0.5f);\n    }\n\n    @Override\n    protected void onFinishInflate() {\n        super.onFinishInflate();\n        View view = LayoutInflater.from(getContext()).inflate(R.layout.load_view, null);\n        mDistance = dip2px(54f);\n        LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,\n                ViewGroup.LayoutParams.WRAP_CONTENT);\n        layoutParams.gravity = Gravity.CENTER;\n        mShapeLoadingView = (ShapeLoadingView) view.findViewById(R.id.shapeLoadingView);\n        mIndicationIm = (ImageView) view.findViewById(R.id.indication);\n        mLoadTextView = (TextView) view.findViewById(R.id.promptTV);\n        if (mTextAppearance != -1) {\n            mLoadTextView.setTextAppearance(getContext(), mTextAppearance);\n        }\n        setLoadingText(mLoadText);\n        addView(view, layoutParams);\n//        startLoading(900);\n    }\n\n\n    private AnimatorSet mAnimatorSetThrowUp = null, mAnimatorSetFallDown = null;\n\n    private Runnable mFreeFallRunnable = new Runnable() {\n        @Override\n        public void run() {\n            fallDown();\n        }\n    };\n\n    private void startLoading(long delay) {\n        if (mAnimatorSetThrowUp != null && mAnimatorSetThrowUp.isRunning()) {\n            return;\n        }\n\n        if (mAnimatorSetFallDown != null && mAnimatorSetFallDown.isRunning()) {\n            return;\n        }\n\n        this.removeCallbacks(mFreeFallRunnable);\n        mLoading = true;\n        if (delay > 0) {\n            this.postDelayed(mFreeFallRunnable, delay);\n        } else {\n            this.post(mFreeFallRunnable);\n        }\n    }\n\n    private void stopLoading() {\n        if (mAnimatorSetThrowUp != null) {\n            if (mAnimatorSetThrowUp.isRunning()) {\n                mAnimatorSetThrowUp.cancel();\n            }\n            mAnimatorSetThrowUp = null;\n        }\n\n        if (mAnimatorSetFallDown != null) {\n            if (mAnimatorSetFallDown.isRunning()) {\n                mAnimatorSetFallDown.cancel();\n            }\n            mAnimatorSetFallDown = null;\n        }\n        mLoading = false;\n        this.removeCallbacks(mFreeFallRunnable);\n    }\n\n    @Override\n    public void setVisibility(int visibility) {\n        super.setVisibility(visibility);\n        if (visibility == View.VISIBLE) {\n            startLoading(200);\n        } else {\n            stopLoading();\n        }\n    }\n\n    public void setLoadingText(CharSequence loadingText) {\n        if (TextUtils.isEmpty(loadingText)) {\n            mLoadTextView.setVisibility(GONE);\n        } else {\n            mLoadTextView.setVisibility(VISIBLE);\n        }\n\n        mLoadTextView.setText(loadingText);\n    }\n\n    /**\n     * 上抛\n     */\n    public void throwUp() {\n        if (!mLoading)\n            return;\n\n        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mShapeLoadingView, \"translationY\", mDistance, 0);\n        ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(mIndicationIm, \"scaleX\", 0.2f, 1);\n        ObjectAnimator objectAnimator1 = null;\n        switch (mShapeLoadingView.getShape()) {\n            case SHAPE_RECT:\n                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, \"rotation\", 0, -120);\n                break;\n            case SHAPE_CIRCLE:\n                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, \"rotation\", 0, 180);\n                break;\n            case SHAPE_TRIANGLE:\n                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, \"rotation\", 0, 180);\n                break;\n        }\n\n        objectAnimator.setDuration(ANIMATION_DURATION);\n        objectAnimator1.setDuration(ANIMATION_DURATION);\n        objectAnimator.setInterpolator(new DecelerateInterpolator(factor));\n        objectAnimator1.setInterpolator(new DecelerateInterpolator(factor));\n        mAnimatorSetThrowUp = new AnimatorSet();\n        mAnimatorSetThrowUp.setDuration(ANIMATION_DURATION);\n        mAnimatorSetThrowUp.playTogether(objectAnimator, objectAnimator1, scaleIndication);\n        mAnimatorSetThrowUp.addListener(new Animator.AnimatorListener() {\n            @Override\n            public void onAnimationStart(Animator animation) {\n\n            }\n\n            @Override\n            public void onAnimationEnd(Animator animation) {\n                if (mLoading) {\n                    fallDown();\n                }\n            }\n\n            @Override\n            public void onAnimationCancel(Animator animation) {\n\n            }\n\n            @Override\n            public void onAnimationRepeat(Animator animation) {\n\n            }\n        });\n        mAnimatorSetThrowUp.start();\n    }\n\n    public float factor = 1.2f;\n\n    /**\n     * 下落\n     */\n    public void fallDown() {\n        if (!mLoading)\n            return;\n\n        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mShapeLoadingView, \"translationY\", 0, mDistance);\n        ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(mIndicationIm, \"scaleX\", 1, 0.2f);\n        objectAnimator.setDuration(ANIMATION_DURATION);\n        objectAnimator.setInterpolator(new AccelerateInterpolator(factor));\n        mAnimatorSetFallDown = new AnimatorSet();\n        mAnimatorSetFallDown.setDuration(ANIMATION_DURATION);\n        mAnimatorSetFallDown.playTogether(objectAnimator, scaleIndication);\n        mAnimatorSetFallDown.addListener(new Animator.AnimatorListener() {\n            @Override\n            public void onAnimationStart(Animator animation) {\n\n            }\n\n            @Override\n            public void onAnimationEnd(Animator animation) {\n                if (mLoading) {\n                    mShapeLoadingView.changeShape();\n                    throwUp();\n                }\n            }\n\n            @Override\n            public void onAnimationCancel(Animator animation) {\n\n            }\n\n            @Override\n            public void onAnimationRepeat(Animator animation) {\n\n            }\n        });\n        mAnimatorSetFallDown.start();\n\n    }\n}"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/MainActivity.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.os.Bundle;\nimport android.os.Handler;\nimport androidx.appcompat.app.AppCompatActivity;\nimport android.view.View;\n\nimport com.hss01248.pagestate.PageStateConfig;\nimport com.hss01248.pagestate.PageStateManager;\n\n\nimport java.util.Random;\n\npublic class MainActivity extends AppCompatActivity {\n\n    PageStateManager pageStateManager;\n    Handler handler = new Handler();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        init();\n\n    }\n\n    private void init() {\n        pageStateManager = PageStateManager.initWhenUse(this, new PageStateConfig() {\n\n\n            @Override\n            public String emptyMsg() {\n                return \"自定义的空msg\\n你可以点击重试一下\";\n            }\n\n            @Override\n            public void onRetry(View retryView) {\n                doNet();\n            }\n\n            @Override\n            public void onEmtptyViewClicked(View emptyView) {\n                super.onEmtptyViewClicked(emptyView);\n\n                doNet();\n            }\n\n            @Override\n            public boolean darkMode() {\n                return true;\n            }\n\n            @Override\n            public boolean isFirstStateLoading() {\n                return false;\n            }\n        });\n        doNet();\n\n    }\n\n    @Override\n    protected void onResume() {\n        super.onResume();\n\n       // doNet();\n\n\n\n\n    }\n\n    private void doNet() {\n        pageStateManager.showLoading(50);\n\n        handler.postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                int  state = new Random().nextInt(3);\n                switch (state){\n                    case 0:\n                        pageStateManager.showError(\"error occured!!!!!!!!!!!!\");\n                        break;\n                    case 1:\n                        pageStateManager.showEmpty();\n                        break;\n                    case 2:\n                        pageStateManager.showContent();\n                }\n\n            }\n        },2000);\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/ShapeLoadingView.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Paint;\nimport android.graphics.Path;\nimport android.os.Build;\nimport androidx.core.content.ContextCompat;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.view.animation.DecelerateInterpolator;\nimport android.view.animation.Interpolator;\n\nimport com.nineoldandroids.animation.ArgbEvaluator;\n\n\n/**\n * Created by cy on 5/24/16.\n * <p/>\n * 功能描述:\n */\npublic class ShapeLoadingView extends View {\n    private static final float genhao3 = 1.7320508075689f;\n    private static final float mTriangle2Circle = 0.25555555f;\n\n    private Context mContext;\n\n    private Shape mShape = Shape.SHAPE_CIRCLE;\n    private Interpolator mInterpolator = new DecelerateInterpolator();\n    private ArgbEvaluator mArgbEvaluator = new ArgbEvaluator();\n\n    private int mTriangleColor;\n    private int mCircleColor;\n    private int mRectColor;\n\n    /**\n     * 用赛贝尔曲线画圆\n     */\n    private float mMagicNumber = 0.55228475f;\n\n    public ShapeLoadingView(Context context) {\n        super(context);\n        this.mContext = context;\n        init();\n    }\n\n    public ShapeLoadingView(Context context, AttributeSet attrs) {\n        super(context, attrs);\n        this.mContext = context;\n        init();\n    }\n\n    public ShapeLoadingView(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        this.mContext = context;\n        init();\n    }\n\n    @TargetApi(Build.VERSION_CODES.LOLLIPOP)\n    public ShapeLoadingView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n        super(context, attrs, defStyleAttr, defStyleRes);\n        this.mContext = context;\n        init();\n    }\n\n    private void init() {\n        mPaint = new Paint();\n        mPaint.setColor(ContextCompat.getColor(mContext, R.color.triangle));\n        mPaint.setAntiAlias(true);\n        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);\n        setBackgroundColor(ContextCompat.getColor(mContext, R.color.view_bg));\n        mTriangleColor = ContextCompat.getColor(mContext, R.color.triangle);\n        mCircleColor = ContextCompat.getColor(mContext, R.color.circle);\n        mRectColor = ContextCompat.getColor(mContext, R.color.triangle);\n    }\n\n    public boolean mIsLoading = false;\n    private Paint mPaint;\n    private float mControlX = 0;\n    private float mControlY = 0;\n    private float mAnimPercent;\n\n    @Override\n    protected void onDraw(Canvas canvas) {\n        super.onDraw(canvas);\n        if (getVisibility() == GONE) {\n            return;\n        }\n        // FIXME: 15/6/15  动画待优化\n        switch (mShape) {\n            case SHAPE_TRIANGLE:\n                if (mIsLoading) {\n                    mAnimPercent += 0.1611113;\n                    int color = (int) mArgbEvaluator.evaluate(mAnimPercent, mTriangleColor, mCircleColor);\n                    mPaint.setColor(color);\n                    // triangle to circle\n                    Path path = new Path();\n                    path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));\n\n                    if (mAnimPercent >= 1) {\n                        mShape = Shape.SHAPE_CIRCLE;\n                        mIsLoading = false;\n                        mAnimPercent = 1;\n                    }\n                    float controlX = mControlX - relativeXFromView(mAnimPercent * mTriangle2Circle)\n                            * genhao3;\n                    float controlY = mControlY - relativeYFromView(mAnimPercent * mTriangle2Circle);\n                    path.quadTo(relativeXFromView(1) - controlX, controlY, relativeXFromView(0.5f + genhao3 / 4), relativeYFromView(0.75f));\n                    path.quadTo(relativeXFromView(0.5f), relativeYFromView(0.75f + 2 * mAnimPercent * mTriangle2Circle), relativeXFromView(0.5f - genhao3 / 4), relativeYFromView(0.75f));\n                    path.quadTo(controlX, controlY, relativeXFromView(0.5f), relativeYFromView(0f));\n                    path.close();\n                    canvas.drawPath(path, mPaint);\n                    invalidate();\n                } else {\n                    Path path = new Path();\n                    mPaint.setColor(ContextCompat.getColor(mContext, R.color.triangle));\n                    path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));\n                    path.lineTo(relativeXFromView(1), relativeYFromView(genhao3 / 2f));\n                    path.lineTo(relativeXFromView(0), relativeYFromView(genhao3 / 2f));\n                    mControlX = relativeXFromView(0.5f - genhao3 / 8.0f);\n                    mControlY = relativeYFromView(3 / 8.0f);\n                    mAnimPercent = 0;\n                    path.close();\n                    canvas.drawPath(path, mPaint);\n                }\n                break;\n            case SHAPE_CIRCLE:\n                if (mIsLoading) {\n                    float magicNumber = mMagicNumber + mAnimPercent;\n                    mAnimPercent += 0.12;\n                    if (magicNumber + mAnimPercent >= 1.9f) {\n                        mShape = Shape.SHAPE_RECT;\n                        mIsLoading = false;\n                    }\n                    int color = (int) mArgbEvaluator.evaluate(mAnimPercent, mCircleColor, mRectColor);\n                    mPaint.setColor(color);\n                    Path path = new Path();\n                    path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));\n                    path.cubicTo(relativeXFromView(0.5f + magicNumber / 2), relativeYFromView(0f),\n                            relativeXFromView(1), relativeYFromView(0.5f - magicNumber / 2),\n                            relativeXFromView(1f), relativeYFromView(0.5f));\n                    path.cubicTo(\n                            relativeXFromView(1), relativeXFromView(0.5f + magicNumber / 2),\n                            relativeXFromView(0.5f + magicNumber / 2), relativeYFromView(1f),\n                            relativeXFromView(0.5f), relativeYFromView(1f));\n                    path.cubicTo(relativeXFromView(0.5f - magicNumber / 2), relativeXFromView(1f),\n                            relativeXFromView(0), relativeYFromView(0.5f + magicNumber / 2),\n                            relativeXFromView(0f), relativeYFromView(0.5f));\n                    path.cubicTo(relativeXFromView(0f), relativeXFromView(0.5f - magicNumber / 2),\n                            relativeXFromView(0.5f - magicNumber / 2), relativeYFromView(0),\n                            relativeXFromView(0.5f), relativeYFromView(0f));\n                    path.close();\n                    canvas.drawPath(path, mPaint);\n                    invalidate();\n                } else {\n                    mPaint.setColor(ContextCompat.getColor(mContext, R.color.circle));\n                    Path path = new Path();\n                    float magicNumber = mMagicNumber;\n                    path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));\n                    path.cubicTo(relativeXFromView(0.5f + magicNumber / 2), 0,\n                            relativeXFromView(1), relativeYFromView(magicNumber / 2),\n                            relativeXFromView(1f), relativeYFromView(0.5f));\n                    path.cubicTo(\n                            relativeXFromView(1), relativeXFromView(0.5f + magicNumber / 2),\n                            relativeXFromView(0.5f + magicNumber / 2), relativeYFromView(1f),\n                            relativeXFromView(0.5f), relativeYFromView(1f));\n                    path.cubicTo(relativeXFromView(0.5f - magicNumber / 2), relativeXFromView(1f),\n                            relativeXFromView(0), relativeYFromView(0.5f + magicNumber / 2),\n                            relativeXFromView(0f), relativeYFromView(0.5f));\n                    path.cubicTo(relativeXFromView(0f), relativeXFromView(0.5f - magicNumber / 2),\n                            relativeXFromView(0.5f - magicNumber / 2), relativeYFromView(0),\n                            relativeXFromView(0.5f), relativeYFromView(0f));\n                    mAnimPercent = 0;\n\n                    path.close();\n                    canvas.drawPath(path, mPaint);\n                }\n                break;\n            case SHAPE_RECT:\n                if (mIsLoading) {\n                    mAnimPercent += 0.15;\n                    if (mAnimPercent >= 1) {\n                        mShape = Shape.SHAPE_TRIANGLE;\n                        mIsLoading = false;\n                        mAnimPercent = 1;\n                    }\n                    int color = (int) mArgbEvaluator.evaluate(mAnimPercent, mRectColor, mTriangleColor);\n                    mPaint.setColor(color);\n                    Path path = new Path();\n                    path.moveTo(relativeXFromView(0.5f * mAnimPercent), 0);\n                    path.lineTo(relativeYFromView(1 - 0.5f * mAnimPercent), 0);\n                    float distanceX = (mControlX) * mAnimPercent;\n                    float distanceY = (relativeYFromView(1f) - mControlY) * mAnimPercent;\n                    path.lineTo(relativeXFromView(1f) - distanceX, relativeYFromView(1f) - distanceY);\n                    path.lineTo(relativeXFromView(0f) + distanceX, relativeYFromView(1f) - distanceY);\n                    path.close();\n                    canvas.drawPath(path, mPaint);\n                    invalidate();\n                } else {\n                    mPaint.setColor(ContextCompat.getColor(mContext, R.color.rect));\n                    mControlX = relativeXFromView(0.5f - genhao3 / 4);\n                    mControlY = relativeYFromView(0.75f);\n                    Path path = new Path();\n                    path.moveTo(relativeXFromView(0f), relativeYFromView(0f));\n                    path.lineTo(relativeXFromView(1f), relativeYFromView(0f));\n                    path.lineTo(relativeXFromView(1f), relativeYFromView(1f));\n                    path.lineTo(relativeXFromView(0f), relativeYFromView(1f));\n                    path.close();\n                    mAnimPercent = 0;\n                    canvas.drawPath(path, mPaint);\n                }\n                break;\n        }\n    }\n\n    private float relativeXFromView(float percent) {\n        return getWidth() * percent;\n    }\n\n    private float relativeYFromView(float percent) {\n        return getHeight() * percent;\n    }\n\n    public void changeShape() {\n        mIsLoading = true;\n        invalidate();\n    }\n\n    public enum Shape {\n        SHAPE_TRIANGLE, SHAPE_RECT, SHAPE_CIRCLE\n    }\n\n    @Override\n    public void setVisibility(int visibility) {\n        super.setVisibility(visibility);\n\n        if (visibility == VISIBLE) {\n            invalidate();\n        }\n    }\n\n    public Shape getShape() {\n        return mShape;\n    }\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/SplashActy.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport androidx.annotation.Nullable;\nimport android.view.View;\nimport android.widget.Button;\n\n\n\n/**\n * Created by huangshuisheng on 2017/10/16.\n */\n\npublic class SplashActy extends Activity implements View.OnClickListener {\n\n\n\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.acty_splash);\n       findViewById(R.id.button).setOnClickListener(this);\n        findViewById(R.id.button2).setOnClickListener(this);\n        findViewById(R.id.button3).setOnClickListener(this);\n    }\n\n    @Override\n    public void onClick(View view) {\n        switch (view.getId()) {\n            case R.id.button:\n                startActivity(new Intent(this,MainActivity.class));\n                break;\n            case R.id.button2:\n                startActivity(new Intent(this,CustomUIActy.class));\n                break;\n            case R.id.button3:\n                startActivity(new Intent(this,XmlActivity.class));\n                break;\n        }\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/hss01248/pagestate/demo/XmlActivity.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport android.os.Bundle;\nimport android.os.Handler;\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.app.AppCompatActivity;\nimport android.view.View;\n\nimport com.hss01248.pagestate.PageStateConfig;\nimport com.hss01248.pagestate.StatefulFrameLayout;\n\nimport java.util.Random;\n\n/**\n * time:2020/4/25\n * author:hss\n * desription:\n */\npublic class XmlActivity extends AppCompatActivity {\n\n    StatefulFrameLayout statefulFrameLayout;\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        setContentView(R.layout.activity_inxml);\n        statefulFrameLayout = (StatefulFrameLayout)findViewById(R.id.pager);\n        statefulFrameLayout.init(new PageStateConfig() {\n            @Override\n            public void onRetry(View retryView) {\n                doNet();\n            }\n        });\n        doNet();\n\n\n\n    }\n\n    private void doNet() {\n        statefulFrameLayout.showLoading();\n\n        new Handler().postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                int  state = new Random().nextInt(3);\n                switch (state){\n                    case 0:\n                        statefulFrameLayout.showError(\"稍候重试222222\");\n                        break;\n                    case 1:\n                        statefulFrameLayout.showEmpty();\n                        break;\n                    case 2:\n                        statefulFrameLayout.showContent();\n                }\n\n            }\n        },2000);\n    }\n}\n"
  },
  {
    "path": "app/src/main/res/attr/loading_arrts.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources >\n    <declare-styleable name=\"LoadingView\">\n        <attr name=\"loadingText\" format=\"string\"/>\n        <attr name=\"loadingTextAppearance\" format=\"reference\"/>\n    </declare-styleable>\n</resources>"
  },
  {
    "path": "app/src/main/res/layout/activity_inxml.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n    <com.hss01248.pagestate.StatefulFrameLayout\n        android:id=\"@+id/pager\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\">\n        <TextView\n            android:id=\"@+id/context\"\n            android:background=\"#ffff00\"\n            android:text=\"i am the content!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"/>\n        <Button\n            android:layout_width=\"match_parent\"\n            android:id=\"@+id/btn\"\n            android:layout_marginTop=\"40dp\"\n            android:text=\"view2\"\n            android:layout_height=\"wrap_content\"/>\n    </com.hss01248.pagestate.StatefulFrameLayout>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:paddingBottom=\"@dimen/activity_vertical_margin\"\n    android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n    android:paddingRight=\"@dimen/activity_horizontal_margin\"\n    android:paddingTop=\"@dimen/activity_vertical_margin\"\n    tools:context=\"com.hss01248.pagestate.demo.MainActivity\">\n\n    <TextView\n            android:id=\"@+id/text2\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Hello World!\\n i am the comtent\" />\n\n\n</RelativeLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/acty_splash.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\t\tandroid:orientation=\"vertical\" android:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\">\n\n\t<Button\n\t\t\tandroid:text=\"全局默认ui\"\n\t\t\tandroid:textAllCaps=\"false\"\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\tandroid:id=\"@+id/button\" />\n\n\t<Button\n\t\t\tandroid:text=\"页面自定义ui\"\n\t\t\tandroid:textAllCaps=\"false\"\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\tandroid:id=\"@+id/button2\" />\n\t<Button\n\t\tandroid:text=\"布局中使用\"\n\t\tandroid:textAllCaps=\"false\"\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"wrap_content\"\n\t\tandroid:id=\"@+id/button3\" />\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/base_activity.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:id=\"@+id/ll_root\"\n    android:layout_height=\"match_parent\">\n    <TextView\n        android:id=\"@+id/titlebar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"56dp\"/>\n    <!--<com.wuhenzhizao.titlebar.widget.CommonTitleBar\n        android:id=\"@+id/titlebar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"56dp\"/>-->\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/load_view.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:orientation=\"vertical\">\n\n    <RelativeLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:minWidth=\"44dp\"\n        android:orientation=\"vertical\">\n\n        <ImageView\n\n            android:id=\"@+id/indication\"\n            android:layout_width=\"23dp\"\n            android:layout_height=\"3dp\"\n            android:layout_centerHorizontal=\"true\"\n            android:layout_marginTop=\"82dp\"\n            android:src=\"@drawable/loading_shadow\" />\n\n        <TextView\n            android:id=\"@+id/promptTV\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_below=\"@+id/indication\"\n            android:layout_centerHorizontal=\"true\"\n            android:layout_marginTop=\"18dp\"\n            android:minWidth=\"44dp\"\n            android:textColor=\"#757575\"\n            android:textSize=\"14sp\"\n            android:visibility=\"gone\" />\n\n        <com.hss01248.pagestate.demo.ShapeLoadingView\n            android:id=\"@+id/shapeLoadingView\"\n            android:layout_width=\"24dp\"\n            android:layout_height=\"24dp\"\n            android:layout_centerHorizontal=\"true\"\n            android:layout_marginTop=\"2dp\" />\n\n    </RelativeLayout>\n</RelativeLayout>"
  },
  {
    "path": "app/src/main/res/layout/pager_empty_2.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:gravity=\"center\"\n    android:orientation=\"vertical\"\n    android:visibility=\"visible\">\n\n    <ImageView\n        android:id=\"@+id/no_result_icon\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:src=\"@mipmap/ic_launcher\" />\n\n    <TextView\n        android:id=\"@+id/no_result_msg\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"10dp\"\n        android:text=\"no result\"\n        android:textColor=\"@color/colorPrimary\" />\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/pager_error_2.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\"\n              android:background=\"@android:color/white\"\n              android:gravity=\"center_horizontal\"\n              android:visibility=\"visible\"\n              android:orientation=\"vertical\">\n\n    <ImageView\n        android:id=\"@+id/error_icon\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"130dp\"\n        android:src=\"@mipmap/network_error\"/>\n\n    <TextView\n        android:id=\"@+id/error_tips\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"30dp\"\n        android:gravity=\"center\"\n        android:text=\"oo,some error occurs!!\"\n        android:textColor=\"@color/colorPrimaryDark\"/>\n\n    <TextView\n        android:id=\"@+id/refresh_again_btn\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"36dp\"\n        android:background=\"@drawable/selector_btn_bg\"\n        android:paddingBottom=\"10dp\"\n        android:paddingLeft=\"20dp\"\n        android:paddingRight=\"20dp\"\n        android:paddingTop=\"10dp\"\n        android:text=\"refresh_again\"\n        android:textColor=\"@color/colorAccent\"/>\n\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/pager_loading_2.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.hss01248.pagestate.demo.LoadingView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\t\tandroid:layout_width=\"match_parent\"\n\t\txmlns:app=\"http://schemas.android.com/apk/res-auto\"\n\t\tapp:loadingText=\"loading..\"\n\t\tandroid:layout_height=\"match_parent\">\n\n</com.hss01248.pagestate.demo.LoadingView>"
  },
  {
    "path": "app/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n    <color name=\"triangle\">#fad0d1</color>\n    <color name=\"circle\">#e62117</color>\n    <color name=\"rect\">#eb686c</color>\n    <color name=\"view_bg\">#00000000</color>\n    <color name=\"shadow\">#25808080</color>\n    <color name=\"dialog_bg\">#f5f5f5</color>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/dimens.xml",
    "content": "<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">PageStateManager</string>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "app/src/test/java/com/hss01248/pagestate/demo/ExampleUnitTest.java",
    "content": "package com.hss01248.pagestate.demo;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        jcenter()\n        google()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.5.3'\n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\nallprojects {\n    repositories {\n        jcenter()\n        google()\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sun Apr 26 13:04:21 CST 2020\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.4.1-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\n# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\nandroid.enableJetifier=true\nandroid.useAndroidX=true"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "pagestate/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "pagestate/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 28\n\n    defaultConfig {\n        minSdkVersion 15\n        targetSdkVersion 28\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    testCompile 'junit:junit:4.12'\n    api 'androidx.appcompat:appcompat:1.1.0'\n}\n"
  },
  {
    "path": "pagestate/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in I:\\dev\\Android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "pagestate/src/androidTest/java/com/hss01248/pagestate/ApplicationTest.java",
    "content": "package com.hss01248.pagestate;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n    public ApplicationTest() {\n        super(Application.class);\n    }\n}"
  },
  {
    "path": "pagestate/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.hss01248.pagestate\">\n\n    <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>\n\n    <application\n        android:allowBackup=\"true\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\">\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "pagestate/src/main/java/com/hss01248/pagestate/IViewState.java",
    "content": "package com.hss01248.pagestate;\n\n/**\n * time:2020/4/25\n * author:hss\n * desription:\n */\npublic interface IViewState {\n\n     void showLoading();\n     default void showLoading(int progress){\n          showLoading();\n     }\n     void showError(CharSequence msg);\n     void showContent();\n     void showEmpty();\n}\n"
  },
  {
    "path": "pagestate/src/main/java/com/hss01248/pagestate/NoNetworkHelper.java",
    "content": "package com.hss01248.pagestate;\n\nimport android.content.Context;\nimport android.content.DialogInterface;\nimport android.content.Intent;\nimport android.net.ConnectivityManager;\nimport android.net.NetworkInfo;\nimport androidx.appcompat.app.AlertDialog;\n\n/**\n * time:2020/4/25\n * author:hss\n * desription:\n */\npublic class NoNetworkHelper {\n\n    public static void setShowDialogImpl(IShowDialog showDialog) {\n        NoNetworkHelper.showDialog = showDialog;\n    }\n\n    static IShowDialog showDialog;\n\n    public interface IShowDialog{\n        void showNoNetWorkDlg(final Context context);\n    }\n\n\n     static void showNoNetWorkDlg(final Context context) {\n        if(showDialog != null){\n            showDialog.showNoNetWorkDlg(context);\n            return;\n        }\n        AlertDialog dialog = null;\n        try {\n            AlertDialog.Builder builder = new AlertDialog.Builder(context);\n            dialog = builder\n                    .setTitle(R.string.pagestate_no_network_title)\n                    .setMessage(R.string.pagestate_no_network_msg).setPositiveButton(R.string.pagestate_go_setting, new DialogInterface.OnClickListener() {\n                        @Override\n                        public void onClick(DialogInterface dialog, int which) {\n                            // 跳转到系统的网络设置界面\n                            Intent intent = null;\n                            // 先判断当前系统版本\n                            if(android.os.Build.VERSION.SDK_INT > 10){  // 3.0以上\n                                //intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);\n                                intent = new Intent(android.provider.Settings.ACTION_SETTINGS);\n                            }else{\n                                intent = new Intent();\n                                intent.setClassName(\"com.android.settings\", \"com.android.settings.WirelessSettings\");\n                            }\n                            context.startActivity(intent);\n                            dialog.dismiss();\n                        }\n                    }).setNegativeButton(R.string.pagestate_cancel, null)\n                    .show();\n        }catch (Exception e){\n            e.printStackTrace();\n        }\n\n    }\n\n     static boolean isNetWorkAvailable(Context context) {\n        ConnectivityManager connectivityManager = (ConnectivityManager) context\n                .getSystemService(Context.CONNECTIVITY_SERVICE);\n        if (connectivityManager == null) {\n            return false;\n        } else {\n            NetworkInfo info = connectivityManager.getActiveNetworkInfo();\n            if (info == null) {\n                return false;\n            } else {\n                if (info.isAvailable()) {\n                    return true;\n                }\n            }\n        }\n        return false;\n    }\n}\n"
  },
  {
    "path": "pagestate/src/main/java/com/hss01248/pagestate/PageStateConfig.java",
    "content": "package com.hss01248.pagestate;\n\nimport android.view.View;\n\npublic abstract class PageStateConfig {\n\n    public abstract void onRetry(View retryView);\n\n    public void onEmtptyViewClicked(View emptyView) {\n        onRetry(emptyView);\n    }\n\n    public boolean isFirstStateLoading(){\n        return true;\n    }\n\n    public String emptyMsg(){\n        return \"\";\n    }\n\n    public boolean darkMode(){\n        return PageStateManager.isDarkMode;\n    }\n\n    public int customLoadingLayoutId() {\n        return PageStateManager.BASE_LOADING_LAYOUT_ID;\n    }\n\n    public int customErrorLayoutId() {\n        return PageStateManager.BASE_RETRY_LAYOUT_ID;\n    }\n\n    public int customEmptyLayoutId() {\n        return PageStateManager.BASE_EMPTY_LAYOUT_ID;\n    }\n\n    public boolean showProgress(View emptyView,int progress){\n        return false;\n    }\n\n\n\n\n\n}"
  },
  {
    "path": "pagestate/src/main/java/com/hss01248/pagestate/PageStateManager.java",
    "content": "package com.hss01248.pagestate;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport androidx.fragment.app.Fragment;\nimport android.view.View;\nimport android.view.ViewGroup;\n\n\n/**\n * Created by zhy on 15/8/27.\n */\npublic class PageStateManager implements IViewState{\n\n     static int BASE_LOADING_LAYOUT_ID = R.layout.pager_loading;\n     static int BASE_RETRY_LAYOUT_ID = R.layout.pager_error;\n     static int BASE_EMPTY_LAYOUT_ID = R.layout.pager_empty;\n\n    public static void setGlobalDarkMode(boolean isDarkMode) {\n        PageStateManager.isDarkMode = isDarkMode;\n    }\n\n    static boolean isDarkMode = false;\n\n    public StatefulFrameLayout getStatefulLayout() {\n        return mLoadingAndRetryLayout;\n    }\n\n    StatefulFrameLayout mLoadingAndRetryLayout;\n    PageStateConfig pageListener = new PageStateConfig() {\n        @Override\n        public void onRetry(View retryView) {\n\n        }\n    };\n\n     PageStateManager(Context context){\n\n    }\n\n\n    private PageStateManager(Object activityOrView, PageStateConfig listener) {\n        ViewGroup contentParent = null;\n        Context context;\n        if (activityOrView instanceof Activity) {\n            Activity activity = (Activity) activityOrView;\n            context = activity;\n            contentParent = (ViewGroup) activity.findViewById(android.R.id.content);\n        } else if (activityOrView instanceof Fragment) {\n\n            Fragment fragment = (Fragment) activityOrView;\n            context = fragment.getActivity();\n            contentParent = (ViewGroup) (fragment.getView().getParent());\n            if (contentParent == null) {\n                throw new IllegalArgumentException(\"the fragment must already has a parent ,please do not invoke this in oncreateView,you should use this method in onActivityCreated() or onstart\");\n            }\n\n            //throw new IllegalArgumentException(\"the support for fragment has been canceled,please use give me a view object which has a parent\");\n\n        } else if (activityOrView instanceof View) {\n            View view = (View) activityOrView;\n            contentParent = (ViewGroup) (view.getParent());\n            if (contentParent == null) {\n                throw new IllegalArgumentException(\"the view must already has a parent \");\n            }\n            context = view.getContext();\n        } else {\n            throw new IllegalArgumentException(\"the container's type must be Fragment or Activity or a view \");\n        }\n\n\n        int childCount = contentParent.getChildCount();\n        //get contentParent\n        int index = 0;\n        View oldContent;\n        if (activityOrView instanceof View) {\n            oldContent = (View) activityOrView;\n            for (int i = 0; i < childCount; i++) {\n                if (contentParent.getChildAt(i) == oldContent) {\n                    index = i;\n                    break;\n                }\n            }\n        } else {\n            oldContent = contentParent.getChildAt(0);\n        }\n        contentParent.removeView(oldContent);\n        //setup content layout\n        StatefulFrameLayout statefulFrameLayout = new StatefulFrameLayout(context);\n        statefulFrameLayout.manager = this;\n        if(listener != null){\n            this.pageListener = listener;\n        }\n\n\n        ViewGroup.LayoutParams lp = oldContent.getLayoutParams();\n        contentParent.addView(statefulFrameLayout, index, lp);\n        statefulFrameLayout.setContentView(oldContent);\n        // setup loading,retry,empty layout\n        //setupLoadingLayout(listener, pageLayout);\n       // setupRetryLayout(listener, pageLayout);\n        //setupEmptyLayout(listener, pageLayout);\n        //callback\n       /* listener.onRetry(pageLayout.getRetryView());\n        listener.setLoadingEvent(pageLayout.getLoadingView());\n        listener.setEmptyEvent(pageLayout.getEmptyView());*/\n\n        mLoadingAndRetryLayout = statefulFrameLayout;\n        //初始状态:loading进去\n        if (pageListener.isFirstStateLoading()) {\n            mLoadingAndRetryLayout.showLoading();\n        } else {\n            mLoadingAndRetryLayout.showContent();\n        }\n\n    }\n\n    /**\n     * @param layoutIdOfEmpty\n     * @param layoutIdOfLoading\n     * @param layoutIdOfError\n     */\n    public static void initInAppOnCreate(int layoutIdOfEmpty, int layoutIdOfLoading, int layoutIdOfError) {\n        if (layoutIdOfEmpty != 0) {\n            BASE_EMPTY_LAYOUT_ID = layoutIdOfEmpty;\n        }\n        if (layoutIdOfLoading != 0) {\n            BASE_LOADING_LAYOUT_ID = layoutIdOfLoading;\n        }\n        if (layoutIdOfError != 0) {\n            BASE_RETRY_LAYOUT_ID = layoutIdOfError;\n        }\n    }\n\n    public static PageStateManager initWhenUse(Object activityOrView, PageStateConfig listener) {\n        return new PageStateManager(activityOrView,  listener);\n    }\n\n\n    @Override\n    public void showLoading() {\n        mLoadingAndRetryLayout.showLoading();\n    }\n\n    @Override\n    public void showLoading(int progress) {\n        mLoadingAndRetryLayout.showLoading(progress);\n    }\n\n    @Override\n    public void showError(CharSequence msg) {\n        mLoadingAndRetryLayout.showError(msg);\n    }\n\n    @Override\n    public void showContent() {\n        mLoadingAndRetryLayout.showContent();\n    }\n\n    @Override\n    public void showEmpty() {\n        mLoadingAndRetryLayout.showEmpty();\n    }\n\n\n\n\n}\n"
  },
  {
    "path": "pagestate/src/main/java/com/hss01248/pagestate/StatefulFrameLayout.java",
    "content": "package com.hss01248.pagestate;\n\nimport android.content.Context;\nimport android.graphics.Color;\nimport android.graphics.drawable.Drawable;\nimport android.os.Looper;\nimport android.text.TextUtils;\nimport android.util.AttributeSet;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.TextureView;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.Button;\nimport android.widget.FrameLayout;\nimport android.widget.TextView;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Created by zhy on 15/8/26.\n */\npublic class StatefulFrameLayout extends FrameLayout implements IViewState {\n    public static final int STATUS_LOADING = 1;\n    public static final int STATUS_CONTENT = 2;\n    public static final int STATUS_EMPTY = 3;\n    public static final int STATUS_ERROR = 4;\n    private static final String TAG = StatefulFrameLayout.class.getSimpleName();\n    int status;\n    private View mLoadingView;\n    private View mRetryView;\n\n    private List<View> contentViews = new ArrayList<>();\n    private View mEmptyView;\n    private LayoutInflater mInflater;\n     PageStateManager manager;\n\n\n    public StatefulFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        mInflater = LayoutInflater.from(context);\n        initView(context, attrs, defStyleAttr);\n    }\n\n    public StatefulFrameLayout(Context context, AttributeSet attrs) {\n        this(context, attrs, -1);\n    }\n\n\n    public StatefulFrameLayout(Context context) {\n        this(context, null);\n    }\n\n    public void init(PageStateConfig listener){\n        manager.pageListener = listener;\n    }\n\n    private void initView(Context context, AttributeSet attrs, int defStyleAttr) {\n        int childCount = this.getChildCount();\n        if (childCount > 1) {\n            throw new RuntimeException(\"content must be one\");\n        }\n        //xml里的布局是在这个layout初始化完成后才加入的\n        manager = new PageStateManager(context);\n    }\n\n    @Override\n    protected void onAttachedToWindow() {\n        super.onAttachedToWindow();\n        if(manager.pageListener.isFirstStateLoading()){\n            showLoading();\n        }\n\n    }\n\n    private boolean isMainThread() {\n        return Looper.myLooper() == Looper.getMainLooper();\n    }\n\n    @Override\n    public void showLoading() {\n        if (isMainThread()) {\n            showView(mLoadingView, STATUS_LOADING);\n        } else {\n            post(new Runnable() {\n                @Override\n                public void run() {\n                    showView(mLoadingView,STATUS_LOADING);\n                }\n            });\n        }\n    }\n\n    @Override\n    public void showLoading(int progress) {\n        if (isMainThread()) {\n            showView(mLoadingView, STATUS_LOADING);\n            showProgress(mLoadingView,progress);\n\n        } else {\n            post(new Runnable() {\n                @Override\n                public void run() {\n                    showView(mLoadingView,STATUS_LOADING);\n                    showProgress(mLoadingView,progress);\n                }\n            });\n        }\n    }\n    TextView tvLoading;\n    private void showProgress(View mLoadingView, int progress) {\n        try {\n            if(manager == null || manager.pageListener == null){\n                showP(mLoadingView,progress+\"%\");\n                return;\n            }\n            if(!manager.pageListener.showProgress(mEmptyView,progress)){\n                showP(mLoadingView,progress+\"%\");\n            }\n        }catch (Throwable throwable){\n            throwable.printStackTrace();\n        }\n\n\n    }\n\n    private void showP(View mLoadingView, String str) {\n        if(tvLoading != null){\n            tvLoading.setText(str);\n            return;\n        }\n        View tv = mLoadingView.findViewById(R.id.tv_msg_loading);\n        if(tv instanceof TextView){\n           tvLoading = (TextView) tv;\n            tvLoading.setText(str);\n        }\n\n    }\n\n    /**\n     * 会找到第一个textview,设置text. 如果msg为空,则不设置\n     *\n     * @param msg\n     */\n    @Override\n    public void showError(final CharSequence msg) {\n        if (isMainThread()) {\n            showView(mRetryView,STATUS_ERROR);\n            setText(mRetryView, msg);\n        } else {\n            post(new Runnable() {\n                @Override\n                public void run() {\n                    showView(mRetryView,STATUS_ERROR);\n                    setText(mRetryView, msg);\n                }\n            });\n        }\n    }\n\n    private void setText(View view1, CharSequence msg) {\n        if (TextUtils.isEmpty(msg)) {\n            return;\n        }\n        if (view1 instanceof ViewGroup) {\n            ViewGroup viewGroup = (ViewGroup) view1;\n            int count = viewGroup.getChildCount();\n            if (count > 0) {\n                for (int i = 0; i < count; i++) {\n                    View view = viewGroup.getChildAt(i);\n                    if (view instanceof TextView) {\n                        TextView textView = (TextView) view;\n                        textView.setText(msg);\n                        return;\n                    }\n                }\n            }\n        }\n\n    }\n\n\n    @Override\n    public void showContent() {\n        if (isMainThread()) {\n            showView(null,STATUS_CONTENT);\n        } else {\n            post(new Runnable() {\n                @Override\n                public void run() {\n                    showView(null,STATUS_CONTENT);\n                }\n            });\n        }\n    }\n\n    @Override\n    public void showEmpty() {\n        if (isMainThread()) {\n            showView(mEmptyView,STATUS_EMPTY);\n        } else {\n            post(new Runnable() {\n                @Override\n                public void run() {\n                    showView(mEmptyView,STATUS_EMPTY);\n                }\n            });\n        }\n    }\n\n\n    private void showView(View view, int status) {\n        if (this.status == status) {\n            return;\n        }\n        this.status = status;\n        if(status == STATUS_LOADING){\n            if(mLoadingView == null){\n              view =  setLoadingView(manager.pageListener.customLoadingLayoutId());\n            }\n        }else if(status == STATUS_EMPTY){\n            if(mEmptyView == null){\n                view =  setEmptyView(manager.pageListener.customEmptyLayoutId());\n\n            }\n        }else if(status == STATUS_ERROR){\n            if(mRetryView == null){\n                view =  setRetryView(manager.pageListener.customErrorLayoutId());\n\n            }\n        }\n\n        if(contentViews.isEmpty()){\n           findContentViews();\n        }\n        if(status == STATUS_CONTENT){\n            if (mLoadingView != null)\n                mLoadingView.setVisibility(View.GONE);\n            if (mRetryView != null)\n                mRetryView.setVisibility(View.GONE);\n            if (mEmptyView != null)\n                mEmptyView.setVisibility(View.GONE);\n            showContentView();\n            return;\n        }\n\n        if (view == mLoadingView) {\n            mLoadingView.setVisibility(View.VISIBLE);\n            if (mRetryView != null)\n                mRetryView.setVisibility(View.GONE);\n            hideContentView();\n            if (mEmptyView != null)\n                mEmptyView.setVisibility(View.GONE);\n        } else if (view == mRetryView) {\n            mRetryView.setVisibility(View.VISIBLE);\n            if (mLoadingView != null)\n                mLoadingView.setVisibility(View.GONE);\n            hideContentView();\n            if (mEmptyView != null)\n                mEmptyView.setVisibility(View.GONE);\n        }  else if (view == mEmptyView) {\n            mEmptyView.setVisibility(View.VISIBLE);\n            if (mLoadingView != null)\n                mLoadingView.setVisibility(View.GONE);\n            if (mRetryView != null)\n                mRetryView.setVisibility(View.GONE);\n            hideContentView();\n        }\n\n        setDarkMode(view);\n\n\n\n    }\n\n    private void setDarkMode(View view) {\n        if(view == null){\n            Log.w(\"setDarkMode\",\"view is null!!!\");\n            return;\n        }\n        if(manager != null && manager.pageListener != null){\n            if(manager.pageListener.darkMode()){\n                view.setBackgroundColor(Color.BLACK);\n                findChildTextviewAndSetWhite(view);\n            }\n        }\n    }\n\n    private void findChildTextviewAndSetWhite(View view) {\n        if(view instanceof ViewGroup){\n            ViewGroup viewGroup = (ViewGroup) view;\n            int childCount = viewGroup.getChildCount();\n            for (int i = 0; i < childCount; i++) {\n                View child = viewGroup.getChildAt(i);\n                findChildTextviewAndSetWhite(child);\n            }\n        }else if(view instanceof TextView ){\n            TextView textView = (TextView) view;\n            textView.setTextColor(Color.WHITE);\n            Drawable background = textView.getBackground();\n            //Log.w(\"setDarkMode\",\"background \"+background);\n            if(background != null){\n                textView.setBackgroundColor(Color.parseColor(\"#333333\"));\n            }\n        }\n    }\n\n    private void hideContentView() {\n        for (int i = 0; i < contentViews.size(); i++) {\n            contentViews.get(i).setVisibility(GONE);\n        }\n    }\n\n    private void showContentView() {\n        for (int i = 0; i < contentViews.size(); i++) {\n            contentViews.get(i).setVisibility(VISIBLE);\n        }\n    }\n\n    private void  findContentViews() {\n        int count = getChildCount();\n        int contentCount = 0;\n        for (int i = 0; i < count; i++) {\n            View view = getChildAt(i);\n            if(view.equals(mEmptyView)){\n                continue;\n            }\n            if(view.equals(mLoadingView)){\n                continue;\n            }\n            if(view.equals(mRetryView)){\n                continue;\n            }\n            contentViews.add(view);\n            contentCount++;\n        }\n       if(contentCount == 0){\n            Log.w(\"pager\",\"还没有设置contentview\");\n        }\n    }\n\n     View setLoadingView(int layoutId) {\n        return setLoadingView(mInflater.inflate(layoutId, this, false));\n    }\n\n     View setEmptyView(int layoutId) {\n        return setEmptyView(mInflater.inflate(layoutId, this, false));\n    }\n\n     View setRetryView(int layoutId) {\n        return setRetryView(mInflater.inflate(layoutId, this, false));\n    }\n\n     View setLoadingView(View view) {\n        View loadingView = mLoadingView;\n        if (loadingView != null) {\n            Log.w(TAG, \"you have already set a loading view and would be instead of this new one.\");\n        }\n        removeView(loadingView);\n        addView(view,0);\n        mLoadingView = view;\n        return mLoadingView;\n    }\n\n     View setEmptyView(View view) {\n        View emptyView = mEmptyView;\n        if (emptyView != null) {\n            Log.w(TAG, \"you have already set a empty view and would be instead of this new one.\");\n        }\n        removeView(emptyView);\n        addView(view,0);\n        mEmptyView = view;\n         mEmptyView.setOnClickListener(new View.OnClickListener() {\n             @Override\n             public void onClick(View v) {\n                 if (manager.pageListener != null) {\n                     manager.pageListener.onEmtptyViewClicked(v);\n                 }\n             }\n         });\n        return mEmptyView;\n    }\n\n     View setRetryView(View view) {\n        View retryView = mRetryView;\n        if (retryView != null) {\n            Log.w(TAG, \"you have already set a retry view and would be instead of this new one.\");\n        }\n        removeView(retryView);\n        addView(view,0);\n        mRetryView = view;\n         mRetryView.setOnClickListener(new View.OnClickListener() {\n             @Override\n             public void onClick(View v) {\n                 if (!NoNetworkHelper.isNetWorkAvailable(v.getContext())) {\n                     NoNetworkHelper.showNoNetWorkDlg(v.getContext());\n                 } else {\n                     if (manager.pageListener != null) {\n                         manager.pageListener.onRetry(v);\n                     }\n                 }\n             }\n         });\n        return mRetryView;\n\n    }\n\n\n    //给外部使用\n     View getErrorView() {\n        if(mRetryView == null){\n            setRetryView(manager.pageListener.customErrorLayoutId()).setVisibility(GONE);\n        }\n        return mRetryView;\n    }\n\n     View getLoadingView() {\n        if(mLoadingView == null){\n            setLoadingView(manager.pageListener.customLoadingLayoutId()).setVisibility(GONE);\n        }\n        return mLoadingView;\n    }\n\n\n\n     List<View> getContentView() {\n        if(contentViews.isEmpty()){\n            findContentViews();\n        }\n        return contentViews;\n    }\n\n     View getEmptyView() {\n         if(mEmptyView == null){\n             setEmptyView(manager.pageListener.customEmptyLayoutId()).setVisibility(GONE);\n         }\n        return mEmptyView;\n    }\n\n     void setContentView(View oldContent) {\n        addView(oldContent);\n        contentViews.add(oldContent);\n    }\n}\n"
  },
  {
    "path": "pagestate/src/main/res/drawable/loading_shadow.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:shape=\"oval\">\n\n    <solid android:color=\"@color/shadow\"/>\n\n</shape>"
  },
  {
    "path": "pagestate/src/main/res/drawable/progressstyleshape.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rotate xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:fromDegrees=\"0\"\n    android:toDegrees=\"360\"\n    android:pivotX=\"50%\"\n    android:pivotY=\"50%\"\n     >\n    <!--<bitmap android:src=\"@drawable/audio_pause\"/>-->\n\n    <shape\n        xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        android:innerRadiusRatio=\"3\"\n        android:shape=\"ring\"\n        android:thicknessRatio=\"10\" \n        android:useLevel=\"false\"\n\n        >\n        <gradient\n            android:endColor=\"#9a9a9a\"\n            android:type=\"sweep\"\n\n            android:startColor=\"#ffffff\" >\n        </gradient>\n    </shape>\n\n</rotate>"
  },
  {
    "path": "pagestate/src/main/res/drawable/selector_btn_bg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <item android:drawable=\"@drawable/btn_pressed\" android:state_pressed=\"true\"></item>\n    <item android:drawable=\"@drawable/btn_normal\"></item>\n\n</selector>"
  },
  {
    "path": "pagestate/src/main/res/layout/pager_empty.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:background=\"#ffffff\"\n    android:orientation=\"vertical\"\n    android:gravity=\"center_horizontal\"\n    android:layout_height=\"match_parent\" >\n\n    <ImageView\n        android:id=\"@+id/empty_icon\"\n        android:layout_width=\"204dp\"\n        android:layout_height=\"228dp\"\n       android:layout_centerHorizontal=\"true\"\n        android:layout_marginTop=\"60dp\"\n        android:src=\"@drawable/ic_empty_page_2\" />\n    <TextView\n        android:id=\"@+id/tv_msg_empty\"\n        android:layout_below=\"@id/empty_icon\"\n        android:layout_marginTop=\"20dp\"\n        android:textSize=\"15sp\"\n        android:layout_centerHorizontal=\"true\"\n        android:text=\"@string/pagestate_empty_msg\"\n        android:textColor=\"#666666\"\n        android:gravity=\"center\"\n        android:paddingLeft=\"16dp\"\n        android:paddingRight=\"16dp\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\" />\n\n\n</LinearLayout>"
  },
  {
    "path": "pagestate/src/main/res/layout/pager_error.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:background=\"#ffffff\"\n    android:layout_height=\"match_parent\" >-->\n\n    <LinearLayout\n        xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        android:background=\"#ffffff\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:layout_centerInParent=\"true\"\n        android:gravity=\"center\"\n        android:orientation=\"vertical\" >\n\n        <ImageView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_marginBottom=\"20dp\"\n            android:src=\"@drawable/ic_error_page\" />\n\n        <TextView\n            android:id=\"@+id/tv_msg_error\"\n            android:text=\"@string/pagestate_error_occurs\"\n            android:textColor=\"#333333\"\n            android:textSize=\"14sp\"\n            android:gravity=\"center\"\n            android:layout_marginBottom=\"20dp\"\n            android:layout_marginLeft=\"20dp\"\n            android:layout_marginRight=\"20dp\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\" />\n\n        <TextView\n            android:id=\"@+id/error_btn_retry\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"34dp\"\n            android:gravity=\"center\"\n\n            android:background=\"@drawable/selector_btn_bg\"\n            android:paddingLeft=\"25dp\"\n            android:paddingRight=\"25dp\"\n            android:text=\"@string/pagestate_click_to_retry\"\n            android:textColor=\"#ff717171\"\n            android:textSize=\"14sp\" />\n    </LinearLayout>\n\n<!--\n</RelativeLayout>-->\n"
  },
  {
    "path": "pagestate/src/main/res/layout/pager_loading.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:background=\"#ffffff\"\n    android:layout_height=\"match_parent\"\n    >\n\n    <ProgressBar\n        android:id=\"@+id/progressbar\"\n        android:layout_width=\"40dp\"\n        android:layout_height=\"40dp\"\n        android:layout_centerInParent=\"true\"\n        android:indeterminateDrawable=\"@drawable/progressstyleshape\"\n        android:indeterminateDuration=\"1200\"\n        android:indeterminateBehavior=\"repeat\"\n        />\n\n    <TextView\n        android:id=\"@+id/tv_msg_loading\"\n        android:text=\"@string/page_loading\"\n        android:layout_marginTop=\"6dp\"\n        android:layout_centerHorizontal=\"true\"\n        android:layout_below=\"@id/progressbar\"\n        android:textSize=\"16sp\"\n        android:gravity=\"center\"\n        android:textColor=\"#333333\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\" />\n\n\n\n</RelativeLayout>"
  },
  {
    "path": "pagestate/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">pagestate</string>\n    <color name=\"shadow\">#25808080</color>\n\n    <string name=\"pagestate_no_network_title\">No Network Connection</string>\n    <string name=\"pagestate_no_network_msg\">Turn on your Network Connection or use Wi-Fi to access\n        data.\n    </string>\n    <string name=\"pagestate_go_setting\">Go Settings</string>\n    <string name=\"pagestate_cancel\">Cancel</string>\n    <string name=\"page_loading\">loading…</string>\n    <string name=\"pagestate_click_to_retry\">click to retry</string>\n    <string name=\"pagestate_error_occurs\">some error occurs</string>\n    <string name=\"pagestate_empty_msg\">opps, it seems that response is empty, go to see something else</string>\n</resources>\n"
  },
  {
    "path": "pagestate/src/main/res/values-in/strings.xml",
    "content": "<resources>\n    <string name=\"pagestate_no_network_title\">Tidak Ada Jaringan</string>\n    <string name=\"pagestate_no_network_msg\">Nyalakan Koneksi Data Atau Sambungkan Wifi.</string>\n    <string name=\"pagestate_go_setting\">Pengaturan</string>\n    <string name=\"pagestate_cancel\">Batal</string>\n</resources>\n"
  },
  {
    "path": "pagestate/src/main/res/values-ms/strings.xml",
    "content": "<resources>\n\n\n    <string name=\"pagestate_no_network_title\">Tiada talian</string>\n    <string name=\"pagestate_no_network_msg\">Hidupkan talian internet anda atau gunakan WiFi untuk\n        mengakses data.\n    </string>\n    <string name=\"pagestate_go_setting\">Layari tetapan anda</string>\n    <string name=\"pagestate_cancel\">Sila batal</string>\n</resources>\n"
  },
  {
    "path": "pagestate/src/main/res/values-vi/strings.xml",
    "content": "<resources>\n\n    <string name=\"pagestate_no_network_title\">Không Kết nối mạng</string>\n    <string name=\"pagestate_no_network_msg\">Bật Kết nối mạng hoặc dùng Wi-Fi để lấy dữ liệu.</string>\n    <string name=\"pagestate_go_setting\">Vào Cài đặt</string>\n    <string name=\"pagestate_cancel\">Hủy</string>\n</resources>\n"
  },
  {
    "path": "pagestate/src/main/res/values-zh/strings.xml",
    "content": "<resources>\n\n    <string name=\"pagestate_no_network_title\">无网络</string>\n    <string name=\"pagestate_no_network_msg\">打开网络连接或者wifi才能获取数据\n    </string>\n    <string name=\"pagestate_go_setting\">去设置页</string>\n    <string name=\"pagestate_cancel\">取消</string>\n    <string name=\"page_loading\">加载中…</string>\n    <string name=\"pagestate_click_to_retry\">点击重试</string>\n    <string name=\"pagestate_error_occurs\">发生了一些错误,请稍后重试</string>\n    <string name=\"pagestate_empty_msg\">咦…没有任何内容，先去逛逛别的吧</string>\n</resources>\n"
  },
  {
    "path": "pagestate/src/test/java/com/hss01248/pagestate/ExampleUnitTest.java",
    "content": "package com.hss01248.pagestate;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "settings.gradle",
    "content": "include ':app', ':pagestate'\n"
  }
]