-
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.
Добавлен подсчет рейтнга пользователя
- Loading branch information
Showing
31 changed files
with
830 additions
and
143 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
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
92 changes: 92 additions & 0 deletions
92
app/src/main/java/my/neomer/sixtyseconds/RatingActivity.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,92 @@ | ||
package my.neomer.sixtyseconds; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.ProgressBar; | ||
import android.widget.TextView; | ||
|
||
import org.w3c.dom.Text; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import my.neomer.sixtyseconds.helpers.ApplicationResources; | ||
import my.neomer.sixtyseconds.model.UserRating; | ||
import my.neomer.sixtyseconds.transport.Callback; | ||
|
||
public class RatingActivity extends AppCompatActivity | ||
implements Callback<UserRating> | ||
{ | ||
|
||
@BindView(R.id.txtPoints) | ||
TextView txtPoints; | ||
|
||
@BindView(R.id.txtPlace) | ||
TextView txtPlace; | ||
|
||
@BindView(R.id.imvPlaceIcon) | ||
ImageView imvPlaceIcon; | ||
|
||
@BindView(R.id.loadUserRatingProgressBar) | ||
ProgressBar loadUserRatingProgressBar; | ||
|
||
@BindView(R.id.txtFirstPlace) | ||
TextView txtFirstPlace; | ||
|
||
@BindView(R.id.txtSecondPlace) | ||
TextView txtSecondPlace; | ||
|
||
@BindView(R.id.txtThirdPlace) | ||
TextView txtThirdPlace; | ||
|
||
@BindView(R.id.txtFourthPlace) | ||
TextView txtFourthPlace; | ||
|
||
@BindView(R.id.txtFifthPlace) | ||
TextView txtFifthPlace; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_rating); | ||
|
||
ButterKnife.bind(this); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
|
||
loadUserRatingProgressBar.setVisibility(View.VISIBLE); | ||
|
||
ApplicationResources.getInstance() | ||
.getQuestionProvider() | ||
.loadUserRating(this); | ||
|
||
} | ||
|
||
@Override | ||
public void onReady(UserRating data) { | ||
loadUserRatingProgressBar.setVisibility(View.INVISIBLE); | ||
imvPlaceIcon.setVisibility(View.INVISIBLE); | ||
txtPlace.setText(String.valueOf(data.getPlace())); | ||
txtPoints.setText(String.valueOf(data.getPoints())); | ||
|
||
txtFirstPlace.setText(String.valueOf(data.getLeaderboard().get(0).getPoints())); | ||
txtSecondPlace.setText(String.valueOf(data.getLeaderboard().get(1).getPoints())); | ||
txtThirdPlace.setText(String.valueOf(data.getLeaderboard().get(2).getPoints())); | ||
txtFourthPlace.setText(String.valueOf(data.getLeaderboard().get(3).getPoints())); | ||
txtFifthPlace.setText(String.valueOf(data.getLeaderboard().get(4).getPoints())); | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable t) { | ||
|
||
ApplicationResources.getInstance() | ||
.getQuestionProvider() | ||
.loadUserRating(this); | ||
|
||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/src/main/java/my/neomer/sixtyseconds/dao/LeaderboardRecordDTO.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,17 @@ | ||
package my.neomer.sixtyseconds.dao; | ||
|
||
import my.neomer.sixtyseconds.model.LeaderboardRecord; | ||
|
||
public class LeaderboardRecordDTO { | ||
|
||
private String user; | ||
private int points; | ||
|
||
public LeaderboardRecord toLeaderBoardRecord() { | ||
LeaderboardRecord record = new LeaderboardRecord(); | ||
record.setPoints(points); | ||
return record; | ||
} | ||
|
||
|
||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/my/neomer/sixtyseconds/dao/UserRatingDTO.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,32 @@ | ||
package my.neomer.sixtyseconds.dao; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import my.neomer.sixtyseconds.model.LeaderboardRecord; | ||
import my.neomer.sixtyseconds.model.UserRating; | ||
|
||
public class UserRatingDTO { | ||
|
||
private String user_id; | ||
private long points; | ||
private int place; | ||
private List<LeaderboardRecordDTO> leaderboard; | ||
|
||
public UserRating toUserRating() { | ||
UserRating userRating = new UserRating(); | ||
userRating.setPlace(place); | ||
userRating.setPoints(points); | ||
|
||
List<LeaderboardRecord> list = new ArrayList<>(); | ||
if (leaderboard != null) { | ||
for (LeaderboardRecordDTO rec : leaderboard) { | ||
list.add(rec.toLeaderBoardRecord()); | ||
} | ||
} | ||
userRating.setLeaderboard(list); | ||
return userRating; | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.