package com.ved.musicmapapp.Objects;
import java.io.Serializable;
import java.util.ArrayList;
import com.ved.musicmapapp.utils.Statics;
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2227983388487365438L;
private int ID;
private String fbid, firstName, lastName, fullName, email, birthday, city,
country, address;
private double lat, lon;
private String aboutMe, gender, religion, deviceId;
private long joinDate;
private String gcmRegId;
private int noSong, /* noFollowYou, */percentage;
// private String lastUDArtist;
// private long lastUDTime;
private boolean followed, followMe;
private long startFollow, endFollow;
private ArrayList<Artist> artists;
private ArrayList<Playlist> playlists;
private String distance;
private int typeUpdate, valueTypeUpdate;
private String lastUDString;
private int noLastAdd;
private int totalLike = 0, totalFollowYou = 0, totalYouFollow = 0;
private String userName;
private int artistcount = 0;
private ArrayList<String> allGenres;
private String lastUpdate;
private long lastArtistUpdate;
private byte[] avatar;
public byte[] getAvatar() {
return avatar;
}
public void setAvatar(byte[] avatar) {
this.avatar = avatar;
}
public User() {
}
public String getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}
/**
* @return the totalFollowYou
*/
public int getTotalFollowYou() {
return totalFollowYou;
}
/**
* @param totalFollowYou
* the totalFollowYou to set
*/
public void setTotalFollowYou(int totalFollowYou) {
this.totalFollowYou = totalFollowYou;
}
/**
* @return the totalYouFollow
*/
// public int getTotalYouFollow() {
// return totalYouFollow;
// }
/**
* @param totalYouFollow
* the totalYouFollow to set
*/
public void setTotalYouFollow(int totalYouFollow) {
this.totalYouFollow = totalYouFollow;
}
/**
* @return the totalLike
*/
public int getTotalLike() {
return totalLike;
}
/**
* @param totalLike
* the totalLike to set
*/
public void setTotalLike(int totalLike) {
this.totalLike = totalLike;
}
/**
* @return the noLastAdd
*/
public int getNoLastAdd() {
return noLastAdd;
}
/**
* @param noLastAdd
* the noLastAdd to set
*/
public void setNoLastAdd(int noLastAdd) {
this.noLastAdd = noLastAdd;
}
/**
* @return the valueTypeUpdate
*/
public int getValueTypeUpdate() {
return valueTypeUpdate;
}
/**
* @param valueTypeUpdate
* the valueTypeUpdate to set
*/
public void setValueTypeUpdate(int valueTypeUpdate) {
this.valueTypeUpdate = valueTypeUpdate;
}
/**
* @return the followMe
*/
public boolean isFollowMe() {
return followMe;
}
/**
* @param followMe
* the followMe to set
*/
public void setFollowMe(boolean followMe) {
this.followMe = followMe;
}
/**
* @return the lastUDString
*/
public String getLastUDString() {
return lastUDString;
}
/**
* @param lastUDString
* the lastUDString to set
*/
public void setLastUDString(String lastUDString) {
this.lastUDString = lastUDString;
}
/**
* @return the typeUpdate
*/
public int getTypeUpdate() {
return typeUpdate;
}
/**
* @param typeUpdate
* the typeUpdate to set
*/
public void setTypeUpdate(int typeUpdate) {
this.typeUpdate = typeUpdate;
}
/**
* @return the percentage
*/
public int getPercentage() {
return percentage;
}
/**
* @param percentage
* the percentage to set
*/
public void setPercentage(int percentage) {
this.percentage = percentage;
}
/**
* @return the followed
*/
public boolean isFollowed() {
return followed;
}
/**
* @param followed
* the followed to set
*/
public void setFollowed(boolean followed) {
this.followed = followed;
}
/**
* @return the startFollow
*/
public long getStartFollow() {
return startFollow;
}
/**
* @param startFollow
* the startFollow to set
*/
public void setStartFollow(long startFollow) {
this.startFollow = startFollow;
}
/**
* @return the endFollow
*/
public long getEndFollow() {
return endFollow;
}
/**
* @param endFollow
* the endFollow to set
*/
public void setEndFollow(long endFollow) {
this.endFollow = endFollow;
}
// /**
// * @return the lastUDArtist
// */
// public String getLastUDArtist() {
// return lastUDArtist;
// }
//
//
//
// /**
// * @param lastUDArtist the lastUDArtist to set
// */
// public void setLastUDArtist(String lastUDArtist) {
// this.lastUDArtist = lastUDArtist;
// }
//
//
//
// /**
// * @return the lastUDTime
// */
// public long getLastUDTime() {
// return lastUDTime;
// }
//
//
//
// /**
// * @param lastUDTime the lastUDTime to set
// */
// public void setLastUDTime(long lastUDTime) {
// this.lastUDTime = lastUDTime;
// }
/**
* @return the noSong
*/
public int getNoSong() {
return noSong;
}
/**
* @param noSong
* the noSong to set
*/
public void setNoSong(int noSong) {
this.noSong = noSong;
}
public ArrayList<Playlist> getPlaylists() {
return playlists;
}
public void setPlaylists(ArrayList<Playlist> playlists) {
this.playlists = playlists;
}
/**
* @return the artists
*/
public ArrayList<Artist> getArtists() {
return artists;
}
/**
* @param artists
* the artists to set
*/
public void setArtists(ArrayList<Artist> artists) {
this.artists = artists;
}
/**
* @return the id
*/
public int getID() {
return ID;
}
/**
* @param id
* the id to set
*/
public void setID(int ID) {
this.ID = ID;
}
/**
* @return the fbid
*/
public String getFbid() {
return fbid;
}
/**
* @param fbid
* the fbid to set
*/
public void setFbid(String fbid) {
this.fbid = fbid;
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName
* the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName
* the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the fullName
*/
public String getFullName() {
// if(fullName.equals(""))
// return userName;
// else
return fullName;
}
/**
* @param fullName
* the fullName to set
*/
public void setFullName(String fullName) {
this.fullName = fullName;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email
* the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return the birthday
*/
public String getBirthday() {
return birthday;
}
/**
* @param birthday
* the birthday to set
*/
public void setBirthday(String birthday) {
this.birthday = birthday;
}
/**
* @return the city
*/
public String getCity() {
return city;
}
/**
* @param city
* the city to set
*/
public void setCity(String city) {
this.city = city;
}
/**
* @return the country
*/
public String getCountry() {
return country;
}
/**
* @param country
* the country to set
*/
public void setCountry(String country) {
this.country = country;
}
/**
* @return the address
*/
public String getAddress() {
return address;
}
/**
* @param address
* the address to set
*/
public void setAddress(String address) {
this.address = address;
}
/**
* @return the lat
*/
public double getLat() {
return lat;
}
/**
* @param lat
* the lat to set
*/
public void setLat(double lat) {
this.lat = lat;
}
/**
* @return the lon
*/
public double getLon() {
return lon;
}
/**
* @param lon
* the lon to set
*/
public void setLon(double lon) {
this.lon = lon;
}
/**
* @return the aboutMe
*/
public String getAboutMe() {
return aboutMe;
}
/**
* @param aboutMe
* the aboutMe to set
*/
public void setAboutMe(String aboutMe) {
this.aboutMe = aboutMe;
}
/**
* @return the gender
*/
public String getGender() {
return gender;
}
/**
* @param gender
* the gender to set
*/
public void setGender(String gender) {
this.gender = gender;
}
/**
* @return the religion
*/
public String getReligion() {
return religion;
}
/**
* @param religion
* the religion to set
*/
public void setReligion(String religion) {
this.religion = religion;
}
/**
* @return the deviceId
*/
public String getDeviceId() {
return deviceId;
}
/**
* @param deviceId
* the deviceId to set
*/
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
/**
* @return the joinDate
*/
public long getJoinDate() {
return joinDate;
}
/**
* @param joinDate
* the joinDate to set
*/
public void setJoinDate(long joinDate) {
this.joinDate = joinDate;
}
/**
* @return the gcmRegId
*/
public String getGcmRegId() {
return gcmRegId;
}
/**
* @param gcmRegId
* the gcmRegId to set
*/
public void setGcmRegId(String gcmRegId) {
this.gcmRegId = gcmRegId;
}
public String getDistance() {
return distance;
}
public void setDistance(String distance) {
this.distance = distance;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
/*public int getArtistcount() {
if (getArtists() == null)
return artistcount;
else if(getArtists().size() == 0){
return artistcount;
}else
return getArtists().size();
}
*/
public int getArtistcount() {
if (getArtists() == null)
return artistcount;
else if(getArtists().size() == 0){
return artistcount;
}else if(getArtists().size() != artistcount){
return artistcount;
}else{
return getArtists().size();
}
}
public void setArtistcount(int artistcount) {
this.artistcount = artistcount;
}
public long getLastArtistUpdateTime() {
ArrayList<Artist> tempArtists = getArtists();
if (tempArtists != null && tempArtists.size() > 0) {
return (tempArtists.get(0).getLatUpdate());
} else
return lastArtistUpdate;
}
public void setLastArtistUpdateTime(long lastArtistUpdate) {
this.lastArtistUpdate = lastArtistUpdate;
}
public void compareTo(User newUser) {
this.fbid = newUser.getFbid();
this.firstName = newUser.getFirstName();
this.lastName = newUser.getLastName();
this.fullName = newUser.getFullName();
this.email = newUser.getEmail();
this.birthday = newUser.getBirthday();
this.city = newUser.getCity();
this.country = newUser.getCountry();
this.address = newUser.getAddress();
this.lat = newUser.getLat();
this.lon = newUser.getLon();
this.aboutMe = newUser.getAboutMe();
this.gender = newUser.getGender();
this.religion = newUser.getReligion();
this.deviceId = newUser.getDeviceId();
this.joinDate = newUser.getJoinDate();
this.gcmRegId = newUser.getGcmRegId();
this.noSong = newUser.getNoSong();
this.percentage = newUser.getPercentage();
this.followed = newUser.isFollowed();
this.followMe = newUser.isFollowMe();
this.startFollow = newUser.getStartFollow();
this.endFollow = newUser.getEndFollow();
this.distance = newUser.getDistance();
this.typeUpdate = newUser.getTypeUpdate();
this.valueTypeUpdate = newUser.getValueTypeUpdate();
this.lastUDString = newUser.getLastUDString();
this.noLastAdd = newUser.getNoLastAdd();
this.totalLike = newUser.getTotalLike();
this.totalFollowYou = newUser.getTotalFollowYou();
this.userName = newUser.getUserName();
this.artistcount = newUser.getArtistcount();
this.lastUpdate = newUser.getLastUpdate();
this.lastArtistUpdate = newUser.getLastArtistUpdateTime();
this.avatar = newUser.getAvatar();
if (newUser.getArtists() != null
&& (newUser.getArtists().size() > 0 || newUser.getArtists()
.size() == 0 && newUser.getNoSong() == 0)) {
this.artists = newUser.getArtists();
}
this.playlists = getUpdatedPlaylist(newUser);
this.allGenres = newUser.getGenre();
// this.genres = getUpdatedGenres(newUser);
}
// private ArrayList<Genre> getUpdatedGenres(User newUser) {
// ArrayList<Genre> currentGenres = this.genres;
// ArrayList<Genre> newGenre = newUser.getGenre();
//
// if(currentGenres == null) {
// return newUser.getGenre();
// } else if(newGenre != null && newGenre.size() != currentGenres.size()) {
// return newGenre;
// } else if(newGenre != null && newGenre.size() == currentGenres.size()) {
//// for(int i = 0 ; i < newGenre.size(); i++) {
//// Genre genreFromNew = newGenre.get(i);
//// Genre genreFromCurrent = currentGenres.get(i);
//// if(playlistFromNew.getNumberOfTracks() != playlistFromCurrent.getNumberOfTracks()) {
//// playlistFromCurrent.setNumberOfTracks(playlistFromNew.getNumberOfTracks());
//// playlistFromCurrent.setArtists(null);
//// }
//// else if(playlistFromNew.getNumberOfTracks() != Statics.getSelectedPlaylistSongCount(playlistFromCurrent)) {
//// playlistFromCurrent.setNumberOfTracks(playlistFromNew.getNumberOfTracks());
//// playlistFromCurrent.setArtists(null);
//// }
//// }
// }
// return currentGenres;
//
// }
private ArrayList<Playlist> getUpdatedPlaylist(User newUser) {
ArrayList<Playlist> currentPlaylists = this.playlists;
ArrayList<Playlist> newPlaylists = newUser.getPlaylists();
if(currentPlaylists == null) {
return newUser.getPlaylists();
} else if(newPlaylists != null && newPlaylists.size() != currentPlaylists.size()) {
return newPlaylists;
} else if(newPlaylists != null && newPlaylists.size() == currentPlaylists.size()) {
for(int i = 0 ; i < newPlaylists.size(); i++) {
Playlist playlistFromNew = newPlaylists.get(i);
Playlist playlistFromCurrent = currentPlaylists.get(i);
if(playlistFromNew.getNumberOfTracks() != playlistFromCurrent.getNumberOfTracks()) {
playlistFromCurrent.setNumberOfTracks(playlistFromNew.getNumberOfTracks());
playlistFromCurrent.setArtists(null);
}
else if(playlistFromNew.getNumberOfTracks() != Statics.getSelectedPlaylistSongCount(playlistFromCurrent)) {
playlistFromCurrent.setNumberOfTracks(playlistFromNew.getNumberOfTracks());
playlistFromCurrent.setArtists(null);
}
}
}
return currentPlaylists;
}
public static User copyObject(User oldUser, User newUser) {
if (newUser.getArtists() != null
&& (newUser.getArtists().size() > 0 || newUser.getArtists()
.size() == 0 && newUser.getNoSong() == 0)) {
//this.artists = newUser.getArtists();
}else{
newUser.setArtists(oldUser.getArtists());
}
return newUser;
}
public void removeUserPlaylistById(int playlistId) {
for(Playlist playlist: playlists) {
if(playlist.getID() == playlistId) {
playlists.remove(playlist);
return;
}
}
}
public void setGenre(ArrayList<String> genre) {
if(this.allGenres != null)
this.allGenres.clear();
this.allGenres = genre;
}
public ArrayList<String> getGenre() {
return allGenres;
}
}