/// <summary>
        /// Activitie's create event handeler.
        /// </summary>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            ListAdapter = new SimpleAdapter(this, _GetItems(), Android.Resource.Layout.SimpleListItem2,
                                            new string[] { TitleKey, DetailsKey },
                                            new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 });
        }
	  /// <summary>
	  /// Called when the activity is first created. </summary>
	  public override void onCreate(Bundle savedInstanceState)
	  {
		base.onCreate(savedInstanceState);
		// I know, I know, this should go into strings.xml and accessed using
		// getString(R.string....)
		mMenuText = new string[] {"Line chart", "Scatter chart", "Time chart", "Bar chart"};
		mMenuSummary = new string[] {"Line chart with randomly generated values", "Scatter chart with randomly generated values", "Time chart with randomly generated values", "Bar chart with randomly generated values"};
		ListAdapter = new SimpleAdapter(this, ListValues, android.R.layout.simple_list_item_2, new string[] {org.achartengine.chartdemo.demo.chart.IDemoChart_Fields.NAME, org.achartengine.chartdemo.demo.chart.IDemoChart_Fields.DESC}, new int[] {android.R.id.text1, android.R.id.text2});
	  }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            mMenuText = new String[] { "Line chart", "Scatter chart", "Time chart", "Bar chart" };
            mMenuSummary = new String[] { "Line chart with randomly generated values",
            "Scatter chart with randomly generated values","Time chart with randomly generated values",
            "Bar chart with randomly generated values"};

            ListAdapter = new SimpleAdapter(this, GetListValues(), Android.Resource.Layout.SimpleListItem2,
                new String[] { "name", "desc" }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 });
        }
예제 #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            var baseDir = Path.Combine (Application.ApplicationInfo.DataDir, "image_cache");
            if (!Directory.Exists (baseDir))
                Directory.CreateDirectory (baseDir);

            var data = new List<IDictionary<string,object>> ();
            var hr = new HttpWebRequest (new Uri ("http://api.twitter.com/1/statuses/public_timeline.json"));
            #if REACTIVE
            var req = Observable.FromAsyncPattern<WebResponse> (hr.BeginGetResponse, hr.EndGetResponse);
            Observable.Defer (req).Subscribe (v => {
            #else
            {
                var v = hr.GetResponse ();
            #endif
                var urls = new Dictionary<Uri,string> ();
                var json = (IEnumerable<JsonValue>)JsonValue.Load (v.GetResponseStream ());
            #if REACTIVE
                json.ToObservable ().Select (j => j.AsDynamic ()).Subscribe (jitem => {
            #else
                var items = from item in json select item.AsDynamic ();
                foreach (dynamic jitem in items) {
            #endif
                    var dic = new Dictionary<string,object> ();
                    dic ["Text"] = (string) jitem.text;
                    dic ["Name"] = (string) jitem.user.name;
                    var uri = new Uri ((string) jitem.user.profile_image_url);
                    var file = Path.Combine (baseDir, (string) jitem.id + new FileInfo (uri.LocalPath).Extension);
                    urls.Add (uri, file);
                    dic ["Icon"] = Path.Combine (baseDir, file);
                    data.Add (dic);
            #if REACTIVE
                });
            #else
                }
            #endif
                urls.ToList ().ForEach (p => new WebClient ().DownloadFileAsync (p.Key, p.Value));

                var from = new string [] {"Text", "Name", "Icon"};
                var to = new int [] { Resource.Id.textMessage, Resource.Id.textName, Resource.Id.iconView};

                this.RunOnUiThread (() => {
                    ListAdapter = new SimpleAdapter (this, data, Resource.Layout.ListItem, from, to);
                });
            #if REACTIVE
            });
            #else
            }
            #endif
        }
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
		
			String path = Intent.GetStringExtra ("com.example.android.apis.Path");
		
			if (path == null) {
				path = "";
			}
		
			ListAdapter = new SimpleAdapter (this, GetData (path),
				Android.Resource.Layout.SimpleListItem1, new String[] { "title" },
				new int[] { Android.Resource.Id.Text1 });
			ListView.TextFilterEnabled = true;
		}
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			
			var baseDir = Path.Combine (Application.ApplicationInfo.DataDir, "image_cache");
			if (!Directory.Exists (baseDir))
				Directory.CreateDirectory (baseDir);
			
			var data = new List<IDictionary<string,object>> ();
			var urls = new Dictionary<Uri,List<string>> ();
			var getUrl = new Uri ("https://api.github.com/users/mono/repos");
			var hr = new HttpWebRequest (getUrl);
			var req = Observable.FromAsyncPattern<WebResponse> (hr.BeginGetResponse, hr.EndGetResponse);
			Observable.Defer (req).Subscribe (v => {
				var json = (IEnumerable<JsonValue>) JsonValue.Load (v.GetResponseStream ());
				json.Cast<JsonObject> ().ToList ().ForEach (item => {
					var uri = new Uri ((string) ((JsonObject) item ["owner"])["avatar_url"]);
					var file = Path.Combine (baseDir, ((int) item ["id"]) + new FileInfo (uri.LocalPath).Extension);
					if (!urls.ContainsKey (uri))
						urls.Add (uri, new List<string> () {file});
					else
						urls [uri].Add (file);
					data.Add (new JavaDictionary<string,object> () { {"Text", item ["description"]}, {"Name", item ["name"]}, {"Icon", Path.Combine (baseDir, file) }});
					urls.ToList ().ForEach (p => {
						var iwc = new WebClient ();
						iwc.DownloadDataCompleted += (isender, ie) => p.Value.ForEach (s => {
							if (ie.Result != null)
								using (var fs = File.Create (s))
									fs.Write (ie.Result, 0, ie.Result.Length);
						});
						iwc.DownloadDataAsync (p.Key);
					});
				});

				var from = new string [] {"Text", "Name", "Icon"};
				var to = new int [] { Resource.Id.textMessage, Resource.Id.textName, Resource.Id.iconView};
					
				this.RunOnUiThread (() => {
					ListAdapter = new SimpleAdapter (this, data, Resource.Layout.ListItem, from, to);
				});
			});
		}
예제 #7
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     int length = mCharts.Length;
     mMenuText = new String[length + 3];
     mMenuSummary = new String[length + 3];
     mMenuText[0] = "Embedded line chart demo";
     mMenuSummary[0] = "A demo on how to include a clickable line chart into a graphical activity";
     mMenuText[1] = "Embedded pie chart demo";
     mMenuSummary[1] = "A demo on how to include a clickable pie chart into a graphical activity";
     for (int i = 0; i < length; i++)
     {
         mMenuText[i + 2] = mCharts[i].Name;
         mMenuSummary[i + 2] = mCharts[i].Desc;
     }
     mMenuText[length + 2] = "Random values charts";
     mMenuSummary[length + 2] = "Chart demos using randomly generated values";
     ListAdapter = new SimpleAdapter(this, GetListValues(), Android.Resource.Layout.SimpleListItem1,
     new String[] { "name", "desc" }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 });
 }
