Skip to content

Commit

Permalink
update angle slider
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Aug 25, 2023
1 parent dda3c52 commit 867fc72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void onClick(View v) {
} else if ("CustomiseFragment".equals(homeFAB.getTag())) {

homeFAB.setTag(null);
homeFAB.setElevation(0);
homeFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu));

updateViewPager();
Expand Down Expand Up @@ -186,6 +187,7 @@ public void onClick(View v) {
.commit();

homeFAB.setTag("CustomiseFragment");
homeFAB.setElevation(Utils.Companion.DPtoPX(this, 12));
homeFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_done));
} else if (id == R.id.bgFAB) {

Expand Down Expand Up @@ -261,6 +263,7 @@ public void onBackPressed() {
if ("CustomiseFragment".equals(homeFAB.getTag())) {

homeFAB.setTag(null);
homeFAB.setElevation(0);
homeFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu));

updateViewPager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import androidx.fragment.app.Fragment;
import com.google.android.material.slider.Slider;
import java.io.File;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
import phone.vishnu.quotes.R;
import phone.vishnu.quotes.helper.Constants;
Expand Down Expand Up @@ -140,7 +141,10 @@ public void onViewCreated(
cardView.setY(
(constraintLayout.getHeight() - offsetViewBounds.top) / cardY);

if (cardRotation != -1) cardView.setRotation(cardRotation);
if (cardRotation != -1) {
cardView.setRotation(cardRotation);
angleSlider.setValue(cardRotation);
}
});

AtomicReference<Float> dX = new AtomicReference<>(cardView.getX());
Expand Down Expand Up @@ -192,6 +196,10 @@ public void onViewCreated(
return true;
});

//noinspection UnnecessaryUnicodeEscape
angleSlider.setLabelFormatter(
value -> String.format(Locale.getDefault(), "%.2f%c", value, '\u00B0'));

angleSlider.addOnChangeListener(
(slider, value, fromUser) -> {
if (fromUser) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_customise.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="64dp"
android:padding="8dp"
android:stepSize="1"
android:theme="@style/Theme.MaterialComponents.DayNight"
android:value="0"
android:valueFrom="-90"
android:valueTo="90"
app:labelBehavior="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand Down

0 comments on commit 867fc72

Please sign in to comment.