{"id":13642401,"url":"https://github.com/WassimBenltaief/FlowLayout","last_synced_at":"2025-04-20T16:32:08.976Z","repository":{"id":75276330,"uuid":"68936710","full_name":"WassimBenltaief/FlowLayout","owner":"WassimBenltaief","description":"A custom Layout packed with a content view, an empty view, a progress bar and network connectivity status","archived":false,"fork":false,"pushed_at":"2018-08-21T14:22:14.000Z","size":433,"stargazers_count":228,"open_issues_count":1,"forks_count":24,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-09T13:38:40.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WassimBenltaief.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-22T15:46:41.000Z","updated_at":"2024-09-19T03:21:02.000Z","dependencies_parsed_at":"2023-06-06T00:00:15.691Z","dependency_job_id":null,"html_url":"https://github.com/WassimBenltaief/FlowLayout","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WassimBenltaief%2FFlowLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WassimBenltaief%2FFlowLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WassimBenltaief%2FFlowLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WassimBenltaief%2FFlowLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WassimBenltaief","download_url":"https://codeload.github.com/WassimBenltaief/FlowLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249926308,"owners_count":21346530,"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":[],"created_at":"2024-08-02T01:01:30.961Z","updated_at":"2025-04-20T16:32:08.670Z","avatar_url":"https://github.com/WassimBenltaief.png","language":"Java","readme":"\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FlowLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/4407)\n\n# FlowLayout\nA custom Layout able to display content, empty view, progress bar and network connectivity status.\n\n1. [Why this layout](https://github.com/WassimBenltaief/FlowLayout#why-this-layout)\n2. [Download](https://github.com/WassimBenltaief/FlowLayout#download)\n3. [How](https://github.com/WassimBenltaief/FlowLayout#how)\n4. [Connectivity Awareness](https://github.com/WassimBenltaief/FlowLayout#connectivity-awareness)\n5. [Customize connectivity view (colors / text / layout)](https://github.com/WassimBenltaief/FlowLayout#customize-connectivity)\n6. [Customize empty view](https://github.com/WassimBenltaief/FlowLayout#customize-empty-view)\n7. [Customize progress view](https://github.com/WassimBenltaief/FlowLayout#customize-progress-bar-)\n8. [Customize error view](https://github.com/WassimBenltaief/FlowLayout#customize-error-view-)\n9. [PR](https://github.com/WassimBenltaief/FlowLayout#pr)\n10. [TODOS](https://github.com/WassimBenltaief/FlowLayout#todos)\n\n#Why this layout\nA very common flow of an android view is :\n- show a progress bar while fetching data from a remote service.\n- if the resut is empty : show an empty view with a custom message and hide the progressbar.\n- If not : show the content and hide the progressbar.\n- showing a notification when phone is not connected or when action requires internet connection.\n\nFlowLayout do all of this for you with a very few code in a customized way.\n\n#Download\n\n```groovy\ncompile 'com.beltaief.flowlayout:flowlayout:0.4.0'\n```\n\n#How\n\nFlowLayout extends a FrameLayout. So add it to your view as a regular View and compose inside it :\n\nin your ```activity_layout.xml``` :\n\n```xml\n\u003ccom.beltaief.flowlayout.FlowLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:id=\"@+id/flow_layout\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    // content goes here\n\n\u003c/com.beltaief.flowlayout.FlowLayout\u003e\n```\n\nthen in your Activity/Fragment :\n```java\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_layout);\n    \n    // lookup for the layout\n    FlowLayout flowLayout = (FlowLayout)findViewById(R.id.flow_layout);\n    \n    //set mode progress\n    flowLayout.setMode(ViewMode.PROGRESS);\n    \n    // fetch data\n    ...\n    \n    // assign result to the view\n    if (data.isEmpty()) {\n      flowLayout.setMode(ViewMode.EMPTY);\n    } else {\n      flowLayout.setMode(ViewMode.CONTENT);\n      // show the data in the view\n      ...\n    }\n    \n    ... \n    // or set error view\n    flowLayout.setMode(ViewMode.ERROR);\n}\n```\n[content]: https://github.com/WassimBenltaief/FlowLayout/blob/master/images/content_loading.gif\n\n[empty]: https://github.com/WassimBenltaief/FlowLayout/blob/master/images/empty_example.gif\n\n| content mode  | empty mode    |   \n|:-------------:|:-------------:|\n| ![][content]  | ![][empty]    |\n\n\n#Connectivity awareness\nIf you would like the view to notify when connectivity status changes, then add this attribute to the XML declaration of FlowLayout :\n\n```xml \napp:isConnectivityAware=\"true\"\n```\n\nor programmatically\n\n```java\nflowLayout.setConnectivityAware(true);\n```\n\nAnd the view will be able to notify whenever the status of the internet connection changes :\n\n![](https://github.com/WassimBenltaief/FlowLayout/blob/master/images/connectivity.gif)\n\n# Customize connectivity\n\nFlowLayout comes with several attributes to help customizing the connectivity view.\nAdd attributes to your xml to apply customization :\n\nto customize color and/or  text in the default connectivity view\n```xml\napp:isConnectivityAware=\"true\" // true, false\napp:connectedText=\"@string/connectedTextStringResource\" // text to show when connected\napp:connectedTextColor=\"@color/connectedTextColorResource\" // text color\napp:connectedBackground=\"@color/connectedBackgroundColorResource\" // background color\napp:disconnectedText=\"@string/disconnectedTextStringResource\" // text to show when disconnected\napp:disconnectedTextColor=\"@color/disconnectedTextColorResource\" // text color\napp:disconnectedBackground=\"@color/disconnectedBackgroundColorResource\" // background color\n```\n\nor i you want to provide your own layout content :\n```xml\napp:connectedLayout=\"@layout/custom_connected_layout\"\napp:disconnectedLayout=\"@layout/custom_disconnected_layout\"\n```\n\n### Example :\n\n```xml\n\u003ccom.beltaief.flowlayout.FlowLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:id=\"@+id/reveLayout\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:isConnectivityAware=\"true\"\n    app:connectedText=\"@string/connected_message\"\n    app:connectedTextColor=\"@color/white\"\n    app:connectedBackground=\"@color/blue_light\"\n    app:disconnectedBackground=\"@color/colorAccent\"\u003e\n\n    \u003candroid.support.v7.widget.RecyclerView\n        android:id=\"@+id/recycler\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\" /\u003e\n\n\u003c/com.beltaief.flowlayout.FlowLayout\u003e\n\n```\n\nor programmatically :\n\n```java\nflowLayout.setConnectivityAware(true);\n\nflowLayout.setConnectedText(R.string.connected_message);\nflowLayout.setConnectedTextColor(R.color.connected_color);\nflowLayout.setConnectedBackground(R.color.connected_color);\n\nflowLayout.setDisconnectedText(R.string.text_disconnected);\nflowLayout.setDisconnectedTextColor(R.color.disconnected_color);\nflowLayout.setDisconnectedBackground(R.color.disconnected_color);\n\n```\n\n### Screenshot\n\n\n![](https://github.com/WassimBenltaief/FlowLayout/blob/master/images/custom_connectivity.gif)\n\n# Customize Empty View\nThere's two ways to customize the empty view :\n\n1. custom text and color :\nTo override the default text and colors, add a reference to your custom text/color in xml\n\n```xml\napp:emptyLayout=\"@layout/custom_empty\"\napp:emptyText=\"@string/text_empty\"\napp:emptyTextColor=\"@color/text_empty_color\"\n```\nor programmatically :\n\n```java\nflowLayout.setEmptyLayout(R.layout.layout_empty);\nflowLayout.setEmptyText(R.string.text_empty); // Do not combine with .setEmptyLayout()\nflowLayout.setEmptyTextColor(R.color.text_empty_color); // Do not combine with .setEmptyLayout()\n```\n\n2. Custom layout :\nOverride the empty layout by providing a reference in xml :\n\n```xml\napp:emptyLayout=\"@layout/custom_empty\"\n```\nor programmatically :\n\n```java\nflowLayout.setEmptyLayout(R.layout.layout_empty);\n```\n\n### Screenshot\n![](https://github.com/WassimBenltaief/FlowLayout/blob/master/images/custom_empty.gif)\n\n# Customize Progress bar :\n\nif you want to provide your own progress view :\n\n```xml\napp:progressLayout=\"@layout/custom_progress\"\n```\n\n\n# Customize Error View :\n\nif you want to provide your own error view :\n\n```xml\napp:errorLayout=\"@layout/custom_error\"\n```\n\n# PR\nOpen.\n\n# TODOS\n\n- \u003cdel\u003eadd customization to progress-bar\u003c/del\u003e Done\n- \u003cdel\u003eadd error view\u003c/del\u003e Done\n- \u003cdel\u003euse @IntDef for setting view modes\u003c/del\u003e Done\n- Use ViewStub\n- any other idea is welcome\n\n#Licence\nThe MIT License (MIT)\n\nCopyright (c) 2014 Wassim Beltaief\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["空白页"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWassimBenltaief%2FFlowLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWassimBenltaief%2FFlowLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWassimBenltaief%2FFlowLayout/lists"}