Search in sources :

Example 1 with OnConversationSelected

use of eu.siacs.conversations.ui.interfaces.OnConversationSelected in project Conversations by siacs.

the class ConversationsOverviewFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.mSwipeEscapeVelocity = getResources().getDimension(R.dimen.swipe_escape_velocity);
    this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversations_overview, container, false);
    this.binding.fab.setOnClickListener((view) -> StartConversationActivity.launch(getActivity()));
    this.conversationsAdapter = new ConversationAdapter(this.activity, this.conversations);
    this.conversationsAdapter.setConversationClickListener((view, conversation) -> {
        if (activity instanceof OnConversationSelected) {
            ((OnConversationSelected) activity).onConversationSelected(conversation);
        } else {
            Log.w(ConversationsOverviewFragment.class.getCanonicalName(), "Activity does not implement OnConversationSelected");
        }
    });
    this.binding.list.setAdapter(this.conversationsAdapter);
    this.binding.list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    this.touchHelper = new ItemTouchHelper(this.callback);
    this.touchHelper.attachToRecyclerView(this.binding.list);
    return binding.getRoot();
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) OnConversationSelected(eu.siacs.conversations.ui.interfaces.OnConversationSelected) ConversationAdapter(eu.siacs.conversations.ui.adapter.ConversationAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 ConversationAdapter (eu.siacs.conversations.ui.adapter.ConversationAdapter)1 OnConversationSelected (eu.siacs.conversations.ui.interfaces.OnConversationSelected)1