Skip to content

Commit 75b8d6f

Browse files
Android UI Kit v2.1.5
1 parent 5cdad5c commit 75b8d6f

File tree

51 files changed

+1693
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1693
-293
lines changed

uikit/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111
<uses-permission android:name="android.permission.VIBRATE" />
1212
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
1313
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14+
1415
<uses-feature android:name="android.hardware.camera2.full" />
16+
1517
<application
1618
android:hardwareAccelerated="true"
1719
android:requestLegacyExternalStorage="true"
1820
android:usesCleartextTraffic="true"
1921
tools:node="merge"
2022
tools:targetApi="m">
21-
<activity android:name="screen.CometChatMediaViewActivity"></activity>
23+
<activity android:name="screen.CometChatReactionInfoScreenActivity"
24+
android:theme="@style/TransparentCompat"></activity>
25+
<activity android:name="screen.CometChatMediaViewActivity" />
2226
<activity android:name="screen.CometChatMessageInfoScreenActivity" />
2327
<activity android:name="screen.CometChatStartCallActivity" />
2428
<activity

uikit/src/main/java/adapter/MessageAdapter.java

Lines changed: 99 additions & 26 deletions
Large diffs are not rendered by default.
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package adapter;
2+
3+
import android.content.Context;
4+
import android.util.Log;
5+
import android.view.LayoutInflater;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
import android.widget.TextView;
9+
10+
import androidx.annotation.NonNull;
11+
import androidx.recyclerview.widget.RecyclerView;
12+
import com.cometchat.pro.uikit.R;
13+
import com.cometchat.pro.uikit.Reaction.model.Reaction;
14+
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
18+
/**
19+
* Purpose - ReactionListAdapter is a subclass of RecyclerView Adapter which is used to display
20+
* the list of users. It helps to organize the users in recyclerView.
21+
*
22+
* Created on - 20th November 2020
23+
*
24+
* Modified on - 20th November 2020
25+
*
26+
*/
27+
28+
public class ReactionListAdapter extends RecyclerView.Adapter<ReactionListAdapter.ReactionViewHolder> {
29+
30+
private Context context;
31+
32+
private List<Reaction> reactionArrayList = new ArrayList<>();
33+
34+
private static final String TAG = "reactionListAdapter";
35+
36+
/**
37+
* It is a contructor which is used to initialize wherever we needed.
38+
*
39+
* @param context is a object of Context.
40+
*/
41+
public ReactionListAdapter(Context context) {
42+
this.context=context;
43+
}
44+
45+
/**
46+
* It is constructor which takes reactionArrayList as parameter and bind it with reactionArrayList in adapter.
47+
*
48+
* @param context is a object of Context.
49+
* @param reactionArrayList is a list of Reactions used in this adapter.
50+
*/
51+
public ReactionListAdapter(Context context, List<Reaction> reactionArrayList) {
52+
this.reactionArrayList = reactionArrayList;
53+
this.context= context;
54+
}
55+
56+
@NonNull
57+
@Override
58+
public ReactionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
59+
60+
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
61+
62+
View view = layoutInflater.inflate(R.layout.reaction_list_row, parent, false);
63+
64+
return new ReactionViewHolder(view);
65+
}
66+
67+
/**
68+
* This method is used to bind the ReactionViewHolder contents with user at given
69+
* position. It set username userAvatar in respective ReactionViewHolder content.
70+
*
71+
* @param reactionViewHolder is a object of ReactionViewHolder.
72+
* @param i is a position of item in recyclerView.
73+
* @see Reaction
74+
*/
75+
@Override
76+
public void onBindViewHolder(@NonNull ReactionViewHolder reactionViewHolder, int i) {
77+
78+
Reaction reaction = reactionArrayList.get(i);
79+
Log.e(TAG, "onBindViewHolder: "+reaction.getCode());
80+
reactionViewHolder.reaction.setText(reaction.getCode());
81+
reactionViewHolder.itemView.setTag(R.string.reaction,reaction);
82+
}
83+
84+
@Override
85+
public int getItemCount() {
86+
return reactionArrayList.size();
87+
}
88+
89+
90+
/**
91+
* This method is used to update the reactions of reactionArrayList in adapter.
92+
*
93+
* @param reactions is a list of updated reactions.
94+
*/
95+
public void updateList(List<Reaction> reactions) {
96+
for (int i = 0; i < reactions.size(); i++) {
97+
if (reactionArrayList.contains(reactions.get(i))){
98+
int index=reactionArrayList.indexOf(reactions.get(i));
99+
reactionArrayList.remove(index);
100+
reactionArrayList.add(index,reactions.get(i));
101+
}else {
102+
reactionArrayList.add(reactions.get(i));
103+
}
104+
}
105+
notifyDataSetChanged();
106+
}
107+
108+
109+
/**
110+
* This method is used to update particular user in userArrayList of adapter.
111+
*
112+
* @param reaction is a object of ReactionModel which will updated in reactionArrayList.
113+
* @see Reaction
114+
*/
115+
public void updateReaction(Reaction reaction) {
116+
if (reactionArrayList.contains(reaction)){
117+
int index=reactionArrayList.indexOf(reaction);
118+
reactionArrayList.remove(index);
119+
reactionArrayList.add(index,reaction);
120+
notifyItemChanged(index);
121+
}else {
122+
reactionArrayList.add(reaction);
123+
notifyItemInserted(getItemCount()-1);
124+
}
125+
}
126+
127+
/**
128+
* This method is used to remove particular reaction from reactionArrayList of adapter.
129+
*
130+
* @param reaction is a object of user which will be removed from reactionArrayList.
131+
* @see Reaction
132+
*/
133+
public void remove(Reaction reaction) {
134+
if (reactionArrayList.contains(reaction)) {
135+
int index=reactionArrayList.indexOf(reaction);
136+
this.reactionArrayList.remove(reaction);
137+
notifyItemRemoved(index);
138+
}
139+
140+
}
141+
142+
/**
143+
* This method is used to add a reaction in reactionArrayList.
144+
* @param reaction is a object of ReactionModel which will be added in reactionArrayList.
145+
* @see Reaction
146+
*/
147+
public void add(Reaction reaction) {
148+
updateReaction(reaction);
149+
}
150+
151+
152+
153+
class ReactionViewHolder extends RecyclerView.ViewHolder {
154+
155+
TextView reaction;
156+
ReactionViewHolder(View view) {
157+
super(view);
158+
reaction = view.findViewById(R.id.reaction);
159+
}
160+
161+
}
162+
}

uikit/src/main/java/adapter/SmartReplyListAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public SmartReplyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)
6969
}
7070

7171
/**
72-
* This method is used to bind the UserViewHolder contents with user at given
73-
* position. It set username userAvatar in respective UserViewHolder content.
72+
* This method is used to bind the ReactionViewHolder contents with user at given
73+
* position. It set username userAvatar in respective ReactionViewHolder content.
7474
*
75-
* @param smartReplyViewHolder is a object of UserViewHolder.
75+
* @param smartReplyViewHolder is a object of ReactionViewHolder.
7676
* @param i is a position of item in recyclerView.
7777
* @see User
7878
*

uikit/src/main/java/adapter/StickerTabAdapter.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,7 @@ public void addFragment(Fragment fragment, String title,String icon) {
5555
@Nullable
5656
@Override
5757
public CharSequence getPageTitle(int position) {
58-
sb = new SpannableStringBuilder(""); // space added before text for convenience
59-
// myDrawable = context.getResources().getDrawable(R.drawable.default_sticker);
60-
// myDrawable.setBounds(5, 15, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight());
61-
// ImageSpan span = new ImageSpan(myDrawable, DynamicDrawableSpan.ALIGN_BASELINE);
62-
// sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
63-
// Glide.with(context).load(mFragmentIconList.get(position)).into(new CustomTarget<Drawable>() {
64-
// @Override
65-
// public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
66-
// myDrawable = resource;
67-
// try {
68-
// sb = new SpannableStringBuilder(" ");
69-
// myDrawable.setBounds(5, 5, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight());
70-
// ImageSpan span = new ImageSpan(myDrawable, DynamicDrawableSpan.ALIGN_BASELINE);
71-
// sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
72-
// } catch (Exception e) {
73-
// Log.e("Icon: ", e.getMessage());
74-
// }
75-
// }
76-
//
77-
// @Override
78-
// public void onLoadCleared(@Nullable Drawable placeholder) {
79-
//
80-
// }
81-
// });
82-
58+
sb = new SpannableStringBuilder("");
8359
return sb;
8460
}
8561
@Override

0 commit comments

Comments
 (0)