1
0
mirror of https://gitlab.com/openlp/android.git synced 2024-12-22 03:42:48 +00:00

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

View File

@ -1,30 +1,28 @@
package org.openlp.android2.fragments;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
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 OnFragmentInteractionListener mListener;
private final String LOG_TAG = SearchFragment.class.getName();
public SearchFragment() {
// Required empty public constructor
Log.d(LOG_TAG, "Constructor");
}
public static SearchFragment newInstance() {
@ -37,51 +35,49 @@ public class SearchFragment extends Fragment {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_search, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context = getActivity();
updateUrl = Api.SERVICE_LIST;
httpClient = new OpenLPHttpClient(context);
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
}
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.SEARCHABLE_PLUGINS);
Log.d(LOG_TAG, "Resumed...");
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <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.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
public void onFragmentInteraction(Uri uri);
public void manageResponse(String response, boolean notInError) {
if (calledURL.equals(updateUrl)) {
populateTabDisplay(response);
}else {
processUpdate(response, notInError);
}
}
private void populateTabDisplay(String response){
int a = 1;
}
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"
android:layout_width="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 -->
<LinearLayout
android:orientation="vertical"
android:id="@+id/fragmentsearchlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top">
android:layout_gravity="center_horizontal|top"
android:weightSum="1">
<LinearLayout
android:orientation="horizontal"
android:id="@+id/fragmentsearchdetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
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
android:layout_width="288dp"
android:layout_height="wrap_content"
android:id="@+id/serach_spinner"
android:id="@+id/search_spinner"
android:layout_weight="0.58" />
<SearchView
@ -32,18 +43,41 @@
</LinearLayout>
<TextView
android:id="@+id/SearchResultsList"
android:layout_width="wrap_content"
<LinearLayout
android:orientation="horizontal"
android:id="@+id/fragmentsearchvalue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#000000"
android:textSize="14sp"
android:paddingTop="10dp"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:paddingEnd="5dp"
android:paddingBottom="10dp" />
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Search Text"
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>

View File

@ -29,7 +29,7 @@
<string name="display_blank_summary">Select the required display</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_reset">Show Live display</string>
<string name="display_reset">Live display</string>
<string name="display_settings">Display Setting</string>
<string name="display_screen">Display Black only</string>
<string name="display_theme">Display Theme only</string>
@ -45,14 +45,6 @@
<string name="next">Next</string>
<string name="none">None</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="process">Process</string>
<string name="service_list">Service List</string>
@ -62,7 +54,4 @@
<string name="title_activity_settings">Settings</string>
<string name="url_hint">Hostname or IP</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>