Add progress layout and img error check

pull/1/head
FongMi 4 years ago
parent 5392e208a6
commit cf93f7478e
  1. 1
      app/build.gradle
  2. 6
      app/src/main/java/com/fongmi/bear/ui/activity/HomeActivity.java
  3. 3
      app/src/main/java/com/fongmi/bear/utils/Utils.java
  4. BIN
      app/src/main/res/drawable-hdpi/ic_img_error.png
  5. BIN
      app/src/main/res/drawable-hdpi/ic_img_loading.png
  6. BIN
      app/src/main/res/drawable-mdpi/ic_img_error.png
  7. BIN
      app/src/main/res/drawable-mdpi/ic_img_loading.png
  8. BIN
      app/src/main/res/drawable-xhdpi/ic_img_error.png
  9. BIN
      app/src/main/res/drawable-xhdpi/ic_img_loading.png
  10. BIN
      app/src/main/res/drawable-xxhdpi/ic_img_error.png
  11. BIN
      app/src/main/res/drawable-xxhdpi/ic_img_loading.png
  12. BIN
      app/src/main/res/drawable-xxxhdpi/ic_img_error.png
  13. BIN
      app/src/main/res/drawable-xxxhdpi/ic_img_loading.png
  14. 17
      app/src/main/res/layout/activity_home.xml
  15. 2
      settings.gradle

@ -38,6 +38,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.room:room-runtime:2.4.2'
implementation 'com.github.androidprogresslayout:library:2.0.2@aar'
implementation 'com.github.bumptech.glide:glide:4.13.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.exoplayer:exoplayer:2.18.0'

@ -61,10 +61,14 @@ public class HomeActivity extends BaseActivity {
private void setViewModel() {
mSiteViewModel = new ViewModelProvider(this).get(SiteViewModel.class);
mSiteViewModel.mResult.observe(this, result -> mVodAdapter.addAll(result.getList()));
mSiteViewModel.mResult.observe(this, result -> {
mVodAdapter.addAll(result.getList());
mBinding.updateLayout.showContent();
});
}
private void homeContent() {
mBinding.updateLayout.showProgress();
mSiteViewModel.homeContent(ApiConfig.get().getHome().getKey());
}

@ -13,6 +13,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.fongmi.bear.App;
import com.fongmi.bear.R;
import com.google.android.exoplayer2.util.Util;
public class Utils {
@ -62,7 +63,7 @@ public class Utils {
}
public static void loadImage(String url, ImageView view) {
Glide.with(App.get()).load(url).transform(new CenterCrop(), new RoundedCorners(ResUtil.dp2px(8))).into(view);
Glide.with(App.get()).load(url).placeholder(R.drawable.ic_img_loading).error(R.drawable.ic_img_error).transform(new CenterCrop(), new RoundedCorners(ResUtil.dp2px(8))).into(view);
}
public static boolean hasPIP() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
@ -44,11 +45,17 @@
android:textColor="@color/white"
android:textSize="24sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/update"
<com.github.androidprogresslayout.ProgressLayout
android:id="@+id/updateLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
android:layout_height="match_parent"
android:layout_marginTop="16dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/update"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.github.androidprogresslayout.ProgressLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

@ -2,6 +2,7 @@ pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
jcenter()
google()
}
}
@ -9,6 +10,7 @@ dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
jcenter()
google()
}
}

Loading…
Cancel
Save