{"id":13848856,"url":"https://github.com/ManuelPeinado/RefreshActionItem","last_synced_at":"2025-07-12T13:32:57.163Z","repository":{"id":7904626,"uuid":"9286207","full_name":"ManuelPeinado/RefreshActionItem","owner":"ManuelPeinado","description":"Android - An action bar item which acts both as a refresh button and as a progress indicator","archived":false,"fork":false,"pushed_at":"2014-01-06T16:43:20.000Z","size":4819,"stargazers_count":650,"open_issues_count":7,"forks_count":108,"subscribers_count":38,"default_branch":"master","last_synced_at":"2024-07-01T10:58:12.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"twitter/ambrose","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ManuelPeinado.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-08T01:23:54.000Z","updated_at":"2024-04-09T14:13:11.000Z","dependencies_parsed_at":"2022-09-26T21:41:27.688Z","dependency_job_id":null,"html_url":"https://github.com/ManuelPeinado/RefreshActionItem","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/ManuelPeinado%2FRefreshActionItem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManuelPeinado%2FRefreshActionItem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManuelPeinado%2FRefreshActionItem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManuelPeinado%2FRefreshActionItem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ManuelPeinado","download_url":"https://codeload.github.com/ManuelPeinado/RefreshActionItem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213949840,"owners_count":15661680,"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-04T19:00:59.607Z","updated_at":"2024-08-04T19:03:31.341Z","avatar_url":"https://github.com/ManuelPeinado.png","language":"Java","funding_links":[],"categories":["Java","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"RefreshActionItem\n=================\n\nAn action bar item that implements this common pattern:\n\n* Initially it shows a refresh button.\n* If the button is clicked, a background operation begins and the button turns into a progress indicator.\n* When the background operation ends, the button is restored to its initial state.\n\nThe progress bar shows a magnitude which represents how far the operation has proceeded. The progress bar can also be made indeterminate, just like the built-in \u003ctt\u003eProgressBar\u003c/tt\u003e.\n \nIt is possible to add a small badge to the action item. This tells the user that there is new data available.\n\nThis library requires [ActionBarSherlock][1], and is thus compatible with Android 2.x and newer. If you use the new ActionBarCompat instead, you can use [this fork][2]. Finally, if you don't need 2.x compatibility and thus use the native action bar, there is [another fork][3] that you can use.\n\n![Example Image][4]\n\nTry out the sample application:\n\n\u003ca href=\"https://play.google.com/store/apps/details?id=com.manuelpeinado.refreshactionitem.demo\"\u003e\n  \u003cimg alt=\"Android app on Google Play\"\n       src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\nOr browse the [source code][5] of the sample application for a complete example of use.\n\n\nIncluding in your project\n-------------------------\n\nIf you’re using Eclipse with the ADT plugin you can include RefreshActionItem as a library project. Create a new Android project in Eclipse using the library/ folder as the existing source. Then, open the properties of this new project and, in the 'Android' category, add a reference to the ActionBarSherlock library project. Finally, in your application project properties, add a reference to the created library project.\n\nIf you use maven to build your Android project you can simply add a dependency for this library.\n\n```xml\n \u003cdependency\u003e\n     \u003cgroupId\u003ecom.github.manuelpeinado.refreshactionitem\u003c/groupId\u003e\n     \u003cartifactId\u003elibrary\u003c/artifactId\u003e\n     \u003cversion\u003e1.0.3\u003c/version\u003e\n     \u003ctype\u003eapklib\u003c/type\u003e\n \u003c/dependency\u003e\n```\n\nUsage\n-----\n\nAdd an element for the refresh action to your XML menu:\n\n```xml\n\u003citem\n    android:id=\"@+id/refresh_button\"          \n    android:actionViewClass=\n        \"com.manuelpeinado.refreshactionitem.RefreshActionItem\"\n    android:showAsAction=\"always\"\n    android:title=\"@string/action_refresh\"/\u003e\n```\n\nThen, configure the action in the \u003ctt\u003eonCreateOptionsMenu\u003c/tt\u003e method of your \u003ctt\u003eSherlockActivity\u003c/tt\u003e-derived activity:\n\n```java\n@Override public boolean onCreateOptionsMenu(Menu menu) {\n    getSupportMenuInflater().inflate(R.menu.main, menu);\n    MenuItem item = menu.findItem(R.id.refresh_button);\n    mRefreshActionItem = (RefreshActionItem) item.getActionView();\n    mRefreshActionItem.setMenuItem(item);\n    mRefreshActionItem.setMax(100);\n    mRefreshActionItem.setRefreshActionListener(this);\n    return true;\n}\n```\n\nThe \u003ctt\u003esetRefreshActionListener\u003c/tt\u003e method registers a callback that will be invoked when the refresh button is clicked. Start your background process from this callback and invoke \u003ctt\u003eshowProgress(true)\u003c/tt\u003e on the action item so that it turns into a progress indicator:\n\n```java\n@Override\npublic void onRefreshButtonClick(RefreshActionItem sender) {\n    mRefreshActionItem.showProgress(true);\n    startBackgroundTask();\n}\n```\n\nFrom your background task, call the action item's \u003ctt\u003esetProgress(int)\u003c/tt\u003e method each time some progress is made:\n\n```java\nmRefreshActionItem.setProgress(progress);\n```\n    \nFinally, when the background task is complete restore the action item to its original state:\n\n```java\nmRefreshActionItem.showProgress(false);\n```\n\n### Progress indicator types\n\nBy default the action item shows the amount of progress using a wheel. There is an additional style, \"pie\", which you can activate by calling \u003ctt\u003esetProgressIndicatorType(ProgressIndicatorType.PIE)\u003c/tt\u003e on your action item.\n\nAlso, if the progress of your background task cannot be easily measured you might prefer to use an indeterminate progress indicator. To achieve this just pass \u003ctt\u003eProgressIndicatorType.INDETERMINATE\u003c/tt\u003e to \u003ctt\u003esetProgressIndicatorType()\u003c/tt\u003e.\n\n### Badges\n\nSometimes it is useful to give the user a visual hint suggesting that there is new data to be loaded. You can easily achieve this by adding a badge to your action item:\n\n```java\nmRefreshActionItem.showBadge();\n```\n\nThe badge shows an exclamation mark by default, but you can specify an alternative text if you desire.\n\n\nCustomization\n---------------------\nYou can easily customize the appearance of your RefreshActionItems. Just define a \u003ctt\u003erefreshActionItemStyle\u003c/tt\u003e attribute in your theme and make it reference a custom style where you specify new values for any of the multiple attributes recognized by the library.\n\nThe following snippet is extracted from the accompanying sample application. To see it in action open the \"Styling\" demo in the main menu.\n\n```xml\n\u003cstyle name=\"AppTheme\" parent=\"Theme.Sherlock.Light\"\u003e\n    \u003citem name=\"refreshActionItemStyle\"\u003e@style/CustomRefreshActionItem\u003c/item\u003e\n\u003c/style\u003e\n\n\u003cstyle name=\"CustomRefreshActionItem\" parent=\"Widget.RefreshActionItem.Light\"\u003e\n    \u003citem name=\"progressIndicatorType\"\u003epie\u003c/item\u003e\n    \u003citem name=\"badgeBackgroundColor\"\u003e#A4F4\u003c/item\u003e\n    \u003citem name=\"badgeTextStyle\"\u003e@style/BadgeText\u003c/item\u003e\n    \u003citem name=\"badgePosition\"\u003ebottomLeft\u003c/item\u003e\n\u003c/style\u003e\n\n\u003cstyle name=\"BadgeText\"\u003e\n    \u003citem name=\"android:textSize\"\u003e14dp\u003c/item\u003e\n    \u003citem name=\"android:textColor\"\u003e#7000\u003c/item\u003e\n\u003c/style\u003e\n```\n\nLibraries used\n--------------------\n\n* [ActionBarSherlock][1] by Jake Wharton.\n* [android-viewbadger][6] by Jeff Gilfelt.\n\nCredits\n-------\n* Thanks to Fede Fernández for [adapting the library][2] to use ActionBarCompat.\n* Cake launcher icon by [IconEden][7].\n\nWho's using it\n--------------\n\n* [The New York Times][8]. Experience the world’s finest journalism with The New York Times app for Android.\n* [DevAppsDirect][9]. Developer Apps Direct is a large and growing collection of library demos.\n* [Signos Fodas][10]. With this app you can follow all horoscope signs, updated daily in real time on your Android (Portuguese only).\n\n*Does your app use RefreshActionItem? If you want to be featured on this list drop me a line.*\n\nDeveloped By\n--------------------\n\nManuel Peinado Gallego - \u003cmanuel.peinado@gmail.com\u003e\n\n\u003ca href=\"https://twitter.com/mpg2\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"https://raw.github.com/ManuelPeinado/NumericPageIndicator/master/art/twitter.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://plus.google.com/106514622630861903655\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"https://raw.github.com/ManuelPeinado/NumericPageIndicator/master/art/google-plus.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"http://www.linkedin.com/pub/manuel-peinado-gallego/1b/435/685\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"https://raw.github.com/ManuelPeinado/NumericPageIndicator/master/art/linkedin.png\" /\u003e\n\nLicense\n-----------\n\n    Copyright 2013 Manuel Peinado\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\n\n\n\n [1]: http://actionbarsherlock.com\n [2]: https://github.com/projectsexception/RefreshActionItem-ActionBarCompat\n [3]: https://github.com/ManuelPeinado/RefreshActionItem-Native\n [4]: https://raw.github.com/ManuelPeinado/RefreshActionItem/master/art/readme_pic.png\n [5]: https://github.com/ManuelPeinado/RefreshActionItem/tree/master/sample\n [6]: https://github.com/jgilfelt/android-viewbadger\n [7]: http://www.iconeden.com\n [8]: https://play.google.com/store/apps/details?id=com.nytimes.android\n [9]: https://play.google.com/store/apps/details?id=com.inappsquared.devappsdirect\n [10]: https://play.google.com/store/apps/details?id=com.contralabs.app.horoscoposignos\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FManuelPeinado%2FRefreshActionItem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FManuelPeinado%2FRefreshActionItem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FManuelPeinado%2FRefreshActionItem/lists"}