diff --git a/README.md b/README.md index 373eb13..ab6a8b6 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,14 @@ USAGE
3. Add the codes below: int badgeCount = 1; - ShortcutBadger.with(getApplicationContext()).count(badgeCount); + ShortcutBadger.applyCount(context, badgeCount);
4. If you want to remove the badge - ShortcutBadger.with(getApplicationContext()).remove(); + ShortcutBadger.removeCount(context); or - ShortcutBadger.with(getApplicationContext()).count(0); + ShortcutBadger.applyCount(context, 0);


diff --git a/SampleApp/src/main/java/me/leolin/shortcutbadger/example/MainActivity.java b/SampleApp/src/main/java/me/leolin/shortcutbadger/example/MainActivity.java index 93cdcd3..387b00e 100644 --- a/SampleApp/src/main/java/me/leolin/shortcutbadger/example/MainActivity.java +++ b/SampleApp/src/main/java/me/leolin/shortcutbadger/example/MainActivity.java @@ -11,18 +11,17 @@ import android.widget.TextView; import android.widget.Toast; import me.leolin.shortcutbadger.ShortcutBadger; +import me.leolin.shortcutbadger.impl.ApexHomeBadger; public class MainActivity extends Activity { - private EditText numInput; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - numInput = (EditText) findViewById(R.id.numInput); + final EditText numInput = (EditText) findViewById(R.id.numInput); Button button = (Button) findViewById(R.id.btnSetBadge); button.setOnClickListener(new View.OnClickListener() { @@ -35,10 +34,19 @@ public void onClick(View v) { Toast.makeText(getApplicationContext(), "Error input", Toast.LENGTH_SHORT).show(); } -// ShortcutBadger.setBadge(getApplicationContext(), badgeCount); - ShortcutBadger.with(getApplicationContext()).count(badgeCount); + boolean success = ShortcutBadger.applyCount(MainActivity.this, badgeCount); + + Toast.makeText(getApplicationContext(), "Set count=" + badgeCount + ", success=" + success, Toast.LENGTH_SHORT).show(); + } + }); + + Button removeBadgeBtn = (Button) findViewById(R.id.btnRemoveBadge); + removeBadgeBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + boolean success = ShortcutBadger.removeCount(MainActivity.this); - Toast.makeText(getApplicationContext(), "Set count=" + badgeCount, Toast.LENGTH_SHORT).show(); + Toast.makeText(getApplicationContext(), "success=" + success, Toast.LENGTH_SHORT).show(); } }); diff --git a/SampleApp/src/main/res/layout/activity_main.xml b/SampleApp/src/main/res/layout/activity_main.xml index fdc9b49..b069a8e 100644 --- a/SampleApp/src/main/res/layout/activity_main.xml +++ b/SampleApp/src/main/res/layout/activity_main.xml @@ -27,5 +27,11 @@ android:text="Set badge" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/> +