diff options
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java | 82 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java) | 42 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java) | 27 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java) | 18 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/database/AppDatabase.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java) | 4 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/database/FriendCodeDao.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java) | 10 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/model/FriendCode.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java) | 2 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java) | 47 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/Player.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/Player.java) | 2 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomAdapter.java) | 16 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java) | 19 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java) | 13 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java (renamed from app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/WiimmfiActivity.java) | 32 |
13 files changed, 188 insertions, 126 deletions
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java new file mode 100644 index 0000000..8f9111c --- /dev/null +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java @@ -0,0 +1,82 @@ +package me.brysonsteck.wiimmfiwatcher; + +import android.annotation.SuppressLint; +import android.os.Bundle; +import android.text.method.LinkMovementMethod; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import com.google.android.material.appbar.MaterialToolbar; + +public class AboutFragment extends Fragment { + View aboutButton; + MaterialToolbar toolbar; + + public AboutFragment() { + super(R.layout.about_fragment); + } + + @SuppressLint("SetTextI18n") + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + aboutButton = getActivity().findViewById(R.id.about_button); + toolbar = getActivity().findViewById(R.id.toolbar); + toolbar.setTitle("About Wiimmfi Watcher"); + + TextView aboutWatcher = view.findViewById(R.id.about_watcher_text); + TextView aboutMe = view.findViewById(R.id.about_me_text); + TextView github = view.findViewById(R.id.github_text); + TextView donations = view.findViewById(R.id.donations_text); + TextView contact = view.findViewById(R.id.contact_text); + TextView bugs = view.findViewById(R.id.bugs_text); + + aboutWatcher.setText("Wiimmfi Watcher is an UNOFFICIAL application created for a school project that I have decided to turn into a full application. " + + "This application was made to provide an easy shortcut to the Wiimmfi website and display data in a mobile friendly way, since the official website doesn't have a mobile friendly version. " + + "Free and open source, you can watch your Wiimmfi Mario Kart Wii matches on your phone in a quick and easy way. " + + ""); + + aboutMe.setText("Hi there! My name is Bryson Steck. I am a student studying Computer Science. This is my first official application that I'm maintaining. " + + "This whole \"application on the Google Play Store\" thing is new to me, so please be patient as I am learning how to maintain something like this. " + + "I hope you enjoy!"); + + github.setClickable(true); + github.setMovementMethod(LinkMovementMethod.getInstance()); + + github.setText(R.string.github); + + donations.setText("Since this application is free and the code is open source, I do not receive income from maintaining this app. Because of that, I'd appreciate any donation in the following methods:\n\n" + + "PayPal: @bryzinga\n" + + "Venmo: @brysonsteck\n" + + "Bitcoin: 1Kbnp5JMTKd7a3Zs2WWm2JMCjfVb5tpcky\n" + + "Litecoin: LRboJVNzoJCjXHmwN6RQgyvYEQjjaFzEA7\n" + + "Dogecoin: DMx362YBEBYw1uDGetX3svdg8RypHsWTCS"); + + contact.setText("If you would like to get ahold of me for any reason unrelated to bug reports or this app in general, you can contact me through email at steck.bryson@gmail.com " + + "or on Discord at bryzinga#9971."); + + bugs.setClickable(true); + bugs.setMovementMethod(LinkMovementMethod.getInstance()); + + bugs.setText(R.string.bugs); + } + + @Override + public void onStop() { + super.onStop(); + aboutButton.setVisibility(View.VISIBLE); + toolbar.setTitle("Wiimmfi Watcher"); + } + @Override + public void onResume() { + super.onResume(); + aboutButton.setVisibility(View.INVISIBLE); + toolbar.setTitle("About Wiimmfi Watcher"); + } + +} diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index 96f1511..c37aaf7 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -1,18 +1,14 @@ -package com.example.wiimmterfaceandroid; - +package me.brysonsteck.wiimmfiwatcher; +import android.os.Bundle; +import android.view.View; import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.ObservableArrayList; -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; +import me.brysonsteck.wiimmfiwatcher.database.AppDatabase; +import me.brysonsteck.wiimmfiwatcher.model.FriendCode; public class MainActivity extends AppCompatActivity { ObservableArrayList<FriendCode> recentFCList = new ObservableArrayList<>(); @@ -21,20 +17,11 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); -// FragmentContainerView fcInput = findViewById(R.id.room_fragment); -// 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(); - - + setContentView(R.layout.activity_main); + View aboutButton = findViewById(R.id.about_button); if (savedInstanceState == null) { + aboutButton.setVisibility(View.VISIBLE); getSupportFragmentManager().beginTransaction() .replace(R.id.friend_code_input_fragment, new WatchCodeFragment(), null) .setReorderingAllowed(true) @@ -42,6 +29,17 @@ public class MainActivity extends AppCompatActivity { } - setContentView(R.layout.activity_main); + + database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build(); + + aboutButton.setOnClickListener((about) -> { + aboutButton.setVisibility(View.INVISIBLE); + getSupportFragmentManager().beginTransaction() + .replace(R.id.friend_code_input_fragment, new AboutFragment(), null) + .setReorderingAllowed(true) + .addToBackStack(null) + .commit(); + }); + } }
\ No newline at end of file diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java index 6e7e69e..715dce8 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java @@ -1,31 +1,31 @@ -package com.example.wiimmterfaceandroid; +package me.brysonsteck.wiimmfiwatcher; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import androidx.annotation.NonNull; import androidx.databinding.ObservableArrayList; import androidx.recyclerview.widget.RecyclerView; -import com.example.wiimmterfaceandroid.model.FriendCode; -import com.example.wiimmterfaceandroid.wiimmfi.WiimmfiActivity; import com.google.android.material.button.MaterialButton; +import java.util.ArrayList; + +import me.brysonsteck.wiimmfiwatcher.model.FriendCode; +import me.brysonsteck.wiimmfiwatcher.wiimmfi.WiimmfiActivity; + public class WatchCodeAdapter extends RecyclerView.Adapter<WatchCodeAdapter.ViewHolder>{ ObservableArrayList<FriendCode> entries; - OnFriendCodeClicked listener; Context context; - public interface OnFriendCodeClicked { - public void onClick(FriendCode entry); - } + ArrayList<String> recentCodes; public WatchCodeAdapter(Context context, ObservableArrayList<FriendCode> entries) { this.context = context; this.entries = entries; + this.recentCodes = new ArrayList<>(); } @NonNull @@ -37,16 +37,17 @@ public class WatchCodeAdapter extends RecyclerView.Adapter<WatchCodeAdapter.View @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + String currentFC = entries.get(position).friendCode; MaterialButton fcButton = holder.itemView.findViewById(R.id.recent_friend_code_button); - FriendCode currentFC = entries.get(position); - fcButton.setText(currentFC.friendCode); + fcButton.setText(currentFC); fcButton.setOnClickListener(view -> { - Intent intent = new Intent(view.getContext(), WiimmfiActivity.class); - intent.putExtra("friendCode", currentFC.friendCode); - context.startActivity(intent); + Intent intent = new Intent(view.getContext(), WiimmfiActivity.class); + intent.putExtra("friendCode", currentFC); + context.startActivity(intent); }); } + @Override public int getItemCount() { return entries.size(); diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java index 6de02dc..c1ba705 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid; +package me.brysonsteck.wiimmfiwatcher; import android.content.Intent; import android.os.Bundle; @@ -14,11 +14,12 @@ import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.example.wiimmterfaceandroid.model.FriendCode; -import com.example.wiimmterfaceandroid.viewmodel.FriendCodeViewModel; -import com.example.wiimmterfaceandroid.wiimmfi.WiimmfiActivity; import com.google.android.material.textview.MaterialTextView; +import me.brysonsteck.wiimmfiwatcher.model.FriendCode; +import me.brysonsteck.wiimmfiwatcher.viewmodel.FriendCodeViewModel; +import me.brysonsteck.wiimmfiwatcher.wiimmfi.WiimmfiActivity; + public class WatchCodeFragment extends Fragment { public WatchCodeFragment() { @@ -82,7 +83,10 @@ public class WatchCodeFragment extends Fragment { } }); RecyclerView recyclerView = view.findViewById(R.id.recent_friend_codes_recycler_view); - recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); + linearLayoutManager.setReverseLayout(true); + linearLayoutManager.setStackFromEnd(true); + recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(adapter); Button watchButton = view.findViewById(R.id.watch_button); EditText friendCode = view.findViewById(R.id.friend_code_edit_text); @@ -97,9 +101,6 @@ public class WatchCodeFragment extends Fragment { } else { errorText.setText(""); viewModel.saveFriendCode("", friendCode.getText().toString()); -// FriendCodeObj friendCodeObj = new FriendCodeObj(); -// friendCodeObj.friendCode = friendCode.getText().toString(); -// database.getFriendCodeDao().insert(friendCodeObj); intent.putExtra("friendCode", friendCode.getText().toString()); startActivity(intent); } @@ -107,5 +108,6 @@ public class WatchCodeFragment extends Fragment { }); + } } diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/database/AppDatabase.java index 0f01149..01884c2 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/database/AppDatabase.java @@ -1,9 +1,9 @@ -package com.example.wiimmterfaceandroid.database; +package me.brysonsteck.wiimmfiwatcher.database; import androidx.room.Database; import androidx.room.RoomDatabase; -import com.example.wiimmterfaceandroid.model.FriendCode; +import me.brysonsteck.wiimmfiwatcher.model.FriendCode; @Database(entities = {FriendCode.class}, version=1) public abstract class AppDatabase extends RoomDatabase { diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/database/FriendCodeDao.java index dbfb9c5..1b0788e 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/database/FriendCodeDao.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid.database; +package me.brysonsteck.wiimmfiwatcher.database; import androidx.room.Dao; import androidx.room.Delete; @@ -6,10 +6,10 @@ import androidx.room.Insert; import androidx.room.Query; import androidx.room.Update; -import com.example.wiimmterfaceandroid.model.FriendCode; - import java.util.List; +import me.brysonsteck.wiimmfiwatcher.model.FriendCode; + @Dao public interface FriendCodeDao { @@ -27,4 +27,8 @@ public interface FriendCodeDao { @Delete public void delete(FriendCode friendCode); + + @Query("DELETE FROM friendcode") + public void nukeTable(); + } diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/model/FriendCode.java index 3aad0a1..5856a22 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/model/FriendCode.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/model/FriendCode.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid.model; +package me.brysonsteck.wiimmfiwatcher.model; import androidx.annotation.NonNull; import androidx.room.ColumnInfo; diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java index c7bbe7d..25cdd64 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/viewmodel/FriendCodeViewModel.java @@ -1,23 +1,15 @@ -package com.example.wiimmterfaceandroid.viewmodel; +package me.brysonsteck.wiimmfiwatcher.viewmodel; import android.app.Application; - -import androidx.lifecycle.AndroidViewModel; -import androidx.lifecycle.MutableLiveData; - -import com.example.wiimmterfaceandroid.database.AppDatabase; -import com.example.wiimmterfaceandroid.model.FriendCode; +import android.database.sqlite.SQLiteDatabase; import androidx.databinding.ObservableArrayList; import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.MutableLiveData; -import androidx.lifecycle.ViewModel; import androidx.room.Room; -import androidx.room.RoomDatabase; -import androidx.databinding.ObservableArrayList; - -import java.util.LinkedHashSet; +import me.brysonsteck.wiimmfiwatcher.database.AppDatabase; +import me.brysonsteck.wiimmfiwatcher.model.FriendCode; public class FriendCodeViewModel extends AndroidViewModel { ObservableArrayList<FriendCode> entries = new ObservableArrayList<>(); @@ -38,22 +30,17 @@ public class FriendCodeViewModel extends AndroidViewModel { }).start(); } - public void setCurrentEntry(FriendCode entry) { - currentEntry.postValue(entry); - } - - public MutableLiveData<FriendCode> getCurrentEntry() { - return currentEntry; - } - - public MutableLiveData<Boolean> getSaving() { - return saving; - } - public ObservableArrayList<FriendCode> getEntries() { return entries; } +// public boolean deleteAll() { +// for (FriendCode entry: entries) { +// db.getFriendCodeDao().nukeTable(); +// } +// return true; +// } + public void saveFriendCode(String name, String friendCode) { saving.setValue(true); new Thread(() -> { @@ -71,10 +58,10 @@ public class FriendCodeViewModel extends AndroidViewModel { }).start(); } - public void deleteEntry(FriendCode entry) { - new Thread(() -> { - db.getFriendCodeDao().delete(entry); - entries.remove(entry); - }).start(); - } +// public void deleteEntry(FriendCode entry) { +// new Thread(() -> { +// db.getFriendCodeDao().delete(entry); +// entries.remove(entry); +// }).start(); +// } } diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/Player.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/Player.java index 792f14f..fe9e072 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/Player.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/Player.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid.wiimmfi; +package me.brysonsteck.wiimmfiwatcher.wiimmfi; public class Player { String rosterNumber; diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java index dfa51e7..c7a0f29 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid.wiimmfi; +package me.brysonsteck.wiimmfiwatcher.wiimmfi; import android.annotation.SuppressLint; import android.graphics.Color; @@ -6,28 +6,24 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import org.jsoup.*; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.example.wiimmterfaceandroid.R; import com.google.android.material.card.MaterialCardView; -import com.google.android.material.color.MaterialColors; -import java.io.IOException; +import org.jsoup.*; + import java.util.ArrayList; -public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{ +import me.brysonsteck.wiimmfiwatcher.R; +public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{ String display; String playerLink; String header; ArrayList<Player> players; - boolean online = true; + public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players) { this.display = display; this.playerLink = playerLink; diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java index 3799180..284b735 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid.wiimmfi; +package me.brysonsteck.wiimmfiwatcher.wiimmfi; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -14,7 +14,7 @@ public class RoomData { String friendCode; ArrayList<Player> players = new ArrayList<>(); - public RoomData (ArrayList<Player> players, String playerLink, String friendCode) { + public RoomData (ArrayList<Player> players, String friendCode) { this.friendCode = friendCode; getPlayerLink(); Document doc = null; @@ -24,7 +24,9 @@ public class RoomData { } else { try { - doc = Jsoup.connect("https://wiimmfi.de/" + this.playerLink).get(); + doc = Jsoup.connect("https://wiimmfi.de/" + this.playerLink) + .userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (UNDER DEVELOPMENT)") + .get(); } catch (IOException e) { e.printStackTrace(); } @@ -89,22 +91,20 @@ public class RoomData { public void getPlayerLink() { try { - Document doc = null; - - doc = Jsoup.connect("https://wiimmfi.de/stats/mkw").get(); + Document doc = Jsoup.connect("https://wiimmfi.de/stats/mkw") + .userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (Developer testing)") + .get(); Element table = doc.select("table").get(0); Elements rows = table.select("tr"); for (int i = 0; i < rows.size(); i++) { Element row = rows.get(i); Elements colPlayers = row.select("td"); - Elements colHeader = row.select("th"); if (colPlayers.size() > 0) { String data = colPlayers.get(0).select("a").toString(); -// System.out.println(data); if (data.contains(friendCode)) { System.out.println("Found friend code"); playerLink = data.split("\"")[3]; @@ -126,8 +126,7 @@ public class RoomData { public RoomData refresh() { players.clear(); roomHeader = ""; - RoomData returningData = new RoomData(players, playerLink, friendCode); - return returningData; + return new RoomData(players, friendCode); } } diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java index 463c635..afb21d6 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java @@ -1,4 +1,4 @@ -package com.example.wiimmterfaceandroid.wiimmfi; +package me.brysonsteck.wiimmfiwatcher.wiimmfi; import android.os.Bundle; import android.view.View; @@ -10,21 +10,22 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.example.wiimmterfaceandroid.R; import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.util.ArrayList; +import me.brysonsteck.wiimmfiwatcher.R; + public class RoomFragment extends Fragment { String display; String header; String playerLink; ArrayList<Player> players; - RoomData roomData; + RoomData roomData; - public RoomFragment(String friendCode, String header, ArrayList<Player> players, String playerLink, String display) { + public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display) { super(R.layout.fragment_room); - this.roomData = new RoomData(players, playerLink, friendCode); + this.roomData = new RoomData(players, friendCode); this.header = roomData.getRoomHeader(); this.display = display; this.players = players; @@ -51,8 +52,6 @@ public class RoomFragment extends Fragment { roomData = roomData.refresh(); RoomData newRoomData = roomData.refresh(); players = roomData.getPlayers(); -// playerLink = roomData.getPlayerLink(); -// String otherPlayerLink = newRoomData.getPlayerLink(); header = newRoomData.getRoomHeader(); if (header == null) { header = "This player is not online, not inside a room or does not exist. Click the refresh button to try again, or click on the back button to enter a different friend code."; diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/WiimmfiActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java index 1d1101d..f3029af 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/WiimmfiActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java @@ -1,27 +1,21 @@ -package com.example.wiimmterfaceandroid.wiimmfi; +package me.brysonsteck.wiimmfiwatcher.wiimmfi; import android.content.Intent; -import android.os.AsyncTask; import android.os.Bundle; import android.os.StrictMode; -import android.widget.TextView; - -import org.jsoup.*; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; import androidx.appcompat.app.AppCompatActivity; import androidx.drawerlayout.widget.DrawerLayout; -import androidx.room.Room; -import com.example.wiimmterfaceandroid.R; import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.navigation.NavigationView; -import java.io.IOException; +import org.jsoup.*; + import java.util.ArrayList; +import me.brysonsteck.wiimmfiwatcher.R; + public class WiimmfiActivity extends AppCompatActivity { ArrayList<Player> players = new ArrayList<>(); final String[] playerLink = new String[1]; @@ -47,7 +41,7 @@ public class WiimmfiActivity extends AppCompatActivity { if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "fc"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc"), null) .setReorderingAllowed(true) .commit(); } @@ -60,49 +54,49 @@ public class WiimmfiActivity extends AppCompatActivity { if (menuItem.getItemId() == R.id.friend_code) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "fc"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.roles) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "roles"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.login_regions) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "login_regions"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.room_match) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "room_match"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.world) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "world"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.conn_fail) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "conn_fail"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.vr_br) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "vr_br"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br"), null) .setReorderingAllowed(true) .commit(); } |