Android-ActionItemBadge


Source link: https://github.com/mikepenz/Android-ActionItemBadge

Android-ActionItemBadge

ActionItemBadge is a library which offers a simple and easy to use method to add a badge to your action item!

Screenshots

Include in your project

Using Maven

The ActionItemBadge Library is pushed to [Maven Central], so you just need to add the following dependency to your build.gradle.

dependencies {
  implementation 'com.mikepenz:actionitembadge:3.3.2@aar'
//SUB-DEPENDENCIES  //Android-Iconics - used to provide an easy API for icons   implementation 'com.mikepenz:iconics-core:{
latestVersion
}
@aar'
//appcompat  implementation "com.android.support:appcompat-v7:${
supportLibVersion
}
" 
}

Additional dependency for the icon font

If you are going to use the icon font you will have to add additional dependency for the font. You can find all available addons here: https://github.com/mikepenz/Android-Iconics#2-choose-your-desired-fonts

UPGRADE NOTES

< 3.0.0

  • If you come from a version prior 3.0.0 you will have to rename some classes, and the default styles also found a new place. Just check out the updated sample app for all the changes.

Usage

menu.xml

Create your menu.xml as you would do normally and add the app:actionLayout param. It is also a good idea to set showAsAction="always" (The badge can only be shown in the actionbar)

<menu xmlns:android="http://schemas.android.com/apk/res/android"

 xmlns:tools="http://schemas.android.com/tools"

 xmlns:app="http://schemas.android.com/apk/res-auto">
  <item

android:id="@+id/item_samplebadge"

app:actionLayout="@layout/menu_action_item_badge"

app:showAsAction="always"

android:title="@string/sample_1"/> </menu>

Activity

Override the onCreateOptionsMenu method

 @Override
  public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

 //you can add some logic (hide it if the count == 0)

if (badgeCount > 0) {

 ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyles.DARK_GREY, badgeCount);

}
 else {

 ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));

}

 //If you want to add your ActionItem programmatically you can do this too. You do the following:

new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(bigStyle, 1);

return super.onCreateOptionsMenu(menu);

  
}

If you want to update the item itself you can do the required stuff in the onOptionsItemSelected method and call invalidateOptionsMenu() afterwards.

 @Override
  public boolean onOptionsItemSelected(MenuItem item) {

int id = item.getItemId();

if (id == R.id.item_samplebadge) {

 Toast.makeText(this, R.string.sample_3, Toast.LENGTH_SHORT).show();

 badgeCount--;

 ActionItemBadge.update(item, badgeCount);

 return true;

}
 else if (id == SAMPLE2_ID) {

 Toast.makeText(this, R.string.sample_4, Toast.LENGTH_SHORT).show();

}

return super.onOptionsItemSelected(item);

  
}

Dependencies

Developed By

License

Copyright 2017 Mike Penz  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

android-openslmediaplayer is a re-implementation of Android's MediaPlayer and audio effect classes based on OpenSL ES APIs.

Features:

  • Provides both C++ and Java API sets
  • Smooth fade in/out when starts/pauses playback
  • High quality resampler
  • 10 bands graphic equalizer & pre. amplifier
  • High quality Visualizer class

MultiSelectListPreferenceCompat

Backport MultiSelectListPreference class to older android devices.

Originally MultiSelectListPreference was introduced to API level 11 (Honeycomb) and official support package does not include this class. This library introduces compatible class of MultiSelectListPreference.

android-verticalseekbar is a vertical SeekBar class which supports Android 2.3 - 5.0.

Pretty is a library that enables one to enhance Android layout inflation without boilerplate and knowledge about LayoutInflater internals. Pretty hooks into the Android layout inflation so you could add new attributes to existing View subtypes.

Statically typed programming language targeting the JVM and JavaScript.

100% interoperable with Java™

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes