Search in sources :

Example 1 with DownloadActivity

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;
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) DownloadActivity(net.osmand.plus.download.DownloadActivity) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) BannerAndDownloadFreeVersion(net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion) LinearLayout(android.widget.LinearLayout) ExpandableListView(android.widget.ExpandableListView) Toolbar(android.support.v7.widget.Toolbar) TypedValue(android.util.TypedValue)

Example 2 with DownloadActivity

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);
    }
}
Also used : DownloadResourceGroup(net.osmand.plus.download.DownloadResourceGroup) BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) IndexItem(net.osmand.plus.download.IndexItem) DownloadActivity(net.osmand.plus.download.DownloadActivity)

Example 3 with DownloadActivity

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;
}
Also used : OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ExpandableListView(android.widget.ExpandableListView) BannerAndDownloadFreeVersion(net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion) DownloadActivity(net.osmand.plus.download.DownloadActivity)

Example 4 with DownloadActivity

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;
}
Also used : DownloadResourceGroup(net.osmand.plus.download.DownloadResourceGroup) OnClickListener(android.view.View.OnClickListener) JSONObject(org.json.JSONObject) IndexItem(net.osmand.plus.download.IndexItem) DownloadActivity(net.osmand.plus.download.DownloadActivity)

Aggregations

DownloadActivity (net.osmand.plus.download.DownloadActivity)4 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 ExpandableListView (android.widget.ExpandableListView)2 BannerAndDownloadFreeVersion (net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion)2 DownloadResourceGroup (net.osmand.plus.download.DownloadResourceGroup)2 IndexItem (net.osmand.plus.download.IndexItem)2 Toolbar (android.support.v7.widget.Toolbar)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 TypedValue (android.util.TypedValue)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)1 JSONObject (org.json.JSONObject)1