This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
doSomethingCool(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button.setOnClickListener { doSomethingCool() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Picasso.with(context).load("http://i.imgur.com/W3C6LA1.png").into(imageView); | |
Glide.with(context).load("http://i.imgur.com/W3C6LA1.png").into(imageView); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias c="clear" # Clears your terminal window of all output | |
alias d="adb devices" # Lists all connected Android devices and emulators | |
alias gs="git status" # Displays status of your working tree in a repository | |
alias gb="git branch" # Displays local branches | |
alias gas="git add *" # Adds all files to the git staging area | |
alias log="adb logcat" # Displays the android logcat | |
alias adbr="adb kill-server; adb start-server; d" # Restarts the adb server, adb can be quite finnicky and restarting helps to alleviate those problems. That last d character is a reference to the alias defined above, which points to “adb devices” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.orobator.konstellations"> | |
<application | |
android:name=".KonstellationsApplication" | |
android:allowBackup="true" | |
android:icon="@drawable/app_icon" | |
android:label="@string/app_name" | |
android:supportsRtl="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> | |
<shortcut | |
android:enabled="true" | |
android:icon="@drawable/random_constellation" | |
android:shortcutDisabledMessage="@string/shortcut_disabled_message" | |
android:shortcutId="random_constellation" | |
android:shortcutLongLabel="@string/shortcut_long_label" | |
android:shortcutShortLabel="@string/shortcut_short_label"> | |
<!-- Each one of these intents needs an android:action, even if you don't |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val shortcutManager = context.getSystemService(ShortcutManager::class.java) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity { | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); | |
if (shortcutManager.getDynamicShortcuts().size() == 0) { | |
// Application restored. Need to re-publish dynamic shortcuts. | |
if (shortcutManager.getPinnedShortcuts().size() > 0) { | |
// Pinned shortcuts have been restored. Use | |
// updateShortcuts(List) to make sure they | |
// contain up-to-date information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@TargetApi(N_MR1) | |
fun trackShortcutUsed(shortcutManager: ShortcutManager, constellation: Constellation) { | |
shortcutManager.reportShortcutUsed(constellation.name) | |
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT) | |
val seenCount = sharedPrefs.getInt(constellation.name, 0) | |
sharedPrefs | |
.edit() | |
.putInt(constellation.name, seenCount + 1) | |
.apply() | |
updateShortcuts(shortcutManager) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shortcutAction { | |
trackShortcutUsed(it, constellation) | |
} |
OlderNewer