Skip to content
Snippets Groups Projects
Commit f4b57936 authored by darshanxyz's avatar darshanxyz
Browse files

Added Hours Fragment

parent bd97221e
Branches
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ dependencies {
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
}
......
package com.darshanbshah.odsystem;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class HoursFragment extends Fragment {
public HoursFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_hours, container, false);
}
}
......@@ -6,6 +6,7 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.google.firebase.auth.FirebaseAuth;
......@@ -18,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
private TextView welcomeText;
Calendar calendar = Calendar.getInstance();
TextView from, to;
FrameLayout frameLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -27,6 +29,7 @@ public class MainActivity extends AppCompatActivity {
welcomeText.setText("Welcome " + mAuth.getCurrentUser().getEmail());
from = (TextView)findViewById(R.id.fromDateTV);
to = (TextView)findViewById(R.id.toDateTV);
frameLayout = (FrameLayout) findViewById(R.id.hours_frame_layout);
}
public void onClickFromDatePicker(View view) {
......@@ -51,6 +54,22 @@ public class MainActivity extends AppCompatActivity {
}
};
public void onFullDayClick(View view) {
if(frameLayout != null) {
frameLayout.setVisibility(View.INVISIBLE);
}
}
public void onHoursClick(View view) {
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction transaction = manager.beginTransaction();
HoursFragment hoursFragment = new HoursFragment();
frameLayout.setVisibility(View.VISIBLE);
transaction.add(R.id.hours_frame_layout, hoursFragment);
transaction.commit();
}
public void signOut(View view) {
mAuth.signOut();
startActivity(new Intent(this, Login.class));
......
......@@ -123,16 +123,26 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fullDayRadioButton"
android:layout_weight="1" />
android:layout_weight="1"
android:onClick="onFullDayClick" />
<RadioButton
android:text="A few hours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hoursRadioButton"
android:layout_weight="1" />
android:layout_weight="1"
android:onClick="onHoursClick" />
</RadioGroup>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/hours_frame_layout"
android:layout_marginTop="@dimen/activity_vertical_margin">
</FrameLayout>
<Button
android:text="Request OD"
android:layout_width="match_parent"
......
<FrameLayout 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"
tools:context="com.darshanbshah.odsystem.HoursFragment"
android:id="@+id/frame_layout">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour1"
android:layout_weight="1" />
<CheckBox
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour2"
android:layout_weight="1" />
<CheckBox
android:text="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour3"
android:layout_weight="1" />
<CheckBox
android:text="4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour4"
android:layout_weight="1" />
<CheckBox
android:text="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour5"
android:layout_weight="1" />
<CheckBox
android:text="6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour6"
android:layout_weight="1" />
</LinearLayout>
</FrameLayout>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment