-
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 - activity, layout and fragment to approve absences
- Loading branch information
Showing
11 changed files
with
701 additions
and
3 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
164 changes: 164 additions & 0 deletions
164
app/src/main/java/com/eusecom/attendance/ApproveActivity.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,164 @@ | ||
/* | ||
* 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.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
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.support.v7.widget.Toolbar; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
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; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
|
||
|
||
public class ApproveActivity extends BaseDatabaseActivity implements LiveFragment.OnFragmentInteractionListener { | ||
|
||
private FragmentPagerAdapter mPagerAdapter; | ||
private ViewPager mViewPager; | ||
private FloatingActionButton fab; | ||
int whatispage=0; | ||
Toolbar mActionBarToolbar; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_approve); | ||
//showProgressDialog(); | ||
|
||
mActionBarToolbar = (Toolbar) findViewById(R.id.tool_bar); | ||
setSupportActionBar(mActionBarToolbar); | ||
getSupportActionBar().setTitle(getString(R.string.action_approve)); | ||
|
||
// Create the adapter that will return a fragment for each section | ||
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { | ||
private final Fragment[] mFragments = new Fragment[] { | ||
new MyAbsenceFragment(), | ||
new AbsTypesFragment() | ||
}; | ||
private final String[] mFragmentNames = new String[] { | ||
getString(R.string.approve), | ||
getString(R.string.abstypes) | ||
}; | ||
@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); | ||
|
||
|
||
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { | ||
public void onPageScrollStateChanged(int state) {} | ||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {} | ||
|
||
public void onPageSelected(int position) { | ||
// Check if this is the page you want. | ||
if(position == 0){ | ||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_post); | ||
fab.setVisibility(View.VISIBLE); | ||
whatispage=0; | ||
} | ||
if(position == 1){ | ||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_post); | ||
fab.setVisibility(View.GONE); | ||
whatispage=1; | ||
} | ||
|
||
} | ||
}); | ||
|
||
|
||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); | ||
tabLayout.setupWithViewPager(mViewPager); | ||
|
||
// Button launches NewPostActivity | ||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_post); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
|
||
Intent i=null; | ||
if( whatispage == 0 ) { | ||
i = new Intent(ApproveActivity.this, NewAbsenceActivity.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); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFragmentInteraction (Uri uri){ | ||
//only for LiveFragment | ||
} | ||
|
||
} |
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
Oops, something went wrong.