| | |
| | | using System; |
| | | using Android.Content; |
| | | using Com.Widget.Jlcountrycode; |
| | | using Com.Widget.Jlcountrycode.Sortselect; |
| | | using System.Collections.Generic; |
| | | using Java.Util; |
| | | |
| | | namespace JLCountrycode |
| | | { |
| | |
| | | JLCountryCodeActivity.OnCountryCodeCallback = new OnCountryCodeCallback(action); |
| | | Shared.Application.Activity.StartActivity(new Intent(Shared.Application.Activity, typeof(JLCountryCodeActivity))); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 自定义传入字典数据 选择 |
| | | /// </summary> |
| | | /// <param name="titleStr"></param> |
| | | /// <param name="dic"></param> |
| | | /// <param name="action"></param> |
| | | public void ShowSortSelection(string titleStr, Dictionary<string, List<string>> dic, Action<string> action) |
| | | { |
| | | try |
| | | { |
| | | SortSelectionUtils.Instance.OnSortSelectCallback = new OnSSCallback(action); |
| | | SortSelectionUtils.Instance.SortSelectTitle = titleStr; |
| | | SortSelectionUtils.Instance.MSortSelectList = ConvertToHashMap(dic); |
| | | Shared.Application.Activity.StartActivity(new Intent(Shared.Application.Activity, typeof(JLSortSelectionActivity))); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Dictionary 转 Android HashMap |
| | | /// </summary> |
| | | /// <param name="dict"></param> |
| | | /// <returns></returns> |
| | | Dictionary<string, ArrayList> ConvertToHashMap(Dictionary<string, List<string>> dict) |
| | | { |
| | | Dictionary<string, ArrayList> newDictionary = new Dictionary<string, ArrayList>(); |
| | | try |
| | | { |
| | | foreach (string key in dict.Keys) |
| | | { |
| | | var value = dict[key]; |
| | | var arrayList = new ArrayList(); |
| | | arrayList.AddAll(value.ToArray()); |
| | | newDictionary.Add(key, arrayList); |
| | | } |
| | | } |
| | | catch (Exception Ex) |
| | | { |
| | | //Logger.LogException(Ex); |
| | | } |
| | | return newDictionary; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | mAction?.Invoke(countryName, code); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// OnSortSelectCallback |
| | | /// </summary> |
| | | public class OnSSCallback : Java.Lang.Object, IOnSortSelectCallback |
| | | { |
| | | |
| | | Action<string> mAction; |
| | | public OnSSCallback(Action<string> action) |
| | | { |
| | | mAction = action; |
| | | } |
| | | |
| | | public void OnSortSelectCallback(string countryName) |
| | | { |
| | | mAction?.Invoke(countryName); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |