Add download progress to description screen

This commit is contained in:
Vitaliy 2020-04-23 19:45:16 +03:00
parent 5223b1c1b3
commit a16b85850b
2 changed files with 36 additions and 3 deletions

View file

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_basic"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
@ -23,9 +22,16 @@
</com.google.android.material.appbar.AppBarLayout>
<include
layout="@layout/free_version_banner"
android:background="#F00" />
<include layout="@layout/progress_with_two_texts" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/activity_background_basic">
<ScrollView
android:layout_width="match_parent"

View file

@ -24,6 +24,8 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.download.CustomIndexItem;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.DownloadResourceGroup;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
@ -36,7 +38,7 @@ import java.util.List;
import static net.osmand.plus.download.ui.DownloadResourceGroupFragment.REGION_ID_DLG_KEY;
public class DownloadItemFragment extends DialogFragment {
public class DownloadItemFragment extends DialogFragment implements DownloadEvents {
public static final String ITEM_ID_DLG_KEY = "index_item_dialog_key";
@ -45,6 +47,7 @@ public class DownloadItemFragment extends DialogFragment {
private String regionId = "";
private int itemIndex = -1;
private BannerAndDownloadFreeVersion banner;
private DownloadResourceGroup group;
private Toolbar toolbar;
@ -87,6 +90,8 @@ public class DownloadItemFragment extends DialogFragment {
}
});
banner = new BannerAndDownloadFreeVersion(view, (DownloadActivity) getActivity(), false);
description = view.findViewById(R.id.description);
imagesPager = view.findViewById(R.id.images_pager);
buttonsContainer = view.findViewById(R.id.buttons_container);
@ -117,6 +122,28 @@ public class DownloadItemFragment extends DialogFragment {
outState.putInt(ITEM_ID_DLG_KEY, itemIndex);
}
@Override
public void newDownloadIndexes() {
if (banner != null) {
banner.updateBannerInProgress();
}
reloadData();
}
@Override
public void downloadHasFinished() {
if (banner != null) {
banner.updateBannerInProgress();
}
}
@Override
public void downloadInProgress() {
if (banner != null) {
banner.updateBannerInProgress();
}
}
private void reloadData() {
DownloadActivity activity = getDownloadActivity();
OsmandApplication app = activity.getMyApplication();