First call and ui started

This commit is contained in:
Tim Bentley 2015-11-21 09:50:04 +00:00
parent 0bdb67e780
commit bb67f7a737
4 changed files with 94 additions and 76 deletions

View File

@ -42,7 +42,6 @@ import android.widget.AdapterView;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SimpleAdapter; import android.widget.SimpleAdapter;
import android.widget.Toast;
import org.openlp.android2.R; import org.openlp.android2.R;
@ -153,8 +152,8 @@ public class NavigationDrawerFragment extends Fragment {
aList.add(hm4); aList.add(hm4);
HashMap<String, String> hm5 = new HashMap<String, String>(); HashMap<String, String> hm5 = new HashMap<String, String>();
hm4.put("title", getString(R.string.action_search)); hm5.put("title", getString(R.string.action_search));
hm4.put("icon", Integer.toString(R.drawable.ic_ondemand_video_black)); hm5.put("icon", Integer.toString(R.drawable.ic_ondemand_video_black));
aList.add(hm5); aList.add(hm5);
// Keys used in Hashmap // Keys used in Hashmap

View File

@ -1,30 +1,28 @@
package org.openlp.android2.fragments; package org.openlp.android2.fragments;
import android.app.Activity;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.app.Fragment; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast;
import org.openlp.android2.R; import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.OpenLPFragment;
import org.openlp.android2.common.OpenLPHttpClient;
/** /**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link SearchFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link SearchFragment#newInstance} factory method to
* create an instance of this fragment.
*/ */
public class SearchFragment extends Fragment { public class SearchFragment extends OpenLPFragment {
private final String LOG_TAG = SearchFragment.class.getName();
private OnFragmentInteractionListener mListener;
public SearchFragment() { public SearchFragment() {
// Required empty public constructor Log.d(LOG_TAG, "Constructor");
} }
public static SearchFragment newInstance() { public static SearchFragment newInstance() {
@ -37,51 +35,49 @@ public class SearchFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle savedInstanceState) { context = getActivity();
// Inflate the layout for this fragment updateUrl = Api.SERVICE_LIST;
return inflater.inflate(R.layout.fragment_search, container, false); httpClient = new OpenLPHttpClient(context);
} return super.onCreateView(inflater, container, savedInstanceState);
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
} }
@Override @Override
public void onAttach(Activity activity) { public void onResume() {
super.onAttach(activity); super.onResume();
try { Log.d(LOG_TAG, "Resuming...");
mListener = (OnFragmentInteractionListener) activity; triggerTextRequest(Api.SEARCHABLE_PLUGINS);
} catch (ClassCastException e) { Log.d(LOG_TAG, "Resumed...");
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
}
} }
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();
mListener = null;
} }
/** public void manageResponse(String response, boolean notInError) {
* This interface must be implemented by activities that contain this if (calledURL.equals(updateUrl)) {
* fragment to allow an interaction in this fragment to be communicated populateTabDisplay(response);
* to the activity and potentially other fragments contained in that }else {
* activity. processUpdate(response, notInError);
* <p/> }
* See the Android Training lesson <a href= }
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information. private void populateTabDisplay(String response){
*/ int a = 1;
public interface OnFragmentInteractionListener { }
// TODO: Update argument type and name
public void onFragmentInteraction(Uri uri); public void itemClicked(int position) {
try {
String request = JsonHelpers.createRequestJSON("id", Integer.toString(position));
triggerTextRequest(String.format("%s%s", Api.SERVICE_SET, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), position(%s)",
Api.SERVICE_SET, position));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
}
} }
} }

View File

@ -2,26 +2,37 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="org.openlp.android2.fragments.SearchFragment"> tools:context="org.openlp.android2.fragments.SearchFragment"
android:id="@+id/search_layout">
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:id="@+id/fragmentsearchlist"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"> android:layout_gravity="center_horizontal|top"
android:weightSum="1">
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
android:id="@+id/fragmentsearchdetails"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:weightSum="1"> android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Plugin"
android:id="@+id/search_title"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner <Spinner
android:layout_width="288dp" android:layout_width="288dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/serach_spinner" android:id="@+id/search_spinner"
android:layout_weight="0.58" /> android:layout_weight="0.58" />
<SearchView <SearchView
@ -32,18 +43,41 @@
</LinearLayout> </LinearLayout>
<TextView <LinearLayout
android:id="@+id/SearchResultsList" android:orientation="horizontal"
android:layout_width="wrap_content" android:id="@+id/fragmentsearchvalue"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" android:weightSum="1">
android:textColor="#000000"
android:textSize="14sp" <TextView
android:paddingTop="10dp" android:layout_width="wrap_content"
android:paddingRight="5dp" android:layout_height="wrap_content"
android:paddingLeft="5dp" android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingEnd="5dp" android:text="Search Text"
android:paddingBottom="10dp" /> android:id="@+id/search_value_desc" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/search_text"
style="@android:style/Animation.InputMethod"
android:layout_weight="0.87" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragmentsearchresults"
android:weightSum="1">
<ListView
android:layout_width="wrap_content"
android:layout_height="333dp"
android:id="@+id/searchresultsdetails" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -29,7 +29,7 @@
<string name="display_blank_summary">Select the required display</string> <string name="display_blank_summary">Select the required display</string>
<string name="display_desktop">Display Desktop background</string> <string name="display_desktop">Display Desktop background</string>
<string name="display_list_autoscroll">Allow the selected item to scroll to the centre of the list</string> <string name="display_list_autoscroll">Allow the selected item to scroll to the centre of the list</string>
<string name="display_reset">Show Live display</string> <string name="display_reset">Live display</string>
<string name="display_settings">Display Setting</string> <string name="display_settings">Display Setting</string>
<string name="display_screen">Display Black only</string> <string name="display_screen">Display Black only</string>
<string name="display_theme">Display Theme only</string> <string name="display_theme">Display Theme only</string>
@ -45,14 +45,6 @@
<string name="next">Next</string> <string name="next">Next</string>
<string name="none">None</string> <string name="none">None</string>
<string name="port">Port</string> <string name="port">Port</string>
<string-array name="plugins_array">
<item>Songs</item>
<item>Bibles</item>
<item>Presentations</item>
<item>Images</item>
<item>Media</item>
<item>Custom</item>
</string-array>
<string name="previous">Previous</string> <string name="previous">Previous</string>
<string name="process">Process</string> <string name="process">Process</string>
<string name="service_list">Service List</string> <string name="service_list">Service List</string>
@ -62,7 +54,4 @@
<string name="title_activity_settings">Settings</string> <string name="title_activity_settings">Settings</string>
<string name="url_hint">Hostname or IP</string> <string name="url_hint">Hostname or IP</string>
<string name="unable">Unable to process request - check network settings</string> <string name="unable">Unable to process request - check network settings</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>