Esempio n. 1
0
        public static async Task LaunchCollection(ActivityCollection coll, Activity context)
        {
            if (coll == null)
            {
                return;
            }

            if (!IsContentVersionCompatible(coll, context))
            {
                return;
            }

            DatabaseManager db = await GetDbManager().ConfigureAwait(false);

            Dictionary <string, string> properties = new Dictionary <string, string>
            {
                { "UserId", db.CurrentUser.Id },
                { "CollectionId", coll.Id.ToString(CultureInfo.InvariantCulture) }
            };

            Analytics.TrackEvent("MainActivity_LaunchCollection", properties);

            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(context);

            // Save this activity to the database for showing in the 'recent' feed section
            db.AddContentCache(coll, int.Parse(preferences.GetString("pref_cacheNumber", "4"), CultureInfo.InvariantCulture));

            MainLandingFragment.ForceRefresh = true;

            string json = JsonConvert.SerializeObject(coll, new JsonSerializerSettings
            {
                TypeNameHandling      = TypeNameHandling.Auto,
                ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                MaxDepth = 6
            });

            using (Intent openCollectionIntent = new Intent(context, typeof(CollectionActivityListActivity)))
            {
                openCollectionIntent.PutExtra("JSON", json);
                context.StartActivity(openCollectionIntent);
            }
        }