aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java17
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/RecentCodesFragment.java7
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java17
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java11
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java30
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java13
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java9
7 files changed, 102 insertions, 2 deletions
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java b/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
index abf1391..b8f7905 100644
--- a/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java
@@ -3,14 +3,31 @@ 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;
+
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ FragmentContainerView fcInput = findViewById(R.id.recent_friend_codes_fragment);
+ AppDatabase database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build();
+
setContentView(R.layout.activity_main);
+ if (savedInstanceState == null) {
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.friend_code_input_fragment, WatchCodeFragment.class, null)
+ .setReorderingAllowed(true)
+ .commit();
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.recent_friend_codes_fragment, RecentCodesFragment.class, null)
+ .setReorderingAllowed(true)
+ .commit();
+ }
}
} \ No newline at end of file
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/RecentCodesFragment.java b/app/src/main/java/com/example/wiimmterfaceandroid/RecentCodesFragment.java
index 886743f..7dff276 100644
--- a/app/src/main/java/com/example/wiimmterfaceandroid/RecentCodesFragment.java
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/RecentCodesFragment.java
@@ -1,4 +1,9 @@
package com.example.wiimmterfaceandroid;
-public class RecentCodesFragment {
+import androidx.fragment.app.Fragment;
+
+public class RecentCodesFragment extends Fragment {
+
+ public RecentCodesFragment() { super(R.layout.fragment_recent_friend_codes); }
+
}
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java b/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java
index bb2385a..145fb2c 100644
--- a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java
@@ -1,4 +1,19 @@
package com.example.wiimmterfaceandroid;
-public class WatchCodeFragment {
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+public class WatchCodeFragment extends Fragment {
+
+ public WatchCodeFragment() { super(R.layout.friend_code_input_fragment); }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ }
}
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java b/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java
new file mode 100644
index 0000000..0f01149
--- /dev/null
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java
@@ -0,0 +1,11 @@
+package com.example.wiimmterfaceandroid.database;
+
+import androidx.room.Database;
+import androidx.room.RoomDatabase;
+
+import com.example.wiimmterfaceandroid.model.FriendCode;
+
+@Database(entities = {FriendCode.class}, version=1)
+public abstract class AppDatabase extends RoomDatabase {
+ public abstract FriendCodeDao getFriendCodeDao();
+}
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java b/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java
new file mode 100644
index 0000000..e9762fd
--- /dev/null
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java
@@ -0,0 +1,30 @@
+package com.example.wiimmterfaceandroid.database;
+
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Update;
+
+import com.example.wiimmterfaceandroid.model.FriendCode;
+
+import java.util.List;
+
+@Dao
+public interface FriendCodeDao {
+
+ @Query("SELECT * FROM friendcode")
+ public List<FriendCode> getAll();
+
+ @Query("SELECT * FROM friendcode")
+ public FriendCode findByCode(String friendCode);
+
+ @Insert
+ public void insert(FriendCode friendCode);
+
+ @Update
+ public void update(FriendCode friendCode);
+
+ @Delete
+ public void delete(FriendCode friendCode);
+}
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java b/app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java
new file mode 100644
index 0000000..4d1cc5e
--- /dev/null
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java
@@ -0,0 +1,13 @@
+package com.example.wiimmterfaceandroid.model;
+
+import androidx.room.ColumnInfo;
+import androidx.room.Entity;
+
+@Entity
+public class FriendCode {
+ @ColumnInfo(name="name")
+ public String name;
+
+ @ColumnInfo(name="friendCode")
+ public String friendCode;
+}
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java b/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java
new file mode 100644
index 0000000..82b892a
--- /dev/null
+++ b/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java
@@ -0,0 +1,9 @@
+package com.example.wiimmterfaceandroid.viewmodel;
+
+import com.example.wiimmterfaceandroid.model.FriendCode;
+
+public class FriendCodeViewModel {
+ FriendCode friendCode = new FriendCode();
+
+
+}