diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-05-09 00:44:42 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-05-09 00:44:42 -0600 |
commit | 2734f6777a6b7c439d9bc55c8756155721f76fa5 (patch) | |
tree | ca830b6dab31abef50e49b1c96698d5b127b5c5c /app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java | |
parent | 5c0ed1708a3f23fcb78cfe8442487a403674c56a (diff) | |
download | wiimmfi-watcher-2734f6777a6b7c439d9bc55c8756155721f76fa5.tar wiimmfi-watcher-2734f6777a6b7c439d9bc55c8756155721f76fa5.tar.gz wiimmfi-watcher-2734f6777a6b7c439d9bc55c8756155721f76fa5.tar.bz2 |
added clear button but doesn't work yet
Diffstat (limited to 'app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java')
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index e48486e..c3933ee 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -7,8 +7,15 @@ import android.view.View; import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.ObservableArrayList; +import androidx.lifecycle.ViewModelProvider; +import androidx.room.Room; +import androidx.sqlite.db.SimpleSQLiteQuery; + +import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; + import me.brysonsteck.wiimmfiwatcher.database.AppDatabase; import me.brysonsteck.wiimmfiwatcher.model.FriendCode; +import me.brysonsteck.wiimmfiwatcher.viewmodel.FriendCodeViewModel; public class MainActivity extends AppCompatActivity { ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>(); @@ -27,7 +34,22 @@ public class MainActivity extends AppCompatActivity { } setContentView(R.layout.activity_main); + database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build(); View aboutButton = findViewById(R.id.about_button); + 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) { + new Thread(() -> { + database.clearAllTables(); + database.query(new SimpleSQLiteQuery("DELETE FROM friendcode")); + }); + } + }); + aboutButton.setOnClickListener((about) -> { getSupportFragmentManager().beginTransaction() |