diff options
Diffstat (limited to 'sample/src/main/kotlin/ca')
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt | 8 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 123 |
2 files changed, 67 insertions, 64 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt deleted file mode 100644 index a0b3dc5..0000000 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ca.allanwang.kau.sample - -import ca.allanwang.kau.imagepicker.ImagePickerActivityBase - -/** - * Created by Allan Wang on 2017-07-04. - */ -class ImageActivity : ImagePickerActivityBase()
\ No newline at end of file diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index 53ec745..4711701 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -1,10 +1,14 @@ package ca.allanwang.kau.sample +import android.content.Intent import android.os.Bundle import android.os.PersistableBundle import android.view.Menu import android.view.MenuItem +import ca.allanwang.kau.about.kauLaunchAbout import ca.allanwang.kau.email.sendEmail +import ca.allanwang.kau.imagepicker.kauLaunchImagePicker +import ca.allanwang.kau.imagepicker.kauOnImagePickerResult import ca.allanwang.kau.kpref.activity.CoreAttributeContract import ca.allanwang.kau.kpref.activity.KPrefActivity import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder @@ -22,53 +26,59 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial class MainActivity : KPrefActivity() { var searchView: SearchView? = null - //some of the most common english words for show - val wordBank: List<String> by lazy { - listOf("the", "name", "of", "very", "to", "through", - "and", "just", "a", "form", "in", "much", "is", "great", "it", "think", "you", "say", - "that", "help", "he", "low", "was", "line", "for", "before", "on", "turn", "are", "cause", - "with", "same", "as", "mean", "I", "differ", "his", "move", "they", "right", "be", "boy", - "at", "old", "one", "too", "have", "does", "this", "tell", "from", "sentence", "or", "set", - "had", "three", "by", "want", "hot", "air", "but", "well", "some", "also", "what", "play", - "there", "small", "we", "end", "can", "put", "out", "home", "other", "read", "were", "hand", - "all", "port", "your", "large", "when", "spell", "up", "add", "use", "even", "word", "land", - "how", "here", "said", "must", "an", "big", "each", "high", "she", "such", "which", "follow", - "do", "act", "their", "why", "time", "ask", "if", "men", "will", "change", "way", "went", - "about", "light", "many", "kind", "then", "off", "them", "need", "would", "house", "write", - "picture", "like", "try", "so", "us", "these", "again", "her", "animal", "long", "point", - "make", "mother", "thing", "world", "see", "near", "him", "build", "two", "self", "has", - "earth", "look", "father", "more", "head", "day", "stand", "could", "own", "go", "page", - "come", "should", "did", "country", "my", "found", "sound", "answer", "no", "school", "most", - "grow", "number", "study", "who", "still", "over", "learn", "know", "plant", "water", "cover", - "than", "food", "call", "sun", "first", "four", "people", "thought", "may", "let", "down", "keep", - "side", "eye", "been", "never", "now", "last", "find", "door", "any", "between", "new", "city", - "work", "tree", "part", "cross", "take", "since", "get", "hard", "place", "start", "made", - "might", "live", "story", "where", "saw", "after", "far", "back", "sea", "little", "draw", - "only", "left", "round", "late", "man", "run", "year", "don't", "came", "while", "show", - "press", "every", "close", "good", "night", "me", "real", "give", "life", "our", "few", "under", - "stopRankWordRankWord", "open", "ten", "seem", "simple", "together", "several", "next", - "vowel", "white", "toward", "children", "war", "begin", "lay", "got", "against", "walk", "pattern", - "example", "slow", "ease", "center", "paper", "love", "often", "person", "always", "money", - "music", "serve", "those", "appear", "both", "road", "mark", "map", "book", "science", "letter", - "rule", "until", "govern", "mile", "pull", "river", "cold", "car", "notice", "feet", "voice", - "care", "fall", "second", "power", "group", "town", "carry", "fine", "took", "certain", "rain", - "fly", "eat", "unit", "room", "lead", "friend", "cry", "began", "dark", "idea", "machine", - "fish", "note", "mountain", "wait", "north", "plan", "once", "figure", "base", "star", "hear", - "box", "horse", "noun", "cut", "field", "sure", "rest", "watch", "correct", "color", "able", - "face", "pound", "wood", "done", "main", "beauty", "enough", "drive", "plain", "stood", "girl", - "contain", "usual", "front", "young", "teach", "ready", "week", "above", "final", "ever", "gave", - "red", "green", "list", "oh", "though", "quick", "feel", "develop", "talk", "sleep", "bird", - "warm", "soon", "free", "body", "minute", "dog", "strong", "family", "special", "direct", "mind", - "pose", "behind", "leave", "clear", "song", "tail", "measure", "produce", "state", "fact", "product", - "street", "black", "inch", "short", "lot", "numeral", "nothing", "class", "course", "wind", "stay", - "question", "wheel", "happen", "full", "complete", "force", "ship", "blue", "area", "object", "half", - "decide", "rock", "surface", "order", "deep", "fire", "moon", "south", "island", "problem", "foot", - "piece", "yet", "told", "busy", "knew", "test", "pass", "record", "farm", "boat", "top", "common", - "whole", "gold", "king", "possible", "size", "plane", "heard", "age", "best", "dry", "hour", "wonder", - "better", "laugh", "true.", "thousand", "during", "ago", "hundred", "ran", "am", "check", "remember", - "game", "step", "shape", "early", "yes", "hold", "hot", "west", "miss", "ground", "brought", "interest", - "heat", "reach", "snow", "fast", "bed", "five", "bring", "sing", "sit", "listen", "perhaps", "six", - "fill", "table", "east", "travel", "weight", "less", "language", "morning", "among") + + companion object { + + //some of the most common english words for show + val wordBank: List<String> by lazy { + listOf("the", "name", "of", "very", "to", "through", + "and", "just", "a", "form", "in", "much", "is", "great", "it", "think", "you", "say", + "that", "help", "he", "low", "was", "line", "for", "before", "on", "turn", "are", "cause", + "with", "same", "as", "mean", "I", "differ", "his", "move", "they", "right", "be", "boy", + "at", "old", "one", "too", "have", "does", "this", "tell", "from", "sentence", "or", "set", + "had", "three", "by", "want", "hot", "air", "but", "well", "some", "also", "what", "play", + "there", "small", "we", "end", "can", "put", "out", "home", "other", "read", "were", "hand", + "all", "port", "your", "large", "when", "spell", "up", "add", "use", "even", "word", "land", + "how", "here", "said", "must", "an", "big", "each", "high", "she", "such", "which", "follow", + "do", "act", "their", "why", "time", "ask", "if", "men", "will", "change", "way", "went", + "about", "light", "many", "kind", "then", "off", "them", "need", "would", "house", "write", + "picture", "like", "try", "so", "us", "these", "again", "her", "animal", "long", "point", + "make", "mother", "thing", "world", "see", "near", "him", "build", "two", "self", "has", + "earth", "look", "father", "more", "head", "day", "stand", "could", "own", "go", "page", + "come", "should", "did", "country", "my", "found", "sound", "answer", "no", "school", "most", + "grow", "number", "study", "who", "still", "over", "learn", "know", "plant", "water", "cover", + "than", "food", "call", "sun", "first", "four", "people", "thought", "may", "let", "down", "keep", + "side", "eye", "been", "never", "now", "last", "find", "door", "any", "between", "new", "city", + "work", "tree", "part", "cross", "take", "since", "get", "hard", "place", "start", "made", + "might", "live", "story", "where", "saw", "after", "far", "back", "sea", "little", "draw", + "only", "left", "round", "late", "man", "run", "year", "don't", "came", "while", "show", + "press", "every", "close", "good", "night", "me", "real", "give", "life", "our", "few", "under", + "stopRankWordRankWord", "open", "ten", "seem", "simple", "together", "several", "next", + "vowel", "white", "toward", "children", "war", "begin", "lay", "got", "against", "walk", "pattern", + "example", "slow", "ease", "center", "paper", "love", "often", "person", "always", "money", + "music", "serve", "those", "appear", "both", "road", "mark", "map", "book", "science", "letter", + "rule", "until", "govern", "mile", "pull", "river", "cold", "car", "notice", "feet", "voice", + "care", "fall", "second", "power", "group", "town", "carry", "fine", "took", "certain", "rain", + "fly", "eat", "unit", "room", "lead", "friend", "cry", "began", "dark", "idea", "machine", + "fish", "note", "mountain", "wait", "north", "plan", "once", "figure", "base", "star", "hear", + "box", "horse", "noun", "cut", "field", "sure", "rest", "watch", "correct", "color", "able", + "face", "pound", "wood", "done", "main", "beauty", "enough", "drive", "plain", "stood", "girl", + "contain", "usual", "front", "young", "teach", "ready", "week", "above", "final", "ever", "gave", + "red", "green", "list", "oh", "though", "quick", "feel", "develop", "talk", "sleep", "bird", + "warm", "soon", "free", "body", "minute", "dog", "strong", "family", "special", "direct", "mind", + "pose", "behind", "leave", "clear", "song", "tail", "measure", "produce", "state", "fact", "product", + "street", "black", "inch", "short", "lot", "numeral", "nothing", "class", "course", "wind", "stay", + "question", "wheel", "happen", "full", "complete", "force", "ship", "blue", "area", "object", "half", + "decide", "rock", "surface", "order", "deep", "fire", "moon", "south", "island", "problem", "foot", + "piece", "yet", "told", "busy", "knew", "test", "pass", "record", "farm", "boat", "top", "common", + "whole", "gold", "king", "possible", "size", "plane", "heard", "age", "best", "dry", "hour", "wonder", + "better", "laugh", "true.", "thousand", "during", "ago", "hundred", "ran", "am", "check", "remember", + "game", "step", "shape", "early", "yes", "hold", "hot", "west", "miss", "ground", "brought", "interest", + "heat", "reach", "snow", "fast", "bed", "five", "bring", "sing", "sit", "listen", "perhaps", "six", + "fill", "table", "east", "travel", "weight", "less", "language", "morning", "among") + } + + const val REQUEST_IMAGE = 27 } override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = { @@ -155,7 +165,7 @@ class MainActivity : KPrefActivity() { } plainText(R.string.gallery_showcase) { - onClick = { _, _, _ -> startActivity(ImageActivity::class.java, transition = true); false } + onClick = { _, _, _ -> kauLaunchImagePicker(REQUEST_IMAGE); false } } plainText(R.string.adapter_showcase) { @@ -163,7 +173,7 @@ class MainActivity : KPrefActivity() { } plainText(R.string.kau_about_app) { - onClick = { _, _, _ -> startActivity(AboutActivity::class.java, transition = true); false } + onClick = { _, _, _ -> kauLaunchAbout(AboutActivity::class.java); false } } } @@ -195,12 +205,6 @@ class MainActivity : KPrefActivity() { } - override fun onPostCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { - super.onPostCreate(savedInstanceState, persistentState) - //TODO testing - startActivity(ImageActivity::class.java, transition = true) - } - override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) if (searchView == null) searchView = bindSearchView(menu, R.id.action_search) { @@ -231,7 +235,7 @@ class MainActivity : KPrefActivity() { when (item.itemId) { R.id.action_settings -> startActivity(AnimActivity::class.java) R.id.action_email -> sendEmail(R.string.your_email, R.string.your_subject) - R.id.test -> startActivity(ImageActivity::class.java, transition = true) + R.id.test -> kauLaunchImagePicker(REQUEST_IMAGE) else -> return super.onOptionsItemSelected(item) } return true @@ -240,4 +244,11 @@ class MainActivity : KPrefActivity() { override fun onBackPressed() { if (!(searchView?.onBackPressed() ?: false)) super.onBackPressed() } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + REQUEST_IMAGE -> toast("${kauOnImagePickerResult(resultCode, data).size} images selected") + } + } } |