예제 #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            // splice the views into the fields
            Geneticist.Splice(this);

            // Contrived code to use the bound fields.
            title.Text = titleText;
            subtitle.Text = subtitleText;
            footer.Text = "by " + authorText;
            hello.Text = sayHelloText;

            headerViews = new List<View> { title, subtitle };

            adapter = new SimpleAdapter(this);
            listview.Adapter = adapter;
        }
        //@Override
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Android.Content.Intent intent = this.Intent;
            string path = intent.GetStringExtra("com.jakewharton.android.viewpagerindicator.sample.Path");

            if (path == null)
            {
                path = "";
            }

            ListAdapter = new SimpleAdapter(this, getData(path),
                    Android.Resource.Layout.SimpleListItem1, new string[] { "title" },
                    new int[] { Android.Resource.Id.Text1 });

            //getListView().setTextFilterEnabled(true);
            ListView.TextFilterEnabled = true;
            
        }
예제 #10
0
        protected override void OnCreate(Bundle bundle)
        {
            this.ChangeStatusBarColor(Color.ParseColor("#2C2C2C"));

            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SettingsActivity);

            OverridePendingTransition(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out);

            InitializeViews();

            var adapter = new SimpleAdapter <SelectableWorkspaceViewModel>(
                Resource.Layout.SettingsActivityWorkspaceCell,
                WorkspaceSelectionViewHolder.Create
                );

            adapter.OnItemTapped = ViewModel.SelectDefaultWorkspace;
            workspacesRecyclerView.SetAdapter(adapter);
            workspacesRecyclerView.SetLayoutManager(new LinearLayoutManager(this));

            this.Bind(ViewModel.Name, nameTextView.BindText());
            this.Bind(ViewModel.Email, emailTextView.BindText());
            this.Bind(ViewModel.Workspaces, adapter.BindItems());
            this.Bind(ViewModel.IsManualModeEnabled, manualModeSwitch.BindChecked());
            this.Bind(ViewModel.BeginningOfWeek, beginningOfWeekTextView.BindText());
            this.Bind(ViewModel.UserAvatar.Select(userImageFromBytes), bitmap =>
            {
                avatarView.SetImageBitmap(bitmap);
                avatarContainer.Visibility = ViewStates.Visible;
            });

            this.Bind(logoutButton.Tapped(), ViewModel.TryLogout);
            this.Bind(helpButton.Tapped(), ViewModel.ShowHelpView);
            this.Bind(feedbackButton.Tapped(), ViewModel.SubmitFeedback);
            this.BindVoid(manualModeView.Tapped(), ViewModel.ToggleManualMode);
            this.Bind(beginningOfWeekView.Tapped(), ViewModel.SelectBeginningOfWeek);

            setupToolbar();
        }
예제 #11
0
 protected void ShowTips()
 {
     try
     {
         var data = new List <IDictionary <string, object> >();
         IDictionary <string, object> dataItem;
         // Logger.ErrorFormat("TipsQueQue:" + TipsQueque.Count.ToString());
         foreach (var item in TipsQueque)
         {
             dataItem = new JavaDictionary <string, object>();
             dataItem["itemImage"] = string.Empty;
             dataItem["itemName"]  = item;
             data.Add(dataItem);
         }
         SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, Resource.Layout.MapListView, new String[] { "itemImage", "itemName" }, new int[] { Resource.Id.itemImage, Resource.Id.itemName });
         TipsListView.SetAdapter(simpleAdapter);
     }
     catch (Exception ex)
     {
         Logger.Error("ShowTips", ex.Message);
     }
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            var view = inflater.Inflate(Resource.Layout.SelectDefaultWorkspaceFragment, null);

            InitializeViews(view);

            var adapter = new SimpleAdapter <SelectableWorkspaceViewModel>(
                Resource.Layout.SelectDefaultWorkspaceFragmentCell,
                SelectDefaultWorkspaceViewHolder.Create
                );

            adapter.Items = ViewModel.Workspaces.ToList();
            adapter.ItemTapObservable
            .Subscribe(ViewModel.SelectWorkspace.Inputs)
            .DisposedBy(DisposeBag);

            recyclerView.SetAdapter(adapter);
            recyclerView.SetLayoutManager(new LinearLayoutManager(Context));

            return(view);
        }
예제 #13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            var texts   = new String[1000];
            var numbers = new String[texts.Length];

            for (int i = 0; i < texts.Length; i++)
            {
                texts[i]   = "Ivan Ivanov" + i;
                numbers[i] = "+375(55)1112222 " + i.ToString(CultureInfo.InvariantCulture);
            }

            var data = new List <IDictionary <String, Object> >(texts.Length);

            for (int i = 0; i < texts.Length; i++)
            {
                var m = new JavaDictionary <String, Object>();
                m[ATTRIBUTE_NAME_NAME]  = texts[i];
                m[ATTRIBUTE_NAME_PHONE] = numbers[i];
                m[ATTRIBUTE_NAME_IMAGE] = i % 2 == 0 ? Resource.Drawable.xamarin : Resource.Drawable.ic_launcher;
                data.Add(m);
            }

            String[] from = { ATTRIBUTE_NAME_NAME, ATTRIBUTE_NAME_PHONE, ATTRIBUTE_NAME_IMAGE };
            int[]    to   = { Resource.Id.tvName, Resource.Id.tvNumber, Resource.Id.tvImage };

            var adapter = new SimpleAdapter(this, data, Resource.Layout.item_row, from, to);
            var list    = (ListView)FindViewById(Resource.Id.list);

            list.Adapter = adapter;

            //subscribing from axml directly doesn't work ;(
            FindViewById <Button>(Resource.Id.test1).Click += Test1;
            FindViewById <Button>(Resource.Id.test2).Click += Test2;
            FindViewById <Button>(Resource.Id.test4).Click += Test3;
        }
