diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-05-08 18:01:47 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-05-08 18:01:47 -0600 |
commit | 2c540ef7ce473fbd681c42959a51224be4784eb7 (patch) | |
tree | 634a6cd2e8993496445a611f484c1e2da07bcc23 /app/src/main/java/me/brysonsteck/wiimmfiwatcher | |
parent | fc908199f136acd2a5030e5085f024857cd2cfb5 (diff) | |
download | wiimmfi-watcher-2c540ef7ce473fbd681c42959a51224be4784eb7.tar wiimmfi-watcher-2c540ef7ce473fbd681c42959a51224be4784eb7.tar.gz wiimmfi-watcher-2c540ef7ce473fbd681c42959a51224be4784eb7.tar.bz2 |
added about fragment
Diffstat (limited to 'app/src/main/java/me/brysonsteck/wiimmfiwatcher')
3 files changed, 40 insertions, 21 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..7851977 --- /dev/null +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java @@ -0,0 +1,18 @@ +package me.brysonsteck.wiimmfiwatcher; + +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +public class AboutFragment extends Fragment { + public AboutFragment() { super(R.layout.about_fragment); } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + +} diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index 31f74fd..e48486e 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -1,7 +1,9 @@ package me.brysonsteck.wiimmfiwatcher; +import android.content.ClipData; import android.os.Bundle; +import android.view.View; import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.ObservableArrayList; @@ -15,18 +17,6 @@ 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(); - - if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() @@ -37,5 +27,15 @@ public class MainActivity extends AppCompatActivity { } setContentView(R.layout.activity_main); + View aboutButton = findViewById(R.id.about_button); + + aboutButton.setOnClickListener((about) -> { + 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/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java index beb684f..715dce8 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java @@ -12,20 +12,20 @@ import androidx.recyclerview.widget.RecyclerView; 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(); |