Skip to content

Commit

Permalink
Android UI Kit v2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Nov 24, 2020
1 parent 5cdad5c commit 75b8d6f
Show file tree
Hide file tree
Showing 51 changed files with 1,693 additions and 293 deletions.
6 changes: 5 additions & 1 deletion uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature android:name="android.hardware.camera2.full" />

<application
android:hardwareAccelerated="true"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
tools:node="merge"
tools:targetApi="m">
<activity android:name="screen.CometChatMediaViewActivity"></activity>
<activity android:name="screen.CometChatReactionInfoScreenActivity"
android:theme="@style/TransparentCompat"></activity>
<activity android:name="screen.CometChatMediaViewActivity" />
<activity android:name="screen.CometChatMessageInfoScreenActivity" />
<activity android:name="screen.CometChatStartCallActivity" />
<activity
Expand Down
125 changes: 99 additions & 26 deletions uikit/src/main/java/adapter/MessageAdapter.java

Large diffs are not rendered by default.

162 changes: 162 additions & 0 deletions uikit/src/main/java/adapter/ReactionListAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.cometchat.pro.uikit.R;
import com.cometchat.pro.uikit.Reaction.model.Reaction;

import java.util.ArrayList;
import java.util.List;

/**
* Purpose - ReactionListAdapter is a subclass of RecyclerView Adapter which is used to display
* the list of users. It helps to organize the users in recyclerView.
*
* Created on - 20th November 2020
*
* Modified on - 20th November 2020
*
*/

public class ReactionListAdapter extends RecyclerView.Adapter<ReactionListAdapter.ReactionViewHolder> {

private Context context;

private List<Reaction> reactionArrayList = new ArrayList<>();

private static final String TAG = "reactionListAdapter";

/**
* It is a contructor which is used to initialize wherever we needed.
*
* @param context is a object of Context.
*/
public ReactionListAdapter(Context context) {
this.context=context;
}

/**
* It is constructor which takes reactionArrayList as parameter and bind it with reactionArrayList in adapter.
*
* @param context is a object of Context.
* @param reactionArrayList is a list of Reactions used in this adapter.
*/
public ReactionListAdapter(Context context, List<Reaction> reactionArrayList) {
this.reactionArrayList = reactionArrayList;
this.context= context;
}

@NonNull
@Override
public ReactionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {

LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());

View view = layoutInflater.inflate(R.layout.reaction_list_row, parent, false);

return new ReactionViewHolder(view);
}

/**
* This method is used to bind the ReactionViewHolder contents with user at given
* position. It set username userAvatar in respective ReactionViewHolder content.
*
* @param reactionViewHolder is a object of ReactionViewHolder.
* @param i is a position of item in recyclerView.
* @see Reaction
*/
@Override
public void onBindViewHolder(@NonNull ReactionViewHolder reactionViewHolder, int i) {

Reaction reaction = reactionArrayList.get(i);
Log.e(TAG, "onBindViewHolder: "+reaction.getCode());
reactionViewHolder.reaction.setText(reaction.getCode());
reactionViewHolder.itemView.setTag(R.string.reaction,reaction);
}

@Override
public int getItemCount() {
return reactionArrayList.size();
}


/**
* This method is used to update the reactions of reactionArrayList in adapter.
*
* @param reactions is a list of updated reactions.
*/
public void updateList(List<Reaction> reactions) {
for (int i = 0; i < reactions.size(); i++) {
if (reactionArrayList.contains(reactions.get(i))){
int index=reactionArrayList.indexOf(reactions.get(i));
reactionArrayList.remove(index);
reactionArrayList.add(index,reactions.get(i));
}else {
reactionArrayList.add(reactions.get(i));
}
}
notifyDataSetChanged();
}


/**
* This method is used to update particular user in userArrayList of adapter.
*
* @param reaction is a object of ReactionModel which will updated in reactionArrayList.
* @see Reaction
*/
public void updateReaction(Reaction reaction) {
if (reactionArrayList.contains(reaction)){
int index=reactionArrayList.indexOf(reaction);
reactionArrayList.remove(index);
reactionArrayList.add(index,reaction);
notifyItemChanged(index);
}else {
reactionArrayList.add(reaction);
notifyItemInserted(getItemCount()-1);
}
}

/**
* This method is used to remove particular reaction from reactionArrayList of adapter.
*
* @param reaction is a object of user which will be removed from reactionArrayList.
* @see Reaction
*/
public void remove(Reaction reaction) {
if (reactionArrayList.contains(reaction)) {
int index=reactionArrayList.indexOf(reaction);
this.reactionArrayList.remove(reaction);
notifyItemRemoved(index);
}

}

/**
* This method is used to add a reaction in reactionArrayList.
* @param reaction is a object of ReactionModel which will be added in reactionArrayList.
* @see Reaction
*/
public void add(Reaction reaction) {
updateReaction(reaction);
}



class ReactionViewHolder extends RecyclerView.ViewHolder {

TextView reaction;
ReactionViewHolder(View view) {
super(view);
reaction = view.findViewById(R.id.reaction);
}

}
}
6 changes: 3 additions & 3 deletions uikit/src/main/java/adapter/SmartReplyListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public SmartReplyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)
}

/**
* This method is used to bind the UserViewHolder contents with user at given
* position. It set username userAvatar in respective UserViewHolder content.
* This method is used to bind the ReactionViewHolder contents with user at given
* position. It set username userAvatar in respective ReactionViewHolder content.
*
* @param smartReplyViewHolder is a object of UserViewHolder.
* @param smartReplyViewHolder is a object of ReactionViewHolder.
* @param i is a position of item in recyclerView.
* @see User
*
Expand Down
26 changes: 1 addition & 25 deletions uikit/src/main/java/adapter/StickerTabAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,7 @@ public void addFragment(Fragment fragment, String title,String icon) {
@Nullable
@Override
public CharSequence getPageTitle(int position) {
sb = new SpannableStringBuilder(""); // space added before text for convenience
// myDrawable = context.getResources().getDrawable(R.drawable.default_sticker);
// myDrawable.setBounds(5, 15, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight());
// ImageSpan span = new ImageSpan(myDrawable, DynamicDrawableSpan.ALIGN_BASELINE);
// sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// Glide.with(context).load(mFragmentIconList.get(position)).into(new CustomTarget<Drawable>() {
// @Override
// public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
// myDrawable = resource;
// try {
// sb = new SpannableStringBuilder(" ");
// myDrawable.setBounds(5, 5, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight());
// ImageSpan span = new ImageSpan(myDrawable, DynamicDrawableSpan.ALIGN_BASELINE);
// sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// } catch (Exception e) {
// Log.e("Icon: ", e.getMessage());
// }
// }
//
// @Override
// public void onLoadCleared(@Nullable Drawable placeholder) {
//
// }
// });

sb = new SpannableStringBuilder("");
return sb;
}
@Override
Expand Down
Loading

0 comments on commit 75b8d6f

Please sign in to comment.