Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 0f4699c

Browse files
#152. Add review fixes.
1 parent fcbc5c4 commit 0f4699c

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

app/src/main/java/com/bogdan/codeforceswatcher/adapter/ContestAdapter.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import java.net.URLEncoder
1919
import java.text.SimpleDateFormat
2020
import java.util.*
2121

22-
class ContestAdapter(private var items: List<Contest>, private val ctx: Context) : RecyclerView.Adapter<ContestAdapter.ViewHolder>() {
22+
class ContestAdapter(private var items: List<Contest>, private val context: Context) : RecyclerView.Adapter<ContestAdapter.ViewHolder>() {
2323

2424
override fun getItemCount() = items.size
2525

2626
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
27-
return ViewHolder(LayoutInflater.from(ctx).inflate(R.layout.contests_list_view, parent, false))
27+
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.contests_list_view, parent, false))
2828
}
2929

3030
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
@@ -41,9 +41,9 @@ class ContestAdapter(private var items: List<Contest>, private val ctx: Context)
4141
val calendarEventLink = "$CALENDAR_LINK?action=TEMPLATE&text=$encodeName&dates=$timeStart/$timeEnd&details=$CODEFORCES_LINK"
4242
val intent = Intent(Intent.ACTION_VIEW).setData(Uri.parse(calendarEventLink))
4343
try {
44-
ctx.startActivity(intent)
44+
context.startActivity(intent)
4545
} catch (error: ActivityNotFoundException) {
46-
Toast.makeText(ctx, ctx.resources.getString(R.string.google_calendar_not_found), Toast.LENGTH_SHORT).show()
46+
Toast.makeText(context, context.resources.getString(R.string.google_calendar_not_found), Toast.LENGTH_SHORT).show()
4747
}
4848
Analytics.logAddContestToCalendarEvent(contest.name)
4949
}

app/src/main/java/com/bogdan/codeforceswatcher/adapter/UserAdapter.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.users_list_view.view.*
1717
import java.text.SimpleDateFormat
1818
import java.util.*
1919

20-
class UserAdapter(private var items: List<User>, private val ctx: Context) : RecyclerView.Adapter<UserAdapter.ViewHolder>() {
20+
class UserAdapter(private var items: List<User>, private val context: Context) : RecyclerView.Adapter<UserAdapter.ViewHolder>() {
2121

2222
override fun getItemCount(): Int {
2323
return items.size
@@ -29,7 +29,7 @@ class UserAdapter(private var items: List<User>, private val ctx: Context) : Rec
2929
}
3030

3131
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
32-
return ViewHolder(LayoutInflater.from(ctx).inflate(R.layout.users_list_view, parent, false))
32+
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.users_list_view, parent, false))
3333
}
3434

3535
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
@@ -39,42 +39,42 @@ class UserAdapter(private var items: List<User>, private val ctx: Context) : Rec
3939
holder.tvRating.text = null
4040
} else holder.tvRating.text = user.rating.toString()
4141
if (user.rank == null) {
42-
holder.tvHandle.setTextColor(ContextCompat.getColor(ctx, grey))
43-
holder.tvRating.setTextColor(ContextCompat.getColor(ctx, grey))
42+
holder.tvHandle.setTextColor(ContextCompat.getColor(context, grey))
43+
holder.tvRating.setTextColor(ContextCompat.getColor(context, grey))
4444
} else {
4545
if (user.rank == "legendary grandmaster") {
4646
val text = "<font color=black>${user.handle[0]}</font><font color=red>${user.handle.subSequence(1, user.handle.lastIndex + 1)}</font>"
4747
holder.tvHandle.text = HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY);
4848
} else {
49-
holder.tvHandle.setTextColor(ContextCompat.getColor(ctx, getColor(user.rank)))
49+
holder.tvHandle.setTextColor(ContextCompat.getColor(context, getColor(user.rank)))
5050
}
51-
holder.tvRating.setTextColor(ContextCompat.getColor(ctx, getColor(user.rank)))
51+
holder.tvRating.setTextColor(ContextCompat.getColor(context, getColor(user.rank)))
5252

5353
}
5454
val lastRatingChange = user.ratingChanges.lastOrNull()
5555
if (lastRatingChange != null) {
5656
val ratingDelta = lastRatingChange.newRating - lastRatingChange.oldRating
57-
holder.tvLastRatingUpdate.text = ctx.resources.getString(
57+
holder.tvLastRatingUpdate.text = context.resources.getString(
5858
R.string.last_rating_update,
5959
getDateTime(lastRatingChange.ratingUpdateTimeSeconds)
6060
)
6161
if (ratingDelta >= 0) {
6262
holder.ivDelta.setImageResource(R.drawable.ic_rating_up)
6363
holder.tvRatingChange.text = ratingDelta.toString()
64-
holder.tvRatingChange.setTextColor(ContextCompat.getColor(ctx, bright_green))
64+
holder.tvRatingChange.setTextColor(ContextCompat.getColor(context, bright_green))
6565
} else {
6666
holder.ivDelta.setImageResource(R.drawable.ic_rating_down)
6767
holder.tvRatingChange.text = (-ratingDelta).toString()
68-
holder.tvRatingChange.setTextColor(ContextCompat.getColor(ctx, red))
68+
holder.tvRatingChange.setTextColor(ContextCompat.getColor(context, red))
6969
}
7070
} else {
71-
holder.tvLastRatingUpdate.text = ctx.resources.getString(R.string.no_rating_update)
71+
holder.tvLastRatingUpdate.text = context.resources.getString(R.string.no_rating_update)
7272
holder.ivDelta.setImageResource(0)
7373
holder.tvRatingChange.text = null
7474
}
7575

7676
holder.itemView.setOnClickListener {
77-
ctx.startActivity(TryActivity.newIntent(ctx, user.id))
77+
context.startActivity(TryActivity.newIntent(context, user.id))
7878
}
7979
}
8080

app/src/main/res/values-ru-rRU/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
<string name="users">Пользователи</string>
3636
<string name="contests">Контесты</string>
3737

38-
<string name="google_calendar_not_found">Извините, но на этом устройстве не найден Календарь Google</string>
38+
<string name="google_calendar_not_found">Извините, но на этом устройстве не найден Google Calendar</string>
3939
</resources>

app/src/main/res/values-uk-rUA/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
<string name="users">Користувачі</string>
3636
<string name="contests">Контести</string>
3737

38-
<string name="google_calendar_not_found">На жаль, на цьому пристрої не знайдено Календаря Google</string>
38+
<string name="google_calendar_not_found">На жаль, на цьому пристрої не знайдено Google Calendar</string>
3939
</resources>

0 commit comments

Comments
 (0)