Commit 67c5a4cf authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomFragment.java

parent ae42f7ec
...@@ -19,6 +19,8 @@ import android.support.v4.widget.SlidingPaneLayout; ...@@ -19,6 +19,8 @@ import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View; import android.view.View;
import chat.rocket.android.fragment.sidebar.SidebarMainFragment; import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
...@@ -127,6 +129,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -127,6 +129,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
private Message edittingMessage = null; private Message edittingMessage = null;
private RoomToolbar toolbar;
private SlidingPaneLayout pane; private SlidingPaneLayout pane;
private SidebarMainFragment sidebarFragment; private SidebarMainFragment sidebarFragment;
...@@ -149,6 +153,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -149,6 +153,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
Bundle args = getArguments(); Bundle args = getArguments();
hostname = args.getString(HOSTNAME); hostname = args.getString(HOSTNAME);
...@@ -241,6 +246,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -241,6 +246,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
} }
}; };
setupToolbar();
setupSidebar(); setupSidebar();
setupSideMenu(); setupSideMenu();
setupMessageComposer(); setupMessageComposer();
...@@ -331,9 +337,40 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -331,9 +337,40 @@ public class RoomFragment extends AbstractChatRoomFragment implements
} }
} }
private void setupToolbar() {
toolbar = getActivity().findViewById(R.id.activity_main_toolbar);
toolbar.getMenu().clear();
toolbar.inflateMenu(R.menu.menu_room);
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane();
}
});
toolbar.setOnMenuItemClickListener(menuItem -> {
switch (menuItem.getItemId()) {
case R.id.action_pinned_messages:
// TODO
break;
case R.id.action_favorite_messages:
// TODO
break;
case R.id.action_file_list:
// TODO
break;
case R.id.action_member_list:
// TODO
break;
default:
return super.onOptionsItemSelected(menuItem);
}
return true;
});
}
private void setupSidebar() { private void setupSidebar() {
SlidingPaneLayout subPane = getActivity().findViewById(R.id.sub_sliding_pane); SlidingPaneLayout subPane = getActivity().findViewById(R.id.sub_sliding_pane);
RoomToolbar toolbar = getActivity().findViewById(R.id.activity_main_toolbar);
sidebarFragment = (SidebarMainFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.sidebar_fragment_container); sidebarFragment = (SidebarMainFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.sidebar_fragment_container);
pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
...@@ -358,12 +395,6 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -358,12 +395,6 @@ public class RoomFragment extends AbstractChatRoomFragment implements
closeUserActionContainer(); closeUserActionContainer();
} }
}); });
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane();
}
});
} }
public void closeUserActionContainer() { public void closeUserActionContainer() {
......
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