diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-05-04 20:18:17 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-05-04 20:18:17 -0600 |
commit | 50dfc57c61a01dc20a42129246b458bf90e26154 (patch) | |
tree | 4c9e38c1fb4130b566b9393b317b7c7c104a51ba /app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java | |
parent | 99643e5be84af7e8da217ed48597ceb3c9d3bc85 (diff) | |
download | wiimmfi-watcher-50dfc57c61a01dc20a42129246b458bf90e26154.tar wiimmfi-watcher-50dfc57c61a01dc20a42129246b458bf90e26154.tar.gz wiimmfi-watcher-50dfc57c61a01dc20a42129246b458bf90e26154.tar.bz2 |
getting closer to implementing the recycler view
Diffstat (limited to 'app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java')
-rw-r--r-- | app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java | 21 |
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(); } |