Revision 804293f0
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java | ||
---|---|---|
38 | 38 |
import org.distorted.main.BuildConfig; |
39 | 39 |
import org.distorted.main.R; |
40 | 40 |
import org.distorted.main.RubikActivity; |
41 |
import org.distorted.objectlib.json.JsonReader; |
|
41 | 42 |
import org.distorted.objects.RubikObject; |
42 | 43 |
import org.distorted.objects.RubikObjectList; |
43 |
import org.distorted.tutorials.TutorialList; |
|
44 |
|
|
45 |
import java.io.InputStream; |
|
44 | 46 |
|
45 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 48 |
|
... | ... | |
68 | 70 |
{ |
69 | 71 |
super(act); |
70 | 72 |
|
71 |
clickPossible(true);
|
|
72 |
int widthT = (int)(width* RubikActivity.TUTORIAL_ITEM_TEXT);
|
|
73 |
InputStream jsonStream = RubikObjectList.getTutorialStream(position,act);
|
|
74 |
String[][] tutorials=null;
|
|
73 | 75 |
|
74 |
RubikActivity ract = (RubikActivity)getContext(); |
|
75 |
Resources res = act.getResources(); |
|
76 |
String packageName = act.getPackageName(); |
|
76 |
if( jsonStream!=null ) |
|
77 |
{ |
|
78 |
JsonReader reader = JsonReader.getInstance(); |
|
79 |
reader.parseJsonTutorial(jsonStream); |
|
80 |
tutorials = reader.getTutorials(); |
|
81 |
} |
|
77 | 82 |
|
78 |
TutorialList list = TutorialList.getObject(position); |
|
79 |
int object = list.getObject(); |
|
83 |
if( tutorials!=null ) |
|
84 |
{ |
|
85 |
clickPossible(true); |
|
86 |
int widthT = (int)(width* RubikActivity.TUTORIAL_ITEM_TEXT); |
|
80 | 87 |
|
81 |
View tab = inflate( act, R.layout.dialog_tutorial_tab, null); |
|
82 |
LinearLayout layout = tab.findViewById(R.id.tabLayout); |
|
88 |
RubikActivity ract = (RubikActivity)getContext(); |
|
89 |
Resources res = act.getResources(); |
|
90 |
String packageName = act.getPackageName(); |
|
83 | 91 |
|
84 |
int numTutorials = list.getNumTutorials(); |
|
92 |
View tab = inflate( act, R.layout.dialog_tutorial_tab, null); |
|
93 |
LinearLayout layout = tab.findViewById(R.id.tabLayout); |
|
85 | 94 |
|
86 |
int colorB = getResources().getColor(R.color.light_grey); |
|
87 |
int colorT = getResources().getColor(R.color.white); |
|
95 |
int colorB = getResources().getColor(R.color.light_grey);
|
|
96 |
int colorT = getResources().getColor(R.color.white);
|
|
88 | 97 |
|
89 |
for(int i=0; i<numTutorials; i++) |
|
90 |
{ |
|
91 |
String coun = list.getTutorialLanguage(i); |
|
92 |
String desc = list.getTutorialDescription(i); |
|
93 |
String url = list.getTutorialURL(i); |
|
94 |
String auth = list.getTutorialAuthor(i); |
|
98 |
int objectOrdinal = RubikObjectList.getObjectOrdinal(position); |
|
95 | 99 |
|
96 |
int countryID = res.getIdentifier( coun, "drawable", packageName); |
|
100 |
for (String[] tutorial : tutorials) |
|
101 |
{ |
|
102 |
String coun = tutorial[0]; |
|
103 |
String url = tutorial[1]; |
|
104 |
String desc = tutorial[2]; |
|
105 |
String auth = tutorial[3]; |
|
97 | 106 |
|
98 |
View row = createRow(ract,countryID,desc,url,auth,widthT,object,colorB,colorT); |
|
99 |
layout.addView(row); |
|
100 |
} |
|
107 |
int countryID = res.getIdentifier(coun, "drawable", packageName); |
|
101 | 108 |
|
102 |
addView(tab); |
|
109 |
View row = createRow(ract, countryID, desc, url, auth, widthT, objectOrdinal, colorB, colorT); |
|
110 |
layout.addView(row); |
|
111 |
} |
|
112 |
|
|
113 |
addView(tab); |
|
114 |
} |
|
103 | 115 |
} |
104 | 116 |
|
105 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Re-organize tutorial list so that we can pull this one from JSON files.