Merge pull request #5030 from goblinr/MAPSME-90-ext-illustrations-refactoring

[android] Placeholders refactoring
This commit is contained in:
Aleksandr Zatsepin 2017-01-11 09:58:06 +03:00 committed by GitHub
commit 8d945dd0d1
61 changed files with 260 additions and 65 deletions

View file

@ -188,7 +188,8 @@
android:name="com.mapswithme.maps.downloader.DownloaderActivity"
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/download_maps"
android:parentActivityName="com.mapswithme.maps.MwmActivity">
android:parentActivityName="com.mapswithme.maps.MwmActivity"
android:windowSoftInputMode="adjustResize">
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
@ -200,7 +201,7 @@
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/search_map"
android:parentActivityName="com.mapswithme.maps.MwmActivity"
android:windowSoftInputMode="stateVisible|adjustNothing">
android:windowSoftInputMode="stateVisible|adjustResize">
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
@ -222,7 +223,8 @@
android:name="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity"
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/bookmark_sets"
android:parentActivityName="com.mapswithme.maps.MwmActivity">
android:parentActivityName="com.mapswithme.maps.MwmActivity"
android:windowSoftInputMode="adjustResize">
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
@ -233,7 +235,8 @@
android:name="com.mapswithme.maps.bookmarks.BookmarkListActivity"
android:configChanges="orientation|screenLayout|screenSize"
android:label="@string/bookmarks"
android:parentActivityName="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity">
android:parentActivityName="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity"
android:windowSoftInputMode="adjustResize">
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View file

@ -38,10 +38,15 @@
android:layout_marginBottom="@dimen/margin_base"
android:src="?fabAdd"/>
<include
layout="@layout/placeholder"
<com.mapswithme.maps.widget.PlaceholderView
android:id="@+id/placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:layout_above="@id/action"/>
android:layout_above="@id/action"
android:paddingLeft="@dimen/margin_double_and_half"
android:paddingRight="@dimen/margin_double_and_half"
android:paddingTop="@dimen/placeholder_margin_top"
android:visibility="gone"
tools:visibility="visible"/>
</RelativeLayout>

View file

@ -57,7 +57,15 @@
android:background="?windowBackgroundForced">
<include layout="@layout/recycler_default"/>
<include layout="@layout/placeholder"/>
<com.mapswithme.maps.widget.PlaceholderView
android:id="@+id/placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/margin_double_and_half"
android:paddingRight="@dimen/margin_double_and_half"
android:paddingTop="@dimen/placeholder_margin_top"
android:visibility="gone"
tools:visibility="visible"/>
</FrameLayout>
<!-- Country download suggest fragment -->

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/MwmWidget.FrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/recycler_default"/>
<com.mapswithme.maps.widget.PlaceholderView
android:id="@+id/placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/margin_double_and_half"
android:paddingRight="@dimen/margin_double_and_half"
android:paddingTop="@dimen/placeholder_margin_top"
android:visibility="gone"
tools:visibility="visible"/>
</FrameLayout>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MwmWidget.FrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/recycler_default"/>
<include layout="@layout/placeholder"/>
</FrameLayout>

View file

@ -9,5 +9,4 @@
android:paddingLeft="@dimen/margin_double_plus"
android:paddingRight="@dimen/margin_double_plus"
android:paddingTop="@dimen/margin_base"
android:text="@string/bookmarks_usage_hint"
android:textAppearance="@style/MwmTextAppearance.Body2"/>

View file

@ -1,36 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mapswithme.maps.widget.HeightLimitedFrameLayout
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/margin_half"
android:paddingRight="@dimen/margin_half"
android:visibility="gone"
tools:visibility="visible">
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/placeholder_size"
android:orientation="vertical"
android:layout_marginTop="@dimen/margin_double"
android:layout_gravity="center_horizontal"
android:gravity="center">
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/placeholder_size"
android:layout_height="@dimen/placeholder_size"
android:layout_marginBottom="@dimen/margin_base_plus"
android:tag="@string/tag_height_limited"
android:layout_marginBottom="@dimen/margin_half_plus"
tools:src="@drawable/img_search_empty_history_light"/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_base"
android:textAppearance="@style/MwmTextAppearance.Title"
android:layout_marginBottom="@dimen/margin_half_plus"
android:textAppearance="@style/MwmTextAppearance.Title.Toolbar"
android:gravity="center_horizontal"
tools:text="Some long long long placeholder title"/>
@ -38,8 +29,8 @@
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.Body2"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:gravity="center_horizontal"
tools:text="Some placeholder text"/>
</LinearLayout>
</com.mapswithme.maps.widget.HeightLimitedFrameLayout>
</merge>

