use of drift.com.drift.adapters.ConversationListAdapter in project drift-sdk-android by Driftt.
the class ConversationListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StatusBarColorizer.setActivityColor(this);
setContentView(R.layout.drift_sdk_activity_conversation_list);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("Conversations");
}
conversationRecyclerView = findViewById(R.id.drift_sdk_conversation_list_recycler_view);
progressBar = findViewById(R.id.drift_sdk_conversation_list_progress_bar);
networkAvailabilityBar = findViewById(R.id.drift_sdk_conversation_list_load_page_text_view);
emptyState = findViewById(R.id.drift_sdk_conversation_list_empty_linear_layout);
emptyStateButton = findViewById(R.id.drift_sdk_conversation_list_empty_state_create_button);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
conversationRecyclerView.setLayoutManager(layoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(conversationRecyclerView.getContext(), layoutManager.getOrientation());
dividerItemDecoration.setDrawable(ContextCompat.getDrawable(this, R.drawable.drift_sdk_recycler_view_divider));
conversationRecyclerView.addItemDecoration(dividerItemDecoration);
conversationRecyclerView.addOnItemTouchListener(new RecyclerTouchListener(this, conversationRecyclerView, new ClickListener() {
@Override
public void onClick(View view, int position) {
Conversation conversation = conversationListAdapter.getItemAt(position);
if (conversation != null) {
Intent intent = ConversationActivity.intentForConversation(ConversationListActivity.this, conversation.id);
ConversationListActivity.this.startActivity(intent);
}
}
}));
emptyStateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = ConversationActivity.intentForCreateConversation(ConversationListActivity.this);
ConversationListActivity.this.startActivity(intent);
}
});
emptyStateButton.setTextColor(ColorHelper.getForegroundColor());
Drawable backgroundDrawable = DrawableCompat.wrap(emptyStateButton.getBackground()).mutate();
DrawableCompat.setTint(backgroundDrawable, ColorHelper.getBackgroundColor());
emptyState.setVisibility(View.GONE);
conversationListAdapter = new ConversationListAdapter(this, ConversationManager.getInstance().getConversations());
conversationRecyclerView.setAdapter(conversationListAdapter);
if (conversationListAdapter.getItemCount() == 0) {
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
}
}
Aggregations