SHOW:
|
|
- or go back to the newest paste.
| 1 | package se.illusionlabs.labyrinth2.adapters; | |
| 2 | ||
| 3 | import java.util.ArrayList; | |
| 4 | ||
| 5 | - | import se.illusionlabs.labyrinth2.managers.AwardManager; |
| 5 | + | |
| 6 | - | import se.illusionlabs.labyrinth2.views.ProgressBarView; |
| 6 | + | |
| 7 | import android.content.Context; | |
| 8 | import android.database.DataSetObserver; | |
| 9 | import android.view.View; | |
| 10 | import android.view.ViewGroup; | |
| 11 | import android.widget.ListAdapter; | |
| 12 | - | import android.widget.ImageView; |
| 12 | + | |
| 13 | public class SettingsListAdapter implements ListAdapter {
| |
| 14 | - | import android.widget.TextView; |
| 14 | + | ArrayList<View> views; |
| 15 | ||
| 16 | - | public class AwardsAdapter implements ListAdapter {
|
| 16 | + | public SettingsListAdapter(Context context) |
| 17 | - | private int[] awards; |
| 17 | + | |
| 18 | - | private Context context; |
| 18 | + | views = new ArrayList<View>(); |
| 19 | views.add(View.inflate(context, R.layout.calibrationitem, null)); | |
| 20 | - | public AwardsAdapter(Context context) |
| 20 | + | views.add(View.inflate(context, R.layout.soundsettingitem, null)); |
| 21 | views.add(View.inflate(context, R.layout.tiltitem, null)); | |
| 22 | - | this.context = context; |
| 22 | + | |
| 23 | - | awards = AwardManager.getAwardArray(); |
| 23 | + | |
| 24 | @Override | |
| 25 | public int getCount() {
| |
| 26 | return views.size(); | |
| 27 | } | |
| 28 | - | return awards.length; |
| 28 | + | |
| 29 | @Override | |
| 30 | public Object getItem(int position) {
| |
| 31 | return null; | |
| 32 | } | |
| 33 | ||
| 34 | @Override | |
| 35 | public long getItemId(int position) {
| |
| 36 | return position; | |
| 37 | } | |
| 38 | ||
| 39 | @Override | |
| 40 | public int getItemViewType(int position) {
| |
| 41 | return position; | |
| 42 | } | |
| 43 | ||
| 44 | @Override | |
| 45 | public View getView(int position, View convertView, ViewGroup parent) {
| |
| 46 | return views.get(position); | |
| 47 | } | |
| 48 | - | int awardId = awards[position]; |
| 48 | + | |
| 49 | - | |
| 49 | + | |
| 50 | - | View v = View.inflate(context, R.layout.awardlistitem, null); |
| 50 | + | |
| 51 | - | TextView tv = (TextView)v.findViewById(R.id.AwardName); |
| 51 | + | return views.size(); |
| 52 | - | tv.setText(AwardManager.getAwardName(awardId)); |
| 52 | + | |
| 53 | - | tv = (TextView)v.findViewById(R.id.AwardDesc); |
| 53 | + | |
| 54 | - | tv.setText(AwardManager.getAwardDesc(awardId)); |
| 54 | + | |
| 55 | public boolean hasStableIds() {
| |
| 56 | - | View lv = v.findViewById(R.id.AwardListItem); |
| 56 | + | |
| 57 | - | ImageView iv = (ImageView)v.findViewById(R.id.AwardImage); |
| 57 | + | |
| 58 | - | ProgressBarView pv = (ProgressBarView)v.findViewById(R.id.AwardProgress); |
| 58 | + | |
| 59 | - | pv.setProgress(AwardManager.getAwardProgress(awardId)); |
| 59 | + | |
| 60 | - | if(AwardManager.getAwardAchieved(awardId)) {
|
| 60 | + | |
| 61 | - | lv.setBackgroundResource(R.color.achived_award); |
| 61 | + | |
| 62 | - | iv.setImageResource(getAwardIcon(AwardManager.getAwardId(awardId))); |
| 62 | + | |
| 63 | - | pv.setBgColor(0xff70754a); |
| 63 | + | |
| 64 | - | pv.setFgColor(0xff8fab30); |
| 64 | + | |
| 65 | - | } else {
|
| 65 | + | |
| 66 | - | lv.setBackgroundResource(R.color.notachived_award); |
| 66 | + | |
| 67 | - | iv.setImageResource(R.drawable.award_icon_notachieved); |
| 67 | + | |
| 68 | - | pv.setBgColor(0xffa6a394); |
| 68 | + | |
| 69 | - | pv.setFgColor(0xff549ea6); |
| 69 | + | |
| 70 | - | } |
| 70 | + | |
| 71 | - | |
| 71 | + | |
| 72 | - | return v; |
| 72 | + | |
| 73 | public boolean areAllItemsEnabled() {
| |
| 74 | return false; | |
| 75 | } | |
| 76 | ||
| 77 | - | return awards.length; |
| 77 | + | |
| 78 | public boolean isEnabled(int arg0) {
| |
| 79 | return false; | |
| 80 | } | |
| 81 | ||
| 82 | } |