2018-02-10 17:34:01 +01:00
|
|
|
|
package de.vanitasvitae.slam.mvp.view;
|
2018-01-31 14:40:01 +01:00
|
|
|
|
|
|
|
|
|
import android.app.Fragment;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
|
import de.vanitasvitae.slam.R;
|
2018-02-10 17:34:01 +01:00
|
|
|
|
import de.vanitasvitae.slam.ui.ConversationEntry;
|
2018-01-31 14:40:01 +01:00
|
|
|
|
|
|
|
|
|
/**
|
2018-02-10 17:34:01 +01:00
|
|
|
|
* Fragment that lists conversations the user takes part in.
|
|
|
|
|
*
|
2018-01-31 14:40:01 +01:00
|
|
|
|
* Created by Paul Schaub on 30.01.18.
|
|
|
|
|
*/
|
2018-02-10 17:34:01 +01:00
|
|
|
|
public class ConversationListFragment extends Fragment {
|
2018-01-31 14:40:01 +01:00
|
|
|
|
|
|
|
|
|
@BindView(R.id.recycler_chatlist)
|
|
|
|
|
RecyclerView recyclerView;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
|
|
Bundle savedInstanceState) {
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_chatlist, container, false);
|
|
|
|
|
ButterKnife.bind(this, view);
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onViewCreated(final View view, Bundle savedInstanceState) {
|
|
|
|
|
final String[] usernames = {"alice@wonderland.lit", "Bob the Builder", "Marvin"};
|
|
|
|
|
final String[] messages = {"But I don’t want to go among mad people", "Yes we can!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "My name is Marvin!"};
|
|
|
|
|
final String[] dates = {"13:37", "yesterday", "24.12.2018"};
|
|
|
|
|
final boolean[] reads = {true, false, true};
|
|
|
|
|
|
|
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
2018-02-10 17:34:01 +01:00
|
|
|
|
recyclerView.setAdapter(new RecyclerView.Adapter<ConversationEntry>() {
|
2018-01-31 14:40:01 +01:00
|
|
|
|
@Override
|
2018-02-10 17:34:01 +01:00
|
|
|
|
public ConversationEntry onCreateViewHolder(ViewGroup parent, int viewType) {
|
2018-01-31 14:40:01 +01:00
|
|
|
|
View view1 = LayoutInflater.from(getActivity()).inflate(R.layout.chatlist_singlechat, parent, false);
|
|
|
|
|
view1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
2018-02-10 17:34:01 +01:00
|
|
|
|
getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.fragment_container, new ConversationFragment()).commit();
|
2018-01-31 14:40:01 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2018-02-10 17:34:01 +01:00
|
|
|
|
return new ConversationEntry(view1);
|
2018-01-31 14:40:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2018-02-10 17:34:01 +01:00
|
|
|
|
public void onBindViewHolder(ConversationEntry holder, int position) {
|
2018-01-31 14:40:01 +01:00
|
|
|
|
holder.bind(
|
|
|
|
|
usernames[position],
|
|
|
|
|
messages[position],
|
|
|
|
|
dates[position],
|
|
|
|
|
reads[position]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getItemCount() {
|
|
|
|
|
return usernames.length;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
recyclerView.getAdapter().notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|