mirror of
https://gitlab.com/openlp/android.git
synced 2024-12-22 03:42:48 +00:00
call add apis
This commit is contained in:
parent
e193bf3496
commit
afd85a2ba8
@ -45,7 +45,26 @@ abstract public class OpenLPDialog extends DialogFragment {
|
|||||||
protected void triggerTextRequest(String url) {
|
protected void triggerTextRequest(String url) {
|
||||||
calledURL = url;
|
calledURL = url;
|
||||||
Log.d(LOG_TAG, "Trigger Request for url " + url);
|
Log.d(LOG_TAG, "Trigger Request for url " + url);
|
||||||
String callurl = String.format("%s%s", httpClient.getAbsoluteUrl(client), url );
|
String callurl = String.format("%s%s", httpClient.getAbsoluteUrl(client), url);
|
||||||
|
processCall(callurl);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void triggerAction(String api, String plugin, String id ) {
|
||||||
|
String request = null;
|
||||||
|
try {
|
||||||
|
request = JsonHelpers.createRequestJSON("text", id);
|
||||||
|
} catch (JsonHelpers.JSONHandlerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
String url = String.format(api, plugin.toLowerCase());
|
||||||
|
triggerTextRequest(String.format("%s%s", url, request));
|
||||||
|
calledURL = url;
|
||||||
|
Log.d(LOG_TAG, "Trigger action for url " + url);
|
||||||
|
String callurl = String.format("%s%s", httpClient.getAbsoluteUrl(client), url);
|
||||||
|
processCall(callurl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processCall(String callurl){
|
||||||
client.get(callurl, null, new TextHttpResponseHandler() {
|
client.get(callurl, null, new TextHttpResponseHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int statusCode, Header[] headers, String responseString) {
|
public void onSuccess(int statusCode, Header[] headers, String responseString) {
|
||||||
|
@ -26,7 +26,6 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import org.openlp.android2.R;
|
import org.openlp.android2.R;
|
||||||
@ -38,7 +37,7 @@ import org.openlp.android2.common.OpenLPHttpClient;
|
|||||||
public class SearchSelectionDialog extends OpenLPDialog {
|
public class SearchSelectionDialog extends OpenLPDialog {
|
||||||
private final String LOG_TAG = SearchSelectionDialog.class.getName();
|
private final String LOG_TAG = SearchSelectionDialog.class.getName();
|
||||||
public AlertDialog dialog;
|
public AlertDialog dialog;
|
||||||
private int num;
|
private String key;
|
||||||
private String plugin;
|
private String plugin;
|
||||||
private String text;
|
private String text;
|
||||||
private RadioButton sendLive;
|
private RadioButton sendLive;
|
||||||
@ -54,7 +53,7 @@ public class SearchSelectionDialog extends OpenLPDialog {
|
|||||||
// title by default, but your custom layout might not need it. So here you can
|
// title by default, but your custom layout might not need it. So here you can
|
||||||
// remove the dialog title, but you must call the superclass to get the Dialog.
|
// remove the dialog title, but you must call the superclass to get the Dialog.
|
||||||
|
|
||||||
num = getArguments().getInt("id");
|
key = getArguments().getString("key");
|
||||||
plugin = getArguments().getString("plugin");
|
plugin = getArguments().getString("plugin");
|
||||||
text = getArguments().getString("text");
|
text = getArguments().getString("text");
|
||||||
|
|
||||||
@ -74,14 +73,15 @@ public class SearchSelectionDialog extends OpenLPDialog {
|
|||||||
sendLive.setOnClickListener(new View.OnClickListener() {
|
sendLive.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
triggerTextRequest(Api.DISPLAY_SHOW);
|
triggerAction(Api.SEARCH_PLUGIN_LIVE, plugin, key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addToService = (RadioButton) view.findViewById(R.id.buttonLive);
|
addToService = (RadioButton) view.findViewById(R.id.buttonLive);
|
||||||
addToService.setOnClickListener(new View.OnClickListener() {
|
addToService.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
triggerTextRequest(Api.DISPLAY_BLANK);
|
triggerAction(Api.SEARCH_PLUGIN_ADD, plugin, key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ public class SearchFragment extends Fragment {
|
|||||||
protected String calledURL;
|
protected String calledURL;
|
||||||
protected OpenLPHttpClient httpClient;
|
protected OpenLPHttpClient httpClient;
|
||||||
protected String updateUrl;
|
protected String updateUrl;
|
||||||
|
protected String seachedPlugin;
|
||||||
|
|
||||||
public SearchFragment() {
|
public SearchFragment() {
|
||||||
Log.d(LOG_TAG, "Constructor");
|
Log.d(LOG_TAG, "Constructor");
|
||||||
@ -87,7 +88,7 @@ public class SearchFragment extends Fragment {
|
|||||||
EditText editText = (EditText)view.findViewById(R.id.search_text);
|
EditText editText = (EditText)view.findViewById(R.id.search_text);
|
||||||
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView tv, int actionId, KeyEvent event) {
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
// Now close the keyboard as finished with
|
// Now close the keyboard as finished with
|
||||||
View view = getActivity().getCurrentFocus();
|
View view = getActivity().getCurrentFocus();
|
||||||
@ -96,10 +97,8 @@ public class SearchFragment extends Fragment {
|
|||||||
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
//String text = spinner.getSelectedItem().toString();
|
seachedPlugin = spinner.getSelectedItem().toString();
|
||||||
// String text1 = v.getText().toString();
|
requestSearch(spinner.getSelectedItem().toString(), tv.getText().toString());
|
||||||
//Toast.makeText(context, "Search Called " + text + " " + text1, Toast.LENGTH_SHORT).show();
|
|
||||||
requestSearch(spinner.getSelectedItem().toString(), v.getText().toString());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -221,17 +220,22 @@ public class SearchFragment extends Fragment {
|
|||||||
final JSONArray item = (JSONArray) parent.getItemAtPosition(position);
|
final JSONArray item = (JSONArray) parent.getItemAtPosition(position);
|
||||||
Toast.makeText(context, "Item Pressed " + String.valueOf(position) + item,
|
Toast.makeText(context, "Item Pressed " + String.valueOf(position) + item,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
String it = "";
|
||||||
|
try {
|
||||||
|
it = (String)item.get(1);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("plugin", "plugin");
|
args.putString("plugin", seachedPlugin);
|
||||||
args.putString("text", "text");
|
args.putString("text", it);
|
||||||
args.putInt("id", 123);
|
args.putString("key", Long.toString(id));
|
||||||
DialogFragment newFragment = new SearchSelectionDialog();
|
DialogFragment newFragment = new SearchSelectionDialog();
|
||||||
newFragment.setArguments(args);
|
newFragment.setArguments(args);
|
||||||
newFragment.show(getFragmentManager(), "TAG");
|
newFragment.show(getFragmentManager(), "TAG");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Log.i(LOG_TAG, "populateListDisplay - exit");
|
Log.i(LOG_TAG, "populateListDisplay - exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user