-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonAdapter.java
More file actions
70 lines (54 loc) · 1.54 KB
/
Copy pathButtonAdapter.java
File metadata and controls
70 lines (54 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.testyourself.adapter;
import com.testyourself.knowyoursport.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class ButtonAdapter extends BaseAdapter {
private final String PREFS_NAME="football";
Boolean[] getAnswered=new Boolean[200];
Boolean answered;
private Context context;
private Integer[] imageIds = new Integer[200];
public ButtonAdapter(Context c) {
context = c;
}
public int getCount() {
return imageIds.length;
}
public Object getItem(int position) {
return imageIds[position];
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View view, ViewGroup parent) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME,context.MODE_PRIVATE);
final int maxUnlockedLevel = prefs.getInt("maxUnlockedLevel", 1);
final boolean answered=prefs.getBoolean("getAnswered_"+(position+1), false);
View gridView;
if(view==null)
{
gridView = new View(context);
gridView.setPadding(5, 5, 5, 5);
}
else
{
gridView=(View) view;
}
if(answered)
{
gridView.setBackgroundResource(R.drawable.correct_btn);
}
else if(position<=maxUnlockedLevel)
{
gridView.setBackgroundResource(R.drawable.unlocked_btn);
}
else
{
gridView.setBackgroundResource(R.drawable.locked_btn);
}
return gridView;
}
}