Revision 054fbee1
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/dialogs/RubikDialogPatternListAdapter.java | ||
|---|---|---|
| 26 | 26 |
import android.widget.BaseExpandableListAdapter; |
| 27 | 27 |
import android.widget.TextView; |
| 28 | 28 |
|
| 29 |
import org.distorted.main.RubikActivity; |
|
| 29 | 30 |
import org.distorted.patterns.RubikPattern; |
| 30 | 31 |
import org.distorted.main.R; |
| 31 | 32 |
|
| ... | ... | |
| 34 | 35 |
class RubikDialogPatternListAdapter extends BaseExpandableListAdapter |
| 35 | 36 |
{
|
| 36 | 37 |
private Context mContext; |
| 37 |
private int mTab; |
|
| 38 |
private int mTab, mWidth;
|
|
| 38 | 39 |
|
| 39 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 | 41 |
|
| 41 |
public RubikDialogPatternListAdapter(Context context, int tab) |
|
| 42 |
public RubikDialogPatternListAdapter(Context context, int tab, int width)
|
|
| 42 | 43 |
{
|
| 43 | 44 |
mContext = context; |
| 44 | 45 |
mTab = tab; |
| 46 |
mWidth = width; |
|
| 45 | 47 |
} |
| 46 | 48 |
|
| 47 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 74 | 76 |
view = infalInflater.inflate(R.layout.dialog_pattern_child_item, null); |
| 75 | 77 |
} |
| 76 | 78 |
|
| 77 |
TextView sequence = view.findViewById(R.id.sequence);
|
|
| 78 |
sequence.setText(mContext.getString(R.string.sq_placeholder,childPosition+1)); |
|
| 79 |
TextView childItem = view.findViewById(R.id.childItem);
|
|
| 79 |
int size = (int)(mWidth* RubikActivity.PATTERN_CHILD_TEXT);
|
|
| 80 |
|
|
| 81 |
TextView childItem = view.findViewById(R.id.child); |
|
| 80 | 82 |
childItem.setText(childName); |
| 83 |
childItem.setTextSize(size); |
|
| 81 | 84 |
|
| 82 | 85 |
return view; |
| 83 | 86 |
} |
| ... | ... | |
| 130 | 133 |
view = inf.inflate(R.layout.dialog_pattern_group_item, null); |
| 131 | 134 |
} |
| 132 | 135 |
|
| 136 |
int size = (int)(mWidth* RubikActivity.PATTERN_GROUP_TEXT); |
|
| 137 |
|
|
| 133 | 138 |
TextView heading = view.findViewById(R.id.heading); |
| 134 | 139 |
heading.setText(groupName); |
| 140 |
heading.setTextSize(size); |
|
| 141 |
|
|
| 142 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
| 143 |
int numPatterns = pattern.getNumPatterns(mTab,groupPosition); |
|
| 144 |
TextView counter = view.findViewById(R.id.counter); |
|
| 145 |
counter.setText(String.format("%d", numPatterns));
|
|
| 146 |
counter.setTextSize(size); |
|
| 135 | 147 |
|
| 136 | 148 |
return view; |
| 137 | 149 |
} |
Also available in: Unified diff
Reinvent the Pattern Dialog (Part 2)