From e48ec8219df1e6175c4de137ded1d2ef7cf6cdca Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 22 Nov 2018 17:09:03 +0100 Subject: [PATCH] Renamed some classes for harmonization purposes --- .../java/org/linphone/LinphoneActivity.java | 20 ++--- ...Holder.java => ChatMessageViewHolder.java} | 8 +- ...sAdapter.java => ChatMessagesAdapter.java} | 20 ++--- ...ragment.java => ChatMessagesFragment.java} | 12 +-- ...ent.java => ChatRoomCreationFragment.java} | 4 +- ...stFragment.java => ChatRoomsFragment.java} | 4 +- ...DeviceAdapter.java => DevicesAdapter.java} | 6 +- .../org/linphone/chat/DevicesFragment.java | 7 +- .../org/linphone/chat/GroupInfoAdapter.java | 2 +- .../java/org/linphone/chat/ImdnFragment.java | 4 +- .../org/linphone/history/HistoryAdapter.java | 67 ++-------------- .../linphone/history/HistoryViewHolder.java | 78 +++++++++++++++++++ 12 files changed, 126 insertions(+), 106 deletions(-) rename app/src/main/java/org/linphone/chat/{ChatBubbleViewHolder.java => ChatMessageViewHolder.java} (93%) rename app/src/main/java/org/linphone/chat/{ChatEventsAdapter.java => ChatMessagesAdapter.java} (97%) rename app/src/main/java/org/linphone/chat/{GroupChatFragment.java => ChatMessagesFragment.java} (98%) rename app/src/main/java/org/linphone/chat/{ChatCreationFragment.java => ChatRoomCreationFragment.java} (99%) rename app/src/main/java/org/linphone/chat/{ChatListFragment.java => ChatRoomsFragment.java} (98%) rename app/src/main/java/org/linphone/chat/{DeviceAdapter.java => DevicesAdapter.java} (98%) create mode 100644 app/src/main/java/org/linphone/history/HistoryViewHolder.java diff --git a/app/src/main/java/org/linphone/LinphoneActivity.java b/app/src/main/java/org/linphone/LinphoneActivity.java index c2a3a444a..e8be295d1 100644 --- a/app/src/main/java/org/linphone/LinphoneActivity.java +++ b/app/src/main/java/org/linphone/LinphoneActivity.java @@ -63,16 +63,16 @@ import android.widget.TextView; import android.widget.Toast; import org.linphone.LinphoneManager.AddressType; +import org.linphone.chat.ChatMessagesFragment; +import org.linphone.chat.ChatRoomCreationFragment; +import org.linphone.chat.ChatRoomsFragment; import org.linphone.settings.LinphonePreferences; import org.linphone.assistant.AssistantActivity; import org.linphone.assistant.RemoteProvisioningLoginActivity; import org.linphone.call.CallActivity; import org.linphone.call.CallIncomingActivity; import org.linphone.call.CallOutgoingActivity; -import org.linphone.chat.ChatCreationFragment; -import org.linphone.chat.ChatListFragment; import org.linphone.chat.DevicesFragment; -import org.linphone.chat.GroupChatFragment; import org.linphone.chat.GroupInfoFragment; import org.linphone.chat.ImdnFragment; import org.linphone.compatibility.Compatibility; @@ -408,17 +408,17 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick fragment = new EmptyFragment(); break; case CHAT_LIST: - fragment = new ChatListFragment(); + fragment = new ChatRoomsFragment(); break; case CREATE_CHAT: checkAndRequestWriteContactsPermission(); - fragment = new ChatCreationFragment(); + fragment = new ChatRoomCreationFragment(); break; case INFO_GROUP_CHAT: fragment = new GroupInfoFragment(); break; case GROUP_CHAT: - fragment = new GroupChatFragment(); + fragment = new ChatMessagesFragment(); break; case MESSAGE_IMDN: fragment = new ImdnFragment(); @@ -442,7 +442,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick ((ContactsListFragment) fragment).displayFirstContact(); break; case CHAT_LIST: - ((ChatListFragment) fragment).displayFirstChat(); + ((ChatRoomsFragment) fragment).displayFirstChat(); break; } } else { @@ -506,7 +506,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick if (newFragmentType == FragmentsAvailable.GROUP_CHAT && leftFragment != FragmentsAvailable.CHAT_LIST) { leftFragment = FragmentsAvailable.CHAT_LIST; - transaction.replace(R.id.fragmentContainer, new ChatListFragment()); + transaction.replace(R.id.fragmentContainer, new ChatRoomsFragment()); } } else { if (newFragmentType == FragmentsAvailable.EMPTY) { @@ -710,7 +710,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick if (isTablet()) { Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.GROUP_CHAT && !emptyFragment) { - GroupChatFragment chatFragment = (GroupChatFragment) fragment2; + ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2; chatFragment.changeDisplayedChat(sipUri); } else { changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras); @@ -788,7 +788,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.GROUP_CHAT) { Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.GROUP_CHAT && !emptyFragment) { - GroupChatFragment chatFragment = (GroupChatFragment) fragment2; + ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2; chatFragment.changeDisplayedChat(sipUri); } else { displayChat(sipUri, message, fileUri, pictureUri, thumbnailUri, displayName, lAddress); diff --git a/app/src/main/java/org/linphone/chat/ChatBubbleViewHolder.java b/app/src/main/java/org/linphone/chat/ChatMessageViewHolder.java similarity index 93% rename from app/src/main/java/org/linphone/chat/ChatBubbleViewHolder.java rename to app/src/main/java/org/linphone/chat/ChatMessageViewHolder.java index 36ae5655d..ca705d00f 100644 --- a/app/src/main/java/org/linphone/chat/ChatBubbleViewHolder.java +++ b/app/src/main/java/org/linphone/chat/ChatMessageViewHolder.java @@ -1,5 +1,5 @@ /* -ChatBubbleViewHolder.java +ChatMessageViewHolder.java Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -33,7 +33,7 @@ import android.widget.TextView; import org.linphone.R; import org.linphone.core.ChatMessage; -public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { +public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public String messageId; public Context mContext; public ChatMessage message; @@ -65,14 +65,14 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie public CheckBox delete; private ClickListener mListener; - public ChatBubbleViewHolder(Context context, View view, ClickListener listener) { + public ChatMessageViewHolder(Context context, View view, ClickListener listener) { this(view); mContext = context; mListener = listener; view.setOnClickListener(this); } - public ChatBubbleViewHolder(View view) { + public ChatMessageViewHolder(View view) { super(view); eventLayout = view.findViewById(R.id.event); //eventTime = view.findViewById(R.id.event_date); diff --git a/app/src/main/java/org/linphone/chat/ChatEventsAdapter.java b/app/src/main/java/org/linphone/chat/ChatMessagesAdapter.java similarity index 97% rename from app/src/main/java/org/linphone/chat/ChatEventsAdapter.java rename to app/src/main/java/org/linphone/chat/ChatMessagesAdapter.java index 20f2cc520..1018d57d1 100644 --- a/app/src/main/java/org/linphone/chat/ChatEventsAdapter.java +++ b/app/src/main/java/org/linphone/chat/ChatMessagesAdapter.java @@ -1,5 +1,5 @@ /* -ChatEventsAdapter.java +ChatMessagesAdapter.java Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -74,7 +74,7 @@ import java.util.List; import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; -public class ChatEventsAdapter extends SelectableAdapter { +public class ChatMessagesAdapter extends SelectableAdapter { private static int MARGIN_BETWEEN_MESSAGES = 10; private static int SIDE_MARGIN = 100; @@ -83,12 +83,12 @@ public class ChatEventsAdapter extends SelectableAdapter { private List mParticipants; private int mItemResource; private Bitmap mDefaultBitmap; - private GroupChatFragment mFragment; + private ChatMessagesFragment mFragment; private ChatMessageListenerStub mListener; - private ChatBubbleViewHolder.ClickListener mClickListener; + private ChatMessageViewHolder.ClickListener mClickListener; - public ChatEventsAdapter(GroupChatFragment fragment, SelectableHelper helper, int itemResource, EventLog[] history, ArrayList participants, ChatBubbleViewHolder.ClickListener clickListener) { + public ChatMessagesAdapter(ChatMessagesFragment fragment, SelectableHelper helper, int itemResource, EventLog[] history, ArrayList participants, ChatMessageViewHolder.ClickListener clickListener) { super(helper); mFragment = fragment; mContext = mFragment.getActivity(); @@ -100,7 +100,7 @@ public class ChatEventsAdapter extends SelectableAdapter { mListener = new ChatMessageListenerStub() { @Override public void onFileTransferProgressIndication(ChatMessage message, Content content, int offset, int total) { - ChatBubbleViewHolder holder = (ChatBubbleViewHolder) message.getUserData(); + ChatMessageViewHolder holder = (ChatMessageViewHolder) message.getUserData(); if (holder == null) return; if (offset == total) { @@ -136,10 +136,10 @@ public class ChatEventsAdapter extends SelectableAdapter { } @Override - public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + public ChatMessageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()) .inflate(mItemResource, parent, false); - ChatBubbleViewHolder VH = new ChatBubbleViewHolder(mContext, v, mClickListener); + ChatMessageViewHolder VH = new ChatMessageViewHolder(mContext, v, mClickListener); //Allows onLongClick ContextMenu on bubbles mFragment.registerForContextMenu(v); @@ -148,7 +148,7 @@ public class ChatEventsAdapter extends SelectableAdapter { } @Override - public void onBindViewHolder(@NonNull final ChatBubbleViewHolder holder, int position) { + public void onBindViewHolder(@NonNull final ChatMessageViewHolder holder, int position) { final EventLog event = mHistory.get(position); holder.eventLayout.setVisibility(View.GONE); holder.bubbleLayout.setVisibility(View.GONE); @@ -525,7 +525,7 @@ public class ChatEventsAdapter extends SelectableAdapter { mContext.startActivity(intent); } - private void displayAttachedFile(ChatMessage message, ChatBubbleViewHolder holder) { + private void displayAttachedFile(ChatMessage message, ChatMessageViewHolder holder) { holder.fileName.setVisibility(View.VISIBLE); String appData = message.getAppdata(); diff --git a/app/src/main/java/org/linphone/chat/GroupChatFragment.java b/app/src/main/java/org/linphone/chat/ChatMessagesFragment.java similarity index 98% rename from app/src/main/java/org/linphone/chat/GroupChatFragment.java rename to app/src/main/java/org/linphone/chat/ChatMessagesFragment.java index 60d466ac6..097c8f8c5 100644 --- a/app/src/main/java/org/linphone/chat/GroupChatFragment.java +++ b/app/src/main/java/org/linphone/chat/ChatMessagesFragment.java @@ -1,5 +1,5 @@ /* -GroupChatFragment.java +ChatMessagesFragment.java Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -91,7 +91,7 @@ import java.util.List; import static android.content.Context.INPUT_METHOD_SERVICE; import static org.linphone.fragments.FragmentsAvailable.CHAT; -public class GroupChatFragment extends Fragment implements ChatRoomListener, ContactsUpdatedListener, ChatBubbleViewHolder.ClickListener, SelectableHelper.DeleteListener { +public class ChatMessagesFragment extends Fragment implements ChatRoomListener, ContactsUpdatedListener, ChatMessageViewHolder.ClickListener, SelectableHelper.DeleteListener { private static final int ADD_PHOTO = 1337; private static final int MESSAGES_PER_PAGE = 20; @@ -107,7 +107,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con private Context mContext; private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener; private Uri mImageToUploadUri; - private ChatEventsAdapter mEventsAdapter; + private ChatMessagesAdapter mEventsAdapter; private String mRemoteSipUri; private Address mRemoteSipAddress, mRemoteParticipantAddress; private ChatRoom mChatRoom; @@ -413,7 +413,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); - ChatBubbleViewHolder holder = (ChatBubbleViewHolder) v.getTag(); + ChatMessageViewHolder holder = (ChatMessageViewHolder) v.getTag(); mContextMenuMessagePosition = holder.getAdapterPosition(); EventLog event = (EventLog) mEventsAdapter.getItem(mContextMenuMessagePosition); @@ -672,9 +672,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con private void displayChatRoomHistory() { if (mChatRoom == null) return; if (mChatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) { - mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, R.layout.chat_bubble, mChatRoom.getHistoryMessageEvents(MESSAGES_PER_PAGE), mParticipants, this); + mEventsAdapter = new ChatMessagesAdapter(this, mSelectionHelper, R.layout.chat_bubble, mChatRoom.getHistoryMessageEvents(MESSAGES_PER_PAGE), mParticipants, this); } else { - mEventsAdapter = new ChatEventsAdapter(this, mSelectionHelper, R.layout.chat_bubble, mChatRoom.getHistoryEvents(MESSAGES_PER_PAGE), mParticipants, this); + mEventsAdapter = new ChatMessagesAdapter(this, mSelectionHelper, R.layout.chat_bubble, mChatRoom.getHistoryEvents(MESSAGES_PER_PAGE), mParticipants, this); } mSelectionHelper.setAdapter(mEventsAdapter); mChatEventsList.setAdapter(mEventsAdapter); diff --git a/app/src/main/java/org/linphone/chat/ChatCreationFragment.java b/app/src/main/java/org/linphone/chat/ChatRoomCreationFragment.java similarity index 99% rename from app/src/main/java/org/linphone/chat/ChatCreationFragment.java rename to app/src/main/java/org/linphone/chat/ChatRoomCreationFragment.java index ba8a1cd7e..ea482a7f4 100644 --- a/app/src/main/java/org/linphone/chat/ChatCreationFragment.java +++ b/app/src/main/java/org/linphone/chat/ChatRoomCreationFragment.java @@ -1,5 +1,5 @@ /* -ChatCreationFragment.java +ChatRoomCreationFragment.java Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -59,7 +59,7 @@ import java.util.List; import static android.content.Context.INPUT_METHOD_SERVICE; -public class ChatCreationFragment extends Fragment implements View.OnClickListener, SearchContactsListAdapter.ViewHolder.ClickListener, ContactsUpdatedListener { +public class ChatRoomCreationFragment extends Fragment implements View.OnClickListener, SearchContactsListAdapter.ViewHolder.ClickListener, ContactsUpdatedListener { private RecyclerView mContactsList; private LinearLayout mContactsSelectedLayout; private HorizontalScrollView mContactsSelectLayout; diff --git a/app/src/main/java/org/linphone/chat/ChatListFragment.java b/app/src/main/java/org/linphone/chat/ChatRoomsFragment.java similarity index 98% rename from app/src/main/java/org/linphone/chat/ChatListFragment.java rename to app/src/main/java/org/linphone/chat/ChatRoomsFragment.java index 21679219a..f6b595baf 100644 --- a/app/src/main/java/org/linphone/chat/ChatListFragment.java +++ b/app/src/main/java/org/linphone/chat/ChatRoomsFragment.java @@ -1,5 +1,5 @@ /* -ChatListFragment.java +ChatRoomsFragment.java Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -54,7 +54,7 @@ import java.util.List; import static org.linphone.fragments.FragmentsAvailable.CHAT_LIST; -public class ChatListFragment extends Fragment implements ContactsUpdatedListener, ChatRoomViewHolder.ClickListener, SelectableHelper.DeleteListener { +public class ChatRoomsFragment extends Fragment implements ContactsUpdatedListener, ChatRoomViewHolder.ClickListener, SelectableHelper.DeleteListener { private RecyclerView mChatRoomsList; private ImageView mNewDiscussionButton, mNewGroupDiscussionButton, mBackToCallButton; diff --git a/app/src/main/java/org/linphone/chat/DeviceAdapter.java b/app/src/main/java/org/linphone/chat/DevicesAdapter.java similarity index 98% rename from app/src/main/java/org/linphone/chat/DeviceAdapter.java rename to app/src/main/java/org/linphone/chat/DevicesAdapter.java index cd76af66c..f58fd4637 100644 --- a/app/src/main/java/org/linphone/chat/DeviceAdapter.java +++ b/app/src/main/java/org/linphone/chat/DevicesAdapter.java @@ -1,7 +1,7 @@ package org.linphone.chat; /* -DeviceAdapter.java +DevicesAdapter.java Copyright (C) 2010-2018 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -38,12 +38,12 @@ import org.linphone.views.ContactAvatar; import java.util.ArrayList; import java.util.List; -public class DeviceAdapter extends BaseExpandableListAdapter { +public class DevicesAdapter extends BaseExpandableListAdapter { private Context mContext; private List mParticipants; private boolean mOnlyDisplayChildsAsGroups; - public DeviceAdapter(Context context) { + public DevicesAdapter(Context context) { mContext = context; mParticipants = new ArrayList<>(); mOnlyDisplayChildsAsGroups = false; diff --git a/app/src/main/java/org/linphone/chat/DevicesFragment.java b/app/src/main/java/org/linphone/chat/DevicesFragment.java index 252d9e2ab..4569d8f2b 100644 --- a/app/src/main/java/org/linphone/chat/DevicesFragment.java +++ b/app/src/main/java/org/linphone/chat/DevicesFragment.java @@ -39,11 +39,8 @@ import org.linphone.core.Address; import org.linphone.core.ChatRoom; import org.linphone.core.ChatRoomCapabilities; import org.linphone.core.Core; -import org.linphone.core.Factory; -import org.linphone.core.Participant; import org.linphone.core.ParticipantDevice; import org.linphone.fragments.FragmentsAvailable; -import org.linphone.mediastream.Log; import java.util.Arrays; @@ -52,7 +49,7 @@ public class DevicesFragment extends Fragment { private ImageView mBackButton; private TextView mTitle; private ExpandableListView mExpandableList; - private DeviceAdapter mAdapter; + private DevicesAdapter mAdapter; private String mRoomUri; private Address mRoomAddr; @@ -151,7 +148,7 @@ public class DevicesFragment extends Fragment { private void initValues() { if (mAdapter == null) { - mAdapter = new DeviceAdapter(getActivity()); + mAdapter = new DevicesAdapter(getActivity()); mExpandableList.setAdapter(mAdapter); } if (mRoom == null) { diff --git a/app/src/main/java/org/linphone/chat/GroupInfoAdapter.java b/app/src/main/java/org/linphone/chat/GroupInfoAdapter.java index 50971d969..a7f4a1785 100644 --- a/app/src/main/java/org/linphone/chat/GroupInfoAdapter.java +++ b/app/src/main/java/org/linphone/chat/GroupInfoAdapter.java @@ -1,5 +1,5 @@ /* -GroupChatFragment.java +GroupInfoAdapter.java Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or diff --git a/app/src/main/java/org/linphone/chat/ImdnFragment.java b/app/src/main/java/org/linphone/chat/ImdnFragment.java index 8ee44d5da..f713d5f7a 100644 --- a/app/src/main/java/org/linphone/chat/ImdnFragment.java +++ b/app/src/main/java/org/linphone/chat/ImdnFragment.java @@ -53,7 +53,7 @@ public class ImdnFragment extends Fragment { private LayoutInflater mInflater; private LinearLayout mRead, mReadHeader, mDelivered, mDeliveredHeader, mSent, mSentHeader, mUndelivered, mUndeliveredHeader; private ImageView mBackButton; - private ChatBubbleViewHolder mBubble; + private ChatMessageViewHolder mBubble; private ViewGroup mContainer; private String mRoomUri, mMessageId; @@ -101,7 +101,7 @@ public class ImdnFragment extends Fragment { mSentHeader = view.findViewById(R.id.sent_layout_header); mUndeliveredHeader = view.findViewById(R.id.undelivered_layout_header); - mBubble = new ChatBubbleViewHolder(view.findViewById(R.id.bubble)); + mBubble = new ChatMessageViewHolder(view.findViewById(R.id.bubble)); mBubble.eventLayout.setVisibility(View.GONE); mBubble.bubbleLayout.setVisibility(View.VISIBLE); mBubble.delete.setVisibility(View.GONE); diff --git a/app/src/main/java/org/linphone/history/HistoryAdapter.java b/app/src/main/java/org/linphone/history/HistoryAdapter.java index d045cb016..aa92547c3 100644 --- a/app/src/main/java/org/linphone/history/HistoryAdapter.java +++ b/app/src/main/java/org/linphone/history/HistoryAdapter.java @@ -22,15 +22,9 @@ package org.linphone.history; import android.annotation.SuppressLint; import android.content.Context; import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CheckBox; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; import org.linphone.utils.LinphoneUtils; import org.linphone.R; @@ -48,61 +42,12 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; -public class HistoryAdapter extends SelectableAdapter { - public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, - View.OnLongClickListener { - public TextView contact; - public ImageView detail; - public CheckBox select; - public ImageView callDirection; - public RelativeLayout avatarLayout; - public RelativeLayout CallContact; - public LinearLayout separator; - public TextView separatorText; - private HistoryAdapter.ViewHolder.ClickListener mListener; - - public ViewHolder(View view, HistoryAdapter.ViewHolder.ClickListener listener) { - super(view); - contact = view.findViewById(R.id.sip_uri); - detail = view.findViewById(R.id.detail); - select = view.findViewById(R.id.delete); - callDirection = view.findViewById(R.id.icon); - avatarLayout = view.findViewById(R.id.avatar_layout); - CallContact = view.findViewById(R.id.history_click); - separator = view.findViewById(R.id.separator); - separatorText = view.findViewById(R.id.separator_text); - mListener = listener; - view.setOnClickListener(this); - view.setOnLongClickListener(this); - } - - @Override - public void onClick(View view) { - if (mListener != null) { - mListener.onItemClicked(getAdapterPosition()); - } - } - - @Override - public boolean onLongClick(View view) { - if (mListener != null) { - return mListener.onItemLongClicked(getAdapterPosition()); - } - return false; - } - - public interface ClickListener { - void onItemClicked(int position); - - boolean onItemLongClicked(int position); - } - } - +public class HistoryAdapter extends SelectableAdapter { private List mLogs; private Context mContext; - private HistoryAdapter.ViewHolder.ClickListener clickListener; + private HistoryViewHolder.ClickListener clickListener; - public HistoryAdapter(Context aContext, List logs, HistoryAdapter.ViewHolder.ClickListener listener, SelectableHelper helper) { + public HistoryAdapter(Context aContext, List logs, HistoryViewHolder.ClickListener listener, SelectableHelper helper) { super(helper); this.mLogs = logs; this.mContext = aContext; @@ -119,14 +64,14 @@ public class HistoryAdapter extends SelectableAdapter @NonNull @Override - public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + public HistoryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.history_cell, parent, false); - return new ViewHolder(v, clickListener); + return new HistoryViewHolder(v, clickListener); } @Override - public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) { + public void onBindViewHolder(@NonNull final HistoryViewHolder holder, final int position) { final CallLog log = mLogs.get(position); long timestamp = log.getStartDate() * 1000; Address address; diff --git a/app/src/main/java/org/linphone/history/HistoryViewHolder.java b/app/src/main/java/org/linphone/history/HistoryViewHolder.java new file mode 100644 index 000000000..f8cf24485 --- /dev/null +++ b/app/src/main/java/org/linphone/history/HistoryViewHolder.java @@ -0,0 +1,78 @@ +package org.linphone.history; + +/* + HistoryViewHolder.java + Copyright (C) 2018 Belledonne Communications, Grenoble, France + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.widget.CheckBox; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import org.linphone.R; + +public class HistoryViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { + public TextView contact; + public ImageView detail; + public CheckBox select; + public ImageView callDirection; + public RelativeLayout avatarLayout; + public RelativeLayout CallContact; + public LinearLayout separator; + public TextView separatorText; + private ClickListener mListener; + + public HistoryViewHolder(View view, ClickListener listener) { + super(view); + contact = view.findViewById(R.id.sip_uri); + detail = view.findViewById(R.id.detail); + select = view.findViewById(R.id.delete); + callDirection = view.findViewById(R.id.icon); + avatarLayout = view.findViewById(R.id.avatar_layout); + CallContact = view.findViewById(R.id.history_click); + separator = view.findViewById(R.id.separator); + separatorText = view.findViewById(R.id.separator_text); + mListener = listener; + view.setOnClickListener(this); + view.setOnLongClickListener(this); + } + + @Override + public void onClick(View view) { + if (mListener != null) { + mListener.onItemClicked(getAdapterPosition()); + } + } + + @Override + public boolean onLongClick(View view) { + if (mListener != null) { + return mListener.onItemLongClicked(getAdapterPosition()); + } + return false; + } + + public interface ClickListener { + void onItemClicked(int position); + + boolean onItemLongClicked(int position); + } +} \ No newline at end of file