packages: application/adapter
* com.app
1)MyApplication.java* com.app
============================
package com.eppico; import android.app.Application;import android.content.SharedPreferences;import android.content.pm.PackageManager;import android.content.res.Configuration;import android.graphics.Typeface;import android.preference.PreferenceManager;import android.support.v4.app.ActivityCompat; import com.crashlytics.android.Crashlytics;import com.eppico.api.RestClient;import com.eppico.utility.PrefHelper;import com.eppico.utility.TimeAgo;import com.eppico.utility.Utils;import com.facebook.FacebookSdk; import io.fabric.sdk.android.Fabric;import java.util.Locale; /** * Created by manisha on 12/12/16. */ public class MyApplication extends Application{ public static SharedPreferences myPref; public static boolean DISABLE_FRAGMENT_ANIMATION=false; RestClient restClient; public Typeface fontRobotoRegular,fontRobotoLight; @Override public void onCreate() { super.onCreate(); //Set language Locale locale = new Locale("en"); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); Fabric.with(this, new Crashlytics()); //Initialize the SDK before executing any other operations. FacebookSdk.sdkInitialize(this); // Initialize preference at application level myPref = PreferenceManager.getDefaultSharedPreferences(this); //Initialize RestClient API class restClient = new RestClient(this,PrefHelper.getString(getString(R.string.prefAuthKey),"")); fontRobotoRegular = getTypeFace("Roboto-Regular_3.ttf"); fontRobotoLight = getTypeFace("Roboto-Light_3.ttf"); // On app start delete Temporary stored images directory e.g Settings if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Utils.getInstance().deleteTempImagesDirectory(this); } } public RestClient getRestClient() { return restClient; } /** * Return typeface */ public Typeface getTypeFace(String typeFaceName) { return Typeface.createFromAsset(getAssets(), typeFaceName); } }2)MyFirebaseInstanceIDService.java
======================================
package com.eppico; import com.eppico.utility.MyLog;import com.eppico.utility.PrefHelper;import com.google.firebase.iid.FirebaseInstanceId;import com.google.firebase.iid.FirebaseInstanceIdService; /** * Created by bhavesh on 16/12/16. */ public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { @Override public void onTokenRefresh() { super.onTokenRefresh(); // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); //Store device token in to preference PrefHelper.setString(getString(R.string.prefDeviceToken),refreshedToken); MyLog.v("MyFirebaseInstanceIDService","Device Token: " +refreshedToken); } }
2)MyFirebaseMessagingService.java**********************com.app.adapter***********************package com.eppico; import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Context;import android.content.Intent;import android.support.v4.app.NotificationCompat;import android.support.v4.content.ContextCompat; import com.eppico.activity.HomeActivity;import com.eppico.utility.MyLog;import com.google.firebase.messaging.FirebaseMessagingService;import com.google.firebase.messaging.RemoteMessage; import java.util.Map; /** * Created by rushil on 16/12/16. */ public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { Map<String, String> data = remoteMessage.getData(); MyLog.e("notification data:", "" + data); createNotification(data); } private void createNotification(Map<String, String> data) { Context context = getBaseContext(); Intent notificationIntent; int notificationId=100; notificationIntent = new Intent(context, HomeActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); NotificationManager notificationManager; NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(context.getResources().getString(R.string.app_name)) .setContentText(data.get("message")) .setColor(ContextCompat.getColor(context, R.color.black)) .setStyle(bigStyle) .setContentIntent(pendingIntent) .setAutoCancel(true) .setPriority(Notification.PRIORITY_DEFAULT) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.FLAG_NO_CLEAR); notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationId, notificationBuilder.build()); } }
1)AppUserListAdapter.java
package com.eppico.adapter; import android.content.Context;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.AppUserModel;import com.eppico.utility.Constants;import com.eppico.widgets.ShapedImageView; import java.util.ArrayList;import java.util.HashMap; /** * Created by manisha on 14/12/16. */ public class AppUserListAdapter extends RecyclerView.Adapter<AppUserListAdapter.ViewHolder> { private Context context; /*private ArrayList<AppUserModel> listAppUsers; private HashMap<Integer, AppUserModel> selectedUsersList;*/ private ArrayList<AppUserModel.User> listAppUsers; private HashMap<Integer, AppUserModel.User> selectedUsersList; //boolean isAllRecordsLoaded; int totalCount=0; public AppUserListAdapter(Context context, ArrayList<AppUserModel.User> listAppUsers, HashMap<Integer, AppUserModel.User> selectedUsersList,int totalCount) { this.listAppUsers = listAppUsers; if (selectedUsersList == null) selectedUsersList = new HashMap<Integer, AppUserModel.User>(); this.selectedUsersList = selectedUsersList; this.context = context; this.totalCount=totalCount; } public void setListItems(ArrayList<AppUserModel.User> listAppUsers, HashMap<Integer, AppUserModel.User> selectedUsersList/*,boolean isAllRecordsLoaded*/) { this.listAppUsers = listAppUsers; if (selectedUsersList == null) selectedUsersList = new HashMap<Integer, AppUserModel.User>(); this.selectedUsersList = selectedUsersList;// this.isAllRecordsLoaded=isAllRecordsLoaded; notifyDataSetChanged(); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; ViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_invite_friends, parent, false); viewHolder = new ViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.load_more_layout, parent, false); viewHolder = new ViewHolder(view); break; } return viewHolder; } @Override public void onBindViewHolder(ViewHolder holder, int position) { if (getItemViewType(position) == Constants.TYPE_ITEM) { AppUserModel.User appUser = listAppUsers.get(position); // Set Tag holder.txtInvite.setTag(appUser); holder.txtFriendName.setText(appUser.getFirstName() + " " + appUser.getLastName()); holder.txtLocationName.setText(appUser.getCountryID()); // In countryId there is name of country Glide.with(context).load(appUser.getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(holder.imgFriend); if (selectedUsersList.containsKey(appUser.getUserId()) || appUser.getIsInvitedSpot()==Constants.INVITATION_STATUS.INVITED.ordinal()) { holder.txtInvite.setBackgroundResource(R.drawable.btn_invite_selected); holder.txtInvite.setTextColor(ContextCompat.getColor(context, R.color.btnInviteSelectedColor)); if(appUser.getIsInvitedSpot()==Constants.INVITATION_STATUS.INVITED.ordinal()) holder.txtInvite.setText(context.getString(R.string.btnInvited)); else holder.txtInvite.setText(context.getString(R.string.btnInviting)); } else { holder.txtInvite.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtInvite.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtInvite.setText(context.getString(R.string.btnInvite)); } } } @Override public int getItemViewType(int position) { if (totalCount>position && position == listAppUsers.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { /*if (!isAllRecordsLoaded) return listAppUsers.size() + 1; else return listAppUsers.size();*/ if (totalCount>listAppUsers.size()) return listAppUsers.size() + 1; else return listAppUsers.size(); } public class ViewHolder extends RecyclerView.ViewHolder { TextView txtFriendName, txtLocationName, txtInvite; ShapedImageView imgFriend; public ViewHolder(View itemView) { super(itemView); imgFriend = (ShapedImageView) itemView.findViewById(R.id.imgFriend); txtFriendName = (TextView) itemView.findViewById(R.id.txtFriendName); txtLocationName = (TextView) itemView.findViewById(R.id.txtLocationName); txtInvite = (TextView) itemView.findViewById(R.id.txtInvite); } } }2)CategoryAdapter.java=======================package com.eppico.adapter; import android.content.Context;import android.graphics.Typeface;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.TextView; import com.eppico.R;import com.eppico.models.CategoryModel;import com.eppico.models.RadiusModel;import com.eppico.utility.Constants; import java.util.ArrayList; /** * Created by manisha on 14/12/16. */ public class CategoryAdapter extends BaseAdapter { private Context mContext; /*private ArrayList<CategoryModel> alstCategory; private ArrayList<RadiusModel> alstRadius;*/ private ArrayList<?> listItems; Constants.POPUP_TYPE popupType; public CategoryAdapter(Context mContext, Constants.POPUP_TYPE popupType,ArrayList<?> listItems) { this.mContext = mContext; this.listItems=listItems; this.popupType = popupType; } @Override public int getCount() { return listItems.size(); /*switch (popupType) { case CATEGORY: return alstCategory.size(); case RADIUS: return alstRadius.size(); } return 0;*/ } @Override public Object getItem(int i) { return null; } @Override public long getItemId(int i) { return 0; } @Override public View getView(int position, View convertView, ViewGroup viewGroup) { ViewHolder viewHolder; if(convertView==null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.spinner_item, null, false); viewHolder=new ViewHolder(convertView); convertView.setTag(viewHolder); } else viewHolder= (ViewHolder) convertView.getTag(); switch (popupType) { case CATEGORY: CategoryModel categoryModel= (CategoryModel) listItems.get(position); viewHolder.textView.setText(categoryModel.getCatName()); break; case RADIUS: RadiusModel radiusModel= (RadiusModel) listItems.get(position); viewHolder.textView.setText(radiusModel.getLength()); break; } return convertView; } private class ViewHolder { TextView textView; public ViewHolder(View item) { textView = (TextView) item.findViewById(R.id.textView); } } }3)CheckInUserAdapter.java===========================package com.eppico.adapter; import android.content.Context;import android.speech.tts.UtteranceProgressListener;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView;import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.AppUserModel;import com.eppico.models.CheckInUserModel;import com.eppico.models.InviteSpotListModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils;import com.eppico.widgets.ShapedImageView;import java.util.ArrayList;import java.util.HashMap; /** * Created by manisha on 14/12/16. */ public class CheckInUserAdapter extends RecyclerView.Adapter<CheckInUserAdapter.CustomViewHolder> { private Context context; private ArrayList<CheckInUserModel.User> alstCheckInUser; int totalCount = 0,loggedInUserId; public CheckInUserAdapter(Context context, int loggedInUserId,ArrayList<CheckInUserModel.User> alstCheckInUser, int totalCount) { this.context = context; this.loggedInUserId=loggedInUserId; this.totalCount = totalCount; this.alstCheckInUser = alstCheckInUser; } // public void setListItems(ArrayList<AppUserModel.User> listAppUsers, HashMap<Integer, AppUserModel.User> selectedUsersList/*,boolean isAllRecordsLoaded*/) {// this.listAppUsers = listAppUsers;// if (selectedUsersList == null)// selectedUsersList = new HashMap<Integer, AppUserModel.User>();// this.selectedUsersList = selectedUsersList;//// this.isAllRecordsLoaded=isAllRecordsLoaded;// notifyDataSetChanged();// } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; CustomViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_checked_in_user, parent, false); viewHolder = new CustomViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.load_more_layout, parent, false); viewHolder = new CustomViewHolder(view); break; } return viewHolder; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { if (getItemViewType(position) == Constants.TYPE_ITEM) { CheckInUserModel.User checkInUser = alstCheckInUser.get(position); checkInUser.setPosition(position); //Set Tag Model holder.txtFollow.setTag(checkInUser); if(Utils.validateString(checkInUser.getUserProfile())) { Glide.with(context).load(checkInUser.getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(holder.imgUser); } // Glide Tag Id is nessasary for settag when we use glide holder.imgUser.setTag(R.string.tagId,checkInUser); if((Utils.validateString(checkInUser.getFirstName()) && (Utils.validateString(checkInUser.getLastName())))){ holder.txtUserName.setText(checkInUser.getFirstName() +" "+ checkInUser.getLastName()); }else if(Utils.validateString(checkInUser.getFirstName())){ holder.txtUserName.setText(checkInUser.getFirstName()); }else if(Utils.validateString(checkInUser.getLastName())){ holder.txtUserName.setText(checkInUser.getLastName()); }else{ holder.txtUserName.setText(""); } if(Utils.validateString(checkInUser.getCity())){ holder.txtLocationName.setVisibility(View.VISIBLE); holder.txtLocationName.setText(checkInUser.getCity()); } else holder.txtLocationName.setVisibility(View.GONE); holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtFollow.setText(context.getString(R.string.btnFollow)); // Set Follow Button if(checkInUser.getUserIsFollowing()==Constants.FOLLOW_STATUS.FOLLOW.ordinal()) { holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_selected); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteSelectedColor)); holder.txtFollow.setText(context.getString(R.string.btnFollowing)); } else { holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtFollow.setText(context.getString(R.string.btnFollow)); } //Hide Follow Button if user is logged in user if(checkInUser.getUserId()==loggedInUserId) holder.txtFollow.setVisibility(View.GONE); else holder.txtFollow.setVisibility(View.VISIBLE); } } @Override public int getItemViewType(int position) { if ((totalCount - 1) > position && position == alstCheckInUser.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > alstCheckInUser.size()) return alstCheckInUser.size() + 1; else return alstCheckInUser.size(); } public void setListItems(ArrayList<CheckInUserModel.User> alstCheckInUser) { this.alstCheckInUser = alstCheckInUser; notifyDataSetChanged(); } public class CustomViewHolder extends RecyclerView.ViewHolder { TextView txtUserName, txtLocationName, txtFollow; ShapedImageView imgUser; public CustomViewHolder(View itemView) { super(itemView); imgUser = (ShapedImageView) itemView.findViewById(R.id.imgUser); txtUserName = (TextView) itemView.findViewById(R.id.txtUserName); txtLocationName = (TextView) itemView.findViewById(R.id.txtLocationName); txtFollow = (TextView) itemView.findViewById(R.id.txtFollow); } } }4)FollowersListAdapter.java=============================package com.eppico.adapter; import android.content.Context;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.FollowersListModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils;import com.eppico.widgets.ShapedImageView; import java.util.ArrayList; /** * Created by manisha on 14/12/16. */ public class FollowersListAdapter extends RecyclerView.Adapter<FollowersListAdapter.CustomViewHolder> { private Context context; private ArrayList<FollowersListModel.Followuser> listFollowers; int totalCount = 0; int loggedInUserId; public FollowersListAdapter(Context context, int loggedInUserId,ArrayList<FollowersListModel.Followuser> listFollowers, int totalCount) { this.context = context; this.loggedInUserId=loggedInUserId; this.totalCount = totalCount; this.listFollowers = listFollowers; } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; CustomViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_followers, parent, false); viewHolder = new CustomViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.load_more_layout, parent, false); viewHolder = new CustomViewHolder(view); break; } return viewHolder; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { if (getItemViewType(position) == Constants.TYPE_ITEM) { FollowersListModel.Followuser followers = listFollowers.get(position); followers.setPosition(position); //Set Tag Model holder.txtFollow.setTag(followers); /**Note: Set Tag with id otherwise glide will gives error*/ holder.imgUser.setTag(R.string.tagId,followers); holder.txtUserName.setTag(R.string.tagId,followers); if(Utils.validateString(followers.getUserProfile())) { Glide.with(context).load(followers.getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(holder.imgUser); } else holder.imgUser.setImageResource(R.mipmap.ic_default_user_list); holder.txtUserName.setText(followers.getFirstName() +" "+ followers.getLastName()); if(Utils.validateString(followers.getCityID())){ holder.txtLocationName.setVisibility(View.VISIBLE); holder.txtLocationName.setText(followers.getCityID()); } else holder.txtLocationName.setVisibility(View.GONE); // Set Follow Button if(followers.getUserIsFollowing()==Constants.FOLLOW_STATUS.FOLLOW.ordinal()) { holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_selected); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteSelectedColor)); holder.txtFollow.setText(context.getString(R.string.btnFollowing)); } else { holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtFollow.setText(context.getString(R.string.btnFollow)); } //Hide Follow Button if user is logged in user if(followers.getUserId() == loggedInUserId) holder.txtFollow.setVisibility(View.GONE); else holder.txtFollow.setVisibility(View.VISIBLE); /* holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtFollow.setText(context.getString(R.string.btnFollow));*/ } } @Override public int getItemViewType(int position) { if ((totalCount - 1) > position && position == listFollowers.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > listFollowers.size()) return listFollowers.size() + 1; else return listFollowers.size(); // return 25; } public void setListItems(ArrayList<FollowersListModel.Followuser> listFollowers) { this.listFollowers = listFollowers; notifyDataSetChanged(); } public class CustomViewHolder extends RecyclerView.ViewHolder { TextView txtUserName, txtLocationName, txtFollow; ShapedImageView imgUser; public CustomViewHolder(View itemView) { super(itemView); imgUser = (ShapedImageView) itemView.findViewById(R.id.imgUser); txtUserName = (TextView) itemView.findViewById(R.id.txtUserName); txtLocationName = (TextView) itemView.findViewById(R.id.txtLocationName); txtFollow = (TextView) itemView.findViewById(R.id.txtFollow); } } }5)FollowingSpotAdapter.java===========================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.FollowingListModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class FollowingSpotAdapter extends RecyclerView.Adapter<FollowingSpotAdapter.CustomViewHolder> { private Context mContext; private ArrayList<FollowingListModel.FollowingSpot> alstFollowingSpot; int totalCount = 0; public FollowingSpotAdapter(Context mContext, ArrayList<FollowingListModel.FollowingSpot> alstFollowingSpot, int totalCount) { this.alstFollowingSpot = alstFollowingSpot; this.mContext = mContext; this.totalCount = totalCount; } public void setListItems(ArrayList<FollowingListModel.FollowingSpot> alstInviteSpot) { this.alstFollowingSpot = alstInviteSpot; notifyDataSetChanged(); } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; CustomViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_following_spot, parent, false); viewHolder = new CustomViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.load_more_layout, parent, false); viewHolder = new CustomViewHolder(view); break; } return viewHolder; } @Override public void onBindViewHolder(final CustomViewHolder holder, int position) { // final InviteSpotListModel mInviteSpotListModel = alstInviteSpot.get(position); if (getItemViewType(position) == Constants.TYPE_ITEM) { FollowingListModel.FollowingSpot followingSpot=alstFollowingSpot.get(position); //Set Position followingSpot.setPosition(position); // Set Tag holder.linFollowingSpotMain.setTag(followingSpot); holder.txtFollowing.setTag(followingSpot); holder.txtSpotName.setText(followingSpot.getSpotName()); /*String strFormattedDate = "", strName = ""; if (Utils.validateString(followingSpot.getCreatedOn())) { try { String datestr = followingSpot.getCreatedOn(); DateFormat formatter; Date convertedDate; // date formate of current string getting from server is yyyy-MM-dd HH:mm:SS // This function will convert this to 25th MArch; formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:SS"); convertedDate = (Date) formatter.parse(datestr); getFormattedDate(convertedDate); strFormattedDate = getFormattedDate(convertedDate); } catch (ParseException e) { e.printStackTrace(); } } if (Utils.validateString(followingSpot.getCreatedOn())) { holder.txtDate.setText(strFormattedDate); } else { holder.txtDate.setText(""); }*/ if (Utils.validateString(followingSpot.getCreatedBy())) { holder.txtFollowName.setText(mContext.getResources().getString(R.string.by)+" "+followingSpot.getCreatedBy()); } else { holder.txtFollowName.setText(""); } holder.txtDate.setText(Utils.getInstance().getFormattedDate(mContext,followingSpot.getCreatedOn())); if (Utils.validateString(followingSpot.getSpotImage())) { Glide.with(mContext) .load(followingSpot.getSpotImage()) .placeholder(R.mipmap.spot_default_img) .error(R.mipmap.spot_default_img) .into(holder.imgFollowing); } else holder.imgFollowing.setImageResource(R.mipmap.ic_default_spot_detail); } } @Override public int getItemCount() { // return alstInviteSpot.size(); if (totalCount > alstFollowingSpot.size()) return alstFollowingSpot.size() + 1; else return alstFollowingSpot.size(); } public class CustomViewHolder extends RecyclerView.ViewHolder { public TextView txtSpotName, txtFollowName, txtDate, txtFollowing; private ImageView imgFollowing; private LinearLayout linFollowingSpotMain; public CustomViewHolder(View itemView) { super(itemView); linFollowingSpotMain = (LinearLayout) itemView.findViewById(R.id.linFollowingSpotMain); txtSpotName = (TextView) itemView.findViewById(R.id.txtSpotName); txtFollowName = (TextView) itemView.findViewById(R.id.txtFollowName); txtDate = (TextView) itemView.findViewById(R.id.txtDate); imgFollowing = (ImageView) itemView.findViewById(R.id.imgFollowing); txtFollowing = (TextView) itemView.findViewById(R.id.txtFollowing); } } class FooterHolder extends RecyclerView.ViewHolder { LinearLayout rlLoadMore; public FooterHolder(View itemView) { super(itemView); rlLoadMore = (LinearLayout) itemView.findViewById(R.id.load_more_rl); } } @Override public int getItemViewType(int position) { /*if (!isAllRecordsLoaded && position == alstInviteSpot.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; }*/ if ((totalCount) > position && position == alstFollowingSpot.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } /* public String getFormattedDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int day = cal.get(Calendar.DATE); switch (day % 10) { case 1: return new SimpleDateFormat("dd MMMM, yyyy").format(date); case 2: return new SimpleDateFormat("dd MMMM, yyyy").format(date); case 3: return new SimpleDateFormat("dd MMMM, yyyy").format(date); default: return new SimpleDateFormat("dd MMMM, yyyy").format(date); } }*/}6)InviteSpotAdapter.java===========================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.CardView;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 android.widget.ImageView;import android.widget.LinearLayout;import android.widget.TextView;import com.bumptech.glide.Glide;import com.bumptech.glide.load.resource.drawable.GlideDrawable;import com.bumptech.glide.request.RequestListener;import com.bumptech.glide.request.target.Target;import com.bumptech.glide.util.Util;import com.eppico.R;import com.eppico.models.InviteSpotListModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils;import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class InviteSpotAdapter extends RecyclerView.Adapter<InviteSpotAdapter.CustomViewHolder> { // private ArrayList<ItemData> itemData;// private OnItemClickListener onItemClickListener; private Context mContext; private ArrayList<InviteSpotListModel.SpotInvitaionUserList> alstInviteSpot; private int visibleThreshold = 1; private int lastVisibleItem, totalItemCount; public boolean loading;// private OnLoadMoreListener onLoadMoreListener; boolean isAllRecordsLoaded; int totalCount=0,marginTop; public InviteSpotAdapter(Context mContext, ArrayList<InviteSpotListModel.SpotInvitaionUserList> alstInviteSpot,int totalCount) { this.alstInviteSpot = alstInviteSpot; this.mContext = mContext; this.totalCount=totalCount; marginTop=mContext.getResources().getDimensionPixelOffset(R.dimen.dp10); } public void setListItems(ArrayList<InviteSpotListModel.SpotInvitaionUserList> alstInviteSpot) { this.alstInviteSpot = alstInviteSpot; notifyDataSetChanged(); } @Override public void onBindViewHolder(final CustomViewHolder holder, int position) { // final InviteSpotListModel mInviteSpotListModel = alstInviteSpot.get(position); if (getItemViewType(position) == Constants.TYPE_ITEM) { holder.txtItem.setText(alstInviteSpot.get(position).getSpotName()); holder.txtSpotDisc.setText(alstInviteSpot.get(position).getSpotDetailDesc()); String strFormattedDate = "", strName = ""; // Set margin top for first item LinearLayout.LayoutParams param= (LinearLayout.LayoutParams) holder.card_view.getLayoutParams(); if(position==0) param.topMargin=marginTop; else param.topMargin=0; holder.card_view.setLayoutParams(param); /*if (Utils.validateString(alstInviteSpot.get(position).getCreateOn())) { try { String datestr = alstInviteSpot.get(position).getCreateOn(); DateFormat formatter; Date convertedDate; // date formate of current string getting from server is yyyy-MM-dd HH:mm:SS // This function will convert this to 25th MArch; formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS"); convertedDate = (Date) formatter.parse(datestr); getFormattedDate(convertedDate); strFormattedDate = getFormattedDate(convertedDate); } catch (ParseException e) { e.printStackTrace(); } } if (Utils.validateString(strName) && Utils.validateString(alstInviteSpot.get(position).getCreateOn())) { holder.txtPosted.setText(strName + " " + mContext.getResources().getString(R.string.posted_on) + " " + strFormattedDate); } else if (Utils.validateString(strName)) { holder.txtPosted.setText(strName); } else if (Utils.validateString(alstInviteSpot.get(position).getCreateOn())) { holder.txtPosted.setText(mContext.getResources().getString(R.string.posted_on) + " " + strFormattedDate); } else { holder.txtPosted.setText(""); }*/ if (Utils.validateString(alstInviteSpot.get(position).getFirstName()) && Utils.validateString(alstInviteSpot.get(position).getLastName())) { strName = alstInviteSpot.get(position).getFirstName() + " " + alstInviteSpot.get(position).getLastName(); } else if (Utils.validateString(alstInviteSpot.get(position).getFirstName())) { strName = alstInviteSpot.get(position).getFirstName(); } else if (Utils.validateString(alstInviteSpot.get(position).getLastName())) { strName = alstInviteSpot.get(position).getLastName(); }else{ strName = ""; } holder.txtPosted.setText(strName + " " + mContext.getResources().getString(R.string.posted_on) + " " + Utils.getInstance().getFormattedDate(mContext,alstInviteSpot.get(position).getCreateOn())); holder.imgPlaceHolder.setVisibility(View.VISIBLE); if (Utils.validateString(alstInviteSpot.get(position).getSpotImage())) { Glide.with(mContext) .load(alstInviteSpot.get(position).getSpotImage()) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { holder.imgPlaceHolder.setVisibility(View.VISIBLE); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { holder.imgPlaceHolder.setVisibility(View.GONE); return false; } }) .into(holder.imgInviteSpot); } if (Utils.validateString("" + alstInviteSpot.get(position).getSpotFollowings())) { holder.txtFollowers.setText("" + alstInviteSpot.get(position).getSpotFollowings()); } if (Utils.validateString("" + alstInviteSpot.get(position).getSpotNoOfUsers())) { holder.txtSpotUser.setText("" + alstInviteSpot.get(position).getSpotNoOfUsers()); } holder.txtItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // onItemClickListener.onItemClick(itemmodel); } }); } } @Override public int getItemCount() { // return alstInviteSpot.size(); if (totalCount>alstInviteSpot.size()) return alstInviteSpot.size() + 1; else return alstInviteSpot.size(); } public class CustomViewHolder extends RecyclerView.ViewHolder { public TextView txtItem, txtSpotDisc, txtPosted,txtFollowers,txtSpotUser; private ImageView imgInviteSpot,imgPlaceHolder; private CardView card_view; public CustomViewHolder(View itemView) { super(itemView); txtItem = (TextView) itemView.findViewById(R.id.txtSpotName); txtSpotDisc = (TextView) itemView.findViewById(R.id.txtSpotDisc); txtPosted = (TextView) itemView.findViewById(R.id.txtPosted); imgInviteSpot = (ImageView)itemView.findViewById(R.id.imgInviteSpot); imgPlaceHolder = (ImageView)itemView.findViewById(R.id.imgPlaceHolder); txtFollowers =(TextView) itemView.findViewById(R.id.txtFollowers); txtSpotUser = (TextView) itemView.findViewById(R.id.txtSpotUser); card_view = (CardView) itemView.findViewById(R.id.card_view); } } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; CustomViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.invite_spot_item, parent, false); viewHolder = new CustomViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.load_more_layout, parent, false); viewHolder = new CustomViewHolder(view); break; } return viewHolder; } @Override public int getItemViewType(int position) { /*if (!isAllRecordsLoaded && position == alstInviteSpot.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; }*/ if ((totalCount)>position && position == alstInviteSpot.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } //// public interface OnItemClickListener {//// void onItemClick(ItemData item);// }//// public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {// this.onLoadMoreListener = onLoadMoreListener;// } public interface OnLoadMoreListener { void onLoadMore(); } /*public String getFormattedDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int day = cal.get(Calendar.DATE); switch (day % 10) { case 1: return new SimpleDateFormat("d MMMM, yyyy").format(date); case 2: return new SimpleDateFormat("d MMMM, yyyy").format(date); case 3: return new SimpleDateFormat("d MMMM, yyyy").format(date); default: return new SimpleDateFormat("d MMMM, yyyy").format(date); } }*/}7)InviteSpotDetailAdapter.java============================package com.eppico.adapter; import android.content.Context;import android.content.Intent;import android.os.Handler;import android.support.design.widget.TabLayout;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.bumptech.glide.load.resource.drawable.GlideDrawable;import com.bumptech.glide.request.RequestListener;import com.bumptech.glide.request.target.Target;import com.bumptech.glide.util.Util;import com.eppico.R;import com.eppico.models.AppUserModel;import com.eppico.models.InviteSpotDetailModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class InviteSpotDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private ArrayList<InviteSpotDetailModel.PostMediaDetails> alstSpotDetail; // private OnItemClickListener onItemClickListener; InviteSpotDetailModel mInviteSpotDetailModel; private Context mContext; int totalCount = 0; int[] screenWH; public InviteSpotDetailAdapter(Context mContext, ArrayList<InviteSpotDetailModel.PostMediaDetails> alstSpotDetail, InviteSpotDetailModel mInviteSpotDetailModel, int totalCount) { this.mContext = mContext; this.totalCount = totalCount; this.alstSpotDetail = alstSpotDetail; this.mInviteSpotDetailModel = mInviteSpotDetailModel; this.mContext = mContext; screenWH=Utils.getInstance().getScreenWidthHeight(mContext); } public void setListItems(ArrayList<InviteSpotDetailModel.PostMediaDetails> alstSpotDetail, InviteSpotDetailModel mInviteSpotDetailModel) { this.alstSpotDetail = alstSpotDetail; this.mInviteSpotDetailModel = mInviteSpotDetailModel; notifyDataSetChanged(); } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == Constants.TYPE_HEADER) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.invite_spot_detail_header, null); HeaderHolder headerHolder = new HeaderHolder(view); return headerHolder; } else if (viewType == Constants.TYPE_FOOTER) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.load_more_layout, parent, false); FooterHolder footerHolder = new FooterHolder(view);// if (!Utils.isNetworkAvailable(getActivity().getApplicationContext())) {// footerHolder.rlLoadMore.setVisibility(View.GONE);// } else {// footerHolder.rlLoadMore.setVisibility(View.VISIBLE);// } return footerHolder; } else { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_grid_item, null); SpotItemHolder spotItemHolder = new SpotItemHolder(view); return spotItemHolder; } } @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof HeaderHolder) { final HeaderHolder headerHolder = ((HeaderHolder) holder); String /*strFormattedDate = "",*/ strName = ""; /*if (Utils.validateString(mInviteSpotDetailModel.getCreatedOn())) { try { String datestr = mInviteSpotDetailModel.getCreatedOn(); DateFormat formatter; Date convertedDate; // date formate of current string getting from server is yyyy-MM-dd HH:mm:SS // This function will convert this to 25th MArch; formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:SS"); convertedDate = (Date) formatter.parse(datestr); getFormattedDate(convertedDate); strFormattedDate = getFormattedDate(convertedDate); } catch (ParseException e) { e.printStackTrace(); } }*/ headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); if (Utils.validateString(mInviteSpotDetailModel.getSpotImage())) { Glide.with(mContext) .load(mInviteSpotDetailModel.getSpotImage()) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { headerHolder.imgPlaceHolder.setVisibility(View.GONE); return false; } }) .into(headerHolder.imgSpot); } if (Utils.validateString(mInviteSpotDetailModel.getFirstName()) && Utils.validateString(mInviteSpotDetailModel.getLasttName())) { strName = mInviteSpotDetailModel.getFirstName() + " " + mInviteSpotDetailModel.getLasttName(); } else if (Utils.validateString(mInviteSpotDetailModel.getFirstName())) { strName = " " + mInviteSpotDetailModel.getFirstName(); } else if (Utils.validateString(mInviteSpotDetailModel.getLasttName())) { strName = " " + mInviteSpotDetailModel.getLasttName(); } headerHolder.txtPostedBy.setText(strName + " " + mContext.getResources().getString(R.string.posted_on) + " " + Utils.getInstance().getFormattedDate(mContext,mInviteSpotDetailModel.getCreatedOn())); /*if (Utils.validateString(strName) && Utils.validateString(mInviteSpotDetailModel.getCreatedOn())) { headerHolder.txtPostedBy.setText(strName + " " + mContext.getResources().getString(R.string.posted_on) + " " + strFormattedDate); } else if (Utils.validateString(strName)) { headerHolder.txtPostedBy.setText(strName); } else if (Utils.validateString(mInviteSpotDetailModel.getCreatedOn())) { headerHolder.txtPostedBy.setText(mContext.getResources().getString(R.string.posted_on) + " " + strFormattedDate); } else { headerHolder.txtPostedBy.setText(""); }*/ if (Utils.validateString(mInviteSpotDetailModel.getSpotName())) { headerHolder.txtSpotName.setText(mInviteSpotDetailModel.getSpotName());// headerHolder.txtSpotName.setText(Utils.getInstance().unescapeJava(mInviteSpotDetailModel.getSpotName())); } if (Utils.validateString("" + mInviteSpotDetailModel.getSpotNoOfUsers())) { headerHolder.txtCheckInUserCount.setText("" + mInviteSpotDetailModel.getSpotNoOfUsers()); } if (Utils.validateString("" + mInviteSpotDetailModel.getSpotFollowings())) { headerHolder.txtFollowersCount.setText("" + mInviteSpotDetailModel.getSpotFollowings()); } if (Utils.validateString("" + mInviteSpotDetailModel.getSpotLocation())) { headerHolder.txtAddress.setText(mInviteSpotDetailModel.getSpotLocation()); } if (Utils.validateString("" + mInviteSpotDetailModel.getSpotDetailDesc())) { // headerHolder.txtDescription.setText(Utils.getInstance().unescapeJava(mInviteSpotDetailModel.getSpotDetailDesc())); headerHolder.txtDescription.setText(mInviteSpotDetailModel.getSpotDetailDesc()); } } else if (holder instanceof SpotItemHolder) { SpotItemHolder spotHolder = ((SpotItemHolder) holder); if ((alstSpotDetail.get(position - 1).getMediaType().equalsIgnoreCase(Constants.POST_MEDIA_TYPE.VIDEO.ordinal()+""))) { spotHolder.imgVideo.setVisibility(View.VISIBLE); } else { spotHolder.imgVideo.setVisibility(View.GONE); } LinearLayout.LayoutParams params= (LinearLayout.LayoutParams) spotHolder.relPostItem.getLayoutParams(); int height=screenWH[0]/4; height-=mContext.getResources().getDimensionPixelSize(R.dimen.dp2); params.height=height; spotHolder.relPostItem.setLayoutParams(params); if (Utils.validateString(alstSpotDetail.get(position - 1).getThumbUrl())) { Glide.with(mContext) .load(alstSpotDetail.get(position - 1).getThumbUrl()) .placeholder(R.mipmap.spot_default_img) .error(R.mipmap.spot_default_img) .into(spotHolder.imgGridImage); } spotHolder.lytPost.setTag(alstSpotDetail.get(position - 1)); } else if (holder instanceof FooterHolder) { FooterHolder footerHolder = ((FooterHolder) holder);// if(removeLoadmore){// ((FooterHolder)holder).rlLoadMore.setVisibility(View.GONE);// }else{// ((FooterHolder)holder).rlLoadMore.setVisibility(View.VISIBLE);// } } } @Override public int getItemViewType(int position) { if (position == 0) { return Constants.TYPE_HEADER; } else if (position >= alstSpotDetail.size() + 1) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > alstSpotDetail.size()) { return alstSpotDetail.size() + 2; } else { return alstSpotDetail.size() + 1; } } public class SpotItemHolder extends RecyclerView.ViewHolder { private ImageView imgGridImage, imgVideo; private LinearLayout lytPost; RelativeLayout relPostItem; public SpotItemHolder(View itemView) { super(itemView); imgVideo = (ImageView) itemView.findViewById(R.id.imgVideo); imgGridImage = (ImageView) itemView.findViewById(R.id.imgGridImage); lytPost = (LinearLayout) itemView.findViewById(R.id.lytPost); relPostItem = (RelativeLayout) itemView.findViewById(R.id.relPostItem); } } class HeaderHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView txtPostedBy, txtSpotName, txtAddress, txtDescription, txtFollowersCount, txtCheckInUserCount; public ImageView imgSpot,imgPlaceHolder; public HeaderHolder(View itemView) { super(itemView); txtPostedBy = (TextView) itemView.findViewById(R.id.txtPosteBy); txtSpotName = (TextView) itemView.findViewById(R.id.txtSpotName); txtAddress = (TextView) itemView.findViewById(R.id.txtAddress); txtDescription = (TextView) itemView.findViewById(R.id.txtDescription); txtFollowersCount = (TextView) itemView.findViewById(R.id.txtFollowersCount); txtCheckInUserCount = (TextView) itemView.findViewById(R.id.txtCheckInUserCount); imgSpot = (ImageView) itemView.findViewById(R.id.imgSpot); imgPlaceHolder = (ImageView) itemView.findViewById(R.id.imgPlaceHolder); } @Override public void onClick(View v) { } } class FooterHolder extends RecyclerView.ViewHolder { LinearLayout rlLoadMore; public FooterHolder(View itemView) { super(itemView); rlLoadMore = (LinearLayout) itemView.findViewById(R.id.load_more_rl); } } // public interface OnItemClickListener {//// void onItemClick(ItemData item);// }// public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {// this.onLoadMoreListener = onLoadMoreListener;// } /*public String getFormattedDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int day = cal.get(Calendar.DATE); switch (day % 10) { case 1: return new SimpleDateFormat("d MMMM, yyyy").format(date); case 2: return new SimpleDateFormat("d MMMM, yyyy").format(date); case 3: return new SimpleDateFormat("d MMMM, yyyy").format(date); default: return new SimpleDateFormat("d MMMM, yyyy").format(date); } }*/}8)LeaderShipBoardAdapter.java============================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.LeadershipBoardModel;import com.eppico.utility.Utils; import java.util.ArrayList; /** * Created by manisha on 30/12/16. */ public class LeaderShipBoardAdapter extends RecyclerView.Adapter<LeaderShipBoardAdapter.CustomViewHolder>{ public Context mContext; ArrayList<LeadershipBoardModel> alstLeaderShipList; public LeaderShipBoardAdapter (Context mContext,ArrayList<LeadershipBoardModel> alstLeaderShipList){ this.mContext = mContext; this.alstLeaderShipList = alstLeaderShipList; } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout. list_leadership_board, null); CustomViewHolder viewHolder = new CustomViewHolder(view); return viewHolder; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { String strName=""; if (Utils.validateString(alstLeaderShipList.get(position).getFirstName()) && Utils.validateString(alstLeaderShipList.get(position).getLastName())) { strName = alstLeaderShipList.get(position).getFirstName() + " " + alstLeaderShipList.get(position).getLastName(); } else if (Utils.validateString(alstLeaderShipList.get(position).getLastName())) { strName = " " + alstLeaderShipList.get(position).getFirstName(); } else if (Utils.validateString(alstLeaderShipList.get(position).getLastName())) { strName = " " +alstLeaderShipList.get(position).getLastName(); } holder.txtLeaderName.setText(strName); if(Utils.validateString(alstLeaderShipList.get(position).getPoint())){ holder.txtLeadershipCount.setText(alstLeaderShipList.get(position).getPoint()); } // if(Utils.validateString(alstLeaderShipList.get(position.getl))) if (Utils.validateString(alstLeaderShipList.get(position).getUserProfile())) { Glide.with(mContext).load(alstLeaderShipList.get(position).getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(holder.imgLeader); } else holder.imgLeader.setImageResource(R.mipmap.ic_default_user_list); } @Override public int getItemCount() { return alstLeaderShipList.size(); } public class CustomViewHolder extends RecyclerView.ViewHolder{ private TextView txtLeaderName,txtLocationName,txtLeadershipCount; private ImageView imgLeader; private LinearLayout lytSpot; public CustomViewHolder(View itemView) { super(itemView); txtLeaderName = (TextView)itemView.findViewById(R.id.txtLeaderName); txtLocationName = (TextView)itemView.findViewById(R.id.txtLocationName); txtLeadershipCount = (TextView)itemView.findViewById(R.id.txtLeadershipCount); imgLeader = (ImageView)itemView.findViewById(R.id.imgLeader);// lytSpot = (LinearLayout)itemView.findViewById(R.id.lytSpot); } } }9)LeaderShipBoardListAdapter .java================================package com.eppico.adapter;import android.content.Context;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.UserLeaderShipListModel;import com.eppico.utility.Utils; import java.util.ArrayList; /** * Created by manisha on 30/12/16. */ public class LeaderShipBoardListAdapter extends RecyclerView.Adapter<LeaderShipBoardListAdapter.CustomViewHolder>{ public Context mContext; private ArrayList<UserLeaderShipListModel>alstLeaderShip; public LeaderShipBoardListAdapter(Context mContext, ArrayList<UserLeaderShipListModel> alstLeaderShip){ this.mContext = mContext; this.alstLeaderShip = alstLeaderShip; } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout. user_leadership_board, null); CustomViewHolder viewHolder = new CustomViewHolder(view); return viewHolder; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { if (Utils.validateString(alstLeaderShip.get(position).getSpotName())) { holder.txtSpotName.setText(alstLeaderShip.get(position).getSpotName()); } if(Utils.validateString(alstLeaderShip.get(position).getPoint())){ holder.txtLeadershipCount.setText(alstLeaderShip.get(position).getPoint()); } if (Utils.validateString(alstLeaderShip.get(position).getSpotImage())) { Glide.with(mContext).load(alstLeaderShip.get(position).getSpotImage()) .placeholder(R.mipmap.spot_default_img) .error(R.mipmap.spot_default_img) .into(holder.imgSpot); } else holder.imgSpot.setImageResource(R.mipmap.spot_default_img); holder.lytSpotName.setTag(alstLeaderShip.get(position)); } @Override public int getItemCount() { return alstLeaderShip.size(); } public class CustomViewHolder extends RecyclerView.ViewHolder{ private TextView txtSpotName,txtLeadershipCount; private ImageView imgSpot; private LinearLayout lytSpotName; public CustomViewHolder(View itemView) { super(itemView); txtSpotName = (TextView) itemView.findViewById(R.id.txtSpotName); txtLeadershipCount = (TextView) itemView.findViewById(R.id.txtLeadershipCount); imgSpot = (ImageView) itemView.findViewById(R.id.imgSpot); lytSpotName = (LinearLayout) itemView.findViewById(R.id.lytSpot); } } }10)PostDetailAdapter.java=========================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.RecyclerView;import android.text.Html;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.bumptech.glide.load.resource.drawable.GlideDrawable;import com.bumptech.glide.request.RequestListener;import com.bumptech.glide.request.target.Target;import com.eppico.R;import com.eppico.models.InviteSpotDetailModel;import com.eppico.models.PostDetailModel;import com.eppico.utility.Constants;import com.eppico.utility.TimeAgo;import com.eppico.utility.Utils; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class PostDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private ArrayList<PostDetailModel.PostComments> alstPostDetail; PostDetailModel mPostDetailModel; private Context mContext; int totalCount = 0, totalLike = 0; int[] screenWH; private int userId; boolean isViewComment; private int mIsActive; public PostDetailAdapter(Context mContext, ArrayList<PostDetailModel.PostComments> alstPostDetail, PostDetailModel mPostDetailModel, int totalCount, int userId, boolean isViewComment,int mIsActive) { this.mContext = mContext; this.totalCount = totalCount; this.alstPostDetail = alstPostDetail; this.mPostDetailModel = mPostDetailModel; this.mContext = mContext; this.userId = userId; this.isViewComment = isViewComment; this.mIsActive = mIsActive; screenWH = Utils.getInstance().getScreenWidthHeight(mContext); } public void setTotalCount(int count, ArrayList<PostDetailModel.PostComments> alstPostDetail, boolean isViewComment) { this.totalCount = count; this.alstPostDetail = alstPostDetail; this.isViewComment = isViewComment; notifyDataSetChanged(); } public void setLike(PostDetailModel mPostDetailModel) { this.mPostDetailModel = mPostDetailModel; notifyDataSetChanged(); } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == Constants.TYPE_HEADER) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_detail_header, parent, false); HeaderHolder headerHolder = new HeaderHolder(view); return headerHolder; } else if (viewType == Constants.TYPE_FOOTER) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.load_more_layout, parent, false); FooterHolder footerHolder = new FooterHolder(view); return footerHolder; } else { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_item, parent, false); CommentHolder commentHolder = new CommentHolder(view); return commentHolder; } } @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof HeaderHolder) { final HeaderHolder headerHolder = ((HeaderHolder) holder); final PostDetailModel.PostDetails postDetails = mPostDetailModel.getPostDetails().get(0); if (Utils.validateString(postDetails.getUserProfile())) { Glide.with(mContext) .load(postDetails.getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(headerHolder.imgUser); } headerHolder.imgUser.setTag(R.string.tagId,postDetails); if(mIsActive == 0){ // 0= Active, 1=Inactive if (postDetails.getUserId() == userId) { // headerHolder.imgReportAbuse.setVisibility(View.GONE); headerHolder.imgReportAbuse.setImageResource(R.mipmap.ic_delete); } else { // headerHolder.imgReportAbuse.setVisibility(View.VISIBLE); headerHolder.imgReportAbuse.setImageResource(R.drawable.selecter_report_abuse); } }else{ headerHolder.imgReportAbuse.setVisibility(View.GONE); } /**Set Delete icon if post is logged in user*/ if((alstPostDetail != null && alstPostDetail.size() > 0) || mIsActive == 1) // 0= Active, 1=Inactive { headerHolder.txtBeTheFirst.setVisibility(View.GONE); }else{ headerHolder.txtBeTheFirst.setVisibility(View.VISIBLE); } headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); String imageURL = ""; if (postDetails.getMediaType().equals(Constants.POST_MEDIA_TYPE.VIDEO.ordinal() + "")) { imageURL = postDetails.getThumbUrl(); headerHolder.imgPlayIcon.setVisibility(View.VISIBLE); } else { imageURL = postDetails.getMediaUrl(); headerHolder.imgPlayIcon.setVisibility(View.GONE); } headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); if (Utils.validateString(imageURL)) { Glide.with(mContext) .load(imageURL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { headerHolder.imgPlaceHolder.setVisibility(View.GONE); return false; } }) .into(headerHolder.imgPost); } if (Utils.validateString(postDetails.getFirstName()) && Utils.validateString(postDetails.getLastName())) { headerHolder.txtName.setText(postDetails.getFirstName() + " " + postDetails.getLastName()); } else if (Utils.validateString(postDetails.getFirstName())) { headerHolder.txtName.setText(postDetails.getFirstName()); } else if (Utils.validateString(postDetails.getLastName())) { headerHolder.txtName.setText(postDetails.getLastName()); } else { headerHolder.txtName.setText(""); } headerHolder.txtName.setTag(R.string.tagId,postDetails); if (Utils.validateString(postDetails.getSpotName())) { headerHolder.txtSpotName.setText(postDetails.getSpotName()); } if (Utils.validateString("" + postDetails.getTotalLikes())) { headerHolder.txtLike.setText("" + (postDetails.getTotalLikes())); } if (Utils.validateString("" + postDetails.getIsLike())) { if (postDetails.getIsLike() == 1) { // headerHolder.imgLike.setImageResource(R.mipmap.ic_like_selected); headerHolder.txtLike.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_like_selected, 0, 0, 0); } else { // headerHolder.imgLike.setImageResource(R.mipmap.ic_like); headerHolder.txtLike.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_like, 0, 0, 0); } } headerHolder.txtComment.setText("" + totalCount); } else if (holder instanceof CommentHolder) { CommentHolder commentHolder = ((CommentHolder) holder); if (position - 1 == 1) { commentHolder.txtComment.setPadding(0, 10, 0, 0); } else { commentHolder.txtComment.setPadding(0, 0, 0, 0); } if (Utils.validateString(alstPostDetail.get(position - 1).getUserProfile())) { Glide.with(mContext) .load(alstPostDetail.get(position - 1).getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) // TODO: Later change this default placeholder .into(commentHolder.imgCommentUser); } commentHolder.imgCommentUser.setTag(R.string.tagId,alstPostDetail.get(position - 1)); String strName = ""; if (Utils.validateString(alstPostDetail.get(position - 1).getFirstname()) && Utils.validateString(alstPostDetail.get(position - 1).getLastName())) { strName = alstPostDetail.get(position - 1).getFirstname() + " " + alstPostDetail.get(position - 1).getLastName(); } else if (Utils.validateString(alstPostDetail.get(position - 1).getFirstname())) { strName = alstPostDetail.get(position - 1).getFirstname(); } else if (Utils.validateString(alstPostDetail.get(position - 1).getLastName())) { strName = alstPostDetail.get(position - 1).getLastName(); } else { strName = ""; } commentHolder.txtCommentName.setText(strName); if (Utils.validateString(alstPostDetail.get(position - 1).getCommentDesc())) { commentHolder.txtComment.setText(alstPostDetail.get(position - 1).getCommentDesc().toString().trim()); } commentHolder.txtDelete.setTag(alstPostDetail.get(position - 1)); if (alstPostDetail.get(position - 1).getUserId() == userId) { commentHolder.imgDot.setVisibility(View.VISIBLE); commentHolder.txtDelete.setVisibility(View.VISIBLE); } else { commentHolder.imgDot.setVisibility(View.GONE); commentHolder.txtDelete.setVisibility(View.GONE); } if (Utils.validateString(alstPostDetail.get(position - 1).getCreatedOn())) { // Log.e("Date:",date.toString());// long millis = date.getTime();// String strTime = TimeAgo.getInstance().toDuration(mContext,millis);// commentHolder.txtHoursAgo.setText(strTime); if (alstPostDetail.get(position - 1) != null) { commentHolder.txtHoursAgo.setText(Utils.getInstance().getDateDifference(mContext,alstPostDetail.get(position - 1).getCreatedOn().toString().trim())); } } // String text = "<b><font color='#525252'>" +strName+" "+ "</font></b>" + "<font color='#585858'>" + alstPostDetail.get(position - 1).getCommentDesc() + "</font";// commentHolder.txtComment.setText(Html.fromHtml(text), com.eppico.widgets.CustomFont.BufferType.SPANNABLE); } else if (holder instanceof FooterHolder) { FooterHolder footerHolder = ((FooterHolder) holder); if (isViewComment) { footerHolder.lytLoadMore.setVisibility(View.VISIBLE); } else { footerHolder.lytLoadMore.setVisibility(View.GONE); } } } @Override public int getItemViewType(int position) { if (position == 0) { return Constants.TYPE_HEADER; } else if (position >= alstPostDetail.size() + 1) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > alstPostDetail.size()) { if (isViewComment) { return alstPostDetail.size() + 2; } else { return alstPostDetail.size() + 1; } } else { return alstPostDetail.size() + 1; } } public class CommentHolder extends RecyclerView.ViewHolder { private TextView txtCommentName, txtComment, txtHoursAgo, txtDelete; private ImageView imgCommentUser, imgDot; public CommentHolder(View itemView) { super(itemView); imgCommentUser = (ImageView) itemView.findViewById(R.id.imgCommentUser); imgDot = (ImageView) itemView.findViewById(R.id.imgDot); txtCommentName = (TextView) itemView.findViewById(R.id.txtCommentName); txtComment = (TextView) itemView.findViewById(R.id.txtComment); txtHoursAgo = (TextView) itemView.findViewById(R.id.txtHoursAgo); txtDelete = (TextView) itemView.findViewById(R.id.txtDelete); } } class HeaderHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView txtName, txtSpotName, txtComment, txtLike,txtBeTheFirst; public ImageView imgUser, imgReportAbuse, imgPost, imgPlayIcon, imgVideo, imgPlaceHolder; public HeaderHolder(View itemView) { super(itemView); txtName = (TextView) itemView.findViewById(R.id.txtName); txtSpotName = (TextView) itemView.findViewById(R.id.txtSpotName); txtComment = (TextView) itemView.findViewById(R.id.txtComment); txtLike = (TextView) itemView.findViewById(R.id.txtLike); txtBeTheFirst = (TextView)itemView.findViewById(R.id.txtBeTheFirst); imgVideo = (ImageView) itemView.findViewById(R.id.imgVideo); imgUser = (ImageView) itemView.findViewById(R.id.imgUser); imgReportAbuse = (ImageView) itemView.findViewById(R.id.imgReportAbuse); imgPost = (ImageView) itemView.findViewById(R.id.imgPost); imgPlayIcon = (ImageView) itemView.findViewById(R.id.imgPlayIcon); imgPlaceHolder = (ImageView) itemView.findViewById(R.id.imgPlaceHolder); } @Override public void onClick(View v) { } } class FooterHolder extends RecyclerView.ViewHolder { LinearLayout lytLoadMore; public FooterHolder(View itemView) { super(itemView); lytLoadMore = (LinearLayout) itemView.findViewById(R.id.load_more_rl); } } /* public String getFormattedDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int day = cal.get(Calendar.DATE); switch (day % 10) { case 1: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); case 2: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); case 3: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); default: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); } }*/}11)PostDetailAdapter.java=========================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.RecyclerView;import android.text.Html;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.bumptech.glide.load.resource.drawable.GlideDrawable;import com.bumptech.glide.request.RequestListener;import com.bumptech.glide.request.target.Target;import com.eppico.R;import com.eppico.models.InviteSpotDetailModel;import com.eppico.models.PostDetailModel;import com.eppico.utility.Constants;import com.eppico.utility.TimeAgo;import com.eppico.utility.Utils; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class PostDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private ArrayList<PostDetailModel.PostComments> alstPostDetail; PostDetailModel mPostDetailModel; private Context mContext; int totalCount = 0, totalLike = 0; int[] screenWH; private int userId; boolean isViewComment; private int mIsActive; public PostDetailAdapter(Context mContext, ArrayList<PostDetailModel.PostComments> alstPostDetail, PostDetailModel mPostDetailModel, int totalCount, int userId, boolean isViewComment,int mIsActive) { this.mContext = mContext; this.totalCount = totalCount; this.alstPostDetail = alstPostDetail; this.mPostDetailModel = mPostDetailModel; this.mContext = mContext; this.userId = userId; this.isViewComment = isViewComment; this.mIsActive = mIsActive; screenWH = Utils.getInstance().getScreenWidthHeight(mContext); } public void setTotalCount(int count, ArrayList<PostDetailModel.PostComments> alstPostDetail, boolean isViewComment) { this.totalCount = count; this.alstPostDetail = alstPostDetail; this.isViewComment = isViewComment; notifyDataSetChanged(); } public void setLike(PostDetailModel mPostDetailModel) { this.mPostDetailModel = mPostDetailModel; notifyDataSetChanged(); } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == Constants.TYPE_HEADER) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_detail_header, parent, false); HeaderHolder headerHolder = new HeaderHolder(view); return headerHolder; } else if (viewType == Constants.TYPE_FOOTER) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.load_more_layout, parent, false); FooterHolder footerHolder = new FooterHolder(view); return footerHolder; } else { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_item, parent, false); CommentHolder commentHolder = new CommentHolder(view); return commentHolder; } } @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof HeaderHolder) { final HeaderHolder headerHolder = ((HeaderHolder) holder); final PostDetailModel.PostDetails postDetails = mPostDetailModel.getPostDetails().get(0); if (Utils.validateString(postDetails.getUserProfile())) { Glide.with(mContext) .load(postDetails.getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(headerHolder.imgUser); } headerHolder.imgUser.setTag(R.string.tagId,postDetails); if(mIsActive == 0){ // 0= Active, 1=Inactive if (postDetails.getUserId() == userId) { // headerHolder.imgReportAbuse.setVisibility(View.GONE); headerHolder.imgReportAbuse.setImageResource(R.mipmap.ic_delete); } else { // headerHolder.imgReportAbuse.setVisibility(View.VISIBLE); headerHolder.imgReportAbuse.setImageResource(R.drawable.selecter_report_abuse); } }else{ headerHolder.imgReportAbuse.setVisibility(View.GONE); } /**Set Delete icon if post is logged in user*/ if((alstPostDetail != null && alstPostDetail.size() > 0) || mIsActive == 1) // 0= Active, 1=Inactive { headerHolder.txtBeTheFirst.setVisibility(View.GONE); }else{ headerHolder.txtBeTheFirst.setVisibility(View.VISIBLE); } headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); String imageURL = ""; if (postDetails.getMediaType().equals(Constants.POST_MEDIA_TYPE.VIDEO.ordinal() + "")) { imageURL = postDetails.getThumbUrl(); headerHolder.imgPlayIcon.setVisibility(View.VISIBLE); } else { imageURL = postDetails.getMediaUrl(); headerHolder.imgPlayIcon.setVisibility(View.GONE); } headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); if (Utils.validateString(imageURL)) { Glide.with(mContext) .load(imageURL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { headerHolder.imgPlaceHolder.setVisibility(View.VISIBLE); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { headerHolder.imgPlaceHolder.setVisibility(View.GONE); return false; } }) .into(headerHolder.imgPost); } if (Utils.validateString(postDetails.getFirstName()) && Utils.validateString(postDetails.getLastName())) { headerHolder.txtName.setText(postDetails.getFirstName() + " " + postDetails.getLastName()); } else if (Utils.validateString(postDetails.getFirstName())) { headerHolder.txtName.setText(postDetails.getFirstName()); } else if (Utils.validateString(postDetails.getLastName())) { headerHolder.txtName.setText(postDetails.getLastName()); } else { headerHolder.txtName.setText(""); } headerHolder.txtName.setTag(R.string.tagId,postDetails); if (Utils.validateString(postDetails.getSpotName())) { headerHolder.txtSpotName.setText(postDetails.getSpotName()); } if (Utils.validateString("" + postDetails.getTotalLikes())) { headerHolder.txtLike.setText("" + (postDetails.getTotalLikes())); } if (Utils.validateString("" + postDetails.getIsLike())) { if (postDetails.getIsLike() == 1) { // headerHolder.imgLike.setImageResource(R.mipmap.ic_like_selected); headerHolder.txtLike.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_like_selected, 0, 0, 0); } else { // headerHolder.imgLike.setImageResource(R.mipmap.ic_like); headerHolder.txtLike.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_like, 0, 0, 0); } } headerHolder.txtComment.setText("" + totalCount); } else if (holder instanceof CommentHolder) { CommentHolder commentHolder = ((CommentHolder) holder); if (position - 1 == 1) { commentHolder.txtComment.setPadding(0, 10, 0, 0); } else { commentHolder.txtComment.setPadding(0, 0, 0, 0); } if (Utils.validateString(alstPostDetail.get(position - 1).getUserProfile())) { Glide.with(mContext) .load(alstPostDetail.get(position - 1).getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) // TODO: Later change this default placeholder .into(commentHolder.imgCommentUser); } commentHolder.imgCommentUser.setTag(R.string.tagId,alstPostDetail.get(position - 1)); String strName = ""; if (Utils.validateString(alstPostDetail.get(position - 1).getFirstname()) && Utils.validateString(alstPostDetail.get(position - 1).getLastName())) { strName = alstPostDetail.get(position - 1).getFirstname() + " " + alstPostDetail.get(position - 1).getLastName(); } else if (Utils.validateString(alstPostDetail.get(position - 1).getFirstname())) { strName = alstPostDetail.get(position - 1).getFirstname(); } else if (Utils.validateString(alstPostDetail.get(position - 1).getLastName())) { strName = alstPostDetail.get(position - 1).getLastName(); } else { strName = ""; } commentHolder.txtCommentName.setText(strName); if (Utils.validateString(alstPostDetail.get(position - 1).getCommentDesc())) { commentHolder.txtComment.setText(alstPostDetail.get(position - 1).getCommentDesc().toString().trim()); } commentHolder.txtDelete.setTag(alstPostDetail.get(position - 1)); if (alstPostDetail.get(position - 1).getUserId() == userId) { commentHolder.imgDot.setVisibility(View.VISIBLE); commentHolder.txtDelete.setVisibility(View.VISIBLE); } else { commentHolder.imgDot.setVisibility(View.GONE); commentHolder.txtDelete.setVisibility(View.GONE); } if (Utils.validateString(alstPostDetail.get(position - 1).getCreatedOn())) { // Log.e("Date:",date.toString());// long millis = date.getTime();// String strTime = TimeAgo.getInstance().toDuration(mContext,millis);// commentHolder.txtHoursAgo.setText(strTime); if (alstPostDetail.get(position - 1) != null) { commentHolder.txtHoursAgo.setText(Utils.getInstance().getDateDifference(mContext,alstPostDetail.get(position - 1).getCreatedOn().toString().trim())); } } // String text = "<b><font color='#525252'>" +strName+" "+ "</font></b>" + "<font color='#585858'>" + alstPostDetail.get(position - 1).getCommentDesc() + "</font";// commentHolder.txtComment.setText(Html.fromHtml(text), com.eppico.widgets.CustomFont.BufferType.SPANNABLE); } else if (holder instanceof FooterHolder) { FooterHolder footerHolder = ((FooterHolder) holder); if (isViewComment) { footerHolder.lytLoadMore.setVisibility(View.VISIBLE); } else { footerHolder.lytLoadMore.setVisibility(View.GONE); } } } @Override public int getItemViewType(int position) { if (position == 0) { return Constants.TYPE_HEADER; } else if (position >= alstPostDetail.size() + 1) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > alstPostDetail.size()) { if (isViewComment) { return alstPostDetail.size() + 2; } else { return alstPostDetail.size() + 1; } } else { return alstPostDetail.size() + 1; } } public class CommentHolder extends RecyclerView.ViewHolder { private TextView txtCommentName, txtComment, txtHoursAgo, txtDelete; private ImageView imgCommentUser, imgDot; public CommentHolder(View itemView) { super(itemView); imgCommentUser = (ImageView) itemView.findViewById(R.id.imgCommentUser); imgDot = (ImageView) itemView.findViewById(R.id.imgDot); txtCommentName = (TextView) itemView.findViewById(R.id.txtCommentName); txtComment = (TextView) itemView.findViewById(R.id.txtComment); txtHoursAgo = (TextView) itemView.findViewById(R.id.txtHoursAgo); txtDelete = (TextView) itemView.findViewById(R.id.txtDelete); } } class HeaderHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView txtName, txtSpotName, txtComment, txtLike,txtBeTheFirst; public ImageView imgUser, imgReportAbuse, imgPost, imgPlayIcon, imgVideo, imgPlaceHolder; public HeaderHolder(View itemView) { super(itemView); txtName = (TextView) itemView.findViewById(R.id.txtName); txtSpotName = (TextView) itemView.findViewById(R.id.txtSpotName); txtComment = (TextView) itemView.findViewById(R.id.txtComment); txtLike = (TextView) itemView.findViewById(R.id.txtLike); txtBeTheFirst = (TextView)itemView.findViewById(R.id.txtBeTheFirst); imgVideo = (ImageView) itemView.findViewById(R.id.imgVideo); imgUser = (ImageView) itemView.findViewById(R.id.imgUser); imgReportAbuse = (ImageView) itemView.findViewById(R.id.imgReportAbuse); imgPost = (ImageView) itemView.findViewById(R.id.imgPost); imgPlayIcon = (ImageView) itemView.findViewById(R.id.imgPlayIcon); imgPlaceHolder = (ImageView) itemView.findViewById(R.id.imgPlaceHolder); } @Override public void onClick(View v) { } } class FooterHolder extends RecyclerView.ViewHolder { LinearLayout lytLoadMore; public FooterHolder(View itemView) { super(itemView); lytLoadMore = (LinearLayout) itemView.findViewById(R.id.load_more_rl); } } /* public String getFormattedDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int day = cal.get(Calendar.DATE); switch (day % 10) { case 1: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); case 2: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); case 3: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); default: return new SimpleDateFormat("dd MMM, yyyy HH:mm a").format(date); } }*/}12)ProfileDetailAdapter.java============================package com.eppico.adapter; import android.content.Context;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.util.Log;import android.view.Gravity;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.bumptech.glide.load.resource.drawable.GlideDrawable;import com.bumptech.glide.request.RequestListener;import com.bumptech.glide.request.target.Target;import com.eppico.R;import com.eppico.models.AppUserModel;import com.eppico.models.ProfileDetailModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils;import com.eppico.widgets.ShapedImageView; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date;import java.util.HashMap;import java.util.List; /** * Created by manisha on 14/12/16. */ public class ProfileDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private Context context; private ArrayList<ProfileDetailModel.PostMediaDetails> listProfileMedia; ProfileDetailModel profileDetailModel; //boolean isAllRecordsLoaded; int totalCount = 0, userId; int[] screenWH; public ProfileDetailAdapter(Context context, ProfileDetailModel profileDetailModel, ArrayList<ProfileDetailModel.PostMediaDetails> listProfileMedia, int userId) { this.context = context; this.profileDetailModel = profileDetailModel; this.listProfileMedia = listProfileMedia; this.totalCount = profileDetailModel.getPostMedia().getTotalCount(); screenWH = Utils.getInstance().getScreenWidthHeight(context); this.userId = userId; /*this.listProfileMedia = new ArrayList<ProfileDetailModel.PostMediaDetails>(); if (profileDetailModel.getPostMedia().getPostMediaDetails() != null) { listProfileMedia.addAll(profileDetailModel.getPostMedia().getPostMediaDetails()); this.totalCount = profileDetailModel.getPostMedia().getTotalCount(); }*/ } public void setListItems(ArrayList<ProfileDetailModel.PostMediaDetails> listProfileMedia) { this.listProfileMedia = listProfileMedia;// this.isAllRecordsLoaded=isAllRecordsLoaded; notifyDataSetChanged(); } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == Constants.TYPE_HEADER) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header_profile_detail, parent, false); HeaderHolder headerHolder = new HeaderHolder(view); return headerHolder; } else if (viewType == Constants.TYPE_FOOTER) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.load_more_layout, parent, false); FooterHolder footerHolder = new FooterHolder(view); return footerHolder; } else { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_grid_item, parent, false); PostItemHolder postItemHolder = new PostItemHolder(view); return postItemHolder; } } @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof HeaderHolder) { HeaderHolder headerHolder = (HeaderHolder) holder; headerHolder.txtUserName.setText(Utils.getInstance().unescapeJava(profileDetailModel.getFirstName() + " " + profileDetailModel.getLastName())); Glide.with(context).load(profileDetailModel.getUserProfile()) /*.placeholder(R.mipmap.ic_default_profile) .error(R.mipmap.ic_default_profile)*/ .into(headerHolder.imgProfileBig); Glide.with(context).load(profileDetailModel.getUserProfile()) .placeholder(R.mipmap.ic_default_profile) .error(R.mipmap.ic_default_profile) .into(headerHolder.imgProfile); headerHolder.txtFollowers.setText(profileDetailModel.getFollowers() + ""); headerHolder.txtFollowing.setText(profileDetailModel.getFollowing() + ""); if (profileDetailModel.getUserIsFollowing() == 0) { headerHolder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); headerHolder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); } else { headerHolder.txtFollow.setBackgroundResource(R.drawable.btn_follow_selected); headerHolder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteSelectedColor)); } headerHolder.txtFollow.setTag(profileDetailModel); if (profileDetailModel.getUserId() == userId) { headerHolder.lytFollow.setVisibility(View.GONE); headerHolder.view.setVisibility(View.VISIBLE); ((LinearLayout.LayoutParams) headerHolder.linFollowers.getLayoutParams()).gravity = Gravity.CENTER; ((LinearLayout.LayoutParams) headerHolder.linFollowing.getLayoutParams()).gravity = Gravity.CENTER; } else { headerHolder.lytFollow.setVisibility(View.VISIBLE); headerHolder.view.setVisibility(View.GONE); } } else if (holder instanceof PostItemHolder) { PostItemHolder postItemHolder = (PostItemHolder) holder; ProfileDetailModel.PostMediaDetails postMediaDetails = listProfileMedia.get(position - 1); if ((postMediaDetails.getMediaType().equalsIgnoreCase(Constants.POST_MEDIA_TYPE.VIDEO.ordinal() + ""))) { postItemHolder.imgVideo.setVisibility(View.VISIBLE); } else { postItemHolder.imgVideo.setVisibility(View.GONE); } LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) postItemHolder.relPostItem.getLayoutParams(); int height = screenWH[0] / 4; height = height - context.getResources().getDimensionPixelSize(R.dimen.dp2); params.height = height; params.width = height; Log.e("PARAM", "Height" + params.height); Log.e("PARAM", "Width" + params.width); postItemHolder.relPostItem.setLayoutParams(params); /*if (Utils.validateString(postMediaDetails.getThumbUrl())) { Glide.with(context) .load(postMediaDetails.getThumbUrl()) .placeholder(R.mipmap.ic_default_spot_detail) .error(R.mipmap.ic_default_spot_detail) .into(postItemHolder.imgGridImage); }*/ Glide.with(context) .load(postMediaDetails.getThumbUrl()) .placeholder(R.mipmap.spot_default_img) .error(R.mipmap.spot_default_img) .into(postItemHolder.imgGridImage); postItemHolder.lytPost.setTag(postMediaDetails); } else if (holder instanceof FooterHolder) { FooterHolder footerHolder = (FooterHolder) holder;// if(removeLoadmore){// ((FooterHolder)holder).rlLoadMore.setVisibility(View.GONE);// }else{// ((FooterHolder)holder).rlLoadMore.setVisibility(View.VISIBLE);// } } } @Override public int getItemViewType(int position) { if (position == 0) { return Constants.TYPE_HEADER; } else if (position >= listProfileMedia.size() + 1) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > listProfileMedia.size()) { return listProfileMedia.size() + 2; } else { return listProfileMedia.size() + 1; } } public class PostItemHolder extends RecyclerView.ViewHolder { private ImageView imgGridImage, imgVideo; private LinearLayout lytPost; RelativeLayout relPostItem; public PostItemHolder(View itemView) { super(itemView); imgVideo = (ImageView) itemView.findViewById(R.id.imgVideo); imgGridImage = (ImageView) itemView.findViewById(R.id.imgGridImage); lytPost = (LinearLayout) itemView.findViewById(R.id.lytPost); relPostItem = (RelativeLayout) itemView.findViewById(R.id.relPostItem); } } class HeaderHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView txtUserName, txtFollowers, txtFollowing, txtFollow; public ImageView imgPlaceHolder, imgProfileBig; ShapedImageView imgProfile; private View view; private LinearLayout lytFollow, linFollowing, linFollowers; public HeaderHolder(View itemView) { super(itemView); imgProfileBig = (ImageView) itemView.findViewById(R.id.imgProfileBig); imgProfile = (ShapedImageView) itemView.findViewById(R.id.imgProfile); txtUserName = (TextView) itemView.findViewById(R.id.txtUserName); txtFollowers = (TextView) itemView.findViewById(R.id.txtFollowers); txtFollowing = (TextView) itemView.findViewById(R.id.txtFollowing); imgPlaceHolder = (ImageView) itemView.findViewById(R.id.imgPlaceHolder); txtFollow = (TextView) itemView.findViewById(R.id.txtFollow); view = (View) itemView.findViewById(R.id.view); lytFollow = (LinearLayout) itemView.findViewById(R.id.lytFollow); linFollowing = (LinearLayout) itemView.findViewById(R.id.linFollowing); linFollowers = (LinearLayout) itemView.findViewById(R.id.linFollowers); } @Override public void onClick(View v) { } } class FooterHolder extends RecyclerView.ViewHolder { LinearLayout rlLoadMore; public FooterHolder(View itemView) { super(itemView); rlLoadMore = (LinearLayout) itemView.findViewById(R.id.load_more_rl); } } }13)SearchPagerAdapter.java ============================package com.eppico.adapter; import android.content.Context;import android.support.v4.app.Fragment;import android.support.v4.app.FragmentManager;import android.support.v4.app.FragmentPagerAdapter;import android.support.v4.content.ContextCompat;import android.view.LayoutInflater;import android.view.View;import android.widget.ImageView;import android.widget.TextView; import com.eppico.R;import com.eppico.fragments.SearchSpotFragment;import com.eppico.fragments.SearchUserFragment; public class SearchPagerAdapter extends FragmentPagerAdapter { Context context; String tabNames[]; SearchSpotFragment searchSpotFragment; SearchUserFragment searchUserFragment; public SearchPagerAdapter(Context context, FragmentManager fm) { super(fm); this.context=context; tabNames=context.getResources().getStringArray(R.array.searchTabNames); } @Override public Fragment getItem(int position) { switch (position) { case 0: if(searchSpotFragment==null) searchSpotFragment=new SearchSpotFragment(); return searchSpotFragment; case 1: default: if(searchUserFragment==null) searchUserFragment= new SearchUserFragment(); return searchUserFragment; } } @Override public int getCount() { return tabNames.length; } @Override public CharSequence getPageTitle(int position) { return tabNames[position]; } public View getTabView(int position) { // Set custom laytout to tab View v = LayoutInflater.from(context).inflate(R.layout.tab_header_layout, null); TextView txtTabTitle = (TextView) v.findViewById(R.id.txtTabTitle); View dividerTab = v.findViewById(R.id.dividerTab); txtTabTitle.setText(tabNames[position]); /**Here set transperent color of divider to hide divider, because when divider is gone then repple effect not work proper*/ if(position==0) dividerTab.setBackgroundColor(ContextCompat.getColor(context,R.color.tabDividerColor)); else dividerTab.setBackgroundColor(ContextCompat.getColor(context,android.R.color.transparent)); return v; } }14)SearchSpotAdapter.java==============================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.FollowingListModel;import com.eppico.models.SearchSpotModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class SearchSpotAdapter extends RecyclerView.Adapter<SearchSpotAdapter.CustomViewHolder> { private Context mContext; private ArrayList<SearchSpotModel.SpotList> listSearchedSpot; int totalCount = 0; public SearchSpotAdapter(Context mContext, ArrayList<SearchSpotModel.SpotList> listSearchedSpot, int totalCount) { this.listSearchedSpot = listSearchedSpot; this.mContext = mContext; this.totalCount = totalCount; } public void setListItems(ArrayList<SearchSpotModel.SpotList> listSearchSpot) { this.listSearchedSpot = listSearchSpot; notifyDataSetChanged(); } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; CustomViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_search_spot, parent, false); viewHolder = new CustomViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.load_more_layout, parent, false); viewHolder = new CustomViewHolder(view); break; } return viewHolder; } @Override public void onBindViewHolder(final CustomViewHolder holder, int position) { // final InviteSpotListModel mInviteSpotListModel = alstInviteSpot.get(position); if (getItemViewType(position) == Constants.TYPE_ITEM) { SearchSpotModel.SpotList searchedSpot= listSearchedSpot.get(position); // Set Tag holder.linSearchSpotMain.setTag(searchedSpot); holder.txtSpotName.setText(searchedSpot.getSpotName()); holder.txtUserName.setText(mContext.getResources().getString(R.string.by)+" "+searchedSpot.getFirstName() + " " +searchedSpot.getLastName()); holder.txtDate.setText(Utils.getInstance().getFormattedDate(mContext,searchedSpot.getCreateOn())); if (Utils.validateString(searchedSpot.getSpotImage())) { Glide.with(mContext) .load(searchedSpot.getSpotImage()) .placeholder(R.mipmap.spot_default_img) .error(R.mipmap.spot_default_img) .into(holder.imgSpot); } else holder.imgSpot.setImageResource(R.mipmap.ic_default_spot_detail); } } @Override public int getItemCount() { // return alstInviteSpot.size(); if (totalCount > listSearchedSpot.size()) return listSearchedSpot.size() + 1; else return listSearchedSpot.size(); } public class CustomViewHolder extends RecyclerView.ViewHolder { public TextView txtSpotName, txtUserName, txtDate; private ImageView imgSpot; private LinearLayout linSearchSpotMain; public CustomViewHolder(View itemView) { super(itemView); linSearchSpotMain = (LinearLayout) itemView.findViewById(R.id.linSearchSpotMain); txtSpotName = (TextView) itemView.findViewById(R.id.txtSpotName); txtUserName = (TextView) itemView.findViewById(R.id.txtUserName); txtDate = (TextView) itemView.findViewById(R.id.txtDate); imgSpot = (ImageView) itemView.findViewById(R.id.imgSpot); } } class FooterHolder extends RecyclerView.ViewHolder { LinearLayout rlLoadMore; public FooterHolder(View itemView) { super(itemView); rlLoadMore = (LinearLayout) itemView.findViewById(R.id.load_more_rl); } } @Override public int getItemViewType(int position) { /*if (!isAllRecordsLoaded && position == alstInviteSpot.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; }*/ if ((totalCount) > position && position == listSearchedSpot.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } }15)SearchUserListAdapter.java==============================package com.eppico.adapter; import android.content.Context;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView; import com.bumptech.glide.Glide;import com.eppico.R;import com.eppico.models.FollowersListModel;import com.eppico.models.SearchUserListModel;import com.eppico.utility.Constants;import com.eppico.utility.Utils;import com.eppico.widgets.ShapedImageView; import java.util.ArrayList; /** * Created by manisha on 14/12/16. */ public class SearchUserListAdapter extends RecyclerView.Adapter<SearchUserListAdapter.CustomViewHolder> { private Context context; private ArrayList<SearchUserListModel.User> listSearchedUsers; int totalCount = 0; int loggedInUserId; public SearchUserListAdapter(Context context, int loggedInUserId, ArrayList<SearchUserListModel.User> listSearchedUsers, int totalCount) { this.context = context; this.loggedInUserId=loggedInUserId; this.totalCount = totalCount; this.listSearchedUsers = listSearchedUsers; } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = null; CustomViewHolder viewHolder = null; switch (viewType) { case Constants.TYPE_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_followers, parent, false); viewHolder = new CustomViewHolder(view); break; case Constants.TYPE_FOOTER: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.load_more_layout, parent, false); viewHolder = new CustomViewHolder(view); break; } return viewHolder; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { if (getItemViewType(position) == Constants.TYPE_ITEM) { SearchUserListModel.User user = listSearchedUsers.get(position); user.setPosition(position); //Set Tag Model holder.txtFollow.setTag(user); /**Note: Set Tag with id otherwise glide will gives error*/ holder.imgUser.setTag(R.string.tagId,user); holder.txtUserName.setTag(R.string.tagId,user); if(Utils.validateString(user.getUserProfile())) { Glide.with(context).load(user.getUserProfile()) .placeholder(R.mipmap.ic_default_user_list) .error(R.mipmap.ic_default_user_list) .into(holder.imgUser); } else holder.imgUser.setImageResource(R.mipmap.ic_default_user_list); holder.txtUserName.setText(user.getFirstName() +" "+ user.getLastName()); if(Utils.validateString(user.getCityID())){ holder.txtLocationName.setVisibility(View.VISIBLE); holder.txtLocationName.setText(user.getCityID()); } else holder.txtLocationName.setVisibility(View.GONE); // Set Follow Button if(user.getUserIsFollowing()==Constants.FOLLOW_STATUS.FOLLOW.ordinal()) { holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_selected); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteSelectedColor)); holder.txtFollow.setText(context.getString(R.string.btnFollowing)); } else { holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtFollow.setText(context.getString(R.string.btnFollow)); } //Hide Follow Button if user is logged in user if(user.getUserId() == loggedInUserId) holder.txtFollow.setVisibility(View.GONE); else holder.txtFollow.setVisibility(View.VISIBLE); /* holder.txtFollow.setBackgroundResource(R.drawable.btn_invite_normal); holder.txtFollow.setTextColor(ContextCompat.getColor(context, R.color.btnInviteNormalColor)); holder.txtFollow.setText(context.getString(R.string.btnFollow));*/ } } @Override public int getItemViewType(int position) { if ((totalCount - 1) > position && position == listSearchedUsers.size()) { return Constants.TYPE_FOOTER; } else { return Constants.TYPE_ITEM; } } @Override public int getItemCount() { if (totalCount > listSearchedUsers.size()) return listSearchedUsers.size() + 1; else return listSearchedUsers.size(); // return 25; } public void setListItems(ArrayList<SearchUserListModel.User> listSearchedUsers) { this.listSearchedUsers = listSearchedUsers; notifyDataSetChanged(); } public class CustomViewHolder extends RecyclerView.ViewHolder { TextView txtUserName, txtLocationName, txtFollow; ShapedImageView imgUser; public CustomViewHolder(View itemView) { super(itemView); imgUser = (ShapedImageView) itemView.findViewById(R.id.imgUser); txtUserName = (TextView) itemView.findViewById(R.id.txtUserName); txtLocationName = (TextView) itemView.findViewById(R.id.txtLocationName); txtFollow = (TextView) itemView.findViewById(R.id.txtFollow); } } }16)SlidingMenuAdapter.java=============================package com.eppico.adapter; import android.content.Context;import android.content.res.TypedArray;import android.support.v4.content.ContextCompat;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.TextView;import com.eppico.R;import com.eppico.models.SlidingMenuModel; /** * Created by Maitrey on 12/21/2015. */public class SlidingMenuAdapter extends RecyclerView.Adapter<SlidingMenuAdapter.ViewHolder> { private TypedArray arrayIcons,arrayIconsSelected; private String arrayItems[]; private int selectedPosition; private Context mContext; public SlidingMenuAdapter(Context context,String arrayItems[],TypedArray arrayImages,int selectedPosition) { // context.getTheme().resolveAttribute(R.attr.selectableItemBackground, mTypedValue, true); this.mContext = context; this.arrayItems = arrayItems; this.arrayIcons = arrayImages; this.selectedPosition=selectedPosition; this.arrayIconsSelected=context.getResources().obtainTypedArray(R.array.menu_icons_selected); } public void setItemSelected(int pos) { selectedPosition = pos; notifyDataSetChanged(); } public static class ViewHolder extends RecyclerView.ViewHolder { public SlidingMenuModel mBoundString; ImageView imgMenuIcon; TextView txtMenuItem; View dividerMenu; public ViewHolder(View view) { super(view); txtMenuItem = (TextView) view.findViewById(R.id.txtMenuItem); imgMenuIcon = (ImageView) view.findViewById(R.id.imgMenuIcon); dividerMenu = view.findViewById(R.id.dividerMenu); } @Override public String toString() { return super.toString() + " '" + txtMenuItem.getText(); } } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.menu_list_item, parent, false); //view.setBackgroundResource(mBackground); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder holder, int position) { holder.txtMenuItem.setText(arrayItems[position]); if(position == selectedPosition) { holder.txtMenuItem.setTextColor(ContextCompat.getColor(mContext,R.color.menu_selected_color)); holder.imgMenuIcon.setImageResource(arrayIconsSelected.getResourceId(position, -1)); } else { holder.txtMenuItem.setTextColor(ContextCompat.getColor(mContext,R.color.white)); holder.imgMenuIcon.setImageResource(arrayIcons.getResourceId(position, -1)); } if(position!=arrayItems.length-1) holder.dividerMenu.setVisibility(View.VISIBLE); else holder.dividerMenu.setVisibility(View.GONE); } @Override public int getItemCount() { return arrayItems.length; } public void setSelection(int pos) { selectedPosition = pos; } public void clearSelections() { notifyDataSetChanged(); } }17)SpotDetailAdapter.java=============================package com.eppico.adapter; import android.content.Context;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView; import com.eppico.R; import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date; /** * Created by manisha on 14/12/16. */ public class SpotDetailAdapter extends RecyclerView.Adapter<SpotDetailAdapter.CustomViewHolder> { // private ArrayList<ItemData> itemData;// private OnItemClickListener onItemClickListener; private Context mContext;// private ArrayList<InviteSpotListModel> alstInviteSpot;// private int visibleThreshold = 1;// private int lastVisibleItem, totalItemCount;// public boolean loading;// private OnLoadMoreListener onLoadMoreListener;// public OnItemClickListener getOnItemClickListener() {// return onItemClickListener;// }//// public void setOnItemClickListener(OnItemClickListener onItemClickListener) {// this.onItemClickListener = onItemClickListener;// } @Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.profile_grid_item, parent, false); CustomViewHolder viewHolder = new CustomViewHolder(view); return viewHolder; } public SpotDetailAdapter(Context mContext) { // this.alstInviteSpot = alstInviteSpot; this.mContext = mContext; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { // final InviteSpotListModel mInviteSpotListModel = alstInviteSpot.get(position);// holder.txtItem.setText(alstInviteSpot.get(position).getSpotName());// holder.txtSpotDisc.setText(alstInviteSpot.get(position).getSpotDetailDesc()); String strFormattedDate = "",strName=""; } @Override public int getItemCount() { return 10; } public class CustomViewHolder extends RecyclerView.ViewHolder { private ImageView imgGridImage,imgVideo; public CustomViewHolder(View itemView) { super(itemView); imgVideo = (ImageView)itemView.findViewById(R.id.imgVideo); imgGridImage = (ImageView)itemView.findViewById(R.id.imgGridImage); } } // public interface OnItemClickListener {//// void onItemClick(ItemData item);// }// public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {// this.onLoadMoreListener = onLoadMoreListener;// } public interface OnLoadMoreListener { void onLoadMore(); } public String getFormattedDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int day = cal.get(Calendar.DATE); switch (day % 10) { case 1: return new SimpleDateFormat("d MMMM, yyyy").format(date); case 2: return new SimpleDateFormat("d MMMM, yyyy").format(date); case 3: return new SimpleDateFormat("d MMMM, yyyy").format(date); default: return new SimpleDateFormat("d MMMM, yyyy").format(date); } } }
No comments:
Post a Comment