View file

@ -45,6 +45,7 @@
<dimen name="panel_width">360dp</dimen>
<dimen name="button_width">240dp</dimen>
<dimen name="placeholder_size">200dp</dimen>
<dimen name="placeholder_size_small">160dp</dimen>
<dimen name="width_dialog_base">300dp</dimen>
@ -170,4 +171,8 @@
<dimen name="placepage_taxi_button_min_width">96dp</dimen>
<dimen name="placepage_taxi_padding_vert">14dp</dimen>
<dimen name="placepage_taxi_button_padding_vert">10dp</dimen>
<!-- Placeholder-->
<dimen name="placeholder_margin_top">20dp</dimen>
<dimen name="placeholder_margin_top_no_image">80dp</dimen>
</resources>

View file

@ -16,6 +16,11 @@
<item name="android:textColor">?android:textColorPrimary</item>
</style>
<style name="MwmTextAppearance.Title.Toolbar">
<item name="android:textSize">@dimen/text_size_toolbar</item>
<item name="android:fontFamily" tools:targetApi="jelly_bean">@string/robotoMedium</item>
</style>
<style name="MwmTextAppearance.Headline">
<item name="android:textSize">@dimen/text_size_headline</item>
<item name="android:textColor">?android:textColorPrimary</item>

View file

@ -2,6 +2,7 @@ package com.mapswithme.maps.base;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@ -11,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import com.mapswithme.maps.R;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@ -18,7 +20,7 @@ public abstract class BaseMwmRecyclerFragment extends Fragment
{
private Toolbar mToolbar;
private RecyclerView mRecycler;
private View mPlaceholder;
private PlaceholderView mPlaceholder;
protected abstract RecyclerView.Adapter createAdapter();
@ -66,7 +68,7 @@ public abstract class BaseMwmRecyclerFragment extends Fragment
mRecycler.setLayoutManager(manager);
mRecycler.setAdapter(createAdapter());
mPlaceholder = view.findViewById(R.id.placeholder);
mPlaceholder = (PlaceholderView) view.findViewById(R.id.placeholder);
setupPlaceholder(mPlaceholder);
}
@ -95,7 +97,7 @@ public abstract class BaseMwmRecyclerFragment extends Fragment
org.alohalytics.Statistics.logEvent("$onPause", this.getClass().getSimpleName());
}
protected void setupPlaceholder(View placeholder) {}
protected void setupPlaceholder(@NonNull PlaceholderView placeholder) {}
public void setupPlaceholder()
{

View file

@ -3,6 +3,7 @@ package com.mapswithme.maps.bookmarks;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.view.View;
@ -12,6 +13,7 @@ import com.mapswithme.maps.base.BaseMwmRecyclerFragment;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.dialog.EditTextDialogFragment;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.maps.widget.recycler.RecyclerClickListener;
import com.mapswithme.maps.widget.recycler.RecyclerLongClickListener;
import com.mapswithme.util.BottomSheetHelper;
@ -28,7 +30,7 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment
@Override
protected @LayoutRes int getLayoutRes()
{
return R.layout.recycler_default;
return R.layout.fragment_search_base;
}
@Override
@ -50,6 +52,19 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment
getAdapter().setOnClickListener(this);
getAdapter().setOnLongClickListener(this);
getAdapter().registerAdapterDataObserver(new RecyclerView.AdapterDataObserver()
{
@Override
public void onChanged()
{
updateResultsPlaceholder();
}
});
}
private void updateResultsPlaceholder()
{
showPlaceholder(getAdapter().getItemCount() == 1);
}
@Override
@ -126,4 +141,10 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment
startActivity(new Intent(getActivity(), BookmarkListActivity.class)
.putExtra(ChooseBookmarkCategoryFragment.CATEGORY_ID, position));
}
@Override
protected void setupPlaceholder(@NonNull PlaceholderView placeholder)
{
placeholder.setContent(R.drawable.img_bookmarks, R.string.bookmarks_empty_title, R.string.bookmarks_usage_hint);
}
}

