add holders for cards
This commit is contained in:
parent
2973b7f2d3
commit
ad514f2d29
6 changed files with 64 additions and 95 deletions
|
@ -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>
|
|
@ -52,7 +52,7 @@
|
|||
android:background="?attr/wikivoyage_card_divider_color" />
|
||||
|
||||
<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_height="@dimen/bottom_sheet_title_height"
|
||||
android:layout_gravity="center"
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
android:background="?attr/wikivoyage_card_divider_color" />
|
||||
|
||||
<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_height="@dimen/bottom_sheet_title_height"
|
||||
android:layout_gravity="center"
|
||||
|
|
|
@ -29,7 +29,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment {
|
|||
|
||||
final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false);
|
||||
|
||||
|
||||
ArrayList<BaseTravelCard> items = new ArrayList<>();
|
||||
|
||||
BaseTravelCard openBetaTravelCard = new OpenBetaTravelCard(app, nightMode, getFragmentManager());
|
||||
|
|
|
@ -3,8 +3,6 @@ package net.osmand.plus.wikivoyage.explore.travelcards;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -22,23 +20,37 @@ public class OpenBetaTravelCard extends BaseTravelCard {
|
|||
this.fragmentManager = fragmentManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
View view = LayoutInflater.from(new ContextThemeWrapper(app, themeRes))
|
||||
.inflate(R.layout.wikivoyage_open_beta_card, null, false);
|
||||
ImageView imageView = (ImageView) view.findViewById(R.id.background_image);
|
||||
imageView.setImageResource(R.drawable.img_help_wikivoyage_articles);
|
||||
((TextView) view.findViewById(R.id.title)).setText(R.string.welcome_to_open_beta);
|
||||
((TextView) view.findViewById(R.id.description)).setText(R.string.welcome_to_open_beta_description);
|
||||
((TextView) view.findViewById(R.id.left_bottom_button_text)).setText(R.string.get_unlimited_access);
|
||||
view.findViewById(R.id.left_bottom_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChoosePlanDialogFragment.showFreeVersionInstance(fragmentManager);
|
||||
}
|
||||
});
|
||||
if (viewHolder instanceof OpenBetaTravelVH) {
|
||||
final OpenBetaTravelVH holder = (OpenBetaTravelVH) viewHolder;
|
||||
holder.title.setText(R.string.welcome_to_open_beta);
|
||||
holder.description.setText(R.string.welcome_to_open_beta_description);
|
||||
holder.backgroundImage.setImageResource(R.drawable.img_help_wikivoyage_articles);
|
||||
holder.button.setText(R.string.get_unlimited_access);
|
||||
holder.button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
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
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.support.annotation.NonNull;
|
|||
import android.support.customtabs.CustomTabsIntent;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -22,24 +20,39 @@ public class StartEditingTravelCard extends BaseTravelCard {
|
|||
|
||||
@Override
|
||||
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
View view = LayoutInflater.from(new ContextThemeWrapper(app, themeRes))
|
||||
.inflate(R.layout.wikivoyage_open_beta_card, null, false);
|
||||
ImageView imageView = (ImageView) view.findViewById(R.id.background_image);
|
||||
imageView.setImageResource(R.drawable.img_help_wikivoyage_articles);
|
||||
((TextView) view.findViewById(R.id.title)).setText(R.string.welcome_to_open_beta);
|
||||
((TextView) view.findViewById(R.id.description)).setText(R.string.welcome_to_open_beta_description);
|
||||
((TextView) view.findViewById(R.id.left_bottom_button_text)).setText(R.string.get_unlimited_access);
|
||||
view.findViewById(R.id.left_bottom_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
|
||||
.setToolbarColor(ContextCompat.getColor(app, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
|
||||
.build();
|
||||
String text = "https://" + app.getLanguage().toLowerCase() + ".m.wikivoyage.org";
|
||||
customTabsIntent.launchUrl(app, Uri.parse(text));
|
||||
}
|
||||
});
|
||||
if (viewHolder instanceof OpenBetaTravelVH) {
|
||||
final OpenBetaTravelVH holder = (OpenBetaTravelVH) viewHolder;
|
||||
holder.title.setText(R.string.start_editing_card_image_text);
|
||||
holder.description.setText(R.string.start_editing_card_description);
|
||||
holder.backgroundImage.setImageResource(R.drawable.img_help_wikivoyage_contribute);
|
||||
holder.button.setText(R.string.start_editing);
|
||||
holder.button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
|
||||
.setToolbarColor(ContextCompat.getColor(app, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
|
||||
.build();
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue