add holders for cards

This commit is contained in:
Chumva 2018-04-24 14:08:05 +03:00
parent 2973b7f2d3
commit ad514f2d29
6 changed files with 64 additions and 95 deletions

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/left_bottom_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/left_bottom_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Cancel" />
</FrameLayout>
<View
android:id="@+id/bottom_buttons_divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/wikivoyage_card_divider_color"
android:visibility="gone" />
<FrameLayout
android:id="@+id/right_bottom_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:visibility="gone">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/right_bottom_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Some Action" />
</FrameLayout>
</LinearLayout>

View file

@ -52,7 +52,7 @@
android:background="?attr/wikivoyage_card_divider_color" /> android:background="?attr/wikivoyage_card_divider_color" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/left_bottom_button_text" android:id="@+id/bottom_button_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_sheet_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:layout_gravity="center" android:layout_gravity="center"

View file

@ -63,7 +63,7 @@
android:background="?attr/wikivoyage_card_divider_color" /> android:background="?attr/wikivoyage_card_divider_color" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/left_bottom_button_text" android:id="@+id/bottom_button_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_sheet_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:layout_gravity="center" android:layout_gravity="center"

View file

@ -29,7 +29,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment {
final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false); final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false);
ArrayList<BaseTravelCard> items = new ArrayList<>(); ArrayList<BaseTravelCard> items = new ArrayList<>();
BaseTravelCard openBetaTravelCard = new OpenBetaTravelCard(app, nightMode, getFragmentManager()); BaseTravelCard openBetaTravelCard = new OpenBetaTravelCard(app, nightMode, getFragmentManager());

View file

@ -3,8 +3,6 @@ package net.osmand.plus.wikivoyage.explore.travelcards;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -22,23 +20,37 @@ public class OpenBetaTravelCard extends BaseTravelCard {
this.fragmentManager = fragmentManager; this.fragmentManager = fragmentManager;
} }
@Override @Override
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) { public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; if (viewHolder instanceof OpenBetaTravelVH) {
View view = LayoutInflater.from(new ContextThemeWrapper(app, themeRes)) final OpenBetaTravelVH holder = (OpenBetaTravelVH) viewHolder;
.inflate(R.layout.wikivoyage_open_beta_card, null, false); holder.title.setText(R.string.welcome_to_open_beta);
ImageView imageView = (ImageView) view.findViewById(R.id.background_image); holder.description.setText(R.string.welcome_to_open_beta_description);
imageView.setImageResource(R.drawable.img_help_wikivoyage_articles); holder.backgroundImage.setImageResource(R.drawable.img_help_wikivoyage_articles);
((TextView) view.findViewById(R.id.title)).setText(R.string.welcome_to_open_beta); holder.button.setText(R.string.get_unlimited_access);
((TextView) view.findViewById(R.id.description)).setText(R.string.welcome_to_open_beta_description); holder.button.setOnClickListener(new View.OnClickListener() {
((TextView) view.findViewById(R.id.left_bottom_button_text)).setText(R.string.get_unlimited_access); @Override
view.findViewById(R.id.left_bottom_button).setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
@Override ChoosePlanDialogFragment.showFreeVersionInstance(fragmentManager);
public void onClick(View v) { }
ChoosePlanDialogFragment.showFreeVersionInstance(fragmentManager); });
} }
}); }
class OpenBetaTravelVH extends RecyclerView.ViewHolder {
final TextView title;
final TextView description;
final TextView button;
final ImageView backgroundImage;
OpenBetaTravelVH(final View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.title);
description = (TextView) itemView.findViewById(R.id.description);
button = (TextView) itemView.findViewById(R.id.bottom_button_text);
backgroundImage = (ImageView) itemView.findViewById(R.id.background_image);
}
} }
@Override @Override

View file

@ -5,8 +5,6 @@ import android.support.annotation.NonNull;
import android.support.customtabs.CustomTabsIntent; import android.support.customtabs.CustomTabsIntent;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -22,24 +20,39 @@ public class StartEditingTravelCard extends BaseTravelCard {
@Override @Override
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) { public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; if (viewHolder instanceof OpenBetaTravelVH) {
View view = LayoutInflater.from(new ContextThemeWrapper(app, themeRes)) final OpenBetaTravelVH holder = (OpenBetaTravelVH) viewHolder;
.inflate(R.layout.wikivoyage_open_beta_card, null, false); holder.title.setText(R.string.start_editing_card_image_text);
ImageView imageView = (ImageView) view.findViewById(R.id.background_image); holder.description.setText(R.string.start_editing_card_description);
imageView.setImageResource(R.drawable.img_help_wikivoyage_articles); holder.backgroundImage.setImageResource(R.drawable.img_help_wikivoyage_contribute);
((TextView) view.findViewById(R.id.title)).setText(R.string.welcome_to_open_beta); holder.button.setText(R.string.start_editing);
((TextView) view.findViewById(R.id.description)).setText(R.string.welcome_to_open_beta_description); holder.button.setOnClickListener(new View.OnClickListener() {
((TextView) view.findViewById(R.id.left_bottom_button_text)).setText(R.string.get_unlimited_access); @Override
view.findViewById(R.id.left_bottom_button).setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
@Override CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
public void onClick(View v) { .setToolbarColor(ContextCompat.getColor(app, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() .build();
.setToolbarColor(ContextCompat.getColor(app, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color)) String text = "https://" + app.getLanguage().toLowerCase() + ".m.wikivoyage.org";
.build(); customTabsIntent.launchUrl(app, Uri.parse(text));
String text = "https://" + app.getLanguage().toLowerCase() + ".m.wikivoyage.org"; }
customTabsIntent.launchUrl(app, Uri.parse(text)); });
} }
}); }
class OpenBetaTravelVH extends RecyclerView.ViewHolder {
final TextView title;
final TextView description;
final TextView button;
final ImageView backgroundImage;
OpenBetaTravelVH(final View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.title);
description = (TextView) itemView.findViewById(R.id.description);
button = (TextView) itemView.findViewById(R.id.bottom_button_text);
backgroundImage = (ImageView) itemView.findViewById(R.id.background_image);
}
} }
@Override @Override