Behebung von diversen Fehlern

This commit is contained in:
m_broelemann
2020-12-14 12:11:02 +01:00
parent 1a10d16b7b
commit 3f55ebce81
24 changed files with 253 additions and 135 deletions

View File

@@ -2,13 +2,12 @@ package com.example.aped;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.Menu;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.example.aped.communication.IXML;
import com.example.aped.communication.TestXML;
import com.google.android.material.navigation.NavigationView;
import androidx.annotation.NonNull;
@@ -21,9 +20,10 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
/** was soll angezeigt werden in Navigation.*/
private AppBarConfiguration mAppBarConfiguration;
/** zur Verwendung von xml anstatt der direkten Einbindung.*/
private IXML xml;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -36,13 +36,16 @@ public class MainActivity extends AppCompatActivity {
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_all_IOs, R.id.nav_your_IOs, R.id.nav_slideshow)
R.id.nav_all_IOs, R.id.nav_your_IOs)
.setDrawerLayout(drawer)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavController navController = Navigation.findNavController(this,
R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this,
navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
xml = new TestXML();
}
@Override
@@ -54,29 +57,35 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavController navController = Navigation.findNavController(this,
R.id.nav_host_fragment);
return NavigationUI.navigateUp(navController, mAppBarConfiguration)
|| super.onSupportNavigateUp();
}
/**was sollbeit click auf den jeweiligen itembutton passieren.*/
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
switch (item.getItemId()) {
case R.id.action_settings:
Toast.makeText(this,"Settings",Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Settings",
Toast.LENGTH_SHORT).show();
return true;
case R.id.action_adjust_xml:
Toast.makeText(this,"Adjust .xml",Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Adjust .xml",
Toast.LENGTH_SHORT).show();
return true;
case R.id.action_download_xml:
Toast.makeText(this,"Download .xml",Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Download .xml",
Toast.LENGTH_SHORT).show();
return true;
case R.id.action_upload_xml:
Toast.makeText(this,"Upload .xml",Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Upload .xml",
Toast.LENGTH_SHORT).show();
xml.upload();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
}

View File

@@ -0,0 +1,9 @@
package com.example.aped.communication;
public interface IXML {
/** dowload er XML.*/
int download();
/** upload er XML.*/
int upload();
}

View File

@@ -0,0 +1,14 @@
package com.example.aped.communication;
public class TestXML implements IXML {
/** was soll bei download getan werden.*/
@Override
public int download() {
return 0;
}
/** was soll bei upload getan werden.*/
@Override
public int upload() {
return 0;
}
}

View File

@@ -0,0 +1,4 @@
/**
* package for the communication.
* */
package com.example.aped.communication;

View File

@@ -0,0 +1,5 @@
/**
* Package communication ui and main.
* */
package com.example.aped;

View File

@@ -14,17 +14,19 @@ import androidx.lifecycle.ViewModelProvider;
import com.example.aped.R;
public class All_IOs_Fragment extends Fragment {
public class AllIOsFragment extends Fragment {
private All_IOs_ViewModel allIOsViewModel;
private AllIOsViewModel allIOsViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
allIOsViewModel =
new ViewModelProvider(this).get(All_IOs_ViewModel.class);
View root = inflater.inflate(R.layout.fragment_all_ios, container, false);
new ViewModelProvider(this).get(AllIOsViewModel.class);
View root = inflater.inflate(R.layout.fragment_all_ios, container,
false);
final TextView textView = root.findViewById(R.id.text_all_IOs);
allIOsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
allIOsViewModel.getText().observe(getViewLifecycleOwner(),
new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
@@ -32,4 +34,4 @@ public class All_IOs_Fragment extends Fragment {
});
return root;
}
}
}

View File

@@ -4,16 +4,17 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class All_IOs_ViewModel extends ViewModel {
public class AllIOsViewModel extends ViewModel {
/** .*/
private MutableLiveData<String> mText;
public All_IOs_ViewModel() {
/** Text Ausgabe.*/
public AllIOsViewModel() {
mText = new MutableLiveData<>();
mText.setValue("Anzeige aller Mess & Sollwertvorgaben bestimmt durch die xml");
mText.setValue("Anzeige aller Mess & Sollwertvorgaben bestimmt durch"
+ " die xml");
}
/** Rückgabe des Textes.*/
public LiveData<String> getText() {
return mText;
}
}
}

View File

@@ -0,0 +1,5 @@
/**
* Package for the IO user interface.
* */
package com.example.aped.ui.all_IOs;

View File

@@ -0,0 +1,4 @@
/**
* Package for the user interface.
* */
package com.example.aped.ui;

View File

@@ -1,35 +0,0 @@
package com.example.aped.ui.slideshow;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.example.aped.R;
public class SlideshowFragment extends Fragment {
private SlideshowViewModel slideshowViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
slideshowViewModel =
new ViewModelProvider(this).get(SlideshowViewModel.class);
View root = inflater.inflate(R.layout.fragment_slideshow, container, false);
final TextView textView = root.findViewById(R.id.text_slideshow);
slideshowViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
}
});
return root;
}
}

View File

@@ -1,19 +0,0 @@
package com.example.aped.ui.slideshow;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class SlideshowViewModel extends ViewModel {
private MutableLiveData<String> mText;
public SlideshowViewModel() {
mText = new MutableLiveData<>();
mText.setValue("wird vorraussichtlich nicht benötigt");
}
public LiveData<String> getText() {
return mText;
}
}

View File

@@ -14,17 +14,19 @@ import androidx.lifecycle.ViewModelProvider;
import com.example.aped.R;
public class Your_IOs_Fragment extends Fragment {
public class YourIOsFragment extends Fragment {
private Your_IOs_ViewModel your_IOs_ViewModel;
private YourIOsViewModel yourIOsViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
your_IOs_ViewModel =
new ViewModelProvider(this).get(Your_IOs_ViewModel.class);
View root = inflater.inflate(R.layout.fragment_your_ios, container, false);
yourIOsViewModel =
new ViewModelProvider(this).get(YourIOsViewModel.class);
View root = inflater.inflate(R.layout.fragment_your_ios, container,
false);
final TextView textView = root.findViewById(R.id.text_your_IOs);
your_IOs_ViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
yourIOsViewModel.getText().observe(getViewLifecycleOwner(),
new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
@@ -32,4 +34,4 @@ public class Your_IOs_Fragment extends Fragment {
});
return root;
}
}
}

View File

@@ -4,16 +4,16 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class Your_IOs_ViewModel extends ViewModel {
public class YourIOsViewModel extends ViewModel {
/** .*/
private MutableLiveData<String> mText;
public Your_IOs_ViewModel() {
/** Text Ausgabe.*/
public YourIOsViewModel() {
mText = new MutableLiveData<>();
mText.setValue("Personalisierte Anzeige der Mess- & Sollwerte");
}
public LiveData<String> getText() {
/** Rückgabe des Textes.*/
public final LiveData<String> getText() {
return mText;
}
}
}

View File

@@ -0,0 +1,5 @@
/**
* Package for the IO user interface.
* */
package com.example.aped.ui.your_IOs;

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.all_IOs.All_IOs_Fragment">
tools:context=".ui.all_IOs.AllIOsFragment">
<TextView
android:id="@+id/text_all_IOs"

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.slideshow.SlideshowFragment">
<TextView
android:id="@+id/text_slideshow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.your_IOs.Your_IOs_Fragment">
tools:context=".ui.your_IOs.YourIOsFragment">
<TextView
android:id="@+id/text_your_IOs"

View File

@@ -11,10 +11,6 @@
<item
android:id="@+id/nav_your_IOs"
android:icon="@drawable/ic_menu_gallery"
android:title="@string/menu_all_IOs" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/menu_slideshow" />
android:title="@string/menu_your_IOs" />
</group>
</menu>

View File

@@ -7,19 +7,14 @@
<fragment
android:id="@+id/nav_all_IOs"
android:name="com.example.aped.ui.all_IOs.All_IOs_Fragment"
android:name="com.example.aped.ui.all_IOs.AllIOsFragment"
android:label="@string/menu_all_IOs"
tools:layout="@layout/fragment_all_ios" />
<fragment
android:id="@+id/nav_your_IOs"
android:name="com.example.aped.ui.your_IOs.Your_IOs_Fragment"
android:name="com.example.aped.ui.your_IOs.YourIOsFragment"
android:label="@string/menu_your_IOs"
tools:layout="@layout/fragment_your_ios" />
<fragment
android:id="@+id/nav_slideshow"
android:name="com.example.aped.ui.slideshow.SlideshowFragment"
android:label="@string/menu_slideshow"
tools:layout="@layout/fragment_slideshow" />
</navigation>

View File

@@ -12,5 +12,4 @@
<string name="menu_all_IOs">all IOs</string>
<string name="menu_your_IOs">your IOs</string>
<string name="menu_slideshow">noch zu entfernen</string>
</resources>