aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java')
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java b/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
index 45c20da..71b25fa 100644
--- a/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
@@ -3,6 +3,7 @@ package com.example.wiimmterfaceandroid;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.databinding.ObservableArrayList;
import androidx.fragment.app.FragmentContainerView;
import androidx.room.Room;
@@ -14,23 +15,33 @@ import com.example.wiimmterfaceandroid.model.FriendCode;
import java.util.List;
public class MainActivity extends AppCompatActivity {
- List<FriendCode> recentFCList;
+ ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>();
+ AppDatabase database;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentContainerView fcInput = findViewById(R.id.room_fragment);
- AppDatabase database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build();
- recentFCList = database.getFriendCodeDao().getAll();
+ this.database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build();
+ new Thread(() -> {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ recentFCList.addAll(database.getFriendCodeDao().getAll());
+ }).start();
+
+
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
- .replace(R.id.friend_code_input_fragment, new WatchCodeFragment(database, recentFCList), null)
+ .replace(R.id.friend_code_input_fragment, new WatchCodeFragment(), null)
.setReorderingAllowed(true)
.commit();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RecentCodesFragment(database, recentFCList), null)
+ .replace(R.id.room_fragment, new RecentCodesFragment(), null)
.setReorderingAllowed(true)
.commit();
}