aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
blob: 45c20daae5545c99e4e2eed16bd9d7ee6ac2cf5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.example.wiimmterfaceandroid;



import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentContainerView;
import androidx.room.Room;

import android.os.Bundle;

import com.example.wiimmterfaceandroid.database.AppDatabase;
import com.example.wiimmterfaceandroid.model.FriendCode;

import java.util.List;

public class MainActivity extends AppCompatActivity {
    List<FriendCode> recentFCList;

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

        setContentView(R.layout.activity_main);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.friend_code_input_fragment, new WatchCodeFragment(database, recentFCList), null)
                    .setReorderingAllowed(true)
                    .commit();
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.room_fragment, new RecentCodesFragment(database, recentFCList), null)
                    .setReorderingAllowed(true)
                    .commit();
        }


    }
}