Fragment für Stundenplan hinzugefügt

This commit is contained in:
Joshua
2018-07-03 14:26:08 +02:00
parent 72a0f31775
commit 73d0b155e1
5 changed files with 141 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ dependencies {
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:support-v4:27.1.1'
implementation 'org.jetbrains:annotations-java5:15.0' implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.github.alamkanak:android-week-view:1.2.6'
implementation 'com.ms-square:expandableTextView:0.1.4' implementation 'com.ms-square:expandableTextView:0.1.4'
implementation files('libs/jericho-html-3.4.jar') implementation files('libs/jericho-html-3.4.jar')
} }

View File

@@ -19,6 +19,7 @@ import android.view.MenuItem;
import java.util.Iterator; import java.util.Iterator;
import de.sebse.fuplanner.fragments.LoginFragment; import de.sebse.fuplanner.fragments.LoginFragment;
import de.sebse.fuplanner.fragments.ScheduleFragment;
import de.sebse.fuplanner.fragments.moddetails.ModDetailFragment; import de.sebse.fuplanner.fragments.moddetails.ModDetailFragment;
import de.sebse.fuplanner.fragments.ModulesFragment; import de.sebse.fuplanner.fragments.ModulesFragment;
import de.sebse.fuplanner.fragments.StartupFragment; import de.sebse.fuplanner.fragments.StartupFragment;
@@ -32,7 +33,8 @@ public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, implements NavigationView.OnNavigationItemSelectedListener,
LoginFragment.OnLoginFragmentInteractionListener, LoginFragment.OnLoginFragmentInteractionListener,
ModulesFragment.OnModulesFragmentInteractionListener, ModulesFragment.OnModulesFragmentInteractionListener,
ModDetailFragment.OnModuleDetailFragmentInteractionListener { ModDetailFragment.OnModuleDetailFragmentInteractionListener,
ScheduleFragment.OnFragmentInteractionListener {
FragmentManager fragmentManager; FragmentManager fragmentManager;
private GoogleAuth mGoogleAuth; private GoogleAuth mGoogleAuth;
@@ -127,14 +129,18 @@ public class MainActivity extends AppCompatActivity
// Handle navigation view item clicks here. // Handle navigation view item clicks here.
int id = item.getItemId(); int id = item.getItemId();
FragmentTransaction fragmentTransaction;
switch (id) { switch (id) {
case R.id.nav_modules: case R.id.nav_modules:
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragcontainer, ModulesFragment.newInstance()); fragmentTransaction.replace(R.id.fragcontainer, ModulesFragment.newInstance());
fragmentTransaction.commit(); fragmentTransaction.commit();
break; break;
case R.id.nav_schedule: case R.id.nav_schedule:
log.d("Stundenplan");
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragcontainer, ScheduleFragment.newInstance("bla","bla"));
fragmentTransaction.commit();
break; break;
case R.id.nav_share: case R.id.nav_share:
@@ -264,4 +270,9 @@ public class MainActivity extends AppCompatActivity
public void onModuleDetailFragmentInteraction(Uri uri) { public void onModuleDetailFragmentInteraction(Uri uri) {
log.d("Cooles ding"); log.d("Cooles ding");
} }
@Override
public void onFragmentInteraction(Uri uri) {
}
} }

View File

@@ -0,0 +1,109 @@
package de.sebse.fuplanner.fragments;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import de.sebse.fuplanner.R;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link ScheduleFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link ScheduleFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ScheduleFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public ScheduleFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment ScheduleFragment.
*/
// TODO: Rename and change types and number of parameters
public static ScheduleFragment newInstance(String param1, String param2) {
ScheduleFragment fragment = new ScheduleFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_schedule, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<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=".fragments.ScheduleFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>

View File

@@ -31,4 +31,7 @@
<string name="date_scale">%1$s - %2$s</string> <string name="date_scale">%1$s - %2$s</string>
<string name="open">Open</string> <string name="open">Open</string>
<string name="close">Close</string> <string name="close">Close</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>