Prepare things for selection options

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-04-28 12:26:34 +02:00
parent dd4e00c581
commit 8792c6c16f

View file

@ -26,6 +26,7 @@ import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -76,7 +77,7 @@ import retrofit2.Response;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener, public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener,
MessagesListAdapter.Formatter<Date> { MessagesListAdapter.Formatter<Date>, MessagesListAdapter.SelectionListener {
@Inject @Inject
NcApi ncApi; NcApi ncApi;
@Inject @Inject
@ -100,6 +101,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
private MessagesListAdapter<ChatMessage> adapter; private MessagesListAdapter<ChatMessage> adapter;
private Menu globalMenu;
public ChatController(Bundle args) { public ChatController(Bundle args) {
super(args); super(args);
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -146,6 +149,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
messagesList.setAdapter(adapter); messagesList.setAdapter(adapter);
adapter.setLoadMoreListener(this); adapter.setLoadMoreListener(this);
adapter.setDateHeadersFormatter(this::format); adapter.setDateHeadersFormatter(this::format);
//adapter.enableSelectionMode(this);
messageInput.setInputListener(input -> { messageInput.setInputListener(input -> {
sendMessage(input.toString()); sendMessage(input.toString());
@ -415,4 +419,16 @@ public class ChatController extends BaseController implements MessagesListAdapte
} else { } else {
return DateFormatter.format(date, DateFormatter.Template.STRING_DAY_MONTH_YEAR); return DateFormatter.format(date, DateFormatter.Template.STRING_DAY_MONTH_YEAR);
} }
}} }
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
globalMenu = menu;
}
@Override
public void onSelectionChanged(int count) {
//globalMenu.findItem(R.id.action_delete).setVisible(count > 0);
}
}