use of net.osmand.plus.download.DownloadActivity in project Osmand by osmandapp.
the class SearchDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
if (savedInstanceState != null) {
searchText = savedInstanceState.getString(SEARCH_TEXT_DLG_KEY);
}
if (searchText == null) {
searchText = getArguments().getString(SEARCH_TEXT_DLG_KEY);
}
if (searchText == null)
searchText = "";
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
banner = new BannerAndDownloadFreeVersion(view, (DownloadActivity) getActivity(), false);
LinearLayout ll = (LinearLayout) view;
ExpandableListView expandablelistView = (ExpandableListView) view.findViewById(android.R.id.list);
ll.removeView(expandablelistView);
listView = new ListView(getActivity());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
layoutParams.weight = 1;
layoutParams.setMargins(0, 0, 0, 0);
listView.setLayoutParams(layoutParams);
ll.addView(listView);
listView.setOnItemClickListener(this);
listAdapter = new SearchListAdapter(getDownloadActivity());
listView.setOnItemClickListener(this);
listView.setAdapter(listAdapter);
TypedValue typedValue = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.toolbar_theme, typedValue, true);
searchView = inflater.inflate(R.layout.search_text_layout, toolbar, false);
toolbar.addView(searchView);
searchEditText = (EditText) view.findViewById(R.id.searchEditText);
searchEditText.setHint(R.string.search_map_hint);
searchEditText.setTextColor(Color.WHITE);
boolean isLight = getMyApplication().getSettings().isLightContent();
searchEditText.setHintTextColor(isLight ? getMyApplication().getResources().getColor(R.color.inactive_item_orange) : getMyApplication().getResources().getColor(R.color.searchbar_tab_inactive_dark));
progressBar = (ProgressBar) view.findViewById(R.id.searchProgressBar);
clearButton = (ImageButton) view.findViewById(R.id.clearButton);
clearButton.setVisibility(View.GONE);
searchEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
updateSearchText(s.toString());
}
});
clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (searchEditText.getText().length() == 0) {
dismiss();
} else {
searchEditText.setText("");
}
}
});
searchEditText.requestFocus();
return view;
}
use of net.osmand.plus.download.DownloadActivity in project Osmand by osmandapp.
the class SearchDialogFragment method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Object obj = listAdapter.getItem(position);
if (obj instanceof DownloadResourceGroup) {
String uniqueId = ((DownloadResourceGroup) obj).getUniqueId();
final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment.createInstance(uniqueId);
((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
} else if (obj instanceof IndexItem) {
IndexItem indexItem = (IndexItem) obj;
ItemViewHolder vh = (ItemViewHolder) v.getTag();
View.OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
ls.onClick(v);
}
}
use of net.osmand.plus.download.DownloadActivity in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
if (savedInstanceState != null) {
groupId = savedInstanceState.getString(REGION_ID_DLG_KEY);
}
if (groupId == null && getArguments() != null) {
groupId = getArguments().getString(REGION_ID_DLG_KEY);
}
if (groupId == null) {
groupId = "";
}
activity = (DownloadActivity) getActivity();
activity.getAccessibilityAssistant().registerPage(view, DownloadActivity.DOWNLOAD_TAB_NUMBER);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
if (!openAsDialog()) {
toolbar.setVisibility(View.GONE);
}
setHasOptionsMenu(true);
if (openAsDialog()) {
banner = new BannerAndDownloadFreeVersion(view, (DownloadActivity) getActivity(), false);
} else {
banner = null;
view.findViewById(R.id.freeVersionBanner).setVisibility(View.GONE);
}
listView = (ExpandableListView) view.findViewById(android.R.id.list);
addSubscribeEmailRow();
addSearchRow();
addRestorePurchasesRow();
listView.setOnChildClickListener(this);
listAdapter = new DownloadResourceGroupAdapter(activity);
listView.setAdapter(listAdapter);
return view;
}
use of net.osmand.plus.download.DownloadActivity in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method onChildClick.
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Object child = listAdapter.getChild(groupPosition, childPosition);
if (child instanceof DownloadResourceGroup) {
String uniqueId = ((DownloadResourceGroup) child).getUniqueId();
final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment.createInstance(uniqueId);
((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
return true;
} else if (child instanceof IndexItem) {
IndexItem indexItem = (IndexItem) child;
ItemViewHolder vh = (ItemViewHolder) v.getTag();
OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
ls.onClick(v);
return true;
}
return false;
}
Aggregations