From 9f7623869a1b4d6af30816288bc78ba806d67a19 Mon Sep 17 00:00:00 2001 From: peet Date: Mon, 7 Dec 2020 17:06:32 +0100 Subject: [PATCH] expanded Database integration --- app/src/main/AndroidManifest.xml | 1 - .../git/wdg/vokabel_trainer/MainActivity.java | 22 ++++++ .../git/wdg/vokabel_trainer/VocabModel.java | 47 +++++++++++++ .../notifications/NotificationsFragment.java | 7 -- .../res/layout/fragment_notifications.xml | 70 ++++++++++--------- 5 files changed, 105 insertions(+), 42 deletions(-) create mode 100644 app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/VocabModel.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 94f7e67..ebeeae7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,5 +19,4 @@ - \ No newline at end of file diff --git a/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/MainActivity.java b/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/MainActivity.java index de89575..ddec99b 100644 --- a/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/MainActivity.java +++ b/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/MainActivity.java @@ -1,18 +1,28 @@ package org.ddnss.sfs.git.wdg.vokabel_trainer; +import android.annotation.SuppressLint; import android.os.Bundle; +import android.view.View; +import android.widget.*; import androidx.appcompat.app.AppCompatActivity; import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; +import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.bottomnavigation.BottomNavigationView; public class MainActivity extends AppCompatActivity { + //references + Button btn_add; + EditText text_german_input; + EditText text_english_input; + RecyclerView dbview; + @SuppressLint("WrongViewCast") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -26,5 +36,17 @@ public class MainActivity extends AppCompatActivity { NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); NavigationUI.setupWithNavController(navView, navController); + + btn_add = (Button) findViewById(R.id.btn_add); + text_german_input = (EditText) findViewById(R.id.text_german_input); + text_english_input = (EditText) findViewById(R.id.text_english_input); + dbview = (RecyclerView) findViewById(R.id.dbview); + } + + public void add_entry(){ + //VocabModel vocabmodel = new VocabModel(-1, text_german_input.getText().toString(), text_english_input.getText().toString()); + VocabModel vocabmodel = new VocabModel(1, "hello", "hallo"); + + Toast.makeText(MainActivity.this, vocabmodel.toString(), Toast.LENGTH_LONG).show(); } } \ No newline at end of file diff --git a/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/VocabModel.java b/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/VocabModel.java new file mode 100644 index 0000000..7a8f051 --- /dev/null +++ b/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/VocabModel.java @@ -0,0 +1,47 @@ +package org.ddnss.sfs.git.wdg.vokabel_trainer; + +public class VocabModel { + + private int id; + private String deutsch; + private String english; + + public VocabModel(int id, String deutsch, String english) { + this.id = id; + this.deutsch = deutsch; + this.english = english; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDeutsch() { + return deutsch; + } + + public void setDeutsch(String deutsch) { + this.deutsch = deutsch; + } + + public String getEnglish() { + return english; + } + + public void setEnglish(String english) { + this.english = english; + } + + @Override + public String toString() { + return "VocabModel{" + + "id=" + id + + ", deutsch='" + deutsch + '\'' + + ", english='" + english + '\'' + + '}'; + } +} diff --git a/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/ui/notifications/NotificationsFragment.java b/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/ui/notifications/NotificationsFragment.java index a2a694d..c69b7e3 100644 --- a/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/ui/notifications/NotificationsFragment.java +++ b/app/src/main/java/org/ddnss/sfs/git/wdg/vokabel_trainer/ui/notifications/NotificationsFragment.java @@ -23,13 +23,6 @@ public class NotificationsFragment extends Fragment { notificationsViewModel = ViewModelProviders.of(this).get(NotificationsViewModel.class); View root = inflater.inflate(R.layout.fragment_notifications, container, false); - final TextView textView = root.findViewById(R.id.text_englsich_input); - notificationsViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { - @Override - public void onChanged(@Nullable String s) { - textView.setText(s); - } - }); return root; } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notifications.xml b/app/src/main/res/layout/fragment_notifications.xml index efbbd54..fe76475 100644 --- a/app/src/main/res/layout/fragment_notifications.xml +++ b/app/src/main/res/layout/fragment_notifications.xml @@ -6,45 +6,47 @@ android:layout_height="match_parent" tools:context=".ui.notifications.NotificationsFragment"> - - - -