Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. package com.example.disconnect;
  2.  
  3. import android.location.Location;
  4. import android.os.Parcel;
  5. import android.os.Parcelable;
  6. import android.util.Log;
  7.  
  8. import com.google.android.gms.maps.model.LatLng;
  9. import com.google.firebase.firestore.GeoPoint;
  10. import com.google.firebase.firestore.IgnoreExtraProperties;
  11. import com.google.firebase.firestore.ServerTimestamp;
  12.  
  13. import java.util.Date;
  14. @IgnoreExtraProperties
  15. public class User implements Parcelable{
  16.  
  17. private String email;
  18. private String user_id;
  19. private String username;
  20. private boolean active;
  21. private boolean handshakeDetected;
  22. private Date handShakeTime;
  23. private User potentialMatch;
  24. private int connectionCounter;
  25. private GeoPoint geo_point = new GeoPoint(1.0,2.0);
  26. private @ServerTimestamp
  27. Date timestamp;
  28.  
  29.  
  30.  
  31. // private String avatar;
  32.  
  33. public User(boolean active, int connectionCounter , String email, Date handShakeTime, boolean handshakeDetected, User potentialMatch, String user_id, String username, GeoPoint geo_point, Date timestamp) {
  34. this.user_id = user_id;
  35. this.active = active;
  36. this.connectionCounter = connectionCounter;
  37. this.email = email;
  38. this.username = username;
  39. this.handshakeDetected = handshakeDetected;
  40. this.handShakeTime = handShakeTime;
  41. this.potentialMatch = potentialMatch;
  42. this.geo_point = geo_point;
  43. this.timestamp = timestamp;
  44.  
  45. }
  46.  
  47. public User() {
  48.  
  49. }
  50.  
  51. protected User(Parcel in) {
  52. email = in.readString();
  53. user_id = in.readString();
  54. username = in.readString();
  55. active = Boolean.parseBoolean(in.readString());
  56. timestamp = null;
  57.  
  58. // avatar = in.readString();
  59. }
  60.  
  61. public static final Creator<User> CREATOR = new Creator<User>() {
  62. @Override
  63. public User createFromParcel(Parcel in) {
  64. return new User(in);
  65. }
  66.  
  67. @Override
  68. public User[] newArray(int size) {
  69. return new User[size];
  70. }
  71. };
  72. /*
  73. public String getAvatar() {
  74. return avatar;
  75. }
  76. public void setAvatar(String avatar) {
  77. this.avatar = avatar;
  78. }
  79. */
  80. public static Creator<User> getCREATOR() {
  81. return CREATOR;
  82. }
  83.  
  84. public String getEmail() {
  85. return email;
  86. }
  87.  
  88. public void setEmail(String email) {
  89. this.email = email;
  90. }
  91.  
  92. public void setActive(boolean active){
  93. this.active = active;
  94. }
  95.  
  96. public boolean getActive(){
  97. return active;
  98. }
  99.  
  100. public String getUser_id() {
  101. return user_id;
  102. }
  103.  
  104. public void setUser_id(String user_id) {
  105. this.user_id = user_id;
  106. }
  107.  
  108. public String getUsername() {
  109. return username;
  110. }
  111.  
  112. public void setUsername(String username) {
  113. this.username = username;
  114. }
  115.  
  116. @Override
  117. public String toString() {
  118. return "User{" +
  119. "email='" + email + '\'' +
  120. ", user_id='" + user_id + '\'' +
  121. ", username='" + username + '\'' +
  122. " UserLocation{" +
  123. ", geo_point=" + geo_point +
  124. ", timestamp=" + timestamp +
  125. '}';
  126. //", avatar='" + avatar + '\'' +
  127. }
  128.  
  129.  
  130. @Override
  131. public int describeContents() {
  132. return 0;
  133. }
  134.  
  135. @Override
  136. public void writeToParcel(Parcel dest, int flags) {
  137. dest.writeString(email);
  138. dest.writeString(user_id);
  139. dest.writeString(username);
  140. // dest.writeString(avatar);
  141. }
  142.  
  143. public boolean isHandshakeDetected() {
  144. return handshakeDetected;
  145. }
  146.  
  147. public void setHandshakeDetected(boolean handshakeDetected) {
  148. this.handshakeDetected = handshakeDetected;
  149. }
  150.  
  151. public GeoPoint getGeo_point() {
  152. return geo_point;
  153. }
  154.  
  155. public void setGeo_point(GeoPoint geo_point) {
  156. this.geo_point = geo_point;
  157. }
  158.  
  159. public Date getTimestamp() {
  160. return timestamp;
  161. }
  162.  
  163. public void setTimestamp(Date timestamp) {
  164. this.timestamp = timestamp;
  165. }
  166.  
  167. public Date getHandShakeTime() {
  168. return handShakeTime;
  169. }
  170.  
  171. public void setHandShakeTime(Date handShakeTime) {
  172. this.handShakeTime = handShakeTime;
  173. }
  174.  
  175. public User getPotentialMatch() {
  176. return potentialMatch;
  177. }
  178.  
  179. public void setPotentialMatch(User potentialMatch) {
  180. this.potentialMatch = potentialMatch;
  181. }
  182.  
  183. public int getConnectionCounter() {
  184. return connectionCounter;
  185. }
  186.  
  187. public void incConnectionCounter() {
  188. this.connectionCounter++;
  189. }
  190.  
  191. public void setLocation(LatLng latLng){
  192. this.geo_point = new GeoPoint(latLng.latitude, latLng.longitude);
  193. }
  194. public LatLng getLocation(){
  195. return new LatLng(this.geo_point.getLatitude(), this.getGeo_point().getLongitude());
  196. }
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement