aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/enums
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-12-21 02:16:34 -0500
committerGitHub <noreply@github.com>2017-12-21 02:16:34 -0500
commitd683cae6ffe644a9f63eea6cf3b7e59d2bde617b (patch)
tree517fe1d44c27084ccd87507d9804ba28f15c1647 /app/src/main/kotlin/com/pitchedapps/frost/enums
parent82f9aca96493316bc62008f2b3167d34a6029b38 (diff)
downloadfrost-d683cae6ffe644a9f63eea6cf3b7e59d2bde617b.tar.gz
frost-d683cae6ffe644a9f63eea6cf3b7e59d2bde617b.tar.bz2
frost-d683cae6ffe644a9f63eea6cf3b7e59d2bde617b.zip
Enhancement/fragment interface (#564)
* Begin fragment interfaces and themable contracts * Prepare swiperefresh interface * Snapshot * Add compilable version * Revamp once more * Finalize layouts * Cleanup
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/enums')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/enums/OverlayContext.kt27
1 files changed, 10 insertions, 17 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/OverlayContext.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/OverlayContext.kt
index cc71b19e..8f26e152 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/enums/OverlayContext.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/OverlayContext.kt
@@ -4,10 +4,9 @@ import android.content.Context
import android.view.Menu
import android.view.MenuItem
import ca.allanwang.kau.utils.toDrawable
-import com.mikepenz.iconics.typeface.IIcon
import com.pitchedapps.frost.R
import com.pitchedapps.frost.facebook.FbItem
-import com.pitchedapps.frost.web.FrostWebViewCore
+import com.pitchedapps.frost.views.FrostWebView
/**
* Created by Allan Wang on 2017-09-16.
@@ -19,12 +18,8 @@ import com.pitchedapps.frost.web.FrostWebViewCore
*/
enum class OverlayContext(private val menuItem: FrostMenuItem?) {
- NOTIFICATION(FrostMenuItem(R.id.action_notification, FbItem.NOTIFICATIONS.icon, R.string.notifications) { webview ->
- webview.loadUrl(FbItem.NOTIFICATIONS.url, true)
- }),
- MESSAGE(FrostMenuItem(R.id.action_messages, FbItem.MESSAGES.icon, R.string.messages) { webview ->
- webview.loadUrl(FbItem.MESSAGES.url, true)
- });
+ NOTIFICATION(FrostMenuItem(R.id.action_notification, FbItem.NOTIFICATIONS)),
+ MESSAGE(FrostMenuItem(R.id.action_messages, FbItem.MESSAGES));
/**
* Inject the [menuItem] in the order that they are given at the front of the menu
@@ -40,9 +35,9 @@ enum class OverlayContext(private val menuItem: FrostMenuItem?) {
* Execute selection call for an item by id
* Returns [true] if selection was consumed, [false] otherwise
*/
- fun onOptionsItemSelected(webview: FrostWebViewCore, id: Int): Boolean {
- val consumer = values.firstOrNull { id == it.menuItem?.id } ?: return false
- consumer.menuItem!!.onClick(webview)
+ fun onOptionsItemSelected(web: FrostWebView, id: Int): Boolean {
+ val item = values.firstOrNull { id == it.menuItem?.id }?.menuItem ?: return false
+ web.loadUrl(item.fbItem.url, true)
return true
}
}
@@ -53,13 +48,11 @@ enum class OverlayContext(private val menuItem: FrostMenuItem?) {
*/
class FrostMenuItem(
val id: Int,
- val iicon: IIcon,
- val stringRes: Int,
- val showAsAction: Int = MenuItem.SHOW_AS_ACTION_ALWAYS,
- val onClick: (webview: FrostWebViewCore) -> Unit) {
+ val fbItem: FbItem,
+ val showAsAction: Int = MenuItem.SHOW_AS_ACTION_ALWAYS) {
fun addToMenu(context: Context, menu: Menu, index: Int) {
- val item = menu.add(Menu.NONE, id, index, stringRes)
- item.icon = iicon.toDrawable(context, 18)
+ val item = menu.add(Menu.NONE, id, index, fbItem.titleId)
+ item.icon = fbItem.icon.toDrawable(context, 18)
item.setShowAsAction(showAsAction)
}
} \ No newline at end of file