Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- dats = date of cerating from ServerValue.TIMESTAMP in model
Attendance.java
- dats from model to ViewHolder for "posted by"
  • Loading branch information
eurosecom committed Jan 21, 2017
1 parent 8fe5381 commit 8f6aaa7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
34 changes: 17 additions & 17 deletions app/src/main/java/com/eusecom/attendance/models/Abstype.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Abstype {

public String idm;
public String iname;
private HashMap<String, Object> datm;
private HashMap<String, Object> dats;


public Abstype() {
Expand All @@ -24,9 +24,9 @@ public Abstype(String idm, String iname) {
this.idm = idm;
this.iname = iname;

HashMap<String, Object> datmObj = new HashMap<String, Object>();
datmObj.put("date", ServerValue.TIMESTAMP);
this.datm = datmObj;
HashMap<String, Object> datsObj = new HashMap<String, Object>();
datsObj.put("date", ServerValue.TIMESTAMP);
this.dats = datsObj;

}

Expand All @@ -36,37 +36,37 @@ public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("idm", idm);
result.put("iname", iname);
result.put("datm", datm);
result.put("dats", dats);

return result;
}
// [END AbsType_to_map]


public HashMap<String, Object> getDatm() {
public HashMap<String, Object> getDats() {
//If there is a dateCreated object already, then return that
if (datm!= null) {
return datm;
if (dats!= null) {
return dats;
}
//Otherwise make a new object set to ServerValue.TIMESTAMP
HashMap<String, Object> datmObj = new HashMap<String, Object>();
datmObj.put("date", ServerValue.TIMESTAMP);
return datmObj;
HashMap<String, Object> datsObj = new HashMap<String, Object>();
datsObj.put("date", ServerValue.TIMESTAMP);
return datsObj;
}


@Exclude
public long getDatmLong() {
return (long)datm.get("date");
public long getDatsLong() {
return (long)dats.get("date");
}

@Exclude
public String getDatmString() {
public String getDatsString() {

long datml = (long)datm.get("date");
String datms = datml + "";
long datsl = (long)dats.get("date");
String datss = datsl + "";

return datms;
return datss;
}

}
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/eusecom/attendance/models/Attendance.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.firebase.database.Exclude;
import com.google.firebase.database.IgnoreExtraProperties;
import com.google.firebase.database.ServerValue;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -22,6 +23,7 @@ public class Attendance {
public String longi;
public String lati;
public String datm;
private HashMap<String, Object> dats;

public Attendance() {
// Default constructor required for calls to DataSnapshot.getValue(User.class)
Expand All @@ -43,6 +45,10 @@ public Attendance(String usico, String usid, String ume, String dmxa, String dmn
this.longi = longi;
this.lati = lati;
this.datm = datm;

HashMap<String, Object> datsObj = new HashMap<String, Object>();
datsObj.put("date", ServerValue.TIMESTAMP);
this.dats = datsObj;
}


Expand All @@ -68,10 +74,37 @@ public Map<String, Object> toMap() {
result.put("longi", longi);
result.put("lati", lati);
result.put("datm", datm);
result.put("dats", dats);

return result;
}
// [END post_to_map]

public HashMap<String, Object> getDats() {
//If there is a dateCreated object already, then return that
if (dats!= null) {
return dats;
}
//Otherwise make a new object set to ServerValue.TIMESTAMP
HashMap<String, Object> datsObj = new HashMap<String, Object>();
datsObj.put("date", ServerValue.TIMESTAMP);
return datsObj;
}


@Exclude
public long getDatsLong() {
return (long)dats.get("date");
}

@Exclude
public String getDatsString() {

long datsl = (long)dats.get("date");
String datss = datsl + "";

return datss;
}

}
// [END blog_user_class]
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public AbsTypesViewHolder(View itemView) {

public void bindToAbsence(com.eusecom.attendance.models.Abstype abstypes, View.OnClickListener starClickListener) {

long timestampm = abstypes.getDatmLong();
long timestampm = abstypes.getDatsLong();

absence_name.setText(abstypes.idm + " " + abstypes.iname + " " + getDateTime(timestampm ));
if( abstypes.idm.equals("506")) {
Expand All @@ -61,7 +61,7 @@ public void bindToAbsence(com.eusecom.attendance.models.Abstype abstypes, View.O
private String getDateTime(long timeStamp){

try{
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy hh:mm");
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
Date netDate = (new Date(timeStamp));
return sdf.format(netDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public void bindToAbsence(com.eusecom.attendance.models.Attendance attendance, V
long timestamp = Long.parseLong(attendance.daod) * 1000L;
hodxb.setText(attendance.hodxb);

long timestampm = Long.parseLong(attendance.datm) * 1000L;
//long timestampm = Long.parseLong(attendance.datm) * 1000L;
long timestampm = attendance.getDatsLong();
datm.setText(usemail + " " + getDateTime(timestampm ));

starView.setOnClickListener(starClickListener);
Expand All @@ -107,7 +108,7 @@ private String getDate(long timeStamp){
private String getDateTime(long timeStamp){

try{
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy hh:mm");
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
Date netDate = (new Date(timeStamp));
return sdf.format(netDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void bindToAttendance(com.eusecom.attendance.models.Attendance attendance
}
numStarsView.setText("0");

long timestampm = Long.parseLong(attendance.datm) * 1000L;
//long timestampm = Long.parseLong(attendance.datm) * 1000L;
long timestampm = attendance.getDatsLong();
datm.setText(usemail + " " + getDateTime(timestampm ));

starView.setOnClickListener(starClickListener);
Expand All @@ -79,7 +80,7 @@ private String getDate(long timeStamp){
private String getDateTime(long timeStamp){

try{
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy hh:mm");
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
Date netDate = (new Date(timeStamp));
return sdf.format(netDate);
}
Expand Down

0 comments on commit 8f6aaa7

Please sign in to comment.