forked from organicmaps/organicmaps-tmp
[android] Use fractional progress in downloads
Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
parent
e7a0a419f1
commit
629782ceeb
5 changed files with 11 additions and 17 deletions
|
@ -165,7 +165,7 @@ static void UpdateItem(JNIEnv * env, jobject item, NodeAttrs const & attrs)
|
|||
static jfieldID const countryItemFieldChildCount = env->GetFieldID(g_countryItemClass, "childCount", "I");
|
||||
static jfieldID const countryItemFieldTotalChildCount = env->GetFieldID(g_countryItemClass, "totalChildCount", "I");
|
||||
static jfieldID const countryItemFieldPresent = env->GetFieldID(g_countryItemClass, "present", "Z");
|
||||
static jfieldID const countryItemFieldProgress = env->GetFieldID(g_countryItemClass, "progress", "I");
|
||||
static jfieldID const countryItemFieldProgress = env->GetFieldID(g_countryItemClass, "progress", "F");
|
||||
static jfieldID const countryItemFieldDownloadedBytes = env->GetFieldID(g_countryItemClass, "downloadedBytes", "J");
|
||||
static jfieldID const countryItemFieldBytesToDownload = env->GetFieldID(g_countryItemClass, "bytesToDownload", "J");
|
||||
|
||||
|
@ -226,14 +226,14 @@ static void UpdateItem(JNIEnv * env, jobject item, NodeAttrs const & attrs)
|
|||
env->SetBooleanField(item, countryItemFieldPresent, attrs.m_present);
|
||||
|
||||
// Progress
|
||||
int percentage = 0;
|
||||
float percentage = 0;
|
||||
if (attrs.m_downloadingProgress.m_bytesTotal != 0)
|
||||
{
|
||||
auto const & progress = attrs.m_downloadingProgress;
|
||||
percentage = (int)(progress.m_bytesDownloaded * kMaxProgress / progress.m_bytesTotal);
|
||||
percentage = progress.m_bytesDownloaded * kMaxProgress / progress.m_bytesTotal;
|
||||
}
|
||||
|
||||
env->SetIntField(item, countryItemFieldProgress, percentage);
|
||||
env->SetFloatField(item, countryItemFieldProgress, percentage);
|
||||
env->SetLongField(item, countryItemFieldDownloadedBytes, attrs.m_downloadingProgress.m_bytesDownloaded);
|
||||
env->SetLongField(item, countryItemFieldBytesToDownload, attrs.m_downloadingProgress.m_bytesTotal);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public final class CountryItem implements Comparable<CountryItem>
|
|||
public boolean present;
|
||||
|
||||
// Progress
|
||||
public int progress;
|
||||
public float progress;
|
||||
public long downloadedBytes;
|
||||
public long bytesToDownload;
|
||||
|
||||
|
@ -161,7 +161,7 @@ public final class CountryItem implements Comparable<CountryItem>
|
|||
", totalSize: " + totalSize +
|
||||
", childCount: " + childCount +
|
||||
", totalChildCount: " + totalChildCount +
|
||||
", progress: " + progress +
|
||||
", progress: " + String.format("%.2f", progress) +
|
||||
"% }";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,9 +191,9 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
|
|||
|
||||
private void updateProgress()
|
||||
{
|
||||
String text = String.format(Locale.US, "%1$s %2$d%%", getString(R.string.downloader_downloading), mDownloadingCountry.progress);
|
||||
String text = String.format(Locale.US, "%1$s %2$.2f%%", getString(R.string.downloader_downloading), mDownloadingCountry.progress);
|
||||
mTvProgress.setText(text);
|
||||
mWpvDownloadProgress.setProgress(mDownloadingCountry.progress);
|
||||
mWpvDownloadProgress.setProgress(Math.round(mDownloadingCountry.progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -94,7 +94,7 @@ public class DownloaderStatusIcon
|
|||
if (inProgress)
|
||||
{
|
||||
if (!pending)
|
||||
mProgress.setProgress(country.progress);
|
||||
mProgress.setProgress(Math.round(country.progress));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
|
@ -36,9 +35,6 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
private final WheelProgressView mProgress;
|
||||
private final Button mButton;
|
||||
|
||||
@NonNull
|
||||
private final View mPromoContentDivider;
|
||||
|
||||
private int mStorageSubscriptionSlot;
|
||||
|
||||
@Nullable
|
||||
|
@ -144,8 +140,8 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
if (progress)
|
||||
{
|
||||
mProgress.setPending(false);
|
||||
mProgress.setProgress(mCurrentCountry.progress);
|
||||
sizeText = String.format(Locale.US, "%1$s %2$d%%", mActivity.getString(R.string.downloader_downloading), mCurrentCountry.progress);
|
||||
mProgress.setProgress(Math.round(mCurrentCountry.progress));
|
||||
sizeText = String.format(Locale.US, "%1$s %2$.2f%%", mActivity.getString(R.string.downloader_downloading), mCurrentCountry.progress);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -226,8 +222,6 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
else
|
||||
MapManager.nativeDownload(mCurrentCountry.id);
|
||||
}));
|
||||
|
||||
mPromoContentDivider = mFrame.findViewById(R.id.onmap_downloader_divider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue