Esempio n. 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            parser    = new PublicationsParser();
            dbHelper  = DatabaseHelper.Instance;
            _inflater = inflater;
            cnHelper  = ConnectivityHelper.Instance(Activity);
//			if (_companyId == 0) {
//				layout = _inflater.Inflate (Resource.Layout.RefreshPubList, container, false);
//				var list = layout.FindViewById<PullToRefresharp.Android.Widget.ListView> (Resource.Id.Publications);
//				list.RefreshActivated += (sender, e) => RefreshTable (list);
//				publicationsList = list;
//			} else {
            layout           = _inflater.Inflate(Resource.Layout.PublicationsList, container, false);
            publicationsList = layout.FindViewById <ListView> (Resource.Id.Publications);
            LoadingView      = layout.FindViewById <LinearLayout> (Resource.Id.load_status);
//			}
            if (_reload)
            {
                RefreshTable();
            }
            else
            {
                SetupTable(_companyId);
            }

            return(layout);
        }
Esempio n. 2
0
 public static ConnectivityHelper Instance(Activity context)
 {
     if (currentInstance == null)
     {
         currentInstance = new ConnectivityHelper(context);
     }
     return(currentInstance);
 }
Esempio n. 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SplashView);
            status            = FindViewById <ProgressBar> (Resource.Id.setup_bar);
            status.Visibility = ViewStates.Visible;
            SimpleStorage.SetContext(ApplicationContext);
            var storage  = SimpleStorage.EditGroup("preferences");
            var value    = storage.Get("companies_exist");
            var cnHelper = ConnectivityHelper.Instance(this);

            if (value == null)
            {
                if (cnHelper.NetworkAvailable())
                {
                    UpdateCompanies(storage);
                }
                else
                {
                    var builder = new AlertDialog.Builder(this);
                    builder.SetMessage(Resource.String.network_needed).SetTitle(Resource.String.no_network);
                    builder.SetPositiveButton(Resource.String.ok, delegate {
                        Finish();
                    });
                    var alert = builder.Create();
                    alert.Show();
                }
            }
            else
            {
                if (cnHelper.NetworkAvailable())
                {
                    UpdateCompanies(storage);
                }
                else
                {
                    StartActivity(typeof(MainActivity));
                }
            }
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.IndeterminateProgress);
            SetContentView(Resource.Layout.Navigation);

            if (HasPlayServices)
            {
                GCM   = GoogleCloudMessaging.GetInstance(this);
                RegID = RegistrationId;
                if (String.IsNullOrEmpty(RegID))
                {
                    RegisterInBackground();
                }
                else
                {
                    Console.WriteLine("Seems like we have a RegID");
                }
            }


            cnHelper               = ConnectivityHelper.Instance(this);
            mDrawerLayout          = FindViewById <DrawerLayout> (Resource.Id.drawer_layout);
            mDrawerList            = FindViewById <ListView> (Resource.Id.left_drawer);
            mDrawerList.Adapter    = new DrawerAdapter(this);
            mDrawerList.ItemClick += (sender, e) => {
                switch (e.Position)
                {
                case 0:
                    var publications = new PublicationsFragment(false);
                    FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, publications).Commit();
                    SetTitle(Resource.String.main_title);
                    mDrawerLayout.CloseDrawer(mDrawerList);
                    break;

                case 1:
                    var companies = new CompaniesFragment();
                    FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, companies).Commit();
                    SetTitle(Resource.String.companies);
                    mDrawerLayout.CloseDrawer(mDrawerList);
                    break;
                }
            };

            mDrawerLayout.SetDrawerShadow(Resource.Drawable.drawer_shadow, GravityCompat.Start);

            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            DrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, Resource.Drawable.ic_navigation_drawer, Resource.String.drawer_open, Resource.String.drawer_close);
            mDrawerLayout.SetDrawerListener(DrawerToggle);

            mDrawerLayout.DrawerOpened += delegate {
                ActionBar.SetTitle(Resource.String.menu);
                //mDrawerLayout.
                InvalidateOptionsMenu();
            };
            mDrawerLayout.DrawerClosed += delegate {
                SetTitle(mTitle);
                InvalidateOptionsMenu();
            };

            pubs = new PublicationsFragment();
            FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, pubs).Commit();
            mDrawerList.SetItemChecked(0, true);
            HandleIntent(Intent);
        }