forked from organicmaps/organicmaps
[android] remove progress bar visualization from banner.
This commit is contained in:
parent
b9435bb097
commit
faf7bd70b9
2 changed files with 11 additions and 67 deletions
|
@ -110,38 +110,4 @@
|
|||
android:visibility="gone"
|
||||
tools:text="Заказать"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progress_bar"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
<ProgressBar
|
||||
android:layout_width="@dimen/margin_base_plus"
|
||||
android:layout_height="@dimen/margin_base_plus"
|
||||
android:layout_marginRight="@dimen/margin_half"
|
||||
android:layout_marginEnd="@dimen/margin_half"
|
||||
style="@style/Widget.AppCompat.ProgressBar"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body4"
|
||||
android:lines="1"
|
||||
android:text="@string/downloading"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body4"
|
||||
android:lines="1"
|
||||
android:text="@string/download_failed"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -63,10 +63,6 @@ final class BannerController implements AdListener
|
|||
private final TextView mActionLarge;
|
||||
@Nullable
|
||||
private final View mAds;
|
||||
@Nullable
|
||||
private final View mProgressBar;
|
||||
@Nullable
|
||||
private final View mError;
|
||||
|
||||
private final float mCloseFrameHeight;
|
||||
|
||||
|
@ -74,6 +70,8 @@ final class BannerController implements AdListener
|
|||
private NativeAd mNativeAd;
|
||||
|
||||
private boolean mOpened = false;
|
||||
private boolean mProgress = false;
|
||||
private boolean mError = false;
|
||||
|
||||
BannerController(@NonNull View bannerView)
|
||||
{
|
||||
|
@ -86,50 +84,33 @@ final class BannerController implements AdListener
|
|||
mActionSmall = (TextView) bannerView.findViewById(R.id.tv__action_small);
|
||||
mActionLarge = (TextView) bannerView.findViewById(R.id.tv__action_large);
|
||||
mAds = bannerView.findViewById(R.id.tv__ads);
|
||||
mProgressBar = bannerView.findViewById(R.id.progress_bar);
|
||||
mError = bannerView.findViewById(R.id.error);
|
||||
}
|
||||
|
||||
private void showProgress()
|
||||
{
|
||||
if (mProgressBar != null)
|
||||
UiUtils.show(mProgressBar);
|
||||
|
||||
mProgress = true;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
private void hideProgress()
|
||||
{
|
||||
if (mProgressBar != null)
|
||||
UiUtils.hide(mProgressBar);
|
||||
|
||||
mProgress = false;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
private boolean isDownloading()
|
||||
{
|
||||
return mProgressBar != null && !UiUtils.isHidden(mProgressBar);
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
private void showError()
|
||||
private void showError(boolean value)
|
||||
{
|
||||
if (mError == null)
|
||||
return;
|
||||
|
||||
UiUtils.show(mError);
|
||||
}
|
||||
|
||||
private void hideError()
|
||||
{
|
||||
if (mError == null)
|
||||
return;
|
||||
|
||||
UiUtils.hide(mError);
|
||||
mError = value;
|
||||
}
|
||||
|
||||
private boolean errorHasOccurred()
|
||||
{
|
||||
return mError != null && !UiUtils.isHidden(mError);
|
||||
return mError;
|
||||
}
|
||||
|
||||
private void updateVisibility()
|
||||
|
@ -138,12 +119,9 @@ final class BannerController implements AdListener
|
|||
|| mActionLarge == null || mAds == null)
|
||||
return;
|
||||
|
||||
boolean hasError = errorHasOccurred();
|
||||
if (isDownloading() || hasError)
|
||||
if (isDownloading() || errorHasOccurred())
|
||||
{
|
||||
UiUtils.hide(mIcon, mTitle, mMessage, mActionSmall, mActionLarge, mAds);
|
||||
if (hasError && mProgressBar != null)
|
||||
UiUtils.hide(mProgressBar);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -158,7 +136,7 @@ final class BannerController implements AdListener
|
|||
void updateData(@Nullable Banner banner)
|
||||
{
|
||||
UiUtils.hide(mFrame);
|
||||
hideError();
|
||||
showError(false);
|
||||
|
||||
mBanner = banner;
|
||||
if (mBanner == null || TextUtils.isEmpty(mBanner.getId()) || !isShowcaseSwitchedOnLocal()
|
||||
|
@ -249,7 +227,7 @@ final class BannerController implements AdListener
|
|||
@Override
|
||||
public void onError(Ad ad, AdError adError)
|
||||
{
|
||||
showError();
|
||||
showError(true);
|
||||
updateVisibility();
|
||||
LOGGER.e(TAG, adError.getErrorMessage());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue