add contents for anchor links
This commit is contained in:
parent
d8184ac39a
commit
e440a1301f
6 changed files with 443 additions and 11 deletions
|
@ -1,8 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout 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="match_parent"
|
||||
android:background="?attr/wikivoyage_bg_color">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/wikivoyage_bg_color"
|
||||
|
@ -56,3 +60,92 @@
|
|||
android:layout_height="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bottom_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:background="@color/ctx_menu_card_btn_light"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_row_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/contents_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_padding_small"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_padding_small"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
||||
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:text="@string/article_contents_title"
|
||||
android:textColor="?attr/wikivoyage_active_color"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:drawableLeft="@drawable/ic_action_list_header"
|
||||
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_buttons_divider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground" >
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/save_text_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_padding_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_padding_small"
|
||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
||||
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textColor="?attr/wikivoyage_active_color"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:drawableRight="@drawable/ic_action_read_later_fill"
|
||||
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
15
OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml
Normal file
15
OsmAnd/res/layout/wikivoyage_contents_expandablelistview.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/expandableListView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:childDivider="@color/color_transparent"
|
||||
android:divider="@android:color/darker_gray"
|
||||
android:dividerHeight="0.5dp" />
|
||||
|
||||
</LinearLayout>
|
25
OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml
Normal file
25
OsmAnd/res/layout/wikivoyage_contents_group_list_item.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/expandable_list_item_background"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/group_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/showAllButtonMarginRight"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="@dimen/showAllButtonMarginRight"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:drawableStart="@drawable/ic_action_list_sort"
|
||||
tools:text="@string/article_contents_title"
|
||||
tools:textStyle="bold" />
|
||||
|
||||
|
||||
</LinearLayout>
|
|
@ -12,6 +12,7 @@
|
|||
<string name="shared_string_read">Read</string>
|
||||
<string name="saved_articles">Saved articles</string>
|
||||
<string name="shared_string_explore">Explore</string>
|
||||
<string name="article_contents_title">Contents</string>
|
||||
<string name="shared_string_result">Result</string>
|
||||
<string name="use_two_digits_longitude">Use two digits longitude</string>
|
||||
<string name="shared_string_travel">Travel</string>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.wikivoyage;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
@ -21,9 +22,11 @@ import android.widget.TextView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsBottomSheetDialogFragment;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -42,15 +45,18 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" +
|
||||
"<meta http-equiv=\"cleartype\" content=\"on\" />\n" +
|
||||
"<link href=\"article_style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
|
||||
"</head><body>\n";
|
||||
"</head><body>\n" + "<script>" + "function scrollAnchor(id) {" +
|
||||
"window.location.hash = id;}</script>";
|
||||
private static final String FOOTER_INNER = "</div></body></html>";
|
||||
|
||||
private long cityId = NO_VALUE;
|
||||
private ArrayList<String> langs;
|
||||
private String selectedLang;
|
||||
private String contentsJson;
|
||||
|
||||
private TextView selectedLangTv;
|
||||
private WebView contentWebView;
|
||||
private WikivoyageArticleDialogFragment thiss;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
@ -58,7 +64,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
if (savedInstanceState != null) {
|
||||
selectedLang = savedInstanceState.getString(SELECTED_LANG_KEY);
|
||||
}
|
||||
|
||||
thiss = this;
|
||||
final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container);
|
||||
|
||||
setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar));
|
||||
|
@ -81,6 +87,36 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
}
|
||||
});
|
||||
|
||||
final View buttomBar = mainView.findViewById(R.id.bottom_bar);
|
||||
|
||||
buttomBar.setBackgroundColor(getResolvedColor(isNightMode(false) ? R.color.status_bar_wikivoyage_article_dark : R.color.ctx_menu_card_btn_light));
|
||||
|
||||
TextViewEx contentsButton = mainView.findViewById(R.id.contents_button);
|
||||
TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_text_button);
|
||||
|
||||
saveButton.setCompoundDrawablesWithIntrinsicBounds(null,
|
||||
null, getMyApplication().getIconsCache()
|
||||
.getIcon(R.drawable.ic_action_read_later, isNightMode(false) ?
|
||||
R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null);
|
||||
|
||||
contentsButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_header,
|
||||
isNightMode(false) ? R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light),
|
||||
null, null, null);
|
||||
|
||||
contentsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentManager fm = getActivity().getSupportFragmentManager();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("CONTENTS_JSON", contentsJson);
|
||||
WikivoyageArticleContentsBottomSheetDialogFragment fragment = new WikivoyageArticleContentsBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(thiss, 0);
|
||||
fragment.show(fm, WikivoyageArticleContentsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
contentWebView = (WebView) mainView.findViewById(R.id.content_web_view);
|
||||
|
||||
return mainView;
|
||||
|
@ -97,6 +133,15 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
outState.putString(SELECTED_LANG_KEY, selectedLang);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 0) {
|
||||
String link = data.getStringExtra("test");
|
||||
moveAnchor(link);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getStatusBarColor() {
|
||||
return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light;
|
||||
|
@ -147,12 +192,17 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
if (article == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
contentsJson = article.getContentsJson();
|
||||
WikivoyageLocalDataHelper.getInstance(getMyApplication()).addToHistory(article);
|
||||
|
||||
contentWebView.getSettings().setJavaScriptEnabled(true);
|
||||
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null);
|
||||
}
|
||||
|
||||
public void moveAnchor(String id) {
|
||||
contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\")");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String createHtmlContent(@NonNull WikivoyageArticle article) {
|
||||
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
||||
|
|
|
@ -0,0 +1,248 @@
|
|||
package net.osmand.plus.wikivoyage.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.OnGroupClickListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "WikivoyageArticleContentsBottomSheetDialogFragment";
|
||||
private LinkedHashMap<String, String> map;
|
||||
private String link;
|
||||
private OsmandApplication app;
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
String contentsJson;
|
||||
if (args != null) {
|
||||
contentsJson = args.getString("CONTENTS_JSON");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
app = getMyApplication();
|
||||
final ArrayList<String> listDataHeader = new ArrayList<String>();
|
||||
final LinkedHashMap<String, List<String>> listDataChild = new LinkedHashMap<String, List<String>>();
|
||||
|
||||
map = new LinkedHashMap<>();
|
||||
JSONObject reader = null;
|
||||
try {
|
||||
reader = new JSONObject(contentsJson);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
List<String> secondLevel = null;
|
||||
JSONArray jArray = reader.names();
|
||||
for (int i = 0; i < jArray.length(); i++) {
|
||||
try {
|
||||
JSONArray contacts = reader.getJSONArray(reader.names().getString(i));
|
||||
String link = contacts.getString(1);
|
||||
|
||||
map.put(reader.names().getString(i), link);
|
||||
|
||||
int level = contacts.getInt(0);
|
||||
|
||||
if (level == 2) {
|
||||
listDataHeader.add(reader.names().getString(i));
|
||||
secondLevel = new ArrayList<String>();
|
||||
}
|
||||
if (level == 3) {
|
||||
if (secondLevel == null) {
|
||||
secondLevel = new ArrayList<String>();
|
||||
}
|
||||
secondLevel.add(reader.names().getString(i));
|
||||
listDataChild.put(listDataHeader.get(listDataHeader.size() - 1), secondLevel);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
items.add(new TitleItem(getString(R.string.article_contents_title)));
|
||||
LayoutInflater li = LayoutInflater.from(getContext());
|
||||
View view = li.inflate(R.layout.wikivoyage_contents_expandablelistview, null);
|
||||
ExpandableListView expListView = view.findViewById(R.id.expandableListView);
|
||||
|
||||
ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
|
||||
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v,
|
||||
int groupPosition, int childPosition, long id) {
|
||||
link = map.get(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition));
|
||||
sendResult(0);
|
||||
dismiss();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
DisplayMetrics diaplayMetrics;
|
||||
int width;
|
||||
diaplayMetrics = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(diaplayMetrics);
|
||||
width = diaplayMetrics.widthPixels;
|
||||
if (android.os.Build.VERSION.SDK_INT < 18) {
|
||||
expListView.setIndicatorBounds(width - ((int) (50 * getResources().getDisplayMetrics().density + 0.5f)), width - ((int) (10 * getResources().getDisplayMetrics().density + 0.5f)));
|
||||
} else {
|
||||
expListView.setIndicatorBoundsRelative(width - ((int) (50 * getResources().getDisplayMetrics().density + 0.5f)), width - ((int) (10 * getResources().getDisplayMetrics().density + 0.5f)));
|
||||
}
|
||||
expListView.setIndicatorBounds(200, 50);
|
||||
expListView.setOnGroupClickListener(new OnGroupClickListener() {
|
||||
@Override
|
||||
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
||||
link = map.get(listDataHeader.get(groupPosition));
|
||||
sendResult(0);
|
||||
if (listDataChild.get(listDataHeader.get(groupPosition)) == null) {
|
||||
dismiss();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
expListView.setAdapter(listAdapter);
|
||||
BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder()
|
||||
.setCustomView(view)
|
||||
.create();
|
||||
items.add(favoritesItem);
|
||||
|
||||
}
|
||||
|
||||
private void sendResult(int REQUEST_CODE) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("test", link);
|
||||
getTargetFragment().onActivityResult(
|
||||
getTargetRequestCode(), REQUEST_CODE, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useScrollableItemsContainer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
class ExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
private Context _context;
|
||||
private List<String> _listDataHeader;
|
||||
private LinkedHashMap<String, List<String>> _listDataChild;
|
||||
|
||||
public ExpandableListAdapter(Context context, List<String> listDataHeader,
|
||||
LinkedHashMap<String, List<String>> listChildData) {
|
||||
this._context = context;
|
||||
this._listDataHeader = listDataHeader;
|
||||
this._listDataChild = listChildData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosititon) {
|
||||
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
|
||||
.get(childPosititon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return childPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, final int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
|
||||
final String childText = (String) getChild(groupPosition, childPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
LayoutInflater infalInflater = (LayoutInflater) this._context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = infalInflater.inflate(R.layout.wikivoyage_contents_group_list_item, null);
|
||||
}
|
||||
|
||||
TextView txtListChild = (TextView) convertView.findViewById(R.id.group_label);
|
||||
|
||||
txtListChild.setText(childText);
|
||||
txtListChild.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light));
|
||||
txtListChild.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache()
|
||||
.getIcon(R.drawable.ic_action_list_bullet, isNightMode() ?
|
||||
R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark),
|
||||
null, null, null);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
if (this._listDataChild.get(this._listDataHeader.get(groupPosition)) != null) {
|
||||
return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return this._listDataHeader.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return this._listDataHeader.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return groupPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
String headerTitle = (String) getGroup(groupPosition);
|
||||
if (convertView == null) {
|
||||
LayoutInflater infalInflater = (LayoutInflater) this._context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = infalInflater.inflate(R.layout.wikivoyage_contents_group_list_item, null);
|
||||
}
|
||||
|
||||
TextView lblListHeader = (TextView) convertView.findViewById(R.id.group_label);
|
||||
lblListHeader.setText(headerTitle);
|
||||
lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light));
|
||||
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache()
|
||||
.getIcon(R.drawable.ic_action_list_sort, isNightMode() ?
|
||||
R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light),
|
||||
null, null, null);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue