Commit ff34dd85 by Kunj Gupta

UOFLMA-81: Fixed - References search are not working.

parent 18aac3ae
......@@ -49,12 +49,10 @@ import butterknife.Unbinder;
*/
public class SelectReferenceDialog extends DialogFragment {
@BindView(R.id.dialog_list_view)
ListView mListView;
@BindView(R.id.dialog_title)
TextView mTitleTextView;
@BindView(R.id.dialog_edit_text)
EditText mEditText;
@BindView(R.id.reference_search_dialog_list_view) ListView mListView;
@BindView(R.id.reference_search_dialog_title) TextView mTitleTextView;
@BindView(R.id.reference_search_dialog_no_result_tv) TextView mNoResultTextView;
@BindView(R.id.reference_search_dialog_edit_text) EditText mEditText;
private ReferenceListener mListener;
private Unbinder mUnbinder;
......@@ -63,7 +61,6 @@ public class SelectReferenceDialog extends DialogFragment {
private CatalogueApplication mApplication;
public SelectReferenceDialog() {
}
public void setListener(ReferenceListener listener) {
......@@ -106,7 +103,7 @@ public class SelectReferenceDialog extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.custom_dialog, container, false);
View rootView = inflater.inflate(R.layout.reference_search_dialog, container, false);
mUnbinder = ButterKnife.bind(this, rootView);
mTitleTextView.setText(String.format(getString(R.string.variable_form_reference_dialog_title_string), mReferenceTitle));
......@@ -115,7 +112,7 @@ public class SelectReferenceDialog extends DialogFragment {
return rootView;
}
@OnTouch(R.id.dialog_edit_text)
@OnTouch(R.id.reference_search_dialog_edit_text)
boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_RIGHT = 2;
Drawable drawable = mEditText.getCompoundDrawables()[DRAWABLE_RIGHT];
......@@ -136,7 +133,7 @@ public class SelectReferenceDialog extends DialogFragment {
getDialog().dismiss();
}
@OnItemClick(R.id.dialog_list_view)
@OnItemClick(R.id.reference_search_dialog_list_view)
void listViewItemClick(int position) {
Reference reference = mReferenceList.get(position);
if (reference != null)
......@@ -146,7 +143,7 @@ public class SelectReferenceDialog extends DialogFragment {
getDialog().dismiss();
}
@OnEditorAction(R.id.dialog_edit_text)
@OnEditorAction(R.id.reference_search_dialog_edit_text)
boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Util.hideSoftKeyboard(getActivity(), v);
......@@ -177,7 +174,8 @@ public class SelectReferenceDialog extends DialogFragment {
@Override
protected SyncStatus doInBackground(String... params) {
Map<String, String> stringMap = new HashMap<>(1);
stringMap.put(mReferenceColumnName, params[0]);
stringMap.put(Constants.URL_PARAM_SYSPRM_FIELDS, "sys_id,"+mReferenceColumnName);
stringMap.put(Constants.URL_PARAM_SYSPRM_QUERY, mReferenceColumnName+"LIKE"+params[0]);
return VariableChoiceApiManager.getReference(mReferenceTableName, stringMap, new GetReferenceApiListener() {
@Override
public void onDoneApiCall(List<Reference> referenceList) {
......@@ -193,11 +191,19 @@ public class SelectReferenceDialog extends DialogFragment {
progressDialog.dismiss();
}
if (syncStatus == SyncStatus.SUCCESS) {
ArrayAdapter<String> adapter = new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
getReferenceForDisplay());
mListView.setAdapter(adapter);
List<String> stringList = getReferenceForDisplay();
if(stringList.isEmpty()) {
mNoResultTextView.setVisibility(View.VISIBLE);
mListView.setVisibility(View.GONE);
} else {
mListView.setVisibility(View.VISIBLE);
mNoResultTextView.setVisibility(View.GONE);
ArrayAdapter<String> adapter = new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
getReferenceForDisplay());
mListView.setAdapter(adapter);
}
} else {
showErrorDialog(R.string.failed_to_fetch_reference_string);
}
......
......@@ -7,13 +7,13 @@
android:weightSum="10">
<TextView
android:id="@+id/dialog_title"
android:id="@+id/reference_search_dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/large_text_size"/>
android:textSize="@dimen/large_text_size" />
<View
android:layout_width="match_parent"
......@@ -21,7 +21,7 @@
android:background="@android:color/black" />
<EditText
android:id="@+id/dialog_edit_text"
android:id="@+id/reference_search_dialog_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_margin"
......@@ -32,15 +32,29 @@
android:hint="@string/search_for_reference_string"
android:imeOptions="actionSearch"
android:singleLine="true"
android:textColor="@android:color/black"/>
android:textColor="@android:color/black" />
<ListView
android:id="@+id/dialog_list_view"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:divider="@android:color/black"
android:dividerHeight="0.5dp"/>
android:layout_weight="10">
<TextView
android:id="@+id/reference_search_dialog_no_result_tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/variable_form_reference_no_result_string"
android:textSize="@dimen/large_text_size"
android:visibility="gone" />
<ListView
android:id="@+id/reference_search_dialog_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/black"
android:dividerHeight="0.5dp" />
</FrameLayout>
<View
android:layout_width="match_parent"
......@@ -56,5 +70,5 @@
android:orientation="horizontal"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="@android:string/cancel"/>
android:text="@android:string/cancel" />
</LinearLayout>
\ No newline at end of file
......@@ -58,6 +58,7 @@
<string name="custom_setting_storage_permission_dialog_msg_string">To use this feature, please go to Settings -> Apps -> %s -> Permissions and enable \'Storage\' permission</string>
<string name="variable_form_back_navigation_string">Are you sure you want to navigate away?</string>
<string name="variable_form_order_successful_submission_string">Your Order has been submitted successfully</string>
<string name="variable_form_reference_no_result_string">No Result</string>
<string name="Variable_form_short_description_anchor_line_break_css"><![CDATA[
<style>
a {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment