2021-04-30 09:57:06 -06:00
|
|
|
package com.example.wiimmterfaceandroid;
|
|
|
|
|
2021-04-30 13:40:14 -06:00
|
|
|
|
2021-04-30 09:57:06 -06:00
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2021-05-04 20:18:17 -06:00
|
|
|
import androidx.databinding.ObservableArrayList;
|
2021-05-02 22:38:15 -06:00
|
|
|
import androidx.fragment.app.FragmentContainerView;
|
|
|
|
import androidx.room.Room;
|
2021-04-30 09:57:06 -06:00
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
2021-05-02 22:38:15 -06:00
|
|
|
import com.example.wiimmterfaceandroid.database.AppDatabase;
|
2021-05-04 17:59:55 -06:00
|
|
|
import com.example.wiimmterfaceandroid.model.FriendCode;
|
|
|
|
|
|
|
|
import java.util.List;
|
2021-05-02 22:38:15 -06:00
|
|
|
|
2021-04-30 09:57:06 -06:00
|
|
|
public class MainActivity extends AppCompatActivity {
|
2021-05-04 20:18:17 -06:00
|
|
|
ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>();
|
|
|
|
AppDatabase database;
|
2021-04-30 09:57:06 -06:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2021-05-04 17:59:55 -06:00
|
|
|
FragmentContainerView fcInput = findViewById(R.id.room_fragment);
|
2021-05-04 20:18:17 -06:00
|
|
|
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();
|
|
|
|
|
|
|
|
|
2021-05-02 22:38:15 -06:00
|
|
|
|
2021-04-30 09:57:06 -06:00
|
|
|
setContentView(R.layout.activity_main);
|
2021-05-02 22:38:15 -06:00
|
|
|
if (savedInstanceState == null) {
|
|
|
|
getSupportFragmentManager().beginTransaction()
|
2021-05-04 20:18:17 -06:00
|
|
|
.replace(R.id.friend_code_input_fragment, new WatchCodeFragment(), null)
|
2021-05-02 22:38:15 -06:00
|
|
|
.setReorderingAllowed(true)
|
|
|
|
.commit();
|
|
|
|
getSupportFragmentManager().beginTransaction()
|
2021-05-04 20:18:17 -06:00
|
|
|
.replace(R.id.room_fragment, new RecentCodesFragment(), null)
|
2021-05-02 22:38:15 -06:00
|
|
|
.setReorderingAllowed(true)
|
|
|
|
.commit();
|
|
|
|
}
|
2021-05-04 17:59:55 -06:00
|
|
|
|
|
|
|
|
2021-04-30 09:57:06 -06:00
|
|
|
}
|
|
|
|
}
|