Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- edit layout for AttendanceListFragment.java and
AttendanceViewHolder.java
- set image for ViewHolderItem by picasso library from drawable
  • Loading branch information
eurosecom committed Jan 20, 2017
1 parent 4a1f7c3 commit ee7dcbf
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 33 deletions.
6 changes: 2 additions & 4 deletions app/src/main/java/com/eusecom/attendance/AbsenceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ protected void onCreate(Bundle savedInstanceState) {
private final Fragment[] mFragments = new Fragment[] {
new MyAbsenceFragment(),
new MyAttendanceFragment(),
new AbsTypesFragment(),
new LiveFragment(),
new AbsTypesFragment()
};
private final String[] mFragmentNames = new String[] {
"Absences",
"Attendances",
"AbsTypes",
"Live"
"AbsTypes"
};
@Override
public Fragment getItem(int position) {
Expand Down
66 changes: 54 additions & 12 deletions app/src/main/java/com/eusecom/attendance/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.eusecom.attendance;

import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
Expand All @@ -28,6 +29,7 @@
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
Expand Down Expand Up @@ -191,12 +193,32 @@ public void onClick(View v) {
String usatwx = SettingsActivity.getUsAtw(MainActivity.this);
if( usatwx.equals("0")) {

final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String icox = SettingsActivity.getUsIco(MainActivity.this);
Long tsLong = System.currentTimeMillis() / 1000;
String ts = tsLong.toString();

writeAttendance(icox, userId, "0", "1","Incoming work", ts, ts, "0", "0", "0", "0", ts);
new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.incoming))
.setMessage(getString(R.string.qincoming))
.setPositiveButton(R.string.textyes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {

final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String icox = SettingsActivity.getUsIco(MainActivity.this);
Long tsLong = System.currentTimeMillis() / 1000;
String ts = tsLong.toString();

writeAttendance(icox, userId, "0", "1","Incoming work", ts, ts, "0", "0", "0", "0", ts);

}
})
.setNegativeButton(R.string.textno,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// ignore, just dismiss

}
})
.show();

}else{
Toast.makeText(MainActivity.this, "You are at work now.",
Expand All @@ -223,12 +245,32 @@ public void onClick(View v) {
String usatwx = SettingsActivity.getUsAtw(MainActivity.this);
if( usatwx.equals("1")) {

final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String icox = SettingsActivity.getUsIco(MainActivity.this);
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();

writeAttendance(icox,userId,"0","2","Leaving work",ts,ts,"0","0","0","0", ts );
new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.leaving))
.setMessage(getString(R.string.qleaving))
.setPositiveButton(R.string.textyes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {

final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String icox = SettingsActivity.getUsIco(MainActivity.this);
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();

writeAttendance(icox,userId,"0","2","Leaving work",ts,ts,"0","0","0","0", ts );

}
})
.setNegativeButton(R.string.textno,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// ignore, just dismiss

}
})
.show();

}else{
Toast.makeText(MainActivity.this, "You are out of work now.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eusecom.attendance.viewholder;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
import android.view.MenuInflater;
Expand All @@ -10,6 +11,7 @@
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;
Expand All @@ -18,6 +20,7 @@
public class AbsenceViewHolder extends RecyclerView.ViewHolder {

public TextView absence_name;
public ImageView absence_photo;
public ImageView starView;
public TextView numStarsView;
public TextView datefrom;
Expand All @@ -27,17 +30,20 @@ public class AbsenceViewHolder extends RecyclerView.ViewHolder {
FirebaseUser user;
private FirebaseAuth mAuth;
String usemail = "";
Context mContext;

public AbsenceViewHolder(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();
Expand All @@ -50,6 +56,18 @@ public AbsenceViewHolder(View itemView) {
public void bindToAbsence(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("801")) {
Picasso.with(mContext).load(R.drawable.abs801).resize(120, 120).into(absence_photo);
}
numStarsView.setText("0");

//convert unix epoch timestamp (seconds) to milliseconds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.eusecom.attendance.viewholder;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
import android.view.MenuInflater;
Expand All @@ -10,6 +12,7 @@
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;
Expand All @@ -18,26 +21,24 @@
public class AttendanceViewHolder 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 AttendanceViewHolder(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();
Expand All @@ -48,18 +49,14 @@ public AttendanceViewHolder(View itemView) {

public void bindToAttendance(com.eusecom.attendance.models.Attendance attendance, View.OnClickListener starClickListener) {
absence_name.setText(attendance.dmxa + " " + attendance.dmna);
if( attendance.dmxa.equals("1")) {
Picasso.with(mContext).load(R.drawable.intowork).resize(120, 120).into(absence_photo);
}
if( attendance.dmxa.equals("2")) {
Picasso.with(mContext).load(R.drawable.outsidework).resize(120, 120).into(absence_photo);
}
numStarsView.setText("0");

//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;
datm.setText(usemail + " " + getDateTime(timestampm ));

Expand Down
Binary file added app/src/main/res/drawable/abs506.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/abs510.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/abs518.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/abs520.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/abs801.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions app/src/main/res/layout/include_attendancevalues_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>


<TextView
android:id="@+id/datmdesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:text="@string/postedby" />

<TextView
android:id="@+id/datm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/datmdesc"
android:layout_below="@+id/datefromdesc"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
/>


</RelativeLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_attendance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

</LinearLayout>

<include layout="@layout/include_absencevalues_layout"
<include layout="@layout/include_attendancevalues_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@

<string name="incoming">Incoming work</string>
<string name="leaving">Leaving work</string>
<string name="qincoming">Do you want to income to work ?</string>
<string name="qleaving">Do you want to leave work ?</string>
<string name="login">Login</string>
<string name="logout">Logout</string>
<string name="interruption">Interruption</string>
Expand All @@ -159,5 +161,8 @@
<string name="datm">posted</string>
<string name="postedby">posted by</string>

<string name="textyes">Yes</string>
<string name="textno">No</string>


</resources>

0 comments on commit ee7dcbf

Please sign in to comment.