Beispiel #1
0
        public void CheckFirstRun(NetworkInfo networkInfo)
        {
            const String PREFS_NAME            = "MyPrefsFile";
            const String PREF_VERSION_CODE_KEY = "version_code";
            const int    DOESNT_EXIST          = -1;


            int currentVersionCode = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionCode;

            ISharedPreferences prefs = GetSharedPreferences(PREFS_NAME, FileCreationMode.Private);
            int savedVersionCode     = prefs.GetInt(PREF_VERSION_CODE_KEY, DOESNT_EXIST);


            if (currentVersionCode == savedVersionCode)
            {
                db = new DataBase();
                db.createDataBase();
                mWaluta = db.selectWaluta();
                ListViewAdapter adapter = new ListViewAdapter(this, mWaluta);
                mListView.Adapter = adapter;


                return;
            }
            else if (savedVersionCode == DOESNT_EXIST)
            {
                db = new DataBase();
                db.createDataBase();
                if (networkInfo != null && networkInfo.IsConnectedOrConnecting)
                {
                    GetData();
                }
            }
            else if (currentVersionCode > savedVersionCode)
            {
                db = new DataBase();
                db.createDataBase();
                if (networkInfo != null && networkInfo.IsConnectedOrConnecting)
                {
                    GetData();
                }
            }

            prefs.Edit().PutInt(PREF_VERSION_CODE_KEY, currentVersionCode).Apply();
        }
Beispiel #2
0
        void UpdateData(List <TabelaC.RootObject> mItems)
        {
            for (int i = 0; i < mItems[0].rates.Count; i++)
            {
                Waluta awaluta = new Waluta()
                {
                    Id       = i,
                    Data     = DateTime.Parse(mItems[0].effectiveDate),
                    Nazwa    = mItems[0].rates[i].currency,
                    Kod      = mItems[0].rates[i].code,
                    Kupno    = mItems[0].rates[i].bid,
                    Sprzedaz = mItems[0].rates[i].ask
                };
                db.updateWaluta(awaluta);
            }
            mWaluta = db.selectWaluta();
            ListViewAdapter adapter = new ListViewAdapter(this, mWaluta);

            mListView.Adapter = adapter;
        }