Revision 176308f8
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/dialog/RubikDialogPatternView.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.content.Context; |
23 | 23 |
import android.support.v4.app.FragmentActivity; |
24 |
import android.util.AttributeSet; |
|
24 | 25 |
import android.util.DisplayMetrics; |
25 | 26 |
import android.view.View; |
26 | 27 |
import android.widget.Button; |
... | ... | |
37 | 38 |
|
38 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 40 |
|
40 |
public RubikDialogPatternView(Context context) |
|
41 |
public RubikDialogPatternView(Context context, AttributeSet attrs, int defStyle)
|
|
41 | 42 |
{ |
42 |
super(context); |
|
43 |
super(context, attrs, defStyle); |
|
44 |
} |
|
45 |
|
|
46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
47 |
|
|
48 |
public RubikDialogPatternView(Context context, AttributeSet attrs) |
|
49 |
{ |
|
50 |
super(context, attrs); |
|
51 |
} |
|
43 | 52 |
|
44 |
View tab = inflate( context, R.layout.dialog_tab, null); |
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
public RubikDialogPatternView(FragmentActivity act, String[] categories) |
|
56 |
{ |
|
57 |
super(act); |
|
58 |
|
|
59 |
View tab = inflate( act, R.layout.dialog_tab, null); |
|
45 | 60 |
mLayout = tab.findViewById(R.id.tabLayout); |
61 |
createSection(act,categories); |
|
62 |
|
|
46 | 63 |
addView(tab); |
47 | 64 |
} |
48 | 65 |
|
49 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 67 |
|
51 |
LinearLayout createSection(FragmentActivity act, final String[] categories)
|
|
68 |
private void createSection(FragmentActivity act, final String[] categories)
|
|
52 | 69 |
{ |
53 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); |
|
54 |
LinearLayout layout = new LinearLayout(act); |
|
55 |
layout.setLayoutParams(params); |
|
56 |
layout.setOrientation(LinearLayout.VERTICAL); |
|
57 |
|
|
58 | 70 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
59 | 71 |
final float scale = metrics.density; |
60 | 72 |
int len = categories.length; |
... | ... | |
64 | 76 |
|
65 | 77 |
for(int i=0; i<len; i++) |
66 | 78 |
{ |
67 |
android.util.Log.e("view", "adding button "+i +" to layout!"); |
|
68 |
|
|
69 |
|
|
70 | 79 |
final int fi = i; |
71 | 80 |
Button button = new Button(act); |
72 | 81 |
button.setLayoutParams(bParams); |
... | ... | |
80 | 89 |
android.util.Log.e("view", "category "+categories[fi]+" clicked"); |
81 | 90 |
} |
82 | 91 |
}); |
83 |
} |
|
84 |
|
|
85 |
return layout; |
|
86 |
} |
|
87 | 92 |
|
88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
89 |
// needs to run on UI thread |
|
90 |
|
|
91 |
void addSection(LinearLayout section) |
|
92 |
{ |
|
93 |
android.util.Log.e("view", "adding section to tab!"); |
|
94 |
|
|
95 |
mLayout.addView(section); |
|
93 |
mLayout.addView(button); |
|
94 |
} |
|
96 | 95 |
} |
97 | 96 |
} |
Also available in: Unified diff
Progress with Pretty Patterns.