V1.0.0(3)添加网络重新连接按钮,版本代码加一
This commit is contained in:
parent
24abc51bfe
commit
f64da0aaec
@ -14,7 +14,7 @@ android {
|
|||||||
applicationId = "com.live.dynamicwallpaper"
|
applicationId = "com.live.dynamicwallpaper"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 2
|
versionCode = 3
|
||||||
versionName = "1.0.0"
|
versionName = "1.0.0"
|
||||||
setProperty(
|
setProperty(
|
||||||
"archivesBaseName",
|
"archivesBaseName",
|
||||||
|
|||||||
@ -65,6 +65,12 @@ public class DynamicActivity extends AppCompatActivity {
|
|||||||
viewModel = new ViewModelProvider(this).get(DynamicViewModel.class);
|
viewModel = new ViewModelProvider(this).get(DynamicViewModel.class);
|
||||||
String format = contentData.getWallpaperType() == 2 ? "ViewShiftLive" : "ViewLive";
|
String format = contentData.getWallpaperType() == 2 ? "ViewShiftLive" : "ViewLive";
|
||||||
|
|
||||||
|
downloadVideo(resourceId, imagePath, format);
|
||||||
|
|
||||||
|
observeFavoriteState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadVideo(int resourceId, String imagePath, String format) {
|
||||||
if (contentData.getWallpaperPath().isEmpty()) {
|
if (contentData.getWallpaperPath().isEmpty()) {
|
||||||
mediaFetcher.fetchVideoFile(this, resourceId, imagePath, format, new OnDownloadCallback() {
|
mediaFetcher.fetchVideoFile(this, resourceId, imagePath, format, new OnDownloadCallback() {
|
||||||
@Override
|
@Override
|
||||||
@ -74,13 +80,14 @@ public class DynamicActivity extends AppCompatActivity {
|
|||||||
viewModel.update(contentData);
|
viewModel.update(contentData);
|
||||||
prepareVideoPlayback();
|
prepareVideoPlayback();
|
||||||
hideLoading();
|
hideLoading();
|
||||||
|
hideRetry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Exception e) {
|
public void onFailure(Exception e) {
|
||||||
if (ui == null) return;
|
if (ui == null) return;
|
||||||
hideLoading();
|
hideLoading();
|
||||||
Toast.makeText(DynamicActivity.this, "Download error", Toast.LENGTH_SHORT).show();
|
showRetry();
|
||||||
Log.e("LivePreview", "Media fetch failed", e);
|
Log.e("LivePreview", "Media fetch failed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +102,25 @@ public class DynamicActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
prepareVideoPlayback();
|
prepareVideoPlayback();
|
||||||
hideLoading();
|
hideLoading();
|
||||||
|
hideRetry();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
observeFavoriteState();
|
private void showRetry() {
|
||||||
|
if (ui == null) return;
|
||||||
|
ui.errorContainer.setVisibility(View.VISIBLE);
|
||||||
|
ui.retryButton.setOnClickListener(v -> {
|
||||||
|
ui.errorContainer.setVisibility(View.GONE);
|
||||||
|
showLoading();
|
||||||
|
downloadVideo(contentData.getFlowId(), contentData.getImage(),
|
||||||
|
contentData.getWallpaperType() == 2 ? "ViewShiftLive" : "ViewLive");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideRetry() {
|
||||||
|
if (ui != null) {
|
||||||
|
ui.errorContainer.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindListeners() {
|
private void bindListeners() {
|
||||||
|
|||||||
@ -123,4 +123,35 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/error_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:layout_centerInParent="true">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/error_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Download failed. \nPlease check the network and try again."
|
||||||
|
android:textColor="#FF0000"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/retry_button"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="#FF0000"
|
||||||
|
android:text="Retry"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Loading…
Reference in New Issue
Block a user