예제 #14
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            View view = inflater.Inflate(Resource.Layout.fragment_menu_list, container, false);

            ListView lvMenu = view.FindViewById <ListView>(Resource.Id.lvMenu);

            var menuList = new JavaList <IDictionary <string, object> >();

            JavaDictionary <string, object> menu = new JavaDictionary <string, object>();

            menu.Add("name", "からあげ");
            menu.Add("price", "300");
            menuList.Add(menu);

            menu = new JavaDictionary <string, object>();
            menu.Add("name", "バグった食べ物☆");
            menu.Add("price", "28.8200");
            menuList.Add(menu);

            menu = new JavaDictionary <string, object>();
            menu.Add("name", "ごみ");
            menu.Add("price", "3333300");
            menuList.Add(menu);

            string[] from = { "name", "price" };
            int[]    to   = { Android.Resource.Id.Text1, Android.Resource.Id.Text2 };


            _adapter = new SimpleAdapter(_parentActivity, menuList, Android.Resource.Layout.SimpleListItem2, from, to);

            lvMenu.Adapter = _adapter;

            lvMenu.ItemClick += OnItemClick;

            return(view);
        }
예제 #15
0
        /// <summary>
        /// Called when the activity is first created. </summary>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            int length = mCharts.Length;

            mMenuText       = new string[length + 3];
            mMenuSummary    = new string[length + 3];
            mMenuText[0]    = "Embedded line chart demo";
            mMenuSummary[0] = "A demo on how to include a clickable line chart into a graphical activity";
            mMenuText[1]    = "Embedded pie chart demo";
            mMenuSummary[1] = "A demo on how to include a clickable pie chart into a graphical activity";
            for (int i = 0; i < length; i++)
            {
                mMenuText[i + 2]    = mCharts[i].Name;
                mMenuSummary[i + 2] = mCharts[i].Desc;
            }
            mMenuText[length + 2]    = "Random values charts";
            mMenuSummary[length + 2] = "Chart demos using randomly generated values";
            ListAdapter =
                new SimpleAdapter
                (
                    this,
                    ListValues,
                    Android.Resource.Layout.SimpleListItem2,
                    new string[]
            {
                IDemoChart_Fields.NAME,
                IDemoChart_Fields.DESC
            },
                    new int[]
            {
                Android.Resource.Id.Text1,
                Android.Resource.Id.Text2
            }
                );

            return;
        }
예제 #16
0
        public void InitVersionView()
        {
            try
            {
                var data = new List <IDictionary <string, object> >();
                IDictionary <string, object> dataItem;

                foreach (var item in listExamRoom)
                {
                    dataItem = new JavaDictionary <string, object>();
                    dataItem["itemImage"] = item.Key;
                    dataItem["itemName"]  = item.Value.Key;
                    data.Add(dataItem);
                }
                SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, Resource.Layout.VersionGridView, new String[] { "itemImage", "itemName" }, new int[] { Resource.Id.itemImage, Resource.Id.itemName });
                VersionGridView.SetAdapter(simpleAdapter);
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                LogManager.WriteSystemLog("VersionSelectActivity" + msg);
            }
        }
예제 #17
0
        public void InitRoadMap()
        {
            try
            {
                var data = new List <IDictionary <string, object> >();
                IDictionary <string, object> dataItem;

                foreach (var item in lstRoadMapExamItem)
                {
                    dataItem = new JavaDictionary <string, object>();
                    dataItem["itemImage"] = item.Key;
                    dataItem["itemName"]  = item.Value.Name;
                    data.Add(dataItem);
                }
                SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, Resource.Layout.MapListView, new String[] { "itemImage", "itemName" }, new int[] { Resource.Id.itemImage, Resource.Id.itemName });
                RoadMapListView.SetAdapter(simpleAdapter);
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                Logger.Error("Map", ex.Message);
            }
        }
예제 #18
0
        public void InitExamItem()
        {
            try
            {
                var data = new List <IDictionary <string, object> >();
                IDictionary <string, object> dataItem;

                foreach (var item in dataService.AllExamItems)
                {
                    dataItem = new JavaDictionary <string, object>();
                    dataItem["itemImage"] = "";
                    dataItem["itemName"]  = item.ItemName;
                    data.Add(dataItem);
                }
                SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, Resource.Layout.MapListView, new String[] { "itemImage", "itemName" }, new int[] { Resource.Id.itemImage, Resource.Id.itemName });
                examItemList.SetAdapter(simpleAdapter);
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                Logger.Error("LightRuleInit", ex.Message);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            this.SetContentView (Resource.Layout.AlbumView);

            var album = this.Intent.GetStringExtra ("album");

            var title = FindViewById<TextView> (Resource.Id.albumViewTitle);
            title.Text = album;

            var songs = model.Songs.Where (s => s.Album == album).OrderBy (s => s.Disc).ThenBy (s => s.Track).ToArray ();

            var listView = FindViewById<ListView> (Resource.Id.albumViewSongs);
            var ids = new int [] {
                Resource.Id.songListViewTitle,
                Resource.Id.songListViewArtist,
                Resource.Id.songListViewTime,
            };
            var data = (from s in songs select ToDictionaryItem (s)).ToArray ();

            var adapter = new SimpleAdapter (this, data, Resource.Layout.SongListView,
                                             new string [] {"title", "artist", "time"}, ids);
            listView.Adapter = adapter;
        }
        public MainLogSuggestionsListViewHolder(View itemView, SuggestionsViewModel suggestionsViewModel) : base(itemView)
        {
            this.suggestionsViewModel = suggestionsViewModel;

            hintTextView            = ItemView.FindViewById <TextView>(Resource.Id.SuggestionsHintTextView);
            indicatorTextView       = ItemView.FindViewById <TextView>(Resource.Id.SuggestionsIndicatorTextView);
            suggestionsRecyclerView = ItemView.FindViewById <RecyclerView>(Resource.Id.SuggestionsRecyclerView);

            var adapter = new SimpleAdapter <Suggestion>(Resource.Layout.MainSuggestionsCard, MainLogSuggestionItemViewHolder.Create);

            suggestionsRecyclerView.SetLayoutManager(new LinearLayoutManager(ItemView.Context));
            suggestionsRecyclerView.SetAdapter(adapter);

            hintTextView.Text = TogglResources.WorkingOnThese;

            adapter.ItemTapObservable
            .Subscribe(suggestionsViewModel.StartTimeEntry.Inputs)
            .DisposedBy(DisposeBag);

            suggestionsViewModel.Suggestions
            .Subscribe(adapter.Rx().Items())
            .DisposedBy(DisposeBag);

            suggestionsViewModel.Suggestions
            .Where(items => items.Any())
            .Select(items => items.Count == 1
                    ? TogglResources.WorkingOnThis
                    : TogglResources.WorkingOnThese)
            .Subscribe(hintTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            suggestionsViewModel.IsEmpty
            .Invert()
            .Subscribe(updateViewVisibility)
            .DisposedBy(DisposeBag);
        }
예제 #21
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.Main);

			var texts = new String[1000];
            var numbers = new String[texts.Length];
			for (int i = 0; i < texts.Length; i++)
            {
                texts[i] = "Ivan Ivanov" + i;
                numbers[i] = "+375(55)1112222 " + i.ToString(CultureInfo.InvariantCulture);
            }

            var data = new List<IDictionary<String, Object>>(texts.Length);
		    for (int i = 0; i < texts.Length; i++)
            {
                var m = new JavaDictionary<String, Object>();
                m[ATTRIBUTE_NAME_NAME] = texts[i];
                m[ATTRIBUTE_NAME_PHONE] = numbers[i];
                m[ATTRIBUTE_NAME_IMAGE] = i % 2 == 0 ? Resource.Drawable.xamarin : Resource.Drawable.ic_launcher;
                data.Add(m);
            }

            String[] from = { ATTRIBUTE_NAME_NAME, ATTRIBUTE_NAME_PHONE, ATTRIBUTE_NAME_IMAGE };
            int[] to = { Resource.Id.tvName, Resource.Id.tvNumber, Resource.Id.tvImage };

            var adapter = new SimpleAdapter(this, data, Resource.Layout.item_row, from, to);
            var list = (ListView)FindViewById(Resource.Id.list);
            list.Adapter = adapter;

            //subscribing from axml directly doesn't work ;(
            FindViewById<Button>(Resource.Id.test1).Click += Test1;
            FindViewById<Button>(Resource.Id.test2).Click += Test2;
            FindViewById<Button>(Resource.Id.test4).Click += Test3;
		}
 public XmlAspectMemberAttribute(ClassAcessor acessor, string localName, bool mandatory, SimpleAdapter adapter)
     : base(acessor, localName, mandatory)
 {
     this._Adapter = adapter;
 }
