Example #1
0
        private void SetAdapter()
        {
            var recyclerView = FindViewById <RecyclerView>(Resource.Id.categoriesRecyclerView);
            var llm          = new LinearLayoutManager(this);

            Adapter = new CategoriesAdapter(this);
            recyclerView.SetLayoutManager(llm);
            recyclerView.SetAdapter(Adapter);
            Adapter?.Refresh();
        }
Example #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Categories);

            progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);

            viewModel = new CategoriesViewModel();

            viewModel.IsBusyChanged = (busy) =>
            {
                progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
            };

            ListAdapter = new CategoriesAdapter(this, viewModel);
        }
 private void CategoriesAdapter_OnItemClick(object sender, Categories_AdapterClickEventArgs adapterClickEvents)
 {
     try
     {
         var position = adapterClickEvents.Position;
         if (position >= 0)
         {
             var item = CategoriesAdapter.GetItem(position);
             if (item != null)
             {
                 CategoriesAdapter.Click_Categories(item);
                 CategoryId = item.Catigories_Id;
             }
         }
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
     }
 }
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.CategoriesList);

            // var androidResourceUrlPrefix = string.Format("android.resource://{0}/", Application.Context.PackageName);
            // var resources = Application.Context.Resources;
            try
            {
                await SampleManager.Current.InitializeAsync();

                var jsonInBytes = loadJSONFromAsset();
                var sampleStructureMap = CreateSampleStructureMap(jsonInBytes);
                var sampleModel = CreateSampleModel(jsonInBytes);

                _sampleCategories = SampleManager.Current.GetSamplesAsTree(sampleStructureMap);
                //List<string> categories = new List<string>();

                //foreach (var item in data)
                //{
                //    categories.Add(item.Name);
                //}

                //  var adapter = new ArrayAdapter<TreeItem>(this, Android.Resource.Layout.SimpleListItem1, data);
                //  var newAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, categories);

                var categoriesAdapter = new CategoriesAdapter(this, _sampleCategories);

                ListView categoriesListView = FindViewById<ListView>(Resource.Id.categoriesListView);

                categoriesListView.Adapter = categoriesAdapter;

                categoriesListView.ItemClick += CategoriesItemClick;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 private void DestroyBasic()
 {
     try
     {
         ViewPager                = null !;
         TabLayout                = null !;
         MarketTab                = null !;
         MyProductsTab            = null !;
         FloatingActionButtonView = null !;
         CatRecyclerView          = null !;
         CategoriesAdapter        = null !;
         DiscoverButton           = null !;
         FilterButton             = null !;
         KeySearch                = null !;
         Instance = null !;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Example #6
0
 private void DestroyBasic()
 {
     try
     {
         ViewPager                = null;
         TabLayout                = null;
         MarketTab                = null;
         MyProductsTab            = null;
         FloatingActionButtonView = null;
         CatRecyclerView          = null;
         CategoriesAdapter        = null;
         DiscoverButton           = null;
         FilterButton             = null;
         KeySearch                = null;
         Instance = null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        private void SetRecyclerViewAdapters()
        {
            try
            {
                if (CategoriesController.ListCategoriesProducts.Count > 0)
                {
                    var check = CategoriesController.ListCategoriesProducts.Where(a => a.CategoriesColor == AppSettings.MainColor).ToList();
                    if (check.Count > 0)
                    {
                        foreach (var all in check)
                        {
                            all.CategoriesColor = "#ffffff";
                        }
                    }

                    CatRecyclerView.HasFixedSize = true;
                    CatRecyclerView.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false));
                    CategoriesAdapter = new CategoriesAdapter(this)
                    {
                        MCategoriesList = CategoriesController.ListCategoriesProducts,
                    };
                    CatRecyclerView.SetAdapter(CategoriesAdapter);
                    CatRecyclerView.NestedScrollingEnabled = false;
                    CategoriesAdapter.NotifyDataSetChanged();
                    CatRecyclerView.Visibility   = ViewStates.Visible;
                    CategoriesAdapter.ItemClick += CategoriesAdapterOnItemClick;
                }
                else
                {
                    CatRecyclerView.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.CategoriesList);

            try
            {
                // Initialize the SampleManager and create the Sample Categories
                await SampleManager.Current.InitializeAsync(this);
                _sampleCategories = SampleManager.Current.GetSamplesAsTree();

                // Set up the custom ArrayAdapter for displaying the Categories.
                var categoriesAdapter = new CategoriesAdapter(this, _sampleCategories);
                ListView categoriesListView = FindViewById<ListView>(Resource.Id.categoriesListView);
                categoriesListView.Adapter = categoriesAdapter;

                categoriesListView.ItemClick += CategoriesItemClick;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #9
0
        //Get Data Group and set Categories
        private void Get_Data_Group()
        {
            try
            {
                if (Groups_Type == "Joined_UserGroups")
                {
                    _JoinedGroups_Data =
                        JsonConvert.DeserializeObject <Get_User_Data_Object.Joined_Groups>(
                            Intent.GetStringExtra("UserGroups"));
                    if (_JoinedGroups_Data != null)
                    {
                        Txt_title.Text = _JoinedGroups_Data.group_title;
                        Txt_name.Text  = _JoinedGroups_Data.username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_JoinedGroups_Data.about));

                        if (_JoinedGroups_Data.privacy == "0")
                        {
                            RB_Private.Checked = true;
                            RB_Public.Checked  = false;
                        }
                        else
                        {
                            RB_Private.Checked = false;
                            RB_Public.Checked  = true;
                        }

                        GroupPrivacy = _JoinedGroups_Data.privacy;
                        CategoryId   = _JoinedGroups_Data.category_id;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoGroup");
                    }
                }
                else if (Groups_Type == "Joined_MyGroups")
                {
                    _MyGroups_Data =
                        JsonConvert.DeserializeObject <Get_Community_Object.Group>(Intent.GetStringExtra("MyGroups"));
                    if (_MyGroups_Data != null)
                    {
                        Txt_title.Text = _MyGroups_Data.GroupName;
                        Txt_name.Text  = _MyGroups_Data.Username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_MyGroups_Data.About));

                        if (_MyGroups_Data.Privacy == "0")
                        {
                            RB_Private.Checked = true;
                            RB_Public.Checked  = false;
                        }
                        else
                        {
                            RB_Private.Checked = false;
                            RB_Public.Checked  = true;
                        }

                        GroupPrivacy = _MyGroups_Data.Privacy;
                        CategoryId   = _MyGroups_Data.CategoryId;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoGroup");
                    }
                }
                else if (Groups_Type == "Search_Groups")
                {
                    _SearchGroups_Data =
                        JsonConvert.DeserializeObject <Get_Search_Object.Group>(Intent.GetStringExtra("SearchGroups"));
                    if (_SearchGroups_Data != null)
                    {
                        Txt_title.Text = _SearchGroups_Data.GroupName;
                        Txt_name.Text  = _SearchGroups_Data.Username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_SearchGroups_Data.About));

                        if (_SearchGroups_Data.Privacy == "0")
                        {
                            RB_Private.Checked = true;
                            RB_Public.Checked  = false;
                        }
                        else
                        {
                            RB_Private.Checked = false;
                            RB_Public.Checked  = true;
                        }

                        GroupPrivacy = _SearchGroups_Data.Privacy;
                        CategoryId   = _SearchGroups_Data.CategoryId;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoGroup");
                    }
                }
                else if (Groups_Type == "Group_Data")
                {
                    _Group_Data =
                        JsonConvert.DeserializeObject <Get_Group_Data_Object.Group_Data>(
                            Intent.GetStringExtra("GroupData"));
                    if (_Group_Data != null)
                    {
                        Txt_title.Text = _Group_Data.group_title;
                        Txt_name.Text  = _Group_Data.username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_Group_Data.about));

                        if (_Group_Data.privacy == "0")
                        {
                            RB_Private.Checked = true;
                            RB_Public.Checked  = false;
                        }
                        else
                        {
                            RB_Private.Checked = false;
                            RB_Public.Checked  = true;
                        }

                        GroupPrivacy = _Group_Data.privacy;
                        CategoryId   = _Group_Data.category_id;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoGroup");
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
        //Get Data Page and set Categories
        private void Get_Data_Page()
        {
            try
            {
                if (Pages_Type == "Liked_UserPages")
                {
                    _LikedPages_Data =
                        JsonConvert.DeserializeObject <Get_User_Data_Object.Liked_Pages>(
                            Intent.GetStringExtra("UserPages"));
                    if (_LikedPages_Data != null)
                    {
                        Txt_title.Text = _LikedPages_Data.page_title;
                        Txt_name.Text  = _LikedPages_Data.username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_LikedPages_Data.about));

                        CategoryId = _LikedPages_Data.page_category;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoPage");
                    }
                }
                else if (Pages_Type == "Liked_MyPages")
                {
                    _MyPages_Data =
                        JsonConvert.DeserializeObject <Get_Community_Object.Page>(Intent.GetStringExtra("MyPages"));
                    if (_MyPages_Data != null)
                    {
                        Txt_title.Text = _MyPages_Data.PageTitle;
                        Txt_name.Text  = _MyPages_Data.Username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_MyPages_Data.About));

                        CategoryId = _MyPages_Data.PageCategory;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoPage");
                    }
                }
                else if (Pages_Type == "Saerch_Pages")
                {
                    _SearchPages_Data =
                        JsonConvert.DeserializeObject <Get_Search_Object.Page>(Intent.GetStringExtra("SaerchPages"));
                    if (_SearchPages_Data != null)
                    {
                        Txt_title.Text = _SearchPages_Data.PageTitle;
                        Txt_name.Text  = _SearchPages_Data.Username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_SearchPages_Data.About));

                        CategoryId = _SearchPages_Data.PageCategory;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoPage");
                    }
                }
                else if (Pages_Type == "Page_Data")
                {
                    _Page_Data =
                        JsonConvert.DeserializeObject <Get_Page_Data_Object.Page_Data>(
                            Intent.GetStringExtra("PageData"));
                    if (_Page_Data != null)
                    {
                        Txt_title.Text = _Page_Data.page_title;
                        Txt_name.Text  = _Page_Data.username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_Page_Data.about));

                        CategoryId = _Page_Data.page_category;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoPage");
                    }
                }
                else if (Pages_Type == "Liked_PromotedPages")
                {
                    _PromotedPages_Data =
                        JsonConvert.DeserializeObject <Get_General_Data_Object.Promoted_Pages>(
                            Intent.GetStringExtra("PromotedPages"));
                    if (_PromotedPages_Data != null)
                    {
                        Txt_title.Text = _PromotedPages_Data.page_title;
                        Txt_name.Text  = _PromotedPages_Data.username;
                        Txt_about.Text =
                            IMethods.Fun_String.DecodeString(
                                IMethods.Fun_String.DecodeStringWithEnter(_PromotedPages_Data.about));

                        CategoryId = _PromotedPages_Data.page_category;
                        //set value list Categories
                        CategoriesAdapter.Set_Categories(CategoryId, "EditInfoPage");
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Example #11
0
        public override void OnReceive(Context context, Intent intent)
        {
            Log.Debug(nameof(ScreenUnlockReceiver), intent.Action);

            var notificationSender = new NotificationSender(context, DataHolder.ScreenLocksCategory);

            if (_mPreferences == null)
            {
                _mPreferences = PreferenceManager.GetDefaultSharedPreferences(context);
            }

            var now = new Date();

            long monitoringStartTime;

            if ((monitoringStartTime = _mPreferences.GetLong(ScreenUtils.MonitoringLastStartTime, -1)) == -1)
            {
                monitoringStartTime = ScreenUtils.GetMonitoringStartTime(now);
                _mPreferences.Edit().PutLong(ScreenUtils.MonitoringLastStartTime, monitoringStartTime).Apply();
                using (var writer = new StreamWriter(
                           context.OpenFileOutput(DebugFile, FileCreationMode.Append)))
                {
                    writer.WriteLine($"----Monitoring u start Time: {now.GetFormattedDateTime()}----");
                }
            }
            else
            {
                monitoringStartTime = ScreenUtils.GetMonitoringStartTime(new Date(monitoringStartTime));
            }

            if (_lastDayUnlocked == -1)
            {
                int tmpDay;
                if ((tmpDay = _mPreferences.GetInt(ScreenUtils.LastUnlockDay, -1)) != -1)
                {
                    _lastDayUnlocked = tmpDay;
                    UnlockedTimes    = _mPreferences.GetInt(ScreenUtils.UnlocksToday, 0);
                }
                else
                {
                    _lastDayUnlocked = Calendar.Instance.Get(CalendarField.DayOfWeek);
                    _mPreferences.Edit().PutInt(ScreenUtils.LastUnlockDay, _lastDayUnlocked).Apply();
                }
            }

            if (_unlockMillis == null)
            {
                var thisDay = _mPreferences.GetInt($"{ScreenUtils.UnlocksDayNumber}{_lastDayUnlocked}", 0);
                _todayNormalSpeedValue = Math.Max(
                    _abnormalUnlockMinCount,
                    (int)(thisDay * _abnormalUnlockPercentage / 100d));
                _unlockMillis = new List <long>();
            }

            if (TimeUnit.Milliseconds.ToDays(now.Time - monitoringStartTime) >= 1)
            {
                var unlocksToPut = UnlockedTimes;
                int u;

                if ((u = _mPreferences.GetInt($"{ScreenUtils.UnlocksDayNumber}{_lastDayUnlocked}", -1)) != -1)
                {
                    unlocksToPut = (int)Math.Ceiling((u + unlocksToPut) / 2d);
                }

                var tmpDay = _lastDayUnlocked;
                _lastDayUnlocked = Calendar.Instance.Get(CalendarField.DayOfWeek);
                UnlockedTimes    = 1;

                var thisDay = _mPreferences.GetInt($"{ScreenUtils.UnlocksDayNumber}{_lastDayUnlocked}", 0);
                _todayNormalSpeedValue = Math.Max(
                    _abnormalUnlockMinCount,
                    (int)(thisDay * _abnormalUnlockPercentage / 100d));
                _unlockMillis = new List <long>();

                _mPreferences.Edit()
                .PutInt($"{ScreenUtils.UnlocksDayNumber}{tmpDay}", unlocksToPut)
                .PutInt(ScreenUtils.LastUnlockDay, _lastDayUnlocked)
                .PutLong(ScreenUtils.MonitoringLastStartTime, ScreenUtils.GetMonitoringStartTime(now))
                .PutInt(ScreenUtils.UnlocksToday, UnlockedTimes)
                .PutInt(ScreenUtils.UnlocksNewNormalCount, -1)
                .Apply();

                MainActivity.Adapter?.Refresh();
                return;
            }

            Log.Debug("AbScreenReceiver",
                      $"Not new day. Was {new Date(monitoringStartTime).GetFormattedDateTime()}, now {now.GetFormattedDateTime()}");

            _mPreferences.Edit().PutInt(ScreenUtils.UnlocksToday, ++UnlockedTimes).Apply();

            var mode = 0;

            if (UnlockedTimes > GetNormalUnlocksCount(_mPreferences) * 1.1)
            {
                mode = 1;
            }

            _abnormalUnlockInterval = _mPreferences.GetInt(AbnormalUnlocksTimeInterval, _abnormalUnlockInterval);

            if (_unlockMillis.Count > _todayNormalSpeedValue)
            {
                var s = TimeUnit.Milliseconds.ToSeconds(now.Time - _unlockMillis[0]);

                if (s <= _abnormalUnlockInterval && s > 0)
                {
                    mode = 2;
                    using (var writer = new StreamWriter(
                               context.OpenFileOutput(DebugFile, FileCreationMode.Append)))
                    {
                        writer.WriteLine($"----Time: {new Date().GetFormattedDateTime()}----");
                        foreach (var unlock in _unlockMillis)
                        {
                            writer.WriteLine($"Unlock at {new Date(unlock).GetFormattedDateTime()}, val = {unlock}");
                        }

                        writer.WriteLine("-----End1-----");
                    }
                }
                else
                {
                    var  tmpList = new List <long>();
                    long sec;
                    foreach (var time in _unlockMillis)
                    {
                        sec = TimeUnit.Milliseconds.ToSeconds(now.Time - time);
                        if (sec <= _abnormalUnlockInterval && sec > 0)
                        {
                            tmpList.Add(time);
                        }
                    }

                    _unlockMillis = tmpList;
                    sec           = TimeUnit.Milliseconds.ToSeconds(now.Time - _unlockMillis[0]);
                    if (_unlockMillis.Count > _todayNormalSpeedValue && sec <= _abnormalUnlockInterval && sec > 0)
                    {
                        mode = 2;
                        using (var writer = new StreamWriter(
                                   context.OpenFileOutput(DebugFile, FileCreationMode.Append)))
                        {
                            writer.WriteLine($"----Time: {new Date().GetFormattedDateTime()}----");
                            foreach (var unlock in _unlockMillis)
                            {
                                writer.WriteLine(
                                    $"Unlock at {new Date(unlock).GetFormattedDateTime()}, val = {unlock}");
                            }

                            writer.WriteLine("-----End2-----");
                        }
                    }
                }
            }

            _unlockMillis.Add(now.Time);

            string notificationText;

            switch (mode)
            {
            case 1:
                Status           = ScreenStatus.Many;
                notificationText =
                    string.Format(context.GetString(Resource.String.category_screen_notif_daily_overflow),
                                  UnlockedTimes, NormalCount);
                notificationSender.PutNormalizeExtra(ScreenUtils.UnlocksNewNormalCount,
                                                     (int)(UnlockedTimes * 1.2));

                CategoriesAdapter.Refresh(DataHolder.ScreenCategory);
                break;

            case 2:
                var tmpInterval = (int)(.9 * _abnormalUnlockInterval);
                if (tmpInterval >= _abnormalUnlockInterval)
                {
                    if (tmpInterval > 1)
                    {
                        tmpInterval--;
                    }
                }

                Status           = ScreenStatus.Speed;
                notificationText =
                    string.Format(context.GetString(Resource.String.category_screen_notif_west_fast_hand),
                                  _unlockMillis.Count,
                                  TimeUnit.Milliseconds.ToSeconds(_unlockMillis.Last() - _unlockMillis.First()));

                notificationSender.PutNormalizeExtra(AbnormalUnlocksTimeInterval, tmpInterval);
                CategoriesAdapter.Refresh(DataHolder.ScreenCategory);
                break;

            default:
                Status = ScreenStatus.OK;
                CategoriesAdapter.Refresh(DataHolder.ScreenCategory);
                return;
            }

            using (var writer =
                       new StreamWriter(context.OpenFileOutput(AlarmReceiver.CurrentSummaryFile, FileCreationMode.Append)))
            {
                writer.WriteLine(notificationText);
            }

            notificationSender.Send(NotificationType.WarningNotification, notificationText);
        }