[android] Upgraded placeholder view

This commit is contained in:
Dmitry Donskoy 2018-07-18 16:14:09 +03:00 committed by Vlad Mihaylenko
parent 39264c355a
commit c759831a45
3 changed files with 13 additions and 35 deletions

View file

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapsme="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
@ -61,7 +61,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/bookmark_recycler_view_bottom_margin"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -107,5 +107,5 @@
android:textAppearance="@style/MwmTextAppearance.Body3"
android:text="@string/load_kmz_title"/>
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>

View file

@ -20,7 +20,7 @@ public class SearchHistoryFragment extends BaseMwmRecyclerFragment<SearchHistory
private void updatePlaceholder()
{
UiUtils.showIf(getAdapter() != null && getAdapter().getItemCount() == 0, mPlaceHolder);
UiUtils.showIf(getAdapter().getItemCount() == 0, mPlaceHolder);
}
@NonNull
@ -45,17 +45,14 @@ public class SearchHistoryFragment extends BaseMwmRecyclerFragment<SearchHistory
mPlaceHolder.setContent(R.drawable.img_search_empty_history_light,
R.string.search_history_title, R.string.search_history_text);
if (getAdapter() != null)
getAdapter().registerAdapterDataObserver(new RecyclerView.AdapterDataObserver()
{
getAdapter().registerAdapterDataObserver(new RecyclerView.AdapterDataObserver()
@Override
public void onChanged()
{
@Override
public void onChanged()
{
updatePlaceholder();
}
});
}
updatePlaceholder();
}
});
updatePlaceholder();
}

View file

@ -9,8 +9,6 @@ import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.WindowInsetsCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@ -119,7 +117,6 @@ public class PlaceholderView extends FrameLayout
mSubtitle = (TextView) findViewById(R.id.subtitle);
setupDefaultContent();
ViewCompat.setOnApplyWindowInsetsListener(this, new ApplyWindowInsetsListener());
}
private void setupDefaultContent()
@ -201,20 +198,4 @@ public class PlaceholderView extends FrameLayout
if (mSubtitle != null)
mSubtitle.setText(subtitleRes);
}
private class ApplyWindowInsetsListener implements android.support.v4.view.OnApplyWindowInsetsListener
{
@Override
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets)
{
int height = (int) (mOrientation == Configuration.ORIENTATION_LANDSCAPE
? mScreenWidth : mScreenHeight);
int[] location = new int[2];
getLocationOnScreen(location);
ViewGroup.LayoutParams lp = getLayoutParams();
lp.height = height - insets.getStableInsetBottom() - location[1];
setLayoutParams(lp);
return insets;
}
}
}