View file

@ -14,6 +14,7 @@ import com.mapswithme.maps.base.BaseMwmRecyclerFragment;
import com.mapswithme.maps.base.OnBackPressListener;
import com.mapswithme.maps.search.NativeMapSearchListener;
import com.mapswithme.maps.search.SearchEngine;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.util.UiUtils;
public class DownloaderFragment extends BaseMwmRecyclerFragment
@ -201,13 +202,13 @@ public class DownloaderFragment extends BaseMwmRecyclerFragment
}
@Override
protected void setupPlaceholder(View placeholder)
protected void setupPlaceholder(@NonNull PlaceholderView placeholder)
{
if (mAdapter.isSearchResultsMode())
UiUtils.setupPlaceholder(placeholder, R.drawable.img_search_nothing_found_light,
R.string.search_not_found, R.string.search_not_found_query);
placeholder.setContent(R.drawable.img_search_nothing_found_light,
R.string.search_not_found, R.string.search_not_found_query);
else
UiUtils.setupPlaceholder(placeholder, R.drawable.img_search_no_maps,
R.string.downloader_no_downloaded_maps_title, R.string.downloader_no_downloaded_maps_message);
placeholder.setContent(R.drawable.img_search_no_maps,
R.string.downloader_no_downloaded_maps_title, R.string.downloader_no_downloaded_maps_message);
}
}

View file

