change click behaviour in expListView and style
This commit is contained in:
parent
f680d192d1
commit
f0e894a537
4 changed files with 71 additions and 63 deletions
|
@ -69,17 +69,6 @@
|
||||||
android:layout_gravity="bottom|center_horizontal"
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/bottom_row_divider"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?attr/wikivoyage_bottom_bar_divider_color"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||||
|
|
|
@ -1,54 +1,56 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/expandable_list_item_background"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/upper_row_divider"
|
android:id="@+id/upper_row_divider"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||||
android:background="?attr/wikivoyage_card_divider_color" />
|
android:background="?attr/wikivoyage_card_divider_color" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/item_label"
|
android:id="@+id/item_label"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
||||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:drawablePadding="@dimen/bottom_sheet_content_margin"
|
android:drawablePadding="@dimen/bottom_sheet_content_margin"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:drawableStart="@drawable/ic_action_list_header"
|
tools:drawableStart="@drawable/ic_action_list_header"
|
||||||
tools:text="@string/shared_string_contents" />
|
tools:text="@string/shared_string_contents" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/explist_indicator"
|
android:id="@+id/explist_indicator"
|
||||||
android:layout_width="24dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:layout_marginRight="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
android:scaleType="center" />
|
android:paddingRight="@dimen/list_content_padding"
|
||||||
|
android:scaleType="center"
|
||||||
|
tools:src="@drawable/ic_action_arrow_up"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/bottom_row_divider"
|
android:id="@+id/bottom_row_divider"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||||
android:background="?attr/wikivoyage_card_divider_color" />
|
android:background="?attr/wikivoyage_card_divider_color" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -10,10 +10,10 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
@ -35,6 +35,8 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
||||||
|
|
||||||
public static final int REQUEST_LINK_CODE = 0;
|
public static final int REQUEST_LINK_CODE = 0;
|
||||||
|
|
||||||
|
private ExpandableListView expListView;
|
||||||
|
|
||||||
private LinkedHashMap<String, String> map;
|
private LinkedHashMap<String, String> map;
|
||||||
private String link;
|
private String link;
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
||||||
|
|
||||||
items.add(new TitleItem(getString(R.string.shared_string_contents)));
|
items.add(new TitleItem(getString(R.string.shared_string_contents)));
|
||||||
|
|
||||||
ExpandableListView expListView = new ExpandableListView(getContext());
|
expListView = new ExpandableListView(getContext());
|
||||||
ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
|
ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
|
||||||
|
|
||||||
expListView.setAdapter(listAdapter);
|
expListView.setAdapter(listAdapter);
|
||||||
|
@ -84,6 +86,15 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
||||||
|
link = map.get(listDataHeader.get(groupPosition));
|
||||||
|
sendResult();
|
||||||
|
dismiss();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
LinearLayout container = new LinearLayout(getContext());
|
LinearLayout container = new LinearLayout(getContext());
|
||||||
container.addView(expListView);
|
container.addView(expListView);
|
||||||
|
|
||||||
|
@ -163,12 +174,11 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
||||||
txtListChild.setCompoundDrawablesWithIntrinsicBounds(itemChildIcon, null, null, null);
|
txtListChild.setCompoundDrawablesWithIntrinsicBounds(itemChildIcon, null, null, null);
|
||||||
|
|
||||||
convertView.findViewById(R.id.upper_row_divider).setVisibility(View.GONE);
|
convertView.findViewById(R.id.upper_row_divider).setVisibility(View.GONE);
|
||||||
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
|
|
||||||
txtListChild.setTypeface(null);
|
txtListChild.setTypeface(null);
|
||||||
if (childPosition == listDataChild.get(listDataHeader.get(groupPosition)).size() - 1) {
|
if (childPosition == listDataChild.get(listDataHeader.get(groupPosition)).size() - 1) {
|
||||||
convertView.setPadding(0, 0, 0, AndroidUtils.dpToPx(getContext(),7));
|
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
convertView.setPadding(0, 0, 0, 0);
|
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
@ -196,8 +206,8 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(final int groupPosition, boolean isExpanded,
|
public View getGroupView(final int groupPosition, final boolean isExpanded,
|
||||||
View convertView, ViewGroup parent) {
|
View convertView, ViewGroup parent) {
|
||||||
String headerTitle = (String) getGroup(groupPosition);
|
String headerTitle = (String) getGroup(groupPosition);
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = LayoutInflater.from(context)
|
convertView = LayoutInflater.from(context)
|
||||||
|
@ -209,17 +219,22 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
|
||||||
lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_contents_parent_icon_dark : R.color.wikivoyage_contents_parent_icon_light));
|
lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_contents_parent_icon_dark : R.color.wikivoyage_contents_parent_icon_light));
|
||||||
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(itemGroupIcon, null, null, null);
|
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(itemGroupIcon, null, null, null);
|
||||||
|
|
||||||
lblListHeader.setOnClickListener(new View.OnClickListener() {
|
adjustIndicator(getMyApplication(), groupPosition, isExpanded, convertView, light);
|
||||||
|
ImageView indicator = (ImageView) convertView.findViewById(R.id.explist_indicator);
|
||||||
|
indicator.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
link = map.get(listDataHeader.get(groupPosition));
|
if(isExpanded){
|
||||||
sendResult();
|
expListView.collapseGroup(groupPosition);
|
||||||
dismiss();
|
} else {
|
||||||
|
expListView.expandGroup(groupPosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
adjustIndicator(getMyApplication(), groupPosition, isExpanded, convertView, light);
|
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
|
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
View contents = (View) mainView.findViewById(R.id.bottom_bar);
|
||||||
|
AndroidUtils.setBackground(getContext(), contents, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
TextView contentsBtn = (TextView) mainView.findViewById(R.id.contents_button);
|
TextView contentsBtn = (TextView) mainView.findViewById(R.id.contents_button);
|
||||||
contentsBtn.setCompoundDrawablesWithIntrinsicBounds(
|
contentsBtn.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
getActiveIcon(R.drawable.ic_action_contents), null, null, null
|
getActiveIcon(R.drawable.ic_action_contents), null, null, null
|
||||||
|
|
Loading…
Reference in a new issue