-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Jookie262/version-2
Version 2
- Loading branch information
Showing
29 changed files
with
844 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/example/animalmatchup/HighScoreScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.example.animalmatchup; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.recyclerview.widget.GridLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.example.animalmatchup.adapter.scoreadapter.ScoreAdapter; | ||
import com.example.animalmatchup.game.InfoBox; | ||
import com.example.animalmatchup.game.PopulateScore; | ||
import com.example.animalmatchup.model.ScoreModel; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class HighScoreScreen extends AppCompatActivity { | ||
ImageView backBtn, infoBtn; | ||
TextView highest_score_txt, highest_score_name_txt; | ||
RecyclerView score_view; | ||
InfoBox infoBox; | ||
PopulateScore populateScore; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_high_score_screen); | ||
init(); | ||
clickBackInfo(); | ||
scoreRecyclerView(); | ||
changeHighestScore(); | ||
} | ||
|
||
public void init(){ | ||
backBtn = findViewById(R.id.back_btn); | ||
infoBtn = findViewById(R.id.info_btn); | ||
infoBox = new InfoBox(); | ||
highest_score_txt = findViewById(R.id.highest_score_txt); | ||
highest_score_name_txt = findViewById(R.id.highest_score_name_txt); | ||
score_view = findViewById(R.id.score_view); | ||
populateScore = new PopulateScore(getApplicationContext()); | ||
} | ||
|
||
public void clickBackInfo(){ | ||
backBtn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
finish(); | ||
} | ||
}); | ||
|
||
infoBtn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
infoBox.infoBox(HighScoreScreen.this); | ||
} | ||
}); | ||
} | ||
|
||
public void changeHighestScore(){ | ||
ArrayList<ScoreModel> highestScores = populateScore.getHighestScore(); | ||
if (!highestScores.isEmpty()) { | ||
ScoreModel highestScore = highestScores.get(0); | ||
String highestScoreValue = String.valueOf(highestScore.getScore()); | ||
String highestScoreName = highestScore.getName(); | ||
highest_score_txt.setText(highestScoreValue); | ||
highest_score_name_txt.setText(highestScoreName); | ||
} | ||
} | ||
|
||
public void scoreRecyclerView(){ | ||
PopulateScore populateScore = new PopulateScore(getApplicationContext()); | ||
ScoreAdapter scoreAdapter = new ScoreAdapter(populateScore.populateScore()); | ||
score_view.setLayoutManager(new GridLayoutManager(this, 1)); | ||
score_view.setAdapter(scoreAdapter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ple/animalmatchup/adapter/CardHolder.java → ...tchup/adapter/gameadapter/CardHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/example/animalmatchup/adapter/scoreadapter/ScoreAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.example.animalmatchup.adapter.scoreadapter; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.example.animalmatchup.R; | ||
import com.example.animalmatchup.adapter.gameadapter.CardHolder; | ||
import com.example.animalmatchup.model.ScoreModel; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ScoreAdapter extends RecyclerView.Adapter<ScoreHolder> { | ||
private ArrayList<ScoreModel> scoreModels; | ||
|
||
public ScoreAdapter(ArrayList<ScoreModel> scoreModels){ | ||
this.scoreModels = scoreModels; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ScoreHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.score_card, parent, false); | ||
return new ScoreHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull ScoreHolder holder, int position) { | ||
ScoreModel scoreModel = scoreModels.get(position); | ||
holder.getName().setText(scoreModel.getName()); | ||
holder.getScore().setText(String.valueOf(scoreModel.getScore())); | ||
holder.getRank().setText(String.valueOf(position + 2)); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return scoreModels.size(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/example/animalmatchup/adapter/scoreadapter/ScoreHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.example.animalmatchup.adapter.scoreadapter; | ||
|
||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.example.animalmatchup.R; | ||
|
||
public class ScoreHolder extends RecyclerView.ViewHolder { | ||
private TextView rank, name, score; | ||
|
||
public ScoreHolder(@NonNull View itemView) { | ||
super(itemView); | ||
rank = itemView.findViewById(R.id.rank_txt); | ||
name = itemView.findViewById(R.id.name_txt); | ||
score = itemView.findViewById(R.id.score_txt); | ||
} | ||
|
||
public TextView getRank() { | ||
return rank; | ||
} | ||
|
||
|
||
public TextView getName() { | ||
return name; | ||
} | ||
|
||
public TextView getScore() { | ||
return score; | ||
} | ||
|
||
} |
Oops, something went wrong.