Skip to content

Commit

Permalink
AddUserPreferences refactoring UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosdel committed Jan 7, 2018
1 parent 10556f3 commit 21a77e0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {

}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class UserPreferences extends AppCompatActivity {
private ArrayAdapter<String> spinContentAdapter;
private Spinner spinnerCat;
private String auth;
private EditText tags;

@SuppressLint("SetTextI18n")
@Override
Expand All @@ -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);



Expand Down Expand Up @@ -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);
Expand Down
39 changes: 36 additions & 3 deletions app/src/main/res/layout/activity_user_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<TextView
android:id="@+id/tvPrice"
Expand Down Expand Up @@ -106,8 +109,38 @@
android:text="ΠΡΟΣΘΗΚΗ"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.607"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/seekBarPrice" />
app:layout_constraintTop_toBottomOf="@id/seekBarPrice"
app:layout_constraintVertical_bias="0.784" />

<TextView
android:id="@+id/tagsText"
android:layout_width="45dp"
android:layout_height="16dp"
android:layout_marginBottom="207dp"
android:text="Tags"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<EditText
android:id="@+id/textTag"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="25dp"
android:layout_marginStart="25dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/btSavePreferences"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tagsText" />

</android.support.constraint.ConstraintLayout>

Expand Down

0 comments on commit 21a77e0

Please sign in to comment.