Skip to content

Commit bc461a0

Browse files
committed
Enhance TechnologyActivity and remove fragment_technology.xml
1 parent 9ce4ecd commit bc461a0

File tree

6 files changed

+117
-157
lines changed

6 files changed

+117
-157
lines changed

src/AndroidClient/techstacks/src/main/java/servicestack/net/techstacks/MainActivity.java

Lines changed: 14 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
218218
Intent intent = new Intent(getActivity(), TechnologyActivity.class);
219219
intent.putExtra("slug", result.getSlug());
220220
startActivity(intent);
221-
// getActivity().getSupportFragmentManager().beginTransaction()
222-
// .replace(R.id.pager, TechnologyFragment.create(result.getSlug())).commit();
223221
}
224222
});
225223

@@ -298,6 +296,7 @@ public static TechStacksFragment create(int sectionNumber) {
298296
public void onCreate(Bundle savedInstanceState) {
299297
super.onCreate(savedInstanceState);
300298
App.getData().addListener(this);
299+
App.getData().searchTechStacks("");
301300
}
302301

303302
@Override
@@ -312,13 +311,8 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
312311
App.getData().searchTechStacks(s.toString());
313312
}
314313

315-
@Override
316-
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
317-
}
318-
319-
@Override
320-
public void afterTextChanged(Editable s) {
321-
}
314+
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
315+
@Override public void afterTextChanged(Editable s) {}
322316
});
323317

324318
return rootView;
@@ -362,6 +356,7 @@ public static TechnologiesFragment create(int sectionNumber) {
362356
public void onCreate(Bundle savedInstanceState) {
363357
super.onCreate(savedInstanceState);
364358
App.getData().addListener(this);
359+
App.getData().searchTechnologies("");
365360
}
366361

367362
@Override
@@ -376,12 +371,18 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
376371
App.getData().searchTechnologies(s.toString());
377372
}
378373

379-
@Override
380-
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
381-
}
374+
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
375+
@Override public void afterTextChanged(Editable s) {}
376+
});
382377

378+
ListView list = (ListView) rootView.findViewById(R.id.listTechnologies);
379+
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
383380
@Override
384-
public void afterTextChanged(Editable s) {
381+
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
382+
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);
385386
}
386387
});
387388

@@ -412,68 +413,4 @@ public String apply(Technology o) {
412413
}
413414
}
414415
}
415-
416-
public static class TechnologyFragment extends Fragment implements App.AppDataListener {
417-
String slug;
418-
419-
public static TechnologyFragment create(String slug) {
420-
TechnologyFragment fragment = new TechnologyFragment();
421-
Bundle args = new Bundle();
422-
args.putString("slug", slug);
423-
fragment.setArguments(args);
424-
return fragment;
425-
}
426-
427-
@Override
428-
public void onCreate(Bundle savedInstanceState) {
429-
super.onCreate(savedInstanceState);
430-
App.getData().addListener(this);
431-
}
432-
433-
@Override
434-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
435-
Bundle savedInstanceState) {
436-
437-
App.getData().loadTechnology(getArguments().getString("slug"));
438-
439-
View rootView = inflater.inflate(R.layout.fragment_technology, container, false);
440-
441-
return rootView;
442-
}
443-
444-
@Override
445-
public void onUpdate(App.AppData data, App.DataType dataType) {
446-
switch (dataType){
447-
case Technology:
448-
449-
GetTechnologyResponse result = data.getTechnology();
450-
TextView lblName = (TextView) getActivity().findViewById(R.id.lblTechnologyName);
451-
if (lblName == null) return;
452-
lblName.setText(result.getTechnology().getName());
453-
454-
TextView lblVendor = (TextView) getActivity().findViewById(R.id.lblTechnologyVendor);
455-
if (lblVendor == null) return;
456-
lblVendor.setText(result.getTechnology().getVendorName());
457-
458-
TextView lblVendorUrl = (TextView) getActivity().findViewById(R.id.lblTechnologyVendorUrl);
459-
if (lblVendorUrl == null) return;
460-
lblVendorUrl.setText(result.getTechnology().getVendorUrl());
461-
462-
String logoUrl = result.getTechnology().getLogoUrl();
463-
if (logoUrl == null) return;
464-
final ImageView imgLogo = (ImageView) getActivity().findViewById(R.id.imgTechnologyLogo);
465-
if (imgLogo == null) return;
466-
467-
data.loadImage(logoUrl, new App.ImageResult() {
468-
@Override
469-
public void success(Bitmap img) {
470-
imgLogo.setImageBitmap(img);
471-
}
472-
});
473-
474-
break;
475-
}
476-
}
477-
478-
}
479416
}

src/AndroidClient/techstacks/src/main/java/servicestack/net/techstacks/TechnologyActivity.java

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
package servicestack.net.techstacks;
22

33
import android.app.Activity;
4+
import android.content.Intent;
45
import android.graphics.Bitmap;
6+
import android.net.Uri;
57
import android.os.Bundle;
8+
import android.view.View;
9+
import android.widget.ArrayAdapter;
610
import android.widget.ImageView;
11+
import android.widget.ListView;
712
import android.widget.TextView;
813

14+
import net.servicestack.client.Utils;
15+
16+
import java.util.ArrayList;
17+
18+
import servicestack.net.techstacks.dto.GetTechnologyResponse;
19+
import servicestack.net.techstacks.dto.TechnologyStack;
20+
21+
import static net.servicestack.client.Func.*;
22+
923
public class TechnologyActivity extends Activity implements App.AppDataListener {
1024

1125
@Override
@@ -16,6 +30,35 @@ protected void onCreate(Bundle savedInstanceState) {
1630

1731
Bundle extras = getIntent().getExtras();
1832
App.getData().loadTechnology(extras.getString("slug"));
33+
34+
setLoadingTextViews(
35+
R.id.lblTechnologyName,
36+
R.id.lblTechnologyVendor,
37+
R.id.lblTechnologyVendorUrl,
38+
R.id.lblTechnologyDescription);
39+
40+
ImageView imgLogo = (ImageView) findViewById(R.id.imgTechnologyLogo);
41+
imgLogo.setImageBitmap(null);
42+
43+
TextView url = (TextView)findViewById(R.id.lblTechnologyVendorUrl);
44+
url.setOnClickListener(new View.OnClickListener() {
45+
@Override
46+
public void onClick(View v){
47+
GetTechnologyResponse result = App.getData().getTechnology();
48+
if (result == null) return;
49+
String url = result.getTechnology().getVendorUrl();
50+
if (url == null) return;
51+
52+
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
53+
}
54+
});
55+
}
56+
57+
void setLoadingTextViews(int... viewIds){
58+
for (int viewId : viewIds){
59+
TextView txtView = (TextView)findViewById(viewId);
60+
txtView.setText("Loading...");
61+
}
1962
}
2063

2164
public Activity getActivity(){
@@ -27,7 +70,7 @@ public void onUpdate(App.AppData data, App.DataType dataType) {
2770
switch (dataType){
2871
case Technology:
2972

30-
dto.GetTechnologyResponse result = data.getTechnology();
73+
GetTechnologyResponse result = data.getTechnology();
3174
TextView lblName = (TextView) getActivity().findViewById(R.id.lblTechnologyName);
3275
if (lblName == null) return;
3376
lblName.setText(result.getTechnology().getName());
@@ -38,19 +81,33 @@ public void onUpdate(App.AppData data, App.DataType dataType) {
3881

3982
TextView lblVendorUrl = (TextView) getActivity().findViewById(R.id.lblTechnologyVendorUrl);
4083
if (lblVendorUrl == null) return;
41-
lblVendorUrl.setText(result.getTechnology().getVendorUrl());
84+
lblVendorUrl.setText(Utils.toHumanFriendlyUrl(result.getTechnology().getVendorUrl()));
85+
86+
TextView lblDescription = (TextView) getActivity().findViewById(R.id.lblTechnologyDescription);
87+
if (lblDescription == null) return;
88+
lblDescription.setText(result.getTechnology().getDescription());
4289

4390
String logoUrl = result.getTechnology().getLogoUrl();
44-
if (logoUrl == null) return;
45-
final ImageView imgLogo = (ImageView) getActivity().findViewById(R.id.imgTechnologyLogo);
46-
if (imgLogo == null) return;
91+
if (logoUrl != null){
92+
final ImageView imgLogo = (ImageView) getActivity().findViewById(R.id.imgTechnologyLogo);
93+
if (imgLogo == null) return;
94+
95+
data.loadImage(logoUrl, new App.ImageResult() {
96+
@Override
97+
public void success(Bitmap img) {
98+
imgLogo.setImageBitmap(img);
99+
}
100+
});
101+
}
47102

48-
data.loadImage(logoUrl, new App.ImageResult() {
103+
ListView list = (ListView)getActivity().findViewById(R.id.listTechnologyTechStacks);
104+
ArrayList<String> stackNames = map(result.getTechnologyStacks(), new Function<TechnologyStack,String>(){
49105
@Override
50-
public void success(Bitmap img) {
51-
imgLogo.setImageBitmap(img);
106+
public String apply(TechnologyStack x) {
107+
return x.getName();
52108
}
53109
});
110+
list.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, stackNames));
54111

55112
break;
56113
}
17.9 KB
Loading
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager"
33
android:layout_width="match_parent" android:layout_height="match_parent"
4-
tools:context=".MainActivity" />
4+
tools:context=".MainActivity"
5+
android:background="#ffffffff" />
Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,69 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:orientation="vertical" android:layout_width="match_parent"
4-
android:layout_height="match_parent">
3+
android:orientation="vertical"
4+
android:layout_height="match_parent"
5+
android:layout_width="fill_parent"
6+
android:weightSum="1.0"
7+
android:background="#ffffffff">
58

69
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
710
android:layout_width="fill_parent"
8-
android:layout_height="fill_parent"
9-
android:orientation="horizontal" >
11+
android:layout_height="100dp"
12+
android:orientation="horizontal"
13+
android:paddingTop="5dp"
14+
android:paddingLeft="10dp"
15+
android:paddingRight="5dp">
1016

1117
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
12-
android:layout_width="fill_parent"
13-
android:layout_height="fill_parent"
14-
android:orientation="vertical" >
18+
android:layout_width="0dp"
19+
android:layout_height="match_parent"
20+
android:orientation="vertical"
21+
android:layout_weight=".5">
1522

1623
<TextView
1724
android:id="@+id/lblTechnologyName"
1825
android:layout_width="wrap_content"
1926
android:layout_height="wrap_content"
20-
android:text="Name"/>
27+
android:text="Name"
28+
android:textSize="24dp"
29+
android:textColor="#ff212121" />
2130

2231
<TextView
2332
android:id="@+id/lblTechnologyVendor"
2433
android:layout_width="wrap_content"
2534
android:layout_height="wrap_content"
26-
android:text="Vendor"/>
35+
android:text="Vendor"
36+
android:textSize="14dp"
37+
android:textColor="#ff212121" />
2738
</LinearLayout>
2839

2940
<ImageView
3041
android:id="@+id/imgTechnologyLogo"
31-
android:layout_width="wrap_content"
32-
android:layout_height="wrap_content" />
42+
android:layout_height="wrap_content"
43+
android:layout_weight=".5"
44+
android:layout_width="0dip"/>
3345

3446
</LinearLayout>
3547

3648
<TextView
3749
android:id="@+id/lblTechnologyVendorUrl"
3850
android:layout_width="wrap_content"
3951
android:layout_height="wrap_content"
40-
android:text="url.com"/>
52+
android:text="url.com"
53+
android:paddingLeft="10dp"
54+
android:textColor="#ff03a9f4"
55+
android:textSize="14dp" />
56+
57+
<TextView
58+
android:layout_width="fill_parent"
59+
android:layout_height="wrap_content"
60+
android:text="New Text"
61+
android:id="@+id/lblTechnologyDescription"
62+
android:padding="10dp" />
4163

4264
<ListView
4365
android:id="@+id/listTechnologyTechStacks"
44-
android:layout_width="fill_parent"
45-
android:layout_height="wrap_content" />
66+
android:layout_height="wrap_content"
67+
android:layout_width="wrap_content" />
4668

4769
</LinearLayout>

src/AndroidClient/techstacks/src/main/res/layout/fragment_technology.xml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)