예제 #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var baseDir = Path.Combine(Application.ApplicationInfo.DataDir, "image_cache");

            if (!Directory.Exists(baseDir))
            {
                Directory.CreateDirectory(baseDir);
            }

            var from = new string [] { "Text", "Name", "Icon" };
            var to   = new int [] { Resource.Id.textMessage, Resource.Id.textName, Resource.Id.iconView };
            var data = new List <IDictionary <string, object> > ();

            data.Add(new JavaDictionary <string, object> ()
            {
                { "Text", "loading" }, { "Name", "" }
            });
            var urls   = new Dictionary <Uri, List <string> > ();
            var getUrl = new Uri("https://api.github.com/repos/mono/mono/commits");

#if REACTIVE
            var hr  = new HttpWebRequest(getUrl);
            var req = Observable.FromAsyncPattern <WebResponse> (hr.BeginGetResponse, hr.EndGetResponse);
            Observable.Defer(req).Subscribe(v => {
                var v    = hr.GetResponse();
                var json = (IEnumerable <JsonValue>)JsonValue.Load(v.GetResponseStream());
#else
            var wc = new WebClient();
            wc.Headers ["USER-AGENT"]   = "Xamarin Android sample HTTP client";
            wc.DownloadStringCompleted += (sender, e) => {
                data.Clear();
                var v = e.Result;
                var json = (IEnumerable <JsonValue>)JsonValue.Parse(v);
#endif
#if REACTIVE
                json.ToObservable().Select(j => j.AsDynamic()).Subscribe(jitem => {
#else
                foreach (var item in json.Select(j => j.AsDynamic()))
                {
#endif
                    var uri = new Uri((string)item.author.avatar_url);
                    var file = Path.Combine(baseDir, (string)item.author.id + new FileInfo(uri.LocalPath).Extension);
                    if (!urls.ContainsKey(uri))
                    {
                        urls.Add(uri, new List <string> ()
                        {
                            file
                        });
                    }
                    else
                    {
                        urls [uri].Add(file);
                    }
                    data.Add(new JavaDictionary <string, object> ()
                    {
                        { "Text", item.commit.message }, { "Name", item.author.login }, { "Icon", Path.Combine(baseDir, file) }
                    });
#if REACTIVE
                });
#else
                }
#endif
                urls.ToList().ForEach(p => {
                    var iwc = new WebClient();
                    iwc.DownloadDataCompleted += (isender, ie) => p.Value.ForEach(s => {
                        using (var fs = File.Create(s))
                            fs.Write(ie.Result, 0, ie.Result.Length);
                    });
                    iwc.DownloadDataAsync(p.Key);
                });

                this.RunOnUiThread(() => {
                    ListAdapter = new SimpleAdapter(this, data, Resource.Layout.ListItem, from, to);
                });
#if REACTIVE
            });
#else
            };
