-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement showing pursuit/quest rewards (Closes #18)
- Loading branch information
Showing
11 changed files
with
144 additions
and
17 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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/xyz/omnicron/apps/android/dot/ui/objectives/RewardsAdapter.kt
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 xyz.omnicron.apps.android.dot.ui.objectives | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.squareup.picasso.Picasso | ||
import xyz.omnicron.apps.android.dot.R | ||
import xyz.omnicron.apps.android.dot.database.DestinyDatabaseItem | ||
import xyz.omnicron.apps.android.dot.databinding.RewardsListItemBinding | ||
|
||
class RewardsAdapter: RecyclerView.Adapter<RewardsAdapter.RewardsHolder>() { | ||
|
||
private var rewards = arrayListOf<DestinyDatabaseItem>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RewardsHolder { | ||
val inflatedView = LayoutInflater.from(parent.context).inflate(R.layout.rewards_list_item, parent, false) | ||
return RewardsHolder(inflatedView) | ||
} | ||
|
||
override fun onBindViewHolder(holder: RewardsHolder, position: Int) { | ||
holder.bindReward(rewards[position], holder.itemView.context) | ||
} | ||
|
||
override fun getItemCount(): Int = rewards.size | ||
|
||
fun setRewards(rewards: ArrayList<DestinyDatabaseItem>) { | ||
this.rewards = rewards | ||
} | ||
|
||
class RewardsHolder(private val baseView: View): RecyclerView.ViewHolder(baseView) { | ||
|
||
private val binding = RewardsListItemBinding.bind(baseView) | ||
|
||
fun bindReward(reward: DestinyDatabaseItem, ctx: Context) { | ||
binding.rewardDescription.text = reward.displayProperties?.name | ||
Picasso.with(ctx).load("https://bungie.net${reward.displayProperties!!.icon}").into(binding.rewardImage) | ||
} | ||
|
||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_height="wrap_content"> | ||
|
||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_margin="10dp" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<ImageView | ||
android:id="@+id/rewardImage" | ||
android:contentDescription="@string/pursuit_reward_description" | ||
tools:src="@drawable/reward_example_experience" | ||
android:layout_width="32dp" | ||
android:layout_height="32dp" /> | ||
|
||
<TextView | ||
android:id="@+id/rewardDescription" | ||
tools:text = "Test Item Entry" | ||
android:textStyle="bold" | ||
android:textColor="#FFFFFF" | ||
tools:textColor="#000000" | ||
android:layout_marginStart="15dp" | ||
android:layout_gravity="center_vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
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