No chat_bubble displayed, save this stage to go back and remove code to go forward step by step
This commit is contained in:
parent
3fe92f7f71
commit
0341e5da61
4 changed files with 23 additions and 21 deletions
|
@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
package org.linphone.chat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
@ -39,7 +40,7 @@ import org.linphone.core.LimeState;
|
|||
|
||||
public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
|
||||
public String messageId;
|
||||
public EventLog mEvent;
|
||||
public Context mContext;
|
||||
public ChatMessage message;
|
||||
public LinearLayout eventLayout;
|
||||
//public TextView eventTime;
|
||||
|
@ -70,8 +71,10 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
public CheckBox delete;
|
||||
private ClickListener listener;
|
||||
|
||||
public ChatBubbleViewHolder(View view, ClickListener listener) {
|
||||
public ChatBubbleViewHolder(Context context, View view, ClickListener listener) {
|
||||
super(view);
|
||||
this.mContext = context;
|
||||
|
||||
this.listener = listener;
|
||||
eventLayout = view.findViewById(R.id.event);
|
||||
//eventTime = view.findViewById(R.id.event_date);
|
||||
|
@ -135,8 +138,8 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
}
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onItemClicked(getAdapterPosition()); }
|
||||
|
||||
listener.onItemClicked(getAdapterPosition());
|
||||
}
|
||||
public interface ClickListener {
|
||||
public void onItemClicked(int position);
|
||||
}
|
||||
|
|
|
@ -82,22 +82,24 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
private Context mContext;
|
||||
private List<EventLog> mHistory;
|
||||
private List<LinphoneContact> mParticipants;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
// private LayoutInflater mLayoutInflater;
|
||||
private int itemResource;
|
||||
private Bitmap mDefaultBitmap;
|
||||
private GroupChatFragment mFragment;
|
||||
private ChatMessageListenerStub mListener;
|
||||
|
||||
private ChatBubbleViewHolder.ClickListener clickListener;
|
||||
|
||||
// public ChatEventsAdapter(GroupChatFragment fragment, ListSelectionHelper helper, LayoutInflater inflater, EventLog[] history, ArrayList<LinphoneContact> participants) {
|
||||
public ChatEventsAdapter(GroupChatFragment fragment, SelectableHelper helper, LayoutInflater inflater, ArrayList<EventLog> mHistory, ArrayList<LinphoneContact> participants, ChatBubbleViewHolder.ClickListener clickListener) {
|
||||
public ChatEventsAdapter(GroupChatFragment fragment, SelectableHelper helper, int itemResource, ArrayList<EventLog> mHistory, ArrayList<LinphoneContact> participants, ChatBubbleViewHolder.ClickListener clickListener) {
|
||||
// public ChatEventsAdapter(GroupChatFragment fragment, SelectableHelper helper, LayoutInflater inflater, ArrayList<EventLog> mHistory, ArrayList<LinphoneContact> participants, ChatBubbleViewHolder.ClickListener clickListener) {
|
||||
|
||||
super(helper);
|
||||
this.mFragment = fragment;
|
||||
this.mContext = mFragment.getActivity();
|
||||
// itemResource = inflater.;
|
||||
this.mLayoutInflater = inflater;
|
||||
this.mContext = fragment.getActivity();
|
||||
this.itemResource = itemResource;
|
||||
// this.mLayoutInflater = inflater;
|
||||
this.mHistory = mHistory;
|
||||
|
||||
this.mParticipants = participants;
|
||||
|
||||
mListener = new ChatMessageListenerStub() {
|
||||
|
@ -133,14 +135,15 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
|
||||
@Override
|
||||
public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = mLayoutInflater.inflate(R.layout.chat_bubble, parent, false);
|
||||
return new ChatBubbleViewHolder(v, clickListener);
|
||||
// View v = mLayoutInflater.inflate(R.layout.chat_bubble, parent, false);
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(this.itemResource, parent, false);
|
||||
return new ChatBubbleViewHolder(this.mContext,v, clickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ChatBubbleViewHolder holder, int position) {
|
||||
EventLog event = (EventLog)getItem(position);
|
||||
|
||||
EventLog event = this.mHistory.get(position);
|
||||
holder.eventLayout.setVisibility(View.GONE);
|
||||
holder.bubbleLayout.setVisibility(View.GONE);
|
||||
holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -176,7 +176,6 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
|
|||
this.mRooms = mRooms;
|
||||
this.mContext = context;
|
||||
this.itemResource = itemResource;
|
||||
mContext = context;
|
||||
mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap();
|
||||
//mDefaultGroupBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.chat_group_avatar);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.os.Bundle;
|
|||
import android.os.Environment;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
|
@ -53,7 +52,6 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
|
@ -64,6 +62,7 @@ import org.linphone.activities.LinphoneActivity;
|
|||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatMessage;
|
||||
|
@ -76,10 +75,8 @@ import org.linphone.core.EventLog;
|
|||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.LimeState;
|
||||
import org.linphone.core.Participant;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ListSelectionHelper;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -562,12 +559,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
if (mChatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||
EventLog[] history = mChatRoom.getHistoryMessageEvents(0);
|
||||
mHistory = new ArrayList<>(Arrays.asList(history));
|
||||
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, mInflater, mHistory, mParticipants, this);
|
||||
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, R.layout.chat_bubble, mHistory, mParticipants, this);
|
||||
// mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this, mSelectionHelper);
|
||||
} else {
|
||||
EventLog[] history = mChatRoom.getHistoryEvents(0);
|
||||
mHistory = new ArrayList<>(Arrays.asList(history));
|
||||
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, mInflater, mHistory, mParticipants, this);
|
||||
mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, R.layout.chat_bubble, mHistory, mParticipants, this);
|
||||
}
|
||||
mChatEventsList.setAdapter(mEventsAdapter);
|
||||
mSelectionHelper.setAdapter(mEventsAdapter);
|
||||
|
|
Loading…
Reference in a new issue