예제 #24
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            var view = inflater.Inflate(Resource.Layout.SelectColorFragment, null);

            initializeViews(view);

            recyclerView.SetLayoutManager(new GridLayoutManager(Context, 5));

            selectableColorsAdapter = new SimpleAdapter <SelectableColorViewModel>(
                Resource.Layout.SelectColorFragmentCell, ColorSelectionViewHolder.Create);

            selectableColorsAdapter.ItemTapObservable
            .Select(x => x.Color)
            .Subscribe(ViewModel.SelectColor.Inputs)
            .DisposedBy(DisposeBag);

            recyclerView.SetAdapter(selectableColorsAdapter);

            ViewModel.Hue
            .Subscribe(hueSaturationPicker.Rx().HueObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Saturation
            .Subscribe(hueSaturationPicker.Rx().SaturationObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Value
            .Subscribe(hueSaturationPicker.Rx().ValueObserver())
            .DisposedBy(DisposeBag);

            hueSaturationPicker.Rx().Hue()
            .Subscribe(ViewModel.SetHue.Inputs)
            .DisposedBy(DisposeBag);

            hueSaturationPicker.Rx().Saturation()
            .Subscribe(ViewModel.SetSaturation.Inputs)
            .DisposedBy(DisposeBag);

            valueSlider.Rx().Progress()
            .Select(invertedNormalizedProgress)
            .Subscribe(ViewModel.SetValue.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Hue
            .Subscribe(valueSlider.Rx().HueObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Saturation
            .Subscribe(valueSlider.Rx().SaturationObserver())
            .DisposedBy(DisposeBag);

            saveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            closeButton.Rx()
            .BindAction(ViewModel.Close)
            .DisposedBy(DisposeBag);

            ViewModel.SelectableColors
            .Subscribe(updateColors)
            .DisposedBy(DisposeBag);

            hueSaturationPicker.Visibility = ViewModel.AllowCustomColors.ToVisibility();
            valueSlider.Visibility         = ViewModel.AllowCustomColors.ToVisibility();

            return(view);
        }
예제 #25
0
	  /// <summary>
	  /// Called when the activity is first created. </summary>
	  public override void onCreate(Bundle savedInstanceState)
	  {
		base.onCreate(savedInstanceState);
		int length = mCharts.Length;
		mMenuText = new string[length + 3];
		mMenuSummary = new string[length + 3];
		mMenuText[0] = "Embedded line chart demo";
		mMenuSummary[0] = "A demo on how to include a clickable line chart into a graphical activity";
		mMenuText[1] = "Embedded pie chart demo";
		mMenuSummary[1] = "A demo on how to include a clickable pie chart into a graphical activity";
		for (int i = 0; i < length; i++)
		{
		  mMenuText[i + 2] = mCharts[i].Name;
		  mMenuSummary[i + 2] = mCharts[i].Desc;
		}
		mMenuText[length + 2] = "Random values charts";
		mMenuSummary[length + 2] = "Chart demos using randomly generated values";
		ListAdapter = new SimpleAdapter(this, ListValues, android.R.layout.simple_list_item_2, new string[] {org.achartengine.chartdemo.demo.chart.IDemoChart_Fields.NAME, org.achartengine.chartdemo.demo.chart.IDemoChart_Fields.DESC}, new int[] {android.R.id.text1, android.R.id.text2});
	  }
예제 #26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SettingsActivity);

            OverridePendingTransition(Resource.Animation.abc_slide_in_right, Resource.Animation.abc_fade_out);

            InitializeViews();

            var adapter = new SimpleAdapter <SelectableWorkspaceViewModel>(
                Resource.Layout.SettingsActivityWorkspaceCell,
                WorkspaceSelectionViewHolder.Create
                );

            adapter.ItemTapObservable
            .Subscribe(ViewModel.SelectDefaultWorkspace.Inputs)
            .DisposedBy(DisposeBag);

            workspacesRecyclerView.SetAdapter(adapter);
            workspacesRecyclerView.SetLayoutManager(new LinearLayoutManager(this));

            versionTextView.Text = ViewModel.Version;

            ViewModel.Name
            .Subscribe(nameTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Email
            .Subscribe(emailTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Workspaces
            .Subscribe(adapter.Rx().Items())
            .DisposedBy(DisposeBag);

            ViewModel.IsManualModeEnabled
            .Subscribe(manualModeSwitch.Rx().Checked())
            .DisposedBy(DisposeBag);

            ViewModel.UseTwentyFourHourFormat
            .Subscribe(is24hoursModeSwitch.Rx().Checked())
            .DisposedBy(DisposeBag);

            ViewModel.AreRunningTimerNotificationsEnabled
            .Subscribe(runningTimerNotificationsSwitch.Rx().Checked())
            .DisposedBy(DisposeBag);

            ViewModel.AreStoppedTimerNotificationsEnabled
            .Subscribe(stoppedTimerNotificationsSwitch.Rx().Checked())
            .DisposedBy(DisposeBag);

            ViewModel.DateFormat
            .Subscribe(dateFormatTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.BeginningOfWeek
            .Subscribe(beginningOfWeekTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.DurationFormat
            .Subscribe(durationFormatTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.UserAvatar
            .Select(userImageFromBytes)
            .Subscribe(bitmap =>
            {
                avatarView.SetImageBitmap(bitmap);
                avatarContainer.Visibility = ViewStates.Visible;
            })
            .DisposedBy(DisposeBag);

            ViewModel.LoggingOut
            .Subscribe(this.CancelAllNotifications)
            .DisposedBy(DisposeBag);

            ViewModel.IsFeedbackSuccessViewShowing
            .Subscribe(showFeedbackSuccessToast)
            .DisposedBy(DisposeBag);

            logoutView.Rx()
            .BindAction(ViewModel.TryLogout)
            .DisposedBy(DisposeBag);

            helpView.Rx()
            .BindAction(ViewModel.OpenHelpView)
            .DisposedBy(DisposeBag);

            aboutView.Rx()
            .BindAction(ViewModel.OpenAboutView)
            .DisposedBy(DisposeBag);

            feedbackView.Rx()
            .BindAction(ViewModel.SubmitFeedback)
            .DisposedBy(DisposeBag);

            manualModeView.Rx().Tap()
            .Subscribe(ViewModel.ToggleManualMode)
            .DisposedBy(DisposeBag);

            is24hoursModeView.Rx()
            .BindAction(ViewModel.ToggleTwentyFourHourSettings)
            .DisposedBy(DisposeBag);

            runningTimerNotificationsView.Rx().Tap()
            .Subscribe(ViewModel.ToggleRunningTimerNotifications)
            .DisposedBy(DisposeBag);

            stoppedTimerNotificationsView.Rx().Tap()
            .Subscribe(ViewModel.ToggleStoppedTimerNotifications)
            .DisposedBy(DisposeBag);

            dateFormatView.Rx().Tap()
            .Subscribe(ViewModel.SelectDateFormat.Inputs)
            .DisposedBy(DisposeBag);

            beginningOfWeekView.Rx()
            .BindAction(ViewModel.SelectBeginningOfWeek)
            .DisposedBy(DisposeBag);

            durationFormatView.Rx().Tap()
            .Subscribe(ViewModel.SelectDurationFormat.Inputs)
            .DisposedBy(DisposeBag);

            setupToolbar();
        }
예제 #27
0
 public XmlAspectMemberAttribute(ClassAcessor acessor, string localName, bool mandatory, SimpleAdapter adapter)
     : base(acessor, localName, mandatory)
 {
     this._Adapter = adapter;
 }
예제 #28
0
        //初始化考试项目地图
        public void InitExamItemMap()
        {
            //一共19个考试项目

            try
            {
                mapLinePoint = new MapLinePoint()
                {
                    Name = "公交汽车", PointType = MapPointType.BusArea, SequenceNumber = 1
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.bus_station, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "学校区域", PointType = MapPointType.SchoolArea, SequenceNumber = 2
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.school, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "人行横道", PointType = MapPointType.PedestrianCrossing, SequenceNumber = 3
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.zebra, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "减速慢行", PointType = MapPointType.SlowSpeed, SequenceNumber = 4
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.slowspeed, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "路口左转", PointType = MapPointType.TurnLeft, SequenceNumber = 5
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.turn_left, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "路口右转", PointType = MapPointType.TurnRight, SequenceNumber = 6
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.turn_right, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "路口直行", PointType = MapPointType.StraightThrough, SequenceNumber = 7
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.straight_driving, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "直线行驶", PointType = MapPointType.StraightDriving, SequenceNumber = 8
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.straight_driving, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "加减档", PointType = MapPointType.ModifiedGear, SequenceNumber = 9
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.modified_gear, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "掉头", PointType = MapPointType.TurnRound, SequenceNumber = 10
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.turn_round, mapLinePoint);
                lstExamItem.Add(mapKeyValue);



                mapLinePoint = new MapLinePoint()
                {
                    Name = "靠边停车", PointType = MapPointType.PullOver, SequenceNumber = 11
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.stop, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "会车", PointType = MapPointType.Meeting, SequenceNumber = 12
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.meeting, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "超车", PointType = MapPointType.Overtaking, SequenceNumber = 13
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.overtaking, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "变更车道", PointType = MapPointType.ChangeLines, SequenceNumber = 14
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.change_lines, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                //mapLinePoint = new MapLinePoint() { Name = "下一个项", PointType = MapPointType.NextItem,SequenceNumber=15 };
                //mapKeyValue = new KeyValuePair<int, MapLinePoint>(Resource.Drawable.next, mapLinePoint);
                //lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "环岛", PointType = MapPointType.Roundabout, SequenceNumber = 16
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.roundabout, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "限速", PointType = MapPointType.StartSpeedLimit, SequenceNumber = 17
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.speed_limit_30, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "急弯泼路", PointType = MapPointType.SharpTurn, SequenceNumber = 18
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.sharp_turn, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "掉头点", PointType = MapPointType.TurnRoundPlease, SequenceNumber = 19
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.turn_round, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "通过拱桥", PointType = MapPointType.ArchBridge, SequenceNumber = 20
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.location, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "临时停车", PointType = MapPointType.TempPark, SequenceNumber = 21
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.location, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                //mapLinePoint = new MapLinePoint() { Name = "起伏弯道", PointType = MapPointType.WavedCurve, SequenceNumber = 22 };
                //mapKeyValue = new KeyValuePair<int, MapLinePoint>(Resource.Drawable.location, mapLinePoint);
                //lstExamItem.Add(mapKeyValue);

                mapLinePoint = new MapLinePoint()
                {
                    Name = "考试结束", PointType = MapPointType.ExamEnd, SequenceNumber = 22
                };
                mapKeyValue = new KeyValuePair <int, MapLinePoint>(Resource.Drawable.location, mapLinePoint);
                lstExamItem.Add(mapKeyValue);

                var data = new List <IDictionary <string, object> >();
                IDictionary <string, object> dataItem;

                foreach (var item in lstExamItem)
                {
                    dataItem = new JavaDictionary <string, object>();
                    dataItem["itemImage"] = item.Key;
                    dataItem["itemName"]  = item.Value.Name;
                    data.Add(dataItem);
                }

                SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, Resource.Layout.MapGridView, new String[] { "itemImage", "itemName" }, new int[] { Resource.Id.itemImage, Resource.Id.itemName });
                mGridView.SetAdapter(simpleAdapter);
            }
            catch (Exception ex)
            {
                Logger.Error("Map", ex.Message);
            }
        }
예제 #29
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.SettingsFragment, container, false);

            InitializeViews(view);
            setupToolbar();

            var adapter = new SimpleAdapter <SelectableWorkspaceViewModel>(
                Resource.Layout.SettingsFragmentWorkspaceCell,
                WorkspaceSelectionViewHolder.Create
                );

            adapter.ItemTapObservable
            .Subscribe(ViewModel.SelectDefaultWorkspace.Inputs)
            .DisposedBy(DisposeBag);

            workspacesRecyclerView.SetAdapter(adapter);
            workspacesRecyclerView.SetLayoutManager(new LinearLayoutManager(Context));

            versionTextView.Text = ViewModel.Version;

            ViewModel.Name
            .Subscribe(nameTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Email
            .Subscribe(emailTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Workspaces
            .Subscribe(adapter.Rx().Items())
            .DisposedBy(DisposeBag);

            ViewModel.IsManualModeEnabled
            .Subscribe(manualModeSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            ViewModel.IsGroupingTimeEntries
            .Subscribe(groupTimeEntriesSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            ViewModel.UseTwentyFourHourFormat
            .Subscribe(is24hoursModeSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            ViewModel.AreRunningTimerNotificationsEnabled
            .Subscribe(runningTimerNotificationsSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            ViewModel.AreStoppedTimerNotificationsEnabled
            .Subscribe(stoppedTimerNotificationsSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            ViewModel.DateFormat
            .Subscribe(dateFormatTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.BeginningOfWeek
            .Subscribe(beginningOfWeekTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.DurationFormat
            .Subscribe(durationFormatTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.IsCalendarSmartRemindersVisible
            .Subscribe(smartRemindersView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsCalendarSmartRemindersVisible
            .Subscribe(smartRemindersViewSeparator.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.CalendarSmartReminders
            .Subscribe(smartRemindersTextView.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            ViewModel.UserAvatar
            .Select(userImageFromBytes)
            .Subscribe(bitmap =>
            {
                avatarView.SetImageBitmap(bitmap);
                avatarContainer.Visibility = ViewStates.Visible;
            })
            .DisposedBy(DisposeBag);

            ViewModel.LoggingOut
            .Subscribe(Context.CancelAllNotifications)
            .DisposedBy(DisposeBag);

            ViewModel.IsFeedbackSuccessViewShowing
            .Subscribe(showFeedbackSuccessToast)
            .DisposedBy(DisposeBag);

            logoutView.Rx()
            .BindAction(ViewModel.TryLogout)
            .DisposedBy(DisposeBag);

            helpView.Rx()
            .BindAction(ViewModel.OpenHelpView)
            .DisposedBy(DisposeBag);

            aboutView.Rx()
            .BindAction(ViewModel.OpenAboutView)
            .DisposedBy(DisposeBag);

            feedbackView.Rx()
            .BindAction(ViewModel.SubmitFeedback)
            .DisposedBy(DisposeBag);

            manualModeView.Rx().Tap()
            .Subscribe(ViewModel.ToggleManualMode)
            .DisposedBy(DisposeBag);

            groupTimeEntriesView.Rx()
            .BindAction(ViewModel.ToggleTimeEntriesGrouping)
            .DisposedBy(DisposeBag);

            is24hoursModeView.Rx()
            .BindAction(ViewModel.ToggleTwentyFourHourSettings)
            .DisposedBy(DisposeBag);

            runningTimerNotificationsView.Rx().Tap()
            .Subscribe(ViewModel.ToggleRunningTimerNotifications)
            .DisposedBy(DisposeBag);

            stoppedTimerNotificationsView.Rx().Tap()
            .Subscribe(ViewModel.ToggleStoppedTimerNotifications)
            .DisposedBy(DisposeBag);

            dateFormatView.Rx().Tap()
            .Subscribe(ViewModel.SelectDateFormat.Inputs)
            .DisposedBy(DisposeBag);

            beginningOfWeekView.Rx()
            .BindAction(ViewModel.SelectBeginningOfWeek)
            .DisposedBy(DisposeBag);

            durationFormatView.Rx().Tap()
            .Subscribe(ViewModel.SelectDurationFormat.Inputs)
            .DisposedBy(DisposeBag);

            calendarSettingsView.Rx().Tap()
            .Subscribe(ViewModel.OpenCalendarSettings.Inputs)
            .DisposedBy(DisposeBag);

            smartRemindersView.Rx().Tap()
            .Subscribe(ViewModel.OpenCalendarSmartReminders.Inputs)
            .DisposedBy(DisposeBag);

            return(view);
        }
예제 #30
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            var baseDir = Path.Combine (Application.ApplicationInfo.DataDir, "image_cache");
            if (!Directory.Exists (baseDir))
                Directory.CreateDirectory (baseDir);

            var from = new string [] {"Text", "Name", "Icon"};
            var to = new int [] { Resource.Id.textMessage, Resource.Id.textName, Resource.Id.iconView};
            var data = new List<IDictionary<string,object>> ();
            data.Add (new JavaDictionary<string,object> () { {"Text", "loading"}, {"Name", ""} });
            var urls = new Dictionary<Uri,List<string>> ();
            var getUrl = new Uri ("https://api.github.com/repos/mono/mono/commits");
            #if REACTIVE
            var hr = new HttpWebRequest (getUrl);
            var req = Observable.FromAsyncPattern<WebResponse> (hr.BeginGetResponse, hr.EndGetResponse);
            Observable.Defer (req).Subscribe (v => {
                var v = hr.GetResponse ();
                var json = (IEnumerable<JsonValue>) JsonValue.Load (v.GetResponseStream ());
            #else
            var wc = new WebClient ();
            wc.Headers ["USER-AGENT"] = "Xamarin Android sample HTTP client";
            wc.DownloadStringCompleted += (sender, e) => {
                data.Clear ();
                var v = e.Result;
                var json = (IEnumerable<JsonValue>) JsonValue.Parse (v);
            #endif
            #if REACTIVE
                json.ToObservable ().Select (j => j.AsDynamic ()).Subscribe (jitem => {
            #else
                foreach (var item in json.Select (j => j.AsDynamic ())) {
            #endif
                    var uri = new Uri ((string) item.author.avatar_url);
                    var file = Path.Combine (baseDir, (string) item.author.id + new FileInfo (uri.LocalPath).Extension);
                    if (!urls.ContainsKey (uri))
                        urls.Add (uri, new List<string> () {file});
                    else
                        urls [uri].Add (file);
                    data.Add (new JavaDictionary<string,object> () { {"Text", item.commit.message}, {"Name", item.author.login}, {"Icon", Path.Combine (baseDir, file) }});
            #if REACTIVE
                });
            #else
                }
            #endif
                urls.ToList ().ForEach (p => {
                        var iwc = new WebClient ();
                        iwc.DownloadDataCompleted += (isender, ie) => p.Value.ForEach (s => {
                            using (var fs = File.Create (s))
                                fs.Write (ie.Result, 0, ie.Result.Length);
                        });
                        iwc.DownloadDataAsync (p.Key);
                    });

                this.RunOnUiThread (() => {
                    ListAdapter = new SimpleAdapter (this, data, Resource.Layout.ListItem, from, to);
                });
            #if REACTIVE
            });
            #else
            };
            wc.DownloadStringAsync (getUrl);
            #endif
            ListAdapter = new SimpleAdapter (this, data, Resource.Layout.ListItem, from, to);
        }
예제 #31
0
        protected override bool CreateAspectFor(ClassAcessor acessor, out XmlAspectMember member)
        {
            XmlAttribute xa = acessor.GetAttribute <XmlAttribute>(true);

            if (xa == null)
            {
                member = null;
                return(false);
            }
            else
            {
                SimpleAdapter adapter = SimpleAdapters.CreateInstance(
                    acessor.DataType,
                    xa.FormatString,
                    string.IsNullOrEmpty(xa.Culture) ? null :
                    CultureInfo.GetCultureInfo(xa.Culture)
                    );

                if (adapter != null)
                {
                    switch (xa.XmlType)
                    {
                    case XmlType.Attribute:
                        member = new XmlAspectMemberAttribute(
                            acessor,
                            string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name,
                            xa.IsMandatory,
                            adapter);
                        return(true);

                    case XmlType.CDATA:
                        member = new XmlAspectMemberCDATA(
                            acessor,
                            string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name,
                            xa.IsMandatory,
                            adapter);
                        return(true);

                    case XmlType.Element:
                        member = new XmlAspectMemberText(
                            acessor,
                            string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name,
                            xa.IsMandatory,
                            adapter);
                        return(true);

                    default:
                        throw new NotImplementedException("Unable to serialize primitive type with " + xa.XmlType);
                    }
                }
                else if (typeof(IList).IsAssignableFrom(acessor.DataType))
                {
                    member = new XmlAspectMemberList(
                        acessor,
                        string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name,
                        xa.IsMandatory);
                    return(true);
                }
                else
                {
                    member = new XmlAspectMemberComposite(
                        acessor,
                        string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name,
                        xa.IsMandatory,
                        GetInstance(acessor.DataType),
                        acessor.DataType.GetConstructor(Type.EmptyTypes));
                }

                return(true);
            }
        }
예제 #32
0
        //LOAD LISTA E PÁGINA
        public async void LoadContent()
        {
            aeho = await Get();

            List<Models.Restaurante> list = JsonConvert.DeserializeObject<List<Models.Restaurante>>(aeho);
            IList<IDictionary<string, object>> dados = new List<IDictionary<string, object>>();
            foreach (Models.Restaurante r in list)
            {
                IDictionary<string, object> dado = new JavaDictionary<string, object>();
                dado.Add("Id", r.Id.ToString());
                dado.Add("Descricao", r.Descricao);
                dados.Add(dado);
            }

            string[] from = new String[] { "Id", "Descricao" };
            int[] to = new int[] { Resource.Id.idRest, Resource.Id.descRest };
            int layout = Resource.Layout.ListItem;

            EditText txtid = FindViewById<EditText>(Resource.Id.txtId);
            EditText txtdesc = FindViewById<EditText>(Resource.Id.txtDescricao);
            // ArrayList for data row
            // SimpleAdapter mapping static data to views in xml file
            SimpleAdapter adapter = new SimpleAdapter(this, dados, layout, from, to);

            ListView.Adapter = adapter;
        }
예제 #33
0
		public override void onCreate(Bundle savedInstanceState)
		{
			if (Build.VERSION.SDK_INT == Build.VERSION_CODES.HONEYCOMB || Build.VERSION.SDK_INT == Build.VERSION_CODES.HONEYCOMB_MR1)
			{
				StrictMode.ThreadPolicy = (new StrictMode.ThreadPolicy.Builder()).detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build();
				StrictMode.VmPolicy = (new StrictMode.VmPolicy.Builder()).detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build();
			}
			base.onCreate(savedInstanceState);
			ContentView = R.layout.activity_main;

			List<Dictionary<string, string>> data = new List<Dictionary<string, string>>();
			for (int i = 0; i < FUNCTIONS.Length; i++)
			{
				Dictionary<string, string> hashMap = new Dictionary<string, string>();
				hashMap["item1"] = FUNCTIONS[i][0];
				hashMap["item2"] = FUNCTIONS[i][1];
				data.Add(hashMap);
			}

			SimpleAdapter adapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_2, new string[] {"item1", "item2"}, new int[] {android.R.id.text1, android.R.id.text2});
			mListView = (ListView) findViewById(android.R.id.list);
			mListView.Adapter = adapter;
			mListView.Enabled = false;

			mProgressBar = (ProgressBar) findViewById(R.id.progressBar1);

			mBixolonPrinter = new BixolonPrinter(this, mHandler, null);
		}
예제 #34
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);
            IDictionary<String, Object> item1 = new Dictionary<String, Object>();
            item1.Add("list_title", GetString(Resource.String.title1));
            item1.Add("list_image", Resource.Drawable.p1);
            item1.Add("list_contect", GetString(Resource.String.test));

            IDictionary<String, Object> item2 = new Dictionary<String, Object>();
            item2.Add("list_title", GetString(Resource.String.title1));
            item2.Add("list_image", Resource.Drawable.p2);
            item2.Add("list_contect", GetString(Resource.String.test));

            IDictionary<String, Object> item3 = new Dictionary<String, Object>();
            item3.Add("list_title", GetString(Resource.String.title1));
            item3.Add("list_image", Resource.Drawable.p3);
            item3.Add("list_contect", GetString(Resource.String.test));

            IDictionary<String, Object> item4 = new Dictionary<String, Object>();
            item4.Add("list_title", GetString(Resource.String.title1));
            item4.Add("list_image", Resource.Drawable.p4);
            item4.Add("list_contect", GetString(Resource.String.test));

            IDictionary<String, Object> item5 = new Dictionary<String, Object>();
            item5.Add("list_title", GetString(Resource.String.title1));
            item5.Add("list_image", Resource.Drawable.p5);
            item5.Add("list_contect", GetString(Resource.String.test));

            IDictionary<String, Object> item6 = new Dictionary<String, Object>();
            item6.Add("list_title", GetString(Resource.String.title1));
            item6.Add("list_image", Resource.Drawable.p6);
            item6.Add("list_contect", GetString(Resource.String.test));

            IDictionary<String, Object> item7 = new Dictionary<String, Object>();
            item7.Add("list_title", GetString(Resource.String.title1));
            item7.Add("list_image", Resource.Drawable.p7);
            item7.Add("list_contect", GetString(Resource.String.test));

            IList<IDictionary<String, Object>> data = new List<IDictionary<string, object>>();
            data.Add(item1);
            data.Add(item2);
            data.Add(item3);
            data.Add(item4);
            data.Add(item5);
            data.Add(item6);
            data.Add(item7);

            var from = new String[] { "list_title", "list_image", "list_contect" };
            var to = new int[] { Resource.Id.list_title, Resource.Id.list_image, Resource.Id.list_contect };
            var adapter = new SimpleAdapter(Activity, data, Resource.Layout.list_item, from, to);
            //setListAdapter(adapter);

            lv_left.Click += (sender, e) =>
            {
                (this.Activity as MainActivity).ShowLeft();
            };
            iv_right.Click += (sender, e) =>
            {
                (this.Activity as MainActivity).ShowRight();
            };
        }
 public override void onCreate(Bundle savedInstanceState)
 {
     base.onCreate(savedInstanceState);
     ListAdapter = new SimpleAdapter(this, Data, android.R.layout.simple_list_item_1, new string[] { "title" }, new int[] { android.R.id.text1 });
     ListView.TextFilterEnabled = true;
 }
예제 #36
0
		public override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);
			ListAdapter = new SimpleAdapter(this, Data, android.R.layout.simple_list_item_1, new string[] {"title"}, new int[] {android.R.id.text1});
			ListView.TextFilterEnabled = true;
		}
예제 #37
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            recyclerView.SetLayoutManager(new GridLayoutManager(Context, 5));

            selectableColorsAdapter = new SimpleAdapter <SelectableColorViewModel>(
                Resource.Layout.SelectColorFragmentCell, ColorSelectionViewHolder.Create);

            selectableColorsAdapter.ItemTapObservable
            .Select(x => x.Color)
            .Subscribe(ViewModel.SelectColor.Inputs)
            .DisposedBy(DisposeBag);

            recyclerView.SetAdapter(selectableColorsAdapter);

            ViewModel.Hue
            .Subscribe(hueSaturationPicker.Rx().HueObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Saturation
            .Subscribe(hueSaturationPicker.Rx().SaturationObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Value
            .Subscribe(hueSaturationPicker.Rx().ValueObserver())
            .DisposedBy(DisposeBag);

            hueSaturationPicker.Rx().Hue()
            .Subscribe(ViewModel.SetHue.Inputs)
            .DisposedBy(DisposeBag);

            hueSaturationPicker.Rx().Saturation()
            .Subscribe(ViewModel.SetSaturation.Inputs)
            .DisposedBy(DisposeBag);

            valueSlider.Rx().Progress()
            .Select(invertedNormalizedProgress)
            .Subscribe(ViewModel.SetValue.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Hue
            .Subscribe(valueSlider.Rx().HueObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Saturation
            .Subscribe(valueSlider.Rx().SaturationObserver())
            .DisposedBy(DisposeBag);

            saveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            closeButton.Rx().Tap()
            .Subscribe(ViewModel.CloseWithDefaultResult)
            .DisposedBy(DisposeBag);

            ViewModel.SelectableColors
            .Subscribe(updateColors)
            .DisposedBy(DisposeBag);

            hueSaturationPicker.Visibility = ViewModel.AllowCustomColors.ToVisibility();
            valueSlider.Visibility         = ViewModel.AllowCustomColors.ToVisibility();
        }