Beispiel #1
0
        public void RefreshTable()            //PullToRefresharp.Android.Views.IPullToRefresharpView list = null
        {
            var activity = Activity;

            publicationsList.Visibility = ViewStates.Gone;
            LoadingView.Visibility      = ViewStates.Visible;
            if (cnHelper.NetworkAvailable())
            {
                parser.UpdatePublications(publications => activity.RunOnUiThread(() => {
                    var adapter = new PublicationsListAdapter(_inflater, publications);
                    publicationsList.Adapter    = adapter;
                    publicationsList.ItemClick += (sender, e) => {
                        var pub    = adapter.Publications [e.Position];
                        var intent = new Intent(activity, typeof(PublicationActivity));
                        intent.PutExtra("pub_id", pub.Id);
                        StartActivity(intent);
                    };
                    LoadingView.Visibility      = ViewStates.Gone;
                    publicationsList.Visibility = ViewStates.Visible;
                }), error => activity.RunOnUiThread(() => Toast.MakeText(activity, Resource.String.connection_error, ToastLength.Long).Show()));
            }
            else
            {
                SetupTable(_companyId);
            }
//			if (list != null)
//				list.OnRefreshCompleted ();
        }
Beispiel #2
0
        public void SetupTable(int companyId)
        {
            IList <Publication> publications;

            if (companyId == 0)
            {
                publications = parser.Publications;
            }
            else
            {
                var company = dbHelper.Connection.Get <Company> (companyId);
                publications = dbHelper.Connection.Table <Publication> ().Where(p => p.Company.Equals(company.Name)).ToList();
            }

            var adapter = new PublicationsListAdapter(_inflater, publications);

            publicationsList.Adapter    = adapter;
            publicationsList.ItemClick += (sender, e) => {
                var pub    = adapter.Publications [e.Position];
                var intent = new Intent(Activity, typeof(PublicationActivity));
                intent.PutExtra("pub_id", pub.Id);
                StartActivity(intent);
            };
        }
Beispiel #3
0
        void HandleIntent(Intent intent)
        {
            if (Intent.ActionSearch.Equals(intent.Action))
            {
                var query       = intent.GetStringExtra(SearchManager.Query);
                var suggestions = new SearchRecentSuggestions(this, SuggestionProvider.Authority, SuggestionProvider.Mode);
                suggestions.SaveRecentQuery(query, null);
                var parser = new PublicationsParser();
                SetTitle(Resource.String.search_results);
                mDrawerList.SetItemChecked(0, false);
                var publicationsList = FindViewById <ListView> (Resource.Id.Publications);
                SetProgressBarIndeterminateVisibility(true);
                LoadingView = FindViewById <LinearLayout> (Resource.Id.load_status);
                publicationsList.Visibility = ViewStates.Gone;
                LoadingView.Visibility      = ViewStates.Visible;
                if (cnHelper.NetworkAvailable())
                {
                    parser.SendSearchParameters(publications => RunOnUiThread(() => {
                        var adapter = new PublicationsListAdapter(this.LayoutInflater, publications);
                        publicationsList.Adapter    = adapter;
                        publicationsList.ItemClick += (sender, e) => {
                            var pub      = adapter.Publications [e.Position];
                            var myIntent = new Intent(this, typeof(PublicationActivity));
                            myIntent.PutExtra("remote_id", pub.RemoteId);
                            StartActivity(myIntent);
                        };
                        SetProgressBarIndeterminateVisibility(false);
                        LoadingView.Visibility      = ViewStates.Gone;
                        publicationsList.Visibility = ViewStates.Visible;
                    }), query, state => RunOnUiThread(() => {
                        var builder = new AlertDialog.Builder(this);
                        builder.SetMessage(Resource.String.connection_error).SetTitle(Resource.String.error);
                        builder.SetPositiveButton(Resource.String.ok, delegate {
                            LoadingView.Visibility      = ViewStates.Gone;
                            publicationsList.Visibility = ViewStates.Visible;
                            FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, pubs).Commit();
                            SetProgressBarIndeterminateVisibility(false);
                        });
                        var alert = builder.Create();
                        alert.Show();
                        //Toast.MakeText (this, Resource.String.connection_error, ToastLength.Short).Show ();
                    }));
                }
                else
                {
                    parser.LocalSearch(publications => RunOnUiThread(() => {
                        var adapter          = ((PublicationsListAdapter)publicationsList.Adapter);
                        adapter.Publications = publications;
                        adapter.NotifyDataSetChanged();
                        publicationsList.ItemClick += (sender, e) => {
                            var pub      = adapter.Publications [e.Position];
                            var myIntent = new Intent(this, typeof(PublicationActivity));
                            myIntent.PutExtra("pub_id", pub.Id);
                            StartActivity(myIntent);
                        };
//						FrameView.Visibility = ViewStates.Visible;
                        LoadingView.Visibility = ViewStates.Gone;
                    }), query);
                }
            }
        }