{"id":23375703,"url":"https://github.com/tornelas/segmentedprogressbar","last_synced_at":"2025-04-04T21:10:42.638Z","repository":{"id":39206017,"uuid":"256691390","full_name":"TOrnelas/SegmentedProgressBar","owner":"TOrnelas","description":"An instagram-like segmented progress bar","archived":false,"fork":false,"pushed_at":"2023-03-01T14:00:34.000Z","size":183,"stargazers_count":381,"open_issues_count":14,"forks_count":36,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:11:12.388Z","etag":null,"topics":["android-library","instagram","progress-bar","viewpager"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/TOrnelas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-04-18T07:09:35.000Z","updated_at":"2025-02-19T11:42:46.000Z","dependencies_parsed_at":"2024-01-14T14:31:51.361Z","dependency_job_id":"5c79ec26-f061-4be9-913b-9e28d1c2bd9d","html_url":"https://github.com/TOrnelas/SegmentedProgressBar","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TOrnelas%2FSegmentedProgressBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TOrnelas%2FSegmentedProgressBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TOrnelas%2FSegmentedProgressBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TOrnelas%2FSegmentedProgressBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TOrnelas","download_url":"https://codeload.github.com/TOrnelas/SegmentedProgressBar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249532,"owners_count":20908212,"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-library","instagram","progress-bar","viewpager"],"created_at":"2024-12-21T17:17:13.772Z","updated_at":"2025-04-04T21:10:42.610Z","avatar_url":"https://github.com/TOrnelas.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SegmentedProgressBar\n\nAn Instagram-like stories segmented progress bar\n\n[![](https://jitpack.io/v/TOrnelas/SegmentedProgressBar.svg)](https://jitpack.io/#TOrnelas/SegmentedProgressBar)\n[![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-SegmentedProgressBar-green.svg?style=flat )]( https://android-arsenal.com/details/1/8229 )\n\n![screen-20210306-002812_2 (3)](https://user-images.githubusercontent.com/17816841/110188846-0a784800-7e15-11eb-85c2-897e572173c2.gif)\n\n\n## Setup\n\nAdd Jitpack repository to your project level `build.gradle`\n\n```\nallprojects {\n    repositories {\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\nAdd SegmentedProgressBar to your app's `build.gradle` dependencies\n\n```\ndependencies {\n    implementation 'com.github.TOrnelas:SegmentedProgressBar:{latest-version}'\n}\n```\nFind all versions available [here](https://github.com/TOrnelas/SegmentedProgressBar/releases)\n\n## Usage\n\n### Add it to your layout xml file\n\n```\n\u003cpt.tornelas.segmentedprogressbar.SegmentedProgressBar\n        android:id=\"@+id/spb\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"5dp\"\n        android:layout_margin=\"8dp\"\n        app:layout_constraintTop_toTopOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:segmentBackgroundColor=\"@color/colorAccent\"\n        app:segmentSelectedBackgroundColor=\"@color/colorPrimary\"\n        app:segmentStrokeColor=\"@android:color/black\"\n        app:segmentSelectedStrokeColor=\"@android:color/black\"\n        app:segmentStrokeWidth=\"1dp\"\n        app:segmentCornerRadius=\"2dp\"\n        app:segmentMargins=\"@dimen/default_segment_margin\"\n        app:totalSegments=\"10\"\n        app:timePerSegment=\"2000\"/\u003e\n```\n\nAlternatively, you can set all properties in your Fragment/Activity:\n\n```\nval spb = findViewById\u003cSegmentedProgressBar\u003e(R.id.spb)\nspb.segmentCount = 10\n...\n```\n\n### Initialize it and start it\n\n```\nval spb = findViewById\u003cSegmentedProgressBar\u003e(R.id.spb)\nspb.start()\n```\n\n## Available methods\n\n```\n// Starts/resumes progress animation\nspb.start()\n\n// Pauses progress animation\nspb.pause()\n\n// Restarts progress animation\nspb.reset()\n\n// Completes animation of current segment, starts animating following segment\nspb.next()\n\n// Resets animation of current segment, starts animating previous segment\nspb.previous()\n\n// Resets animation of current segment\nspb.restartSegment()\n\n// Skips X segments (-X option available)\nspb.skip(X)\n\n// Restarts animation for segment at position X\nspb.setPosition(X)\n```\n\n## Set a ViewPager\n\nYou can sync a [ViewPager2](https://developer.android.com/jetpack/androidx/releases/viewpager2) with a SegmentedProgressBar by doing\n\n```\nspb.viewPager = viewPager\n```\n\nThis will\n- Update the SegmentedProgressBar segments automatically when a swipe action is done on a ViewPager\n- Pause/Resume progress animation when user touches down/up on the view pager (Like you do to pause an Instagram story)\n\n## Set a Listener\n\n```\nspb.listener = object : SegmentedProgressBarListener {\n    override fun onPage(oldPageIndex: Int, newPageIndex: Int) {\n        // New page started animating\n    }\n\n    override fun onFinished() {\n        // All segments animated and finished animation\n    }\n}\n```\n\nFeel free to checkout the [sample](https://github.com/TOrnelas/SegmentedProgressBar/tree/master/app) on this repository\n\n```\nMIT License\n\nCopyright (c) 2020 Tiago Ornelas\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject 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,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftornelas%2Fsegmentedprogressbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftornelas%2Fsegmentedprogressbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftornelas%2Fsegmentedprogressbar/lists"}