Commit 923374a2 authored by Mygod's avatar Mygod

Add back handler for ACL fragment

parent 7d3f6096
...@@ -406,7 +406,8 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -406,7 +406,8 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
} }
override def onBackPressed(): Unit = override def onBackPressed(): Unit =
if (drawer.isDrawerOpen) drawer.closeDrawer() else if (currentFragment != profilesFragment) { if (drawer.isDrawerOpen) drawer.closeDrawer() else if (!currentFragment.onBackPressed())
if (currentFragment != profilesFragment) {
displayFragment(profilesFragment) displayFragment(profilesFragment)
drawer.setSelection(DRAWER_PROFILES) drawer.setSelection(DRAWER_PROFILES)
} else super.onBackPressed() } else super.onBackPressed()
......
...@@ -36,4 +36,6 @@ class ToolbarFragment extends Fragment { ...@@ -36,4 +36,6 @@ class ToolbarFragment extends Fragment {
} }
def onTrafficUpdated(profileId: Int, txRate: Long, rxRate: Long, txTotal: Long, rxTotal: Long): Unit = () def onTrafficUpdated(profileId: Int, txRate: Long, rxRate: Long, txTotal: Long, rxTotal: Long): Unit = ()
def onBackPressed(): Boolean = false
} }
...@@ -63,9 +63,8 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi ...@@ -63,9 +63,8 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
} }
private val selectedItems = new mutable.HashSet[AnyRef] private val selectedItems = new mutable.HashSet[AnyRef]
private def onSelectedItemsUpdated(): Unit = if (selectionItem != null) { private def onSelectedItemsUpdated(): Unit =
selectionItem.setVisible(selectedItems.nonEmpty) if (selectionItem != null) selectionItem.setVisible(selectedItems.nonEmpty)
}
private final class AclRuleViewHolder(view: View) extends RecyclerView.ViewHolder(view) private final class AclRuleViewHolder(view: View) extends RecyclerView.ViewHolder(view)
with View.OnClickListener with View.OnLongClickListener { with View.OnClickListener with View.OnLongClickListener {
...@@ -263,6 +262,13 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi ...@@ -263,6 +262,13 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
}).attachToRecyclerView(list) }).attachToRecyclerView(list)
} }
override def onBackPressed(): Boolean = if (selectedItems.nonEmpty) {
selectedItems.clear()
onSelectedItemsUpdated()
adapter.notifyDataSetChanged()
true
} else super.onBackPressed()
override def onSaveInstanceState(outState: Bundle): Unit = { override def onSaveInstanceState(outState: Bundle): Unit = {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
outState.putStringArray(SELECTED_SUBNETS, selectedItems.filter(_.isInstanceOf[Subnet]).map(_.toString).toArray) outState.putStringArray(SELECTED_SUBNETS, selectedItems.filter(_.isInstanceOf[Subnet]).map(_.toString).toArray)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment