Skip to content

Commit

Permalink
Display Parent/Children units for PlacesResultTask
Browse files Browse the repository at this point in the history
  • Loading branch information
famanson committed Oct 5, 2011
1 parent 1facd23 commit 3f2683f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions .classpath
Expand Up @@ -8,5 +8,6 @@
<classpathentry kind="lib" path="libs/osmdroid-android-3.0.5.jar"/>
<classpathentry kind="lib" path="libs/roboguice-1.1.2.jar"/>
<classpathentry kind="lib" path="libs/slf4j-android-1.5.8.jar"/>
<classpathentry kind="lib" path="libs/ical4j-1.0.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file modified bin/mollyandroid.apk
Binary file not shown.
Expand Up @@ -19,11 +19,13 @@
import org.osmdroid.views.overlay.OverlayItem;

import android.content.Intent;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class PlacesResultsTask extends JSONProcessingTask
{
Expand Down Expand Up @@ -57,7 +59,15 @@ public void onClick(View v) {
}
});
unitLayout.setLayoutParams(Page.paramsWithLine);
unitText.setText(oxpoint);

if (jsonValue.has("title"))
{
unitText.setText("title");
}
else
{
unitText.setText(oxpoint);
}
return unitLayout;
}

Expand All @@ -84,6 +94,43 @@ public void updateView(JSONObject jsonContent) {
jsonOxpoints.getDouble("geo_long"));

//extra information: parent unit
if (entity.has("parent"))
{
if (!entity.isNull("parent"))
{
LinearLayout parentLayout = (LinearLayout) page.getLayoutInflater().inflate
(R.layout.general_search_results_page, null);
parentLayout.setBackgroundResource(R.drawable.shape_white);
TextView headerText = (TextView) parentLayout.findViewById(R.id.searchResultsHeader);
headerText.setText("Parent unit:");
headerText.setTextColor(Color.BLACK);
page.getContentLayout().addView(parentLayout);

final JSONObject parentUnit = entity.getJSONObject("parent");
//LinearLayout parent = parseOxpoint(parentUnit, page);
LinearLayout parent = (LinearLayout) page.getLayoutInflater().inflate(R.layout.clickable_search_result, null);
((TextView) parent.findViewById(R.id.clickableResultText)).setText(parentUnit.getString("title"));

parent.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
MyApplication.placesArgs[0] = parentUnit.getString("identifier_scheme");
MyApplication.placesArgs[1] = parentUnit.getString("identifier_value");
Intent myIntent = new Intent(page.getApplicationContext(), MyApplication.getPageClass(MollyModule.PLACES_ENTITY));
page.startActivityForResult(myIntent, 0);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(page.getApplicationContext(), "This operation is currently not available. Please try again later.",
Toast.LENGTH_SHORT).show();
}
}
});
parent.setLayoutParams(Page.paramsWithLine);
parentLayout.addView(parent);
}
}
/*
if (jsonOxpoints.has("dct_isPartOf"))
{
if (!jsonOxpoints.isNull("dct_isPartOf"))
Expand All @@ -92,17 +139,29 @@ public void updateView(JSONObject jsonContent) {
LinearLayout parent = parseOxpoint(parentUnit, page);
page.getContentLayout().addView(parent);
}
}
}*/

//extra info: children units
if (jsonOxpoints.has("passiveProperties"))
{
JSONObject passiveProperties = jsonOxpoints.getJSONObject("passiveProperties");
if (passiveProperties.has("dct_isPartOf"))
{
JSONArray children = passiveProperties.getJSONArray("dct_isPartOf");

LinearLayout childrenLayout = (LinearLayout) page.getLayoutInflater().inflate
(R.layout.general_search_results_page, null);
childrenLayout.setBackgroundResource(R.drawable.shape_white);
TextView headerText = (TextView) childrenLayout.findViewById(R.id.searchResultsHeader);
headerText.setText("Children unit(s):");
headerText.setTextColor(Color.BLACK);
page.getContentLayout().addView(childrenLayout);

for (int i = 0; i < children.length(); i++)
{
page.getContentLayout().addView(parseOxpoint(children.getJSONObject(i), page));
LinearLayout child = parseOxpoint(children.getJSONObject(i), page);
child.setLayoutParams(Page.paramsWithLine);
childrenLayout.addView(child);
}
}
}
Expand Down

0 comments on commit 3f2683f

Please sign in to comment.