11package servicestack .net .techstacks ;
22
3- import android .content .Intent ;
4- import android .graphics .Bitmap ;
5- import android .support .v7 .app .ActionBarActivity ;
6- import android .support .v7 .app .ActionBar ;
3+ import android .os .Bundle ;
74import android .support .v4 .app .Fragment ;
85import android .support .v4 .app .FragmentManager ;
9- import android .support .v4 .app .FragmentTransaction ;
106import android .support .v4 .app .FragmentPagerAdapter ;
11- import android .os . Bundle ;
7+ import android .support . v4 . app . FragmentTransaction ;
128import android .support .v4 .view .ViewPager ;
9+ import android .support .v7 .app .ActionBar ;
10+ import android .support .v7 .app .ActionBarActivity ;
1311import android .text .Editable ;
1412import android .text .TextWatcher ;
1513import android .view .LayoutInflater ;
2018import android .widget .AdapterView ;
2119import android .widget .ArrayAdapter ;
2220import android .widget .EditText ;
23- import android .widget .ImageView ;
2421import android .widget .ListView ;
2522import android .widget .Spinner ;
26- import android .widget .TextView ;
2723
2824import com .android .internal .util .Predicate ;
2925
30- import static net .servicestack .client .Func .*;
31-
3226import java .util .ArrayList ;
3327
34- import static net .servicestack .client .Func .map ;
28+ import servicestack .net .techstacks .dto .Option ;
29+ import servicestack .net .techstacks .dto .Technology ;
30+ import servicestack .net .techstacks .dto .TechnologyInfo ;
31+ import servicestack .net .techstacks .dto .TechnologyStack ;
3532
36- import servicestack .net .techstacks .dto .*;
33+ import static net .servicestack .client .Func .Function ;
34+ import static net .servicestack .client .Func .filter ;
35+ import static net .servicestack .client .Func .map ;
3736
3837public class MainActivity extends ActionBarActivity implements ActionBar .TabListener {
3938
@@ -177,11 +176,7 @@ public static class TopRatedFragment extends Fragment implements App.AppDataList
177176 Option selectedCategory ;
178177
179178 public static TopRatedFragment create (int sectionNumber ) {
180- TopRatedFragment fragment = new TopRatedFragment ();
181- Bundle args = new Bundle ();
182- args .putInt ("sectionNumber" , sectionNumber );
183- fragment .setArguments (args );
184- return fragment ;
179+ return new TopRatedFragment ();
185180 }
186181
187182 @ Override
@@ -215,9 +210,7 @@ public void onNothingSelected(AdapterView<?> parent) {
215210 @ Override
216211 public void onItemClick (AdapterView <?> parent , View view , int position , long id ) {
217212 TechnologyInfo result = getTopTechnologies (App .getData ()).get (position );
218- Intent intent = new Intent (getActivity (), TechnologyActivity .class );
219- intent .putExtra ("slug" , result .getSlug ());
220- startActivity (intent );
213+ App .openTechnology (getActivity (), result .getSlug ());
221214 }
222215 });
223216
@@ -285,18 +278,15 @@ public boolean apply(TechnologyInfo tech) {
285278
286279 public static class TechStacksFragment extends Fragment implements App .AppDataListener {
287280 public static TechStacksFragment create (int sectionNumber ) {
288- TechStacksFragment fragment = new TechStacksFragment ();
289- Bundle args = new Bundle ();
290- args .putInt ("sectionNumber" , sectionNumber );
291- fragment .setArguments (args );
292- return fragment ;
281+ return new TechStacksFragment ();
293282 }
294283
295284 @ Override
296285 public void onCreate (Bundle savedInstanceState ) {
297286 super .onCreate (savedInstanceState );
298- App .getData ().addListener (this );
299- App .getData ().searchTechStacks ("" );
287+ App .getData ()
288+ .addListener (this )
289+ .searchTechStacks ("" );
300290 }
301291
302292 @ Override
@@ -315,6 +305,15 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
315305 @ Override public void afterTextChanged (Editable s ) {}
316306 });
317307
308+ ListView list = (ListView ) rootView .findViewById (R .id .listTechStacks );
309+ list .setOnItemClickListener (new AdapterView .OnItemClickListener () {
310+ @ Override
311+ public void onItemClick (AdapterView <?> parent , View view , int position , long id ) {
312+ TechnologyStack result = App .getData ().getSearchTechStacksResponse ().getResults ().get (position );
313+ App .openTechStack (getActivity (), result .getSlug ());
314+ }
315+ });
316+
318317 return rootView ;
319318 }
320319
@@ -345,18 +344,15 @@ public String apply(TechnologyStack o) {
345344
346345 public static class TechnologiesFragment extends Fragment implements App .AppDataListener {
347346 public static TechnologiesFragment create (int sectionNumber ) {
348- TechnologiesFragment fragment = new TechnologiesFragment ();
349- Bundle args = new Bundle ();
350- args .putInt ("sectionNumber" , sectionNumber );
351- fragment .setArguments (args );
352- return fragment ;
347+ return new TechnologiesFragment ();
353348 }
354349
355350 @ Override
356351 public void onCreate (Bundle savedInstanceState ) {
357352 super .onCreate (savedInstanceState );
358- App .getData ().addListener (this );
359- App .getData ().searchTechnologies ("" );
353+ App .getData ()
354+ .addListener (this )
355+ .searchTechnologies ("" );
360356 }
361357
362358 @ Override
@@ -380,9 +376,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
380376 @ Override
381377 public void onItemClick (AdapterView <?> parent , View view , int position , long id ) {
382378 Technology result = App .getData ().getSearchTechnologiesResponse ().getResults ().get (position );
383- Intent intent = new Intent (getActivity (), TechnologyActivity .class );
384- intent .putExtra ("slug" , result .getSlug ());
385- startActivity (intent );
379+ App .openTechnology (getActivity (), result .getSlug ());
386380 }
387381 });
388382
0 commit comments