Skip to content

Commit

Permalink
added switchCompat for ScheduleFragment.java #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmitt-Florian committed Jun 9, 2017
1 parent 7556208 commit 9c92464
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -26,7 +27,8 @@ public class ScheduleFragment extends Fragment {
@SuppressWarnings({"FieldNever", "unused"})
private OnFragmentInteractionListener mListener;
private View rootView;
private TableRow[] rows = new TableRow[15];
private TableRow[] rows;
private boolean editMode;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -39,8 +41,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
rootView = inflater.inflate(R.layout.fragment_schedule, container, false);

initGui();
// ToggleButton editButton = (ToggleButton) view.findViewById(R.id.toggleEditSchedule);
// editButton.setVisibility(View.VISIBLE);
return rootView;

}
Expand Down Expand Up @@ -86,6 +86,10 @@ public interface OnFragmentInteractionListener {
private void initGui() {
rows = getScheduleRowsInArray();
initVisibilityForSchedule();

SwitchCompat editSwitch = (SwitchCompat) getActivity().findViewById(R.id.appbar_switch);
editSwitch.setVisibility(View.VISIBLE);
editMode = editSwitch.isChecked();
}

/**
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/res/layout/app_bar_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/appbar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="schmitt_florian.schoolplanner.activities.MainActivity">
Expand All @@ -26,16 +25,20 @@
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/app_name" />

<Switch
<android.support.v7.widget.SwitchCompat
android:id="@+id/appbar_switch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
android:switchMinWidth="70dp"
android:checked="false"
android:text="@string/string_edit"
android:textAlignment="textEnd"
android:visibility="gone" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textColor="@color/secondary_text"
android:textStyle="bold"
android:visibility="gone"
app:switchMinWidth="70dp" />

</LinearLayout>

Expand Down
18 changes: 12 additions & 6 deletions app/src/main/res/layout/fragment_schedule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,12 @@

<Button
android:id="@+id/button81"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:text="7" />
android:text="10" />

<Button
android:id="@+id/button82"
Expand Down Expand Up @@ -828,11 +829,12 @@

<Button
android:id="@+id/button89"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:text="7" />
android:text="11" />

<Button
android:id="@+id/button90"
Expand Down Expand Up @@ -899,11 +901,12 @@

<Button
android:id="@+id/button97"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:text="7" />
android:text="12" />

<Button
android:id="@+id/button98"
Expand Down Expand Up @@ -970,11 +973,12 @@

<Button
android:id="@+id/button105"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:text="7" />
android:text="13" />

<Button
android:id="@+id/button106"
Expand Down Expand Up @@ -1041,11 +1045,12 @@

<Button
android:id="@+id/button113"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:text="7" />
android:text="14" />

<Button
android:id="@+id/button114"
Expand Down Expand Up @@ -1112,11 +1117,12 @@

<Button
android:id="@+id/button121"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:text="7" />
android:text="15" />

<Button
android:id="@+id/button122"
Expand Down

0 comments on commit 9c92464

Please sign in to comment.