expanded Database integration

This commit is contained in:
peet 2020-12-07 17:06:32 +01:00
parent e18fdfbd99
commit 9f7623869a
5 changed files with 105 additions and 42 deletions

View File

@ -19,5 +19,4 @@
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -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();
}
}

View File

@ -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 + '\'' +
'}';
}
}

View File

@ -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<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
}
});
return root;
}
}

View File

@ -6,45 +6,47 @@
android:layout_height="match_parent"
tools:context=".ui.notifications.NotificationsFragment">
<TextView
android:id="@+id/text_German_input"
android:layout_width="221dp"
android:layout_height="41dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
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"
app:layout_constraintVertical_bias="0.376" />
<TextView
android:id="@+id/text_englsich_input"
android:layout_width="221dp"
android:layout_height="73dp"
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"
app:layout_constraintVertical_bias="0.186" />
<Button
android:id="@+id/addEntry"
android:id="@+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="161dp"
android:layout_marginTop="388dp"
android:onClick="add_entry"
android:text="Einfügen"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/dbview"
android:layout_width="407dp"
android:layout_height="251dp"
android:layout_marginStart="1dp"
android:layout_marginTop="479dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/text_german_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="97dp"
android:layout_marginTop="65dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Deutsch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/text_english_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="84dp"
android:layout_marginTop="167dp"
android:ems="10"
android:inputType="textPersonName"
android:text="English"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>