@ -31,6 +31,7 @@ import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.location.LocationListener;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.maps.widget.SearchToolbarController;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@ -122,7 +123,7 @@ public class SearchFragment extends BaseMwmFragment
private View mTabFrame;
private View mResultsFrame;
private View mResultsPlaceholder;
private PlaceholderView mResultsPlaceholder;
private SearchToolbarController mToolbarController;
@ -232,8 +233,9 @@ public class SearchFragment extends BaseMwmFragment
mResultsFrame = root.findViewById(R.id.results_frame);
RecyclerView results = (RecyclerView) mResultsFrame.findViewById(R.id.recycler);
setRecyclerScrollListener(results);
mResultsPlaceholder = mResultsFrame.findViewById(R.id.placeholder);
UiUtils.setupPlaceholder(mResultsPlaceholder, R.drawable.img_search_nothing_found_light, R.string.search_not_found, R.string.search_not_found_query);
mResultsPlaceholder = (PlaceholderView) mResultsFrame.findViewById(R.id.placeholder);
mResultsPlaceholder.setContent(R.drawable.img_search_nothing_found_light,
R.string.search_not_found, R.string.search_not_found_query);
if (mSearchAdapter == null)
{

View file

@ -7,12 +7,13 @@ import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmRecyclerFragment;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.maps.widget.SearchToolbarController;
import com.mapswithme.util.UiUtils;
public class SearchHistoryFragment extends BaseMwmRecyclerFragment
{
private View mPlaceHolder;
private PlaceholderView mPlaceHolder;
private void updatePlaceholder()
{
@ -28,15 +29,16 @@ public class SearchHistoryFragment extends BaseMwmRecyclerFragment
@Override
protected @LayoutRes int getLayoutRes()
{
return R.layout.fragment_search_recent;
return R.layout.fragment_search_base;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
mPlaceHolder = view.findViewById(R.id.placeholder);
UiUtils.setupPlaceholder(mPlaceHolder, R.drawable.img_search_empty_history_light, R.string.search_history_title, R.string.search_history_text);
mPlaceHolder = (PlaceholderView) view.findViewById(R.id.placeholder);
mPlaceHolder.setContent(R.drawable.img_search_empty_history_light,
R.string.search_history_title, R.string.search_history_text);
getAdapter().registerAdapterDataObserver(new RecyclerView.AdapterDataObserver()
{

View file

@ -0,0 +1,157 @@
package com.mapswithme.maps.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
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;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
public class PlaceholderView extends FrameLayout
{
@Nullable
private ImageView mImage;
@Nullable
private TextView mTitle;
@Nullable
private TextView mSubtitle;
private final float mImageSizeFull;
private final float mImageSizeSmall;
private final float mPaddingImage;
private final float mPaddingNoImage;
private final float mScreenHeight;
private final float mScreenWidth;
private int mOrientation;
public PlaceholderView(Context context)
{
this(context, null, 0, 0);
}
public PlaceholderView(Context context, @Nullable AttributeSet attrs)
{
this(context, attrs, 0, 0);
}
public PlaceholderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr)
{
this(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public PlaceholderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
int defStyleRes)
{
super(context, attrs, defStyleAttr, defStyleRes);
Resources res = getResources();
mImageSizeFull = res.getDimension(R.dimen.placeholder_size);
mImageSizeSmall = res.getDimension(R.dimen.placeholder_size_small);
mPaddingImage = res.getDimension(R.dimen.placeholder_margin_top);
mPaddingNoImage = res.getDimension(R.dimen.placeholder_margin_top_no_image);
mScreenHeight = res.getDisplayMetrics().heightPixels;
mScreenWidth = res.getDisplayMetrics().widthPixels;
LayoutInflater.from(context).inflate(R.layout.placeholder, this, true);
}
@Override
protected void onFinishInflate()
{
super.onFinishInflate();
mImage = (ImageView) findViewById(R.id.image);
mTitle = (TextView) findViewById(R.id.title);
mSubtitle = (TextView) findViewById(R.id.subtitle);
ViewCompat.setOnApplyWindowInsetsListener(this, new 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.getSystemWindowInsetBottom() - location[1];
setLayoutParams(lp);
return insets;
}
});
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
//isInEditMode() need for correct editor visualization
if (isInEditMode() || mImage == null)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
if (mOrientation == Configuration.ORIENTATION_LANDSCAPE && !UiUtils.isTablet())
{
UiUtils.hide(mImage);
setPadding(getPaddingLeft(), (int) mPaddingNoImage, getPaddingRight(), getPaddingBottom());
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
setPadding(getPaddingLeft(), (int) mPaddingImage, getPaddingRight(), getPaddingBottom());
UiUtils.show(mImage);
ViewGroup.LayoutParams lp = mImage.getLayoutParams();
lp.width = (int) mImageSizeFull;
lp.height = (int) mImageSizeFull;
mImage.setLayoutParams(lp);
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
if (getMeasuredHeight() > MeasureSpec.getSize(heightMeasureSpec))
{
lp.width = (int) mImageSizeSmall;
lp.height = (int) mImageSizeSmall;
mImage.setLayoutParams(lp);
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
if (getMeasuredHeight() > MeasureSpec.getSize(heightMeasureSpec))
{
UiUtils.hide(mImage);
setPadding(getPaddingLeft(), (int) mPaddingNoImage, getPaddingRight(), getPaddingBottom());
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onConfigurationChanged(Configuration newConfig)
{
mOrientation = newConfig.orientation;
}
public void setContent(@DrawableRes int imageRes, @StringRes int titleRes,
@StringRes int subtitleRes)
{
if (mImage != null)
mImage.setImageResource(imageRes);
if (mTitle != null)
mTitle.setText(titleRes);
if (mSubtitle != null)
mSubtitle.setText(subtitleRes);
}
}

View file

@ -13,7 +13,6 @@ import android.net.Uri;
import android.os.Build;
import android.support.annotation.AnyRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
@ -32,12 +31,10 @@ import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.routing.RoutingController;
public final class UiUtils
{
@ -315,18 +312,6 @@ public final class UiUtils
: R.attr.accentButtonTextColorDisabled));
}
public static void setupPlaceholder(View frame, @DrawableRes int imageRes, @StringRes int titleRes, @StringRes int subtitleRes)
{
ImageView image = (ImageView) frame.findViewById(R.id.image);
image.setImageResource(imageRes);
TextView title = (TextView) frame.findViewById(R.id.title);
title.setText(titleRes);
TextView subtitle = (TextView) frame.findViewById(R.id.subtitle);
subtitle.setText(subtitleRes);
}
public static Uri getUriToResId(@NonNull Context context, @AnyRes int resId)
{
final Resources resources = context.getResources();