From 21a77e0b4be0299b025eb433bb869976424b7abd Mon Sep 17 00:00:00 2001 From: Delis Nikos Date: Sun, 7 Jan 2018 21:11:03 +0200 Subject: [PATCH] AddUserPreferences refactoring UI --- .../recyclers/RecyclerPreference.java | 17 +++++--- .../userPreferences/UserPreferenceList.java | 4 ++ .../userPreferences/UserPreferences.java | 4 +- .../res/layout/activity_user_preferences.xml | 39 +++++++++++++++++-- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/recyclers/RecyclerPreference.java b/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/recyclers/RecyclerPreference.java index 8f9ce04..fa78778 100644 --- a/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/recyclers/RecyclerPreference.java +++ b/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/recyclers/RecyclerPreference.java @@ -83,14 +83,13 @@ public int getDiscountId(int position){ public int getItemCount() { return discountPreferencesResponses.size(); } - public static class MyViewHolder extends RecyclerView.ViewHolder { + public static class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { // Button delete; TextView id; TextView price; Context context; - LinearLayout foregroundView; - RelativeLayout backgroundView; - + LinearLayout foregroundViewPreference; + RelativeLayout backgroundViewPreference; TextView tags; TextView categoryTitle; @@ -101,13 +100,19 @@ public MyViewHolder(View itemView,Context context) { price=itemView.findViewById(R.id.priceText); tags=itemView.findViewById(R.id.tagsTextView); this.context = context; - foregroundView = itemView.findViewById(R.id.foreground_view_userpref); - backgroundView = itemView.findViewById(R.id.background_view_userpref); categoryTitle=itemView.findViewById(R.id.categoryTextView); + foregroundViewPreference = itemView.findViewById(R.id.foreground_view_userpref); + backgroundViewPreference = itemView.findViewById(R.id.background_view_userpref); + + itemView.setOnClickListener(this); } + @Override + public void onClick(View view) { + + } } diff --git a/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferenceList.java b/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferenceList.java index cb59c35..45e5ee7 100644 --- a/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferenceList.java +++ b/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferenceList.java @@ -6,6 +6,8 @@ import android.support.constraint.ConstraintLayout; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; +import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; @@ -56,6 +58,8 @@ public void onViewCreated(View view, Bundle savedInstanceState) { recyclerView= view.findViewById(R.id.userPreferenceRecycler); layoutManager=new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(layoutManager); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL)); recyclerView.setHasFixedSize(true); addPreference = view.findViewById(R.id.userPreferencesBtn); addPreference.setOnClickListener(addPreferenceClick); diff --git a/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferences.java b/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferences.java index d5fdab5..b558ba8 100644 --- a/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferences.java +++ b/app/src/main/java/eu/jnksoftware/discountfinderandroid/ui/customer/userPreferences/UserPreferences.java @@ -45,6 +45,7 @@ public class UserPreferences extends AppCompatActivity { private ArrayAdapter spinContentAdapter; private Spinner spinnerCat; private String auth; + private EditText tags; @SuppressLint("SetTextI18n") @Override @@ -53,6 +54,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_user_preferences); iuserService= ApiUtils.getUserService(); user = ManageSharePrefs.readUser(null); + tags=findViewById(R.id.textTag); @@ -101,7 +103,7 @@ public void onClick(View view) { DiscountPreferencesRequest discountPreferencesRequest=new DiscountPreferencesRequest(); discountPreferencesRequest.setCategory(String.valueOf(categories.get((int) spinnerCat.getSelectedItemId()).getId())); discountPreferencesRequest.setPrice(String.valueOf(seekBarProgress)); - discountPreferencesRequest.setTags("Sample"); + discountPreferencesRequest.setTags(tags.getText().toString()); doUserPreference(discountPreferencesRequest); diff --git a/app/src/main/res/layout/activity_user_preferences.xml b/app/src/main/res/layout/activity_user_preferences.xml index e3e7c56..4c08486 100644 --- a/app/src/main/res/layout/activity_user_preferences.xml +++ b/app/src/main/res/layout/activity_user_preferences.xml @@ -50,14 +50,17 @@ android:id="@+id/spinnerCategory" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginBottom="136dp" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" - android:layout_marginTop="20dp" + android:layout_marginTop="88dp" android:background="@android:drawable/btn_dropdown" + app:layout_constraintBottom_toTopOf="@+id/tagsText" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tvCategory" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_chainStyle="spread_inside" /> + app:layout_constraintTop_toBottomOf="@id/seekBarPrice" + app:layout_constraintVertical_bias="0.784" /> + + + +