Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- scroll layout for MainActivity and NewAbsenceActivity.java
  • Loading branch information
eurosecom committed Dec 27, 2016
1 parent 992f53c commit 1229f9a
Show file tree
Hide file tree
Showing 25 changed files with 1,166 additions and 369 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<activity android:name=".PostDetailActivity"/>
<activity android:name=".SettingsActivity"/>
<activity android:name=".MapActivity"/>
<activity android:name=".SplashScreen"/>

<service android:name=".MyDownloadService" android:exported="false"/>
<!-- Android N SDK has new restrictions around sharing file:// URIs https://developer.android.com/reference/android/support/v4/content/FileProvider.html#ProviderDefinition -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.widget.AdapterView;

import com.eusecom.attendance.fragment.AbsTypesFragment;
import com.eusecom.attendance.fragment.ContactFragment;
import com.eusecom.attendance.fragment.LiveFragment;
import com.eusecom.attendance.fragment.MyAbsenceFragment;
import com.eusecom.attendance.fragment.MyAttendanceFragment;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/eusecom/attendance/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void onCreate(Bundle savedInstanceState) {
mText3 = (TextView) findViewById(R.id.text3);

navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
String TITLES[] = {navMenuTitles[0],navMenuTitles[1],navMenuTitles[2],navMenuTitles[3]};
String TITLES[] = {navMenuTitles[0],navMenuTitles[1],navMenuTitles[2],navMenuTitles[3],navMenuTitles[4]};

mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); // Assigning the RecyclerView Object to the xml View

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/eusecom/attendance/MyAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ public void onClick(View v, int pos, boolean isLongClick) {

break;

case 5:

// View v at position pos is clicked.
Intent i5 = new Intent(mContext, SplashScreen.class);
v.getContext().startActivity(i5);

break;

default:
break;
Expand Down
94 changes: 94 additions & 0 deletions app/src/main/java/com/eusecom/attendance/SplashScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.eusecom.attendance;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.util.Log;
import com.eusecom.attendance.models.User;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;



public class SplashScreen extends Activity {

private final static String TAG = SplashScreen.class.getSimpleName();
private static final String USER_IS_LOGIN = "UserIsLogin";
private static final String UI_ID_FIREBASE = "UiIdFirebase";
// Duration of wait
private final int SPLASH_DISPLAY_LENGTH = 2000;

private FirebaseAuth.AuthStateListener mAuthListener;
private FirebaseAuth mAuth;

private User mUser;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);
mAuth = FirebaseAuth.getInstance();
//mUser = User.getInstance();

// New Handler to start the Menu-Activity and close this Splash-Screen after some seconds.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Log.d("run at handler", "Start splash screen");
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
//mUser.setLoginState(true);
//mUser.setUiIdFirebase(user.getUid());

Log.d(TAG, "User state : signed_in:" + user.getUid());
//StartMainActivity();
//SplashScreen.this.finish();
} else {
// User is signed out
//mUser.setLoginState(false);

Log.d(TAG, "User state : signed_out");
//StartSignInActivity();
//SplashScreen.this.finish();
}
}
};
mAuth.addAuthStateListener(mAuthListener);
}
}, SPLASH_DISPLAY_LENGTH);

//mAuth.addAuthStateListener(mAuthListener);
}

public void StartMainActivity() {
Log.d(TAG, "User is in , Start MainActivity");
//Intent i = new Intent(SplashScreen.this,MainActivity.class);
//startActivity(i);
}

public void StartSignInActivity() {
Log.d(TAG, "User need to sign in , Start SignInActivity");
//Intent i = new Intent(SplashScreen.this,SignInActivity.class);
//startActivity(i);
}

@Override
protected void onStart() {
super.onStart();
//mAuth.addAuthStateListener(mAuthListener);
}

@Override
protected void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void onCancelled(DatabaseError firebaseError) {



mAdapter = new FirebaseRecyclerAdapter<Absence, AbsTypesViewHolder>(Absence.class, R.layout.item_absence,
mAdapter = new FirebaseRecyclerAdapter<Absence, AbsTypesViewHolder>(Absence.class, R.layout.item_abstypes,
AbsTypesViewHolder.class, absencesQuery) {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* http://stackoverflow.com/questions/41224253/firebase-database-with-recycler-view-in-fragment
*/

package com.eusecom.attendance.fragment;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.eusecom.attendance.R;
import com.eusecom.attendance.models.Contact;

import java.util.ArrayList;

public class AdapterContact extends RecyclerView.Adapter<AdapterContact.MyViewHolder> {
Context context;
ArrayList<Contact> contacts;



public static class MyViewHolder extends RecyclerView.ViewHolder {
public CardView mCardView1;
public TextView mTextView1,mTextView2,mTextView3,mTextView4;
public MyViewHolder(View v) {
super(v);
//mCardView1 = (CardView) v.findViewById(R.layout.item_contact);
mTextView1 = (TextView) v.findViewById(R.id.contact_profession);
mTextView2 = (TextView) v.findViewById(R.id.contact_name);
//mTextView3 = (TextView) v.findViewById(R.id.contact_address);
//mTextView4 = (TextView) v.findViewById(R.id.contact_number);
}
}
public AdapterContact(Context context,ArrayList<Contact> contacts) {
this.contacts = contacts;
this.context = context;

}
@Override
public AdapterContact.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_contact, parent, false);
// set the view's size, margins, paddings and layout parameters
return new MyViewHolder(v);
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {

holder.mTextView1.setText(contacts.get(position).getContactProfession());
holder.mTextView2.setText(contacts.get(position).getContactName());
//holder.mTextView3.setText(contacts.get(position).getContactAddress());
//holder.mTextView4.setText(contacts.get(position).getContactNumber());
int x = contacts.get(position).getContactStatus();

}
@Override
public int getItemCount() {
return this.contacts.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void onCancelled(DatabaseError firebaseError) {



mAdapter = new FirebaseRecyclerAdapter<Attendance, AttendanceViewHolder>(Attendance.class, R.layout.item_absence,
mAdapter = new FirebaseRecyclerAdapter<Attendance, AttendanceViewHolder>(Attendance.class, R.layout.item_attendance,
AttendanceViewHolder.class, absencesQuery) {

@Override
Expand Down
Loading

0 comments on commit 1229f9a

Please sign in to comment.