Skip to content

Commit 3a229c2

Browse files
committedJun 5, 2024
fix #27 #28 #29 (maybe)
1 parent 584daaf commit 3a229c2

8 files changed

+25
-18
lines changed
 

‎app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
mavenCentral()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:8.4.0'
11+
classpath 'com.android.tools.build:gradle:8.4.1'
1212
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.7"
1313
}
1414
}
@@ -76,6 +76,6 @@ dependencies {
7676

7777
buildscript {
7878
dependencies {
79-
classpath 'com.android.tools.build:gradle:8.4.0'
79+
classpath 'com.android.tools.build:gradle:8.4.1'
8080
}
8181
}

‎app/src/main/java/fr/nuage/souvenirs/view/DataBindingAdapters.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import androidx.annotation.NonNull;
2222
import androidx.annotation.Nullable;
2323
import fr.nuage.souvenirs.R;
24+
import fr.nuage.souvenirs.model.Element;
2425
import fr.nuage.souvenirs.model.ImageElement;
26+
import fr.nuage.souvenirs.viewmodel.AlbumViewModel;
2527
import fr.nuage.souvenirs.viewmodel.ElementViewModel;
2628

2729
public class DataBindingAdapters {
@@ -129,8 +131,17 @@ public static void setLayoutMarginLeft(View v, int marginLeft, int marginTop, in
129131
}
130132
}
131133

132-
public static void onLayoutChange(View view, int left, int top, int right, int bottom) {
133-
setLayoutMarginLeft(view, left, top, right, bottom);
134+
public static void onLayoutChange(View view, ElementViewModel element, AlbumViewModel album) {
135+
if ((element != null) && (album != null)) {
136+
if ((element.getLeft().getValue() != null) && (element.getRight().getValue() != null) && (element.getTop().getValue() != null) && (element.getBottom().getValue() != null)) {
137+
if (album.getLdElementMargin().getValue() != null) {
138+
setLayoutMarginLeft(view, element.getLeft().getValue() + album.getLdElementMargin().getValue(),
139+
element.getTop().getValue() + album.getLdElementMargin().getValue(),
140+
element.getRight().getValue() - album.getLdElementMargin().getValue(),
141+
element.getBottom().getValue() - album.getLdElementMargin().getValue());
142+
}
143+
}
144+
}
134145
}
135146

136147
@BindingAdapter("is_selected")

‎app/src/main/java/fr/nuage/souvenirs/view/EditPageFragment.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.os.Handler;
1414
import android.os.Looper;
1515
import android.provider.MediaStore;
16+
import android.util.Log;
1617
import android.view.LayoutInflater;
1718
import android.view.Menu;
1819
import android.view.MenuInflater;
@@ -21,24 +22,16 @@
2122
import android.view.ViewGroup;
2223
import android.widget.Toast;
2324

24-
import androidx.activity.result.ActivityResultCallback;
2525
import androidx.activity.result.ActivityResultLauncher;
26-
import androidx.activity.result.contract.ActivityResultContract;
2726
import androidx.activity.result.contract.ActivityResultContracts;
2827
import androidx.annotation.NonNull;
29-
import androidx.annotation.Nullable;
3028
import androidx.appcompat.view.menu.MenuBuilder;
31-
import androidx.core.app.ActivityCompat;
3229
import androidx.core.content.FileProvider;
33-
import androidx.core.content.PermissionChecker;
3430
import androidx.databinding.DataBindingUtil;
3531
import androidx.fragment.app.Fragment;
36-
import androidx.lifecycle.Observer;
3732
import androidx.lifecycle.ViewModelProvider;
3833
import androidx.navigation.Navigation;
3934
import androidx.recyclerview.widget.ItemTouchHelper;
40-
import androidx.recyclerview.widget.LinearLayoutManager;
41-
import androidx.recyclerview.widget.RecyclerView;
4235

4336
import com.google.android.material.appbar.AppBarLayout;
4437

@@ -49,7 +42,6 @@
4942

5043
import fr.nuage.souvenirs.R;
5144
import fr.nuage.souvenirs.databinding.FragmentEditPageBinding;
52-
import fr.nuage.souvenirs.model.AudioElement;
5345
import fr.nuage.souvenirs.model.Page;
5446
import fr.nuage.souvenirs.model.TilePageBuilder;
5547
import fr.nuage.souvenirs.view.helpers.Div;
@@ -89,6 +81,10 @@ public void onCreate(Bundle savedInstanceState) {
8981
String pageId = EditPageFragmentArgs.fromBundle(getArguments()).getPageId();
9082
//load view model
9183
albumVM = new ViewModelProvider(requireActivity(),new AlbumListViewModelFactory(requireActivity().getApplication())).get(AlbumListViewModel.class).getAlbum(albumPath);
84+
if (albumVM == null) {
85+
Log.e(getClass().getName(),"Unable to load album at "+albumPath);
86+
getActivity().getSupportFragmentManager().popBackStack();
87+
}
9288
PageViewModel pageVM = albumVM.getPage(UUID.fromString(pageId));
9389
//set focus on that page
9490
albumVM.setFocusPage(pageVM);

‎app/src/main/java/fr/nuage/souvenirs/view/EditPageListAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public void onBindViewHolder(@NonNull EditPageListAdapter.ViewHolder holder, int
111111
ImageElementViewModel ei = (ImageElementViewModel)e;
112112
//load xml layout and bind data
113113
ImageElementViewBinding binding = DataBindingUtil.inflate(inflater, R.layout.image_element_view, layout,false);
114-
binding.setLifecycleOwner(lifecycleOwner);
115114
binding.setElement(ei);
116115
binding.setAlbum(albumViewModel);
117116
layout.addView(binding.getRoot());
117+
binding.setLifecycleOwner(lifecycleOwner);
118118
binding.executePendingBindings();
119119
} else if (e.getClass() == AudioElementViewModel.class) {
120120
continue;

‎app/src/main/res/layout/image_element_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
android:layout_marginBottom="@{element.bottom - album.ldElementMargin}"
1919
android:layout_marginStart="@{element.left + album.ldElementMargin}"
2020
android:layout_marginEnd="@{element.right - album.ldElementMargin}"
21-
android:onLayoutChange="@{(view, a, b, c, d, e, f, g, h) -> DataBindingAdapters.onLayoutChange(view, element.left + album.ldElementMargin, element.top + album.ldElementMargin, element.right - album.ldElementMargin, element.bottom - album.ldElementMargin)}"
21+
android:onLayoutChange="@{(view, a, b, c, d, e, f, g, h) -> DataBindingAdapters.onLayoutChange(view, element, album)}"
2222
android:layout_width="match_parent"
2323
android:layout_height="match_parent"
2424
app:layout_constraintBottom_toBottomOf="parent"

‎app/src/main/res/layout/text_element_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:layout_marginBottom="@{element.bottom - album.ldElementMargin}"
1717
android:layout_marginStart="@{element.left + album.ldElementMargin}"
1818
android:layout_marginEnd="@{element.right - album.ldElementMargin}"
19-
android:onLayoutChange="@{(view, a, b, c, d, e, f, g, h) -> DataBindingAdapters.onLayoutChange(view, element.left + album.ldElementMargin, element.top + album.ldElementMargin, element.right - album.ldElementMargin, element.bottom - album.ldElementMargin)}"
19+
android:onLayoutChange="@{(view, a, b, c, d, e, f, g, h) -> DataBindingAdapters.onLayoutChange(view, element, album)}"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
2222
app:layout_constraintBottom_toBottomOf="parent"

‎app/src/main/res/layout/video_element_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
android:layout_marginBottom="@{element.bottom - album.ldElementMargin}"
1919
android:layout_marginStart="@{element.left + album.ldElementMargin}"
2020
android:layout_marginEnd="@{element.right - album.ldElementMargin}"
21-
android:onLayoutChange="@{(view, a, b, c, d, e, f, g, h) -> DataBindingAdapters.onLayoutChange(view, element.left + album.ldElementMargin, element.top + album.ldElementMargin, element.right - album.ldElementMargin, element.bottom - album.ldElementMargin)}"
21+
android:onLayoutChange="@{(view, a, b, c, d, e, f, g, h) -> DataBindingAdapters.onLayoutChange(view, element, album)}"
2222
android:layout_width="match_parent"
2323
android:layout_height="match_parent"
2424
app:layout_constraintBottom_toBottomOf="parent"

‎build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
mavenCentral()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:8.4.0'
10+
classpath 'com.android.tools.build:gradle:8.4.1'
1111
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.7"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

0 commit comments

Comments
 (0)
Failed to load comments.