mirror of https://gitlab.com/openlp/android.git
84 lines
2.3 KiB
Java
84 lines
2.3 KiB
Java
package org.openlp.android2.fragments;
|
|
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
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;
|
|
|
|
/**
|
|
|
|
*/
|
|
public class SearchFragment extends OpenLPFragment {
|
|
|
|
private final String LOG_TAG = SearchFragment.class.getName();
|
|
|
|
public SearchFragment() {
|
|
Log.d(LOG_TAG, "Constructor");
|
|
}
|
|
|
|
public static SearchFragment newInstance() {
|
|
SearchFragment fragment = new SearchFragment();
|
|
return fragment;
|
|
}
|
|
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
}
|
|
@Override
|
|
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 onResume() {
|
|
super.onResume();
|
|
Log.d(LOG_TAG, "Resuming...");
|
|
triggerTextRequest(Api.SEARCHABLE_PLUGINS);
|
|
Log.d(LOG_TAG, "Resumed...");
|
|
}
|
|
|
|
@Override
|
|
public void onDetach() {
|
|
super.onDetach();
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
}
|