2021-05-08 14:58:18 -06:00
|
|
|
package me.brysonsteck.wiimmfiwatcher;
|
2021-04-30 09:57:06 -06:00
|
|
|
|
2021-04-30 13:40:14 -06:00
|
|
|
|
2021-05-08 18:01:47 -06:00
|
|
|
import android.content.ClipData;
|
2021-05-08 14:58:18 -06:00
|
|
|
import android.os.Bundle;
|
2021-05-08 18:01:47 -06:00
|
|
|
import android.view.View;
|
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-09 00:44:42 -06:00
|
|
|
import androidx.lifecycle.ViewModelProvider;
|
|
|
|
import androidx.room.Room;
|
|
|
|
import androidx.sqlite.db.SimpleSQLiteQuery;
|
|
|
|
|
|
|
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
|
|
|
2021-05-08 14:58:18 -06:00
|
|
|
import me.brysonsteck.wiimmfiwatcher.database.AppDatabase;
|
|
|
|
import me.brysonsteck.wiimmfiwatcher.model.FriendCode;
|
2021-05-09 00:44:42 -06:00
|
|
|
import me.brysonsteck.wiimmfiwatcher.viewmodel.FriendCodeViewModel;
|
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-10 12:54:31 -06:00
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
|
|
View aboutButton = findViewById(R.id.about_button);
|
2021-05-02 22:38:15 -06:00
|
|
|
|
|
|
|
if (savedInstanceState == null) {
|
2021-05-10 12:54:31 -06:00
|
|
|
aboutButton.setVisibility(View.VISIBLE);
|
2021-05-02 22:38:15 -06:00
|
|
|
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();
|
2021-05-04 17:59:55 -06:00
|
|
|
|
|
|
|
|
2021-05-04 23:31:34 -06:00
|
|
|
}
|
2021-05-09 00:44:42 -06:00
|
|
|
database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build();
|
|
|
|
|
2021-05-10 12:54:31 -06:00
|
|
|
// aboutButton.setVisibility(View.INVISIBLE);
|
|
|
|
// ExtendedFloatingActionButton clearButton = findViewById(R.id.clear_button);
|
|
|
|
FriendCodeViewModel viewModel = new ViewModelProvider(MainActivity.this).get(FriendCodeViewModel.class);
|
|
|
|
// clearButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onClick(View view) {
|
|
|
|
// getApplicationContext().deleteDatabase("friend-codes-db");
|
|
|
|
// database = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "friend-codes-db").build();
|
|
|
|
// }
|
|
|
|
// });
|
2021-05-09 00:44:42 -06:00
|
|
|
|
2021-05-08 18:01:47 -06:00
|
|
|
|
|
|
|
aboutButton.setOnClickListener((about) -> {
|
2021-05-10 12:54:31 -06:00
|
|
|
// aboutButton.setClickable(false);
|
|
|
|
aboutButton.setVisibility(View.INVISIBLE);
|
2021-05-08 18:01:47 -06:00
|
|
|
getSupportFragmentManager().beginTransaction()
|
|
|
|
.replace(R.id.friend_code_input_fragment, new AboutFragment(), null)
|
|
|
|
.setReorderingAllowed(true)
|
|
|
|
.addToBackStack(null)
|
|
|
|
.commit();
|
|
|
|
});
|
|
|
|
|
2021-04-30 09:57:06 -06:00
|
|
|
}
|
|
|
|
}
|