{"id":15352697,"url":"https://github.com/therajanmaurya/sweet-error","last_synced_at":"2025-04-15T05:52:51.230Z","repository":{"id":55557708,"uuid":"109558597","full_name":"therajanmaurya/sweet-error","owner":"therajanmaurya","description":"Sweet Error UI","archived":false,"fork":false,"pushed_at":"2022-10-23T10:37:34.000Z","size":5063,"stargazers_count":27,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-04-15T05:52:44.604Z","etag":null,"topics":["android","error-ui","material-design","ui"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/therajanmaurya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-05T06:59:47.000Z","updated_at":"2022-10-21T11:19:29.000Z","dependencies_parsed_at":"2022-08-15T03:10:39.514Z","dependency_job_id":null,"html_url":"https://github.com/therajanmaurya/sweet-error","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therajanmaurya%2Fsweet-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therajanmaurya%2Fsweet-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therajanmaurya%2Fsweet-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/therajanmaurya%2Fsweet-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/therajanmaurya","download_url":"https://codeload.github.com/therajanmaurya/sweet-error/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016318,"owners_count":21198832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","error-ui","material-design","ui"],"created_at":"2024-10-01T12:10:06.614Z","updated_at":"2025-04-15T05:52:51.213Z","avatar_url":"https://github.com/therajanmaurya.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://jitpack.io/v/therajanmaurya/sweet-error.svg)](https://jitpack.io/#therajanmaurya/sweet-error)\n### Google Play Store\n\u003ca href='https://play.google.com/store/apps/details?id=com.github.therajanmaurya.sweeterror.demo'\u003e\u003cimg alt='Get it on Google Play' \nsrc='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' width='180'/\u003e\u003c/a\u003e\n\n![Sweet Error Demo](https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/sweet_error.png)\n\n A Simple android library to handle every type of sweet errors.\n\n## Sweet Designs\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/Home.png\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/EmptyUI.png\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/ErrorUI.png\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/NoInternetUI.png\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/NoInternet.png\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://raw.githubusercontent.com/therajanmaurya/Sweet-Error/master/arts/CustomErrorUI.png\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nUsage\n-----\n\nIn order to use the library\n\n**1. Gradle dependency** \n\n  -  Add the following to your project level `build.gradle`:\n \n```gradle\nallprojects {\n\trepositories {\n\t\tjcenter() or mavenCentral() or maven { url 'https://jitpack.io' } // whatever you use\n\t}\n}\n```\n  -  Add this to your app `build.gradle`:\n \n```gradle\ndependencies {\n    // NOTE: please use latest released version on jitpack\n\timplementation 'com.github.therajanmaurya:sweet-error:1.0.9'\n}\n```\n\n**2. Usage** \n\n  - Add the Sweet-Error xml layout in the parent view of your project xml layout.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003candroidx.coordinatorlayout.widget.CoordinatorLayout\n    android:id=\"@+id/clSweet\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_height=\"match_parent\"\n    android:layout_width=\"match_parent\"\u003e\n\n    \u003cLinearLayout\n        android:id=\"@+id/llSweet\"\n        android:layout_height=\"match_parent\"\n        android:layout_width=\"match_parent\"\n        android:orientation=\"vertical\"\u003e\n\n        ....................................\n\n    \u003c/LinearLayout\u003e\n\n    \u003cinclude\n        layout=\"@layout/layout_sweet_exception_handler\"\n        android:id=\"@+id/layoutError\"\n        android:visibility=\"gone\"/\u003e\n\n\u003c/androidx.coordinatorlayout.widget.CoordinatorLayout\u003e\n\n```\n\n  - Initialize the SweetUIErrorHandler in your **Activity** and use it.\n\n```kotlin\nclass SweetErrorInActivity : AppCompatActivity() {\n\n   private lateinit var sweetUIErrorHandler: SweetUIErrorHandler\n\n   override fun onCreate(savedInstanceState: Bundle?) {\n         super.onCreate(savedInstanceState)\n         setContentView(R.layout.activity_sweet_error)\n        \n        val layoutError = findViewById(R.id.layoutError)\n        val llSweet = findViewById(R.id.llSweet) // It can be any child of your xml like RelativeLayout, RecyclerView etc, as we defined in above xml.\n\n        sweetUIErrorHandler = SweetUIErrorHandler(this, findViewById(android.R.id.content))\n       \n        // Now you are all set. Whatever error UI you want to show according to condition like\n        \n        # Empty UI (1.1)\n        // Need to pass the feature(s) name that is empty and icon image of the feature that you want to show and if \n        // you have feature of addition then pass the feature name and your child view that you want hide and \n        // layoutError UI to visible. It will handle everything.\n         sweetUIErrorHandler.showSweetEmptyUI(getString(R.string.sweets),\n                        getString(R.string.sweet), R.drawable.ic_adb_black_24dp,\n                        llSweet, layoutError)\n\t\t\t\n\t\t\t\n\t\t# Empty UI (1.2)\n\t\t// Need to pass the feature(s) name that is empty and icon image of the feature that you want to show\n\t\t// and your child view that you want hide and layoutError UI to visible. It will handle everything.\n\t\t// See 2nd screenshot above as an example\n\t\t sweetUIErrorHandler.showSweetEmptyUI(getString(R.string.sweets), R.drawable.ic_adb_black_24dp,\n\t\t\t\tllSweet, layoutError)\n\n\n\t\t# Error UI (1.1)\n\t\t// Need to pass the feature name in which error occured and\n\t\t// your child view that you want hide and layoutError UI to visible. It will handle everything.\n\t\tsweetUIErrorHandler.showSweetErrorUI(getString(R.string.sweets), llSweet, layoutError)\n\n\n\t\t# Error UI (1.2)\n\t\t// Need to pass the feature name in which error occured and image that you want to show like \n\t\t// bad internet connection image etc.\n\t\t// your child view that you want hide and layoutError UI to visible. It will handle everything.\n\t\tsweetUIErrorHandler.showSweetErrorUI(getString(R.string.sweets), R.drawable.ic_no_network llSweet, layoutError)\n\n\n\t\t// Use this button click to refresh UI if any error occured or any Network issue occured.\n\t\tval btnTryAgain = findViewById\u003cButton\u003e(R.id.btnTryAgain)\n\n\n\t\t# No Network I UI (1.1)\n\t\t// Need to pass your child view that you want hide and layoutError UI to visible. It will handle everything.\n\t\t// It will look like above 4th screenshot.\n\t\tsweetUIErrorHandler.showSweetNoInternetUI(llSweet, layoutError)\n\n\n\t\t# Custom Error UI (1.1)\n\t\t// Need to pass Image that will show up at the top of title and\n\t\t// the title text that will show bottom to the image and subtext that will show in bottom of title text.\n\t\t// and your child view that you want hide and layoutError UI to visible. It will handle everything.\n\t\t sweetUIErrorHandler.showSweetCustomErrorUI(getString(R.string.no_sweets_found),\n\t\t\t\tgetString(R.string.come_later_again), R.drawable.ic_adb_black_24dp,\n\t\t\t\tllSweet, layoutError)\n\n\n\t\t# Custom Error UI (1.2)\n\t\t// Need to pass Image that will show up at the top of title and subtitle of error message.\n\t\t// the title text that will show bottom to the image and there will be no subtext, only image and error text.\n\t\t// and your child view that you want hide and layoutError UI to visible. It will handle everything.\n\t\t sweetUIErrorHandler.showSweetCustomErrorUI(getString(R.string.no_sweets_found), R.drawable.ic_adb_black_24dp,\n\t\t\t\tllSweet, layoutError)\t\n   \t }\n  }\n```\n\n  - Initialize the SweetUIErrorHandler in your **Fragment** and use it.\n  \n```kotlin\nclass SweetErrorInFragment : Fragment {\n\n    private lateinit var rootView: View\n    private lateinit var sweetUIErrorHandler: SweetUIErrorHandler\n    \n    companion object {\n         fun newInstance() = SweetErrorInFragment().apply {\n             arguments = Bundle()\n         }\n    }\n    \n    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {\n           return inflater.inflate(R.layout.fragment_sweet, container, false)\n    }\n    \n    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {\n       val layoutError = rootView.findViewById(R.id.layout_error)\n       val llSweet = rootView.findViewById(R.id.ll_sweet) // It can be any child of your xml like Relativelayout, RecyclerView etc, as we defined in above xml.\n               \n       sweetUIErrorHandler = SweetUIErrorHandler(activity!!, view)\n              \n       // Now you are all set. Whatever error UI you want to show according to condition like\n       // you can use rest of things as we are using in above activity.\n      \n       // Use this button click to refresh UI if any error occured or any Network issue occured.\n       val btnTryAgain = view.findViewById\u003cButton\u003e(R.id.btnTryAgain)\n              \n       return rootView;\n    }\n}\n```\n\n# Button Style according to your project style\n```xml\n\u003cresources\u003e\n\n    \u003c!-- Base application theme. --\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\"\u003e // whatever parent style you use.\n        \u003c!-- Customize your theme here. --\u003e\n\t\u003c!-- Whatever theme have here. --\u003e\n        \u003citem name=\"colorPrimary\"\u003e@color/colorPrimary\u003c/item\u003e\n        \u003citem name=\"colorPrimaryDark\"\u003e@color/colorPrimaryDark\u003c/item\u003e\n        \u003citem name=\"colorAccent\"\u003e@color/colorAccent\u003c/item\u003e\n\t\n\t** Add this styles to your base project style and you are all set.**\n        \u003citem name=\"colorButtonNormal\"\u003e@color/colorPrimary\u003c/item\u003e\n        \u003citem name=\"android:buttonStyle\"\u003e@style/AppTheme.Button\u003c/item\u003e\n        \u003citem name=\"buttonStyle\"\u003e@style/AppTheme.Button\u003c/item\u003e\n    \u003c/style\u003e\n\n    \u003cstyle name=\"AppTheme.Button\" parent=\"Widget.AppCompat.Button\"\u003e\n        \u003citem name=\"android:textColor\"\u003e@android:color/white\u003c/item\u003e\n        \u003citem name=\"android:textColorPrimary\"\u003e@android:color/white\u003c/item\u003e\n    \u003c/style\u003e\n\n\u003c/resources\u003e\n```\n\n# Design Inspiration\n\nSelf developing projects\n\n# Developers\n\n* [Rajan Maurya](https://github.com/therajanmaurya)\n\n# License\n\n```\nCopyright 2019 Rajan Maurya\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftherajanmaurya%2Fsweet-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftherajanmaurya%2Fsweet-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftherajanmaurya%2Fsweet-error/lists"}