Commit ff34dd85 by Kunj Gupta

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

parent 18aac3ae
...@@ -49,12 +49,10 @@ import butterknife.Unbinder; ...@@ -49,12 +49,10 @@ import butterknife.Unbinder;
*/ */
public class SelectReferenceDialog extends DialogFragment { public class SelectReferenceDialog extends DialogFragment {
@BindView(R.id.dialog_list_view) @BindView(R.id.reference_search_dialog_list_view) ListView mListView;
ListView mListView; @BindView(R.id.reference_search_dialog_title) TextView mTitleTextView;
@BindView(R.id.dialog_title) @BindView(R.id.reference_search_dialog_no_result_tv) TextView mNoResultTextView;
TextView mTitleTextView; @BindView(R.id.reference_search_dialog_edit_text) EditText mEditText;
@BindView(R.id.dialog_edit_text)
EditText mEditText;
private ReferenceListener mListener; private ReferenceListener mListener;
private Unbinder mUnbinder; private Unbinder mUnbinder;
...@@ -63,7 +61,6 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -63,7 +61,6 @@ public class SelectReferenceDialog extends DialogFragment {
private CatalogueApplication mApplication; private CatalogueApplication mApplication;
public SelectReferenceDialog() { public SelectReferenceDialog() {
} }
public void setListener(ReferenceListener listener) { public void setListener(ReferenceListener listener) {
...@@ -106,7 +103,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -106,7 +103,7 @@ public class SelectReferenceDialog extends DialogFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 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); mUnbinder = ButterKnife.bind(this, rootView);
mTitleTextView.setText(String.format(getString(R.string.variable_form_reference_dialog_title_string), mReferenceTitle)); mTitleTextView.setText(String.format(getString(R.string.variable_form_reference_dialog_title_string), mReferenceTitle));
...@@ -115,7 +112,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -115,7 +112,7 @@ public class SelectReferenceDialog extends DialogFragment {
return rootView; return rootView;
} }
@OnTouch(R.id.dialog_edit_text) @OnTouch(R.id.reference_search_dialog_edit_text)
boolean onTouch(View v, MotionEvent event) { boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_RIGHT = 2; final int DRAWABLE_RIGHT = 2;
Drawable drawable = mEditText.getCompoundDrawables()[DRAWABLE_RIGHT]; Drawable drawable = mEditText.getCompoundDrawables()[DRAWABLE_RIGHT];
...@@ -136,7 +133,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -136,7 +133,7 @@ public class SelectReferenceDialog extends DialogFragment {
getDialog().dismiss(); getDialog().dismiss();
} }
@OnItemClick(R.id.dialog_list_view) @OnItemClick(R.id.reference_search_dialog_list_view)
void listViewItemClick(int position) { void listViewItemClick(int position) {
Reference reference = mReferenceList.get(position); Reference reference = mReferenceList.get(position);
if (reference != null) if (reference != null)
...@@ -146,7 +143,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -146,7 +143,7 @@ public class SelectReferenceDialog extends DialogFragment {
getDialog().dismiss(); getDialog().dismiss();
} }
@OnEditorAction(R.id.dialog_edit_text) @OnEditorAction(R.id.reference_search_dialog_edit_text)
boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Util.hideSoftKeyboard(getActivity(), v); Util.hideSoftKeyboard(getActivity(), v);
...@@ -177,7 +174,8 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -177,7 +174,8 @@ public class SelectReferenceDialog extends DialogFragment {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
Map<String, String> stringMap = new HashMap<>(1); 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() { return VariableChoiceApiManager.getReference(mReferenceTableName, stringMap, new GetReferenceApiListener() {
@Override @Override
public void onDoneApiCall(List<Reference> referenceList) { public void onDoneApiCall(List<Reference> referenceList) {
...@@ -193,11 +191,19 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -193,11 +191,19 @@ public class SelectReferenceDialog extends DialogFragment {
progressDialog.dismiss(); progressDialog.dismiss();
} }
if (syncStatus == SyncStatus.SUCCESS) { if (syncStatus == SyncStatus.SUCCESS) {
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(), ArrayAdapter<String> adapter = new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1, android.R.layout.simple_list_item_1,
android.R.id.text1, android.R.id.text1,
getReferenceForDisplay()); getReferenceForDisplay());
mListView.setAdapter(adapter); mListView.setAdapter(adapter);
}
} else { } else {
showErrorDialog(R.string.failed_to_fetch_reference_string); showErrorDialog(R.string.failed_to_fetch_reference_string);
} }
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
android:weightSum="10"> android:weightSum="10">
<TextView <TextView
android:id="@+id/dialog_title" android:id="@+id/reference_search_dialog_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:paddingBottom="@dimen/normal_margin" android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin" android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/large_text_size"/> android:textSize="@dimen/large_text_size" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
android:background="@android:color/black" /> android:background="@android:color/black" />
<EditText <EditText
android:id="@+id/dialog_edit_text" android:id="@+id/reference_search_dialog_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_margin" android:layout_marginLeft="@dimen/large_margin"
...@@ -32,15 +32,29 @@ ...@@ -32,15 +32,29 @@
android:hint="@string/search_for_reference_string" android:hint="@string/search_for_reference_string"
android:imeOptions="actionSearch" android:imeOptions="actionSearch"
android:singleLine="true" android:singleLine="true"
android:textColor="@android:color/black"/> android:textColor="@android:color/black" />
<ListView <FrameLayout
android:id="@+id/dialog_list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="10" 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:divider="@android:color/black"
android:dividerHeight="0.5dp"/> android:dividerHeight="0.5dp" />
</FrameLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -56,5 +70,5 @@ ...@@ -56,5 +70,5 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="@dimen/normal_margin" android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin" android:paddingTop="@dimen/normal_margin"
android:text="@android:string/cancel"/> android:text="@android:string/cancel" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -58,6 +58,7 @@ ...@@ -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="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_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_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[ <string name="Variable_form_short_description_anchor_line_break_css"><![CDATA[
<style> <style>
a { 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