Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- layouts, model, activity, fragment, for Absence
  • Loading branch information
eurosecom committed Dec 7, 2016
1 parent fb8520c commit 0eeb4c2
Show file tree
Hide file tree
Showing 17 changed files with 1,273 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:windowSoftInputMode="stateAlwaysHidden" />

<activity android:name=".DatabaseActivity"/>
<activity android:name=".IntsActivity" android:label="@string/interruption"/>
<activity android:name=".AbsenceActivity" android:label="@string/absence"/>
<activity android:name=".NewPostActivity"/>
<activity android:name=".SignInActivity"/>
<activity android:name=".PostDetailActivity"/>
Expand Down
128 changes: 128 additions & 0 deletions app/src/main/java/com/eusecom/attendance/AbsenceActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.eusecom.attendance;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.eusecom.attendance.fragment.EmptyFragment;
import com.eusecom.attendance.fragment.MyAbsenceFragment;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;


public class AbsenceActivity extends BaseDatabaseActivity {

private FragmentPagerAdapter mPagerAdapter;
private ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ints);
//showProgressDialog();

// Create the adapter that will return a fragment for each section
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
private final Fragment[] mFragments = new Fragment[] {
new MyAbsenceFragment(),
new EmptyFragment(),
new EmptyFragment(),
};
private final String[] mFragmentNames = new String[] {
"Absences",
"Next",
"Next"
};
@Override
public Fragment getItem(int position) {
return mFragments[position];
}
@Override
public int getCount() {
return mFragments.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentNames[position];
}
};
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);

// Button launches NewPostActivity
findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent i = new Intent(AbsenceActivity.this, NewPostActivity.class);
Bundle extras = new Bundle();
extras.putString("editx", "0");
extras.putString("keyx", "0");

i.putExtras(extras);
startActivity(i);

}
});
//hideProgressDialog();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_database, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_logout:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(this, EmailPasswordActivity.class));
finish();
return true;

case R.id.action_settings:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(this, SettingsActivity.class));
finish();
return true;

default:
return super.onOptionsItemSelected(item);
}
}





}
125 changes: 125 additions & 0 deletions app/src/main/java/com/eusecom/attendance/IntsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.eusecom.attendance;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.eusecom.attendance.fragment.MyIntsFragment;
import com.google.firebase.auth.FirebaseAuth;


public class IntsActivity extends BaseDatabaseActivity {

private static final String TAG = "MainActivity";

private FragmentPagerAdapter mPagerAdapter;
private ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ints);
//showProgressDialog();

// Create the adapter that will return a fragment for each section
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
private final Fragment[] mFragments = new Fragment[] {
new MyIntsFragment(),
new MyIntsFragment(),
new MyIntsFragment(),
};
private final String[] mFragmentNames = new String[] {
"Interruptions",
"Next",
"Next"
};
@Override
public Fragment getItem(int position) {
return mFragments[position];
}
@Override
public int getCount() {
return mFragments.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentNames[position];
}
};
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);

// Button launches NewPostActivity
findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent i = new Intent(IntsActivity.this, NewPostActivity.class);
Bundle extras = new Bundle();
extras.putString("editx", "0");
extras.putString("keyx", "0");

i.putExtras(extras);
startActivity(i);

}
});
//hideProgressDialog();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_database, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_logout:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(this, EmailPasswordActivity.class));
finish();
return true;

case R.id.action_settings:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(this, SettingsActivity.class));
finish();
return true;

default:
return super.onOptionsItemSelected(item);
}
}





}
2 changes: 1 addition & 1 deletion app/src/main/java/com/eusecom/attendance/MyAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void onClick(View v, int pos, boolean isLongClick) {
case 2:

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

break;
Expand Down
22 changes: 3 additions & 19 deletions app/src/main/java/com/eusecom/attendance/NewPostActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,8 @@ public void onStop() {

private void submitPost() {

DatabaseReference connectedRef = FirebaseDatabase.getInstance().getReference(".info/connected");
connectedRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
boolean connected = snapshot.getValue(Boolean.class);
if (connected) {
System.out.println("connected");
showProgressDialog();
} else {
System.out.println("not connected");
hideProgressDialog();
Toast.makeText(NewPostActivity.this, "Not connected", Toast.LENGTH_SHORT).show();
}
}
showProgressDialog();

@Override
public void onCancelled(DatabaseError error) {
System.err.println("Listener was cancelled");
}
});
final String title = mTitleField.getText().toString();
final String body = mBodyField.getText().toString();

Expand Down Expand Up @@ -181,6 +163,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {

}

hideProgressDialog();
// Finish this Activity, back to the stream
finish();
// [END_EXCLUDE]
Expand All @@ -189,6 +172,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
@Override
public void onCancelled(DatabaseError databaseError) {
Log.w(TAG, "getUser:onCancelled", databaseError.toException());
hideProgressDialog();
}
});
// [END single_value_read]
Expand Down
Loading

0 comments on commit 0eeb4c2

Please sign in to comment.