-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12 - new ApproveViewHolder.java - Approve / Refuse dialog TODO - do to approve / to refuse absence
- Loading branch information
Showing
6 changed files
with
194 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
app/src/main/java/com/eusecom/attendance/viewholder/ApproveViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.eusecom.attendance.viewholder; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.ContextMenu; | ||
import android.view.MenuInflater; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.eusecom.attendance.R; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.auth.FirebaseUser; | ||
import com.squareup.picasso.Picasso; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class ApproveViewHolder extends RecyclerView.ViewHolder { | ||
|
||
public TextView absence_name; | ||
public ImageView absence_photo; | ||
public ImageView starView; | ||
public TextView numStarsView; | ||
public TextView datefrom; | ||
public TextView dateto; | ||
public TextView hodxb; | ||
public TextView datm; | ||
FirebaseUser user; | ||
private FirebaseAuth mAuth; | ||
String usemail = ""; | ||
Context mContext; | ||
|
||
public ApproveViewHolder(View itemView) { | ||
super(itemView); | ||
|
||
absence_name = (TextView) itemView.findViewById(R.id.absence_name); | ||
absence_photo = (ImageView) itemView.findViewById(R.id.absence_photo); | ||
starView = (ImageView) itemView.findViewById(R.id.star); | ||
numStarsView = (TextView) itemView.findViewById(R.id.post_num_stars); | ||
datefrom = (TextView) itemView.findViewById(R.id.datefrom); | ||
dateto = (TextView) itemView.findViewById(R.id.dateto); | ||
hodxb = (TextView) itemView.findViewById(R.id.hodxb); | ||
datm = (TextView) itemView.findViewById(R.id.datm); | ||
mContext = itemView.getContext(); | ||
|
||
mAuth = FirebaseAuth.getInstance(); | ||
user = mAuth.getCurrentUser(); | ||
if (user != null) { | ||
usemail = user.getEmail(); | ||
} | ||
|
||
} | ||
|
||
public void bindToApprove(com.eusecom.attendance.models.Attendance attendance, View.OnClickListener starClickListener) { | ||
|
||
absence_name.setText(attendance.dmxa + " " + attendance.dmna); | ||
if( attendance.dmxa.equals("506")) { | ||
Picasso.with(mContext).load(R.drawable.abs506).resize(120, 120).into(absence_photo); | ||
} | ||
if( attendance.dmxa.equals("510")) { | ||
Picasso.with(mContext).load(R.drawable.abs510).resize(120, 120).into(absence_photo); | ||
} | ||
if( attendance.dmxa.equals("518")) { | ||
Picasso.with(mContext).load(R.drawable.abs518).resize(120, 120).into(absence_photo); | ||
} | ||
if( attendance.dmxa.equals("520")) { | ||
Picasso.with(mContext).load(R.drawable.abs520).resize(120, 120).into(absence_photo); | ||
} | ||
if( attendance.dmxa.equals("801")) { | ||
Picasso.with(mContext).load(R.drawable.abs801).resize(120, 120).into(absence_photo); | ||
} | ||
numStarsView.setText(attendance.aprv); | ||
if( attendance.aprv.equals("1")) { | ||
Picasso.with(mContext).load(R.drawable.ic_check_circle_black_24dp).resize(120, 120).into(starView); | ||
} | ||
|
||
//convert unix epoch timestamp (seconds) to milliseconds | ||
long timestampod = Long.parseLong(attendance.daod) * 1000L; | ||
datefrom.setText(getDate(timestampod )); | ||
|
||
long timestampdo = Long.parseLong(attendance.dado) * 1000L; | ||
dateto.setText(getDate(timestampdo )); | ||
|
||
long timestamp = Long.parseLong(attendance.daod) * 1000L; | ||
hodxb.setText(attendance.hodxb); | ||
|
||
//long timestampm = Long.parseLong(attendance.datm) * 1000L; | ||
long timestampm = attendance.getDatsLong(); | ||
datm.setText(usemail + " " + getDateTime(timestampm )); | ||
|
||
starView.setOnClickListener(starClickListener); | ||
|
||
|
||
} | ||
|
||
|
||
private String getDate(long timeStamp){ | ||
|
||
try{ | ||
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); | ||
Date netDate = (new Date(timeStamp)); | ||
return sdf.format(netDate); | ||
} | ||
catch(Exception ex){ | ||
return "xx"; | ||
} | ||
} | ||
|
||
private String getDateTime(long timeStamp){ | ||
|
||
try{ | ||
DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm"); | ||
Date netDate = (new Date(timeStamp)); | ||
return sdf.format(netDate); | ||
} | ||
catch(Exception ex){ | ||
return "xx"; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" > | ||
|
||
<ImageView | ||
android:id="@+id/image" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginRight="5dp" /> | ||
|
||
<TextView | ||
android:id="@+id/text" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:textColor="#000" | ||
android:layout_toRightOf="@+id/image"/>/> | ||
|
||
<LinearLayout | ||
style="?android:attr/buttonBarStyle" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:baselineAligned="false" | ||
android:layout_below="@+id/image" | ||
android:orientation="horizontal"> | ||
|
||
<Button | ||
android:id="@+id/buttonApprove" | ||
android:layout_width="150dp" | ||
android:layout_height="wrap_content" | ||
android:text="@string/approve" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginRight="5dp" | ||
/> | ||
|
||
<Button | ||
android:id="@+id/buttonRefuse" | ||
android:layout_width="150dp" | ||
android:layout_height="wrap_content" | ||
android:text="@string/refuse" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginRight="5dp" | ||
/> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters