Ejemplo n.º 1
0
        public void GetNewsFeed(NewsFeedGetParams parameters, Action <BackendResult <NewsFeedData, ResultCode> > callback)
        {
            string methodName = "execute.getNewsfeed";
            Dictionary <string, string> paramDict = new Dictionary <string, string>()
            {
                {
                    "count",
                    parameters.count.ToString()
                },
                {
                    "device_info",
                    new AdvertisingDeviceInfo().ToJsonString()
                }
            };

            paramDict["fields"] = "sex,online,photo_50,photo_100,photo_200,is_friend";
            if (!string.IsNullOrEmpty(parameters.from))
            {
                paramDict["start_from"] = parameters.from;
            }
            bool?nullable;

            if (parameters.NewsListId == -100L)
            {
                paramDict["filters"]  = "video";
                paramDict["grouping"] = "100";
                paramDict["extended"] = "1";
            }
            else if (parameters.photoFeed || parameters.NewsListId == -101L)
            {
                paramDict["filters"]    = "photo,photo_tag,wall_photo";
                paramDict["max_photos"] = "10";
                if (parameters.source_ids.NotNullAndHasAtLeastOneNonNullElement())
                {
                    paramDict["source_ids"] = parameters.source_ids.GetCommaSeparated();
                }
                else
                {
                    paramDict["source_ids"]    = "friends,following";
                    paramDict["return_banned"] = "1";
                }
            }
            else
            {
                paramDict["filters"] = "post,photo,photo_tag";
                long num1 = parameters.NewsListId - -10L;
                long num2 = 3;
                if ((ulong)num1 <= (ulong)num2)
                {
                    switch ((uint)num1)
                    {
                    case 0:
                        paramDict["is_newsfeed"] = "1";
                        Dictionary <string, string> dictionary1 = paramDict;
                        dictionary1["filters"] = dictionary1["filters"] + ",friends_recomm,ads_post";
                        nullable = AppGlobalStateManager.Current.GlobalState.AdsDemoManualSetting;
                        bool flag = true;
                        if ((nullable.GetValueOrDefault() == flag ? (nullable.HasValue ? 1 : 0) : 0) != 0)
                        {
                            Dictionary <string, string> dictionary2 = paramDict;
                            dictionary2["filters"] = dictionary2["filters"] + ",ads_demo";
                            goto label_16;
                        }
                        else
                        {
                            goto label_16;
                        }

                    case 1:
                        paramDict["recommended"] = "1";
                        goto label_16;

                    case 2:
                        paramDict["source_ids"] = "friends,following";
                        goto label_16;

                    case 3:
                        paramDict["source_ids"] = "groups,pages";
                        goto label_16;
                    }
                }
                paramDict["source_ids"] = "list" + parameters.NewsListId;
            }
label_16:
            NewsFeedType? feedType = parameters.FeedType;
            if (feedType.HasValue)
            {
                paramDict["feed_type"] = feedType.Value.ToString();
                if (parameters.UpdateFeedType)
                {
                    paramDict["set_feed_type"] = "1";
                }
            }
            if (parameters.SyncNotifications)
            {
                paramDict["sync_notifications"] = "1";
            }
            nullable = parameters.TopFeedPromoAnswer;
            if (nullable.HasValue)
            {
                Dictionary <string, string> dictionary = paramDict;
                string index = "top_feed_promo_accepted";
                nullable = parameters.TopFeedPromoAnswer;
                string str = nullable.Value ? "1" : "0";
                dictionary[index] = str;
                paramDict["top_feed_promo_id"] = parameters.TopFeedPromoId.ToString();
            }
            ConnectionType connectionType = NetworkStatusInfo.Instance.RetrieveNetworkConnectionType();

            if (connectionType != null)
            {
                paramDict["connection_type"]    = connectionType.Type;
                paramDict["connection_subtype"] = connectionType.Subtype;
            }
            if (parameters.UpdateAwayTime > 0)
            {
                paramDict["update_away_time"] = parameters.UpdateAwayTime.ToString();
            }
            if (parameters.UpdatePosition > -1)
            {
                paramDict["update_position"] = parameters.UpdatePosition.ToString();
            }
            if (!string.IsNullOrEmpty(parameters.UpdatePost))
            {
                paramDict["update_post"] = parameters.UpdatePost;
            }
            NewsFeedService.DoLoadNewsFeed(methodName, paramDict, callback);
        }
Ejemplo n.º 2
0
 public void AddBan(List <long> uids, List <long> gids, Action <BackendResult <ResponseWithId, ResultCode> > callback)
 {
     NewsFeedService.AddDeleteBan(true, uids, gids, callback);
 }
        public void GetNewsFeed(NewsFeedGetParams parameters, Action <BackendResult <NewsFeedData, ResultCode> > callback)
        {
            /*
             * Dictionary<string, string> paramDict = new Dictionary<string, string>()
             * {
             * {
             * "count",
             * parameters.count.ToString()
             * },
             * {
             * "device_info",
             * new AdvertisingDeviceInfo().ToJsonString()
             * }
             * };
             * paramDict["fields"] = "sex,online,photo_50,photo_100,photo_200,is_friend";
             * if (!string.IsNullOrEmpty(parameters.from))
             * paramDict["start_from"] = parameters.from;
             * bool? nullable;
             * if (parameters.NewsListId == -100L)
             * {
             * paramDict["filters"] = "video";
             * paramDict["grouping"] = "100";
             * paramDict["extended"] = "1";
             * }
             * else if (parameters.photoFeed || parameters.NewsListId == -101L)
             * {
             * paramDict["filters"] = "photo,photo_tag,wall_photo";
             * paramDict["max_photos"] = "10";
             * if (parameters.source_ids.NotNullAndHasAtLeastOneNonNullElement())
             * {
             * paramDict["source_ids"] = parameters.source_ids.GetCommaSeparated();
             * }
             * else
             * {
             * paramDict["source_ids"] = "friends,following";
             * paramDict["return_banned"] = "1";
             * }
             * }
             * else
             * {
             * paramDict["filters"] = "post,photo,photo_tag";
             * long num1 = parameters.NewsListId - -10L;
             *
             * if ((ulong) num1 <= (ulong) 3)
             * {
             * switch ((uint) num1)
             * {
             *  case 0:
             *    paramDict["is_newsfeed"] = "1";
             *    Dictionary<string, string> dictionary1 = paramDict;
             *    dictionary1["filters"] = dictionary1["filters"] + ",friends_recomm,ads_post";
             *    nullable = AppGlobalStateManager.Current.GlobalState.AdsDemoManualSetting;
             *    bool flag = true;
             *    if ((nullable.GetValueOrDefault() == flag ? (nullable.HasValue ? 1 : 0) : 0) != 0)
             *    {
             *      Dictionary<string, string> dictionary2 = paramDict;
             *      dictionary2["filters"] = dictionary2["filters"] + ",ads_demo";
             *      goto label_16;
             *    }
             *    else
             *      goto label_16;
             *  case 1:
             *    paramDict["recommended"] = "1";
             *    goto label_16;
             *  case 2:
             *    paramDict["source_ids"] = "friends,following";
             *    goto label_16;
             *  case 3:
             *    paramDict["source_ids"] = "groups,pages";
             *    goto label_16;
             * }
             * }
             * paramDict["source_ids"] = "list" + parameters.NewsListId;
             * }
             * label_16:
             * NewsFeedType? feedType = parameters.FeedType;
             * if (feedType.HasValue)
             * {
             * paramDict["feed_type"] = feedType.Value.ToString();
             * if (parameters.UpdateFeedType)
             * paramDict["set_feed_type"] = "1";
             * }
             * if (parameters.SyncNotifications)
             * paramDict["sync_notifications"] = "1";
             * nullable = parameters.TopFeedPromoAnswer;
             * if (nullable.HasValue)
             * {
             * Dictionary<string, string> dictionary = paramDict;
             * string index = "top_feed_promo_accepted";
             * nullable = parameters.TopFeedPromoAnswer;
             * string str = nullable.Value ? "1" : "0";
             * dictionary[index] = str;
             * paramDict["top_feed_promo_id"] = parameters.TopFeedPromoId.ToString();
             * }
             * ConnectionType connectionType = NetworkStatusInfo.Instance.RetrieveNetworkConnectionType();
             * if (connectionType != null)
             * {
             * paramDict["connection_type"] = connectionType.Type;
             * paramDict["connection_subtype"] = connectionType.Subtype;
             * }
             * if (parameters.UpdateAwayTime > 0)
             * paramDict["update_away_time"] = parameters.UpdateAwayTime.ToString();
             * if (parameters.UpdatePosition > -1)
             * paramDict["update_position"] = parameters.UpdatePosition.ToString();
             * if (!string.IsNullOrEmpty(parameters.UpdatePost))
             * paramDict["update_post"] = parameters.UpdatePost;
             * NewsFeedService.DoLoadNewsFeed("execute.getNewsfeed", paramDict, callback);*/

            Dictionary <string, string> paramDict = new Dictionary <string, string>();

            paramDict["func_v"] = "2";
            ConnectionType connectionType = NetworkStatusInfo.Instance.RetrieveNetworkConnectionType();

            if (connectionType != null)
            {
                paramDict["connection_type"]    = connectionType.Type;
                paramDict["connection_subtype"] = connectionType.Subtype;
            }
            paramDict["user_options"] = "{\"autoplay_video\":{\"value\":\"always\"},\"autoplay_gif\":{\"value\":\"always\"}}";
            if (!string.IsNullOrEmpty(parameters.from))
            {
                paramDict["start_from"] = parameters.from;
            }
            paramDict["count"] = parameters.count.ToString();
            //todo:optimize fields
            paramDict["fields"] = "id,first_name,first_name_dat,last_name,last_name_dat,sex,screen_name,photo_50,photo_100,photo_200,online,video_files";
            //if (forceNotification)
            //{
            //    paramDict["forced_notifications"] = "1";
            //}
            switch (parameters.NewsListId)
            {
            case -100:    //новости видео(-5 андроид)
                paramDict["extended"] = "1";
                break;

            case -101:    //новости фотографий(-4 андроид)
                paramDict["return_banned"] = "1";
                break;

            case -9:    //(-1 андроид)
                paramDict["feed_type"] = "recommended";
                break;
            }

            switch (parameters.NewsListId)
            {
            case -100:    //новости видео(-5 андроид)
                paramDict["filters"] = "video";
                break;

            case -101:    //новости фотографий(-4 андроид)
                paramDict["filters"] = "photo,photo_tag,wall_photo";
                break;

            default:    //новости друзья
                paramDict["filters"] = "post,photo,photo_tag,friends_recomm,app_widget,ads_app,ads_site,ads_post,ads_app_slider,ads_app_video,ads_post_pretty_cards";
                break;
            }

            switch (parameters.NewsListId)
            {
            case -101:    //новости фотографий(-4 андроид)
                paramDict["source_ids"] = "friends,following";
                break;

            case -3:
                paramDict["source_ids"] = "groups,pages";
                break;

            case -8:    //новости друзья(-2 андроид)
                paramDict["source_ids"] = "friends,following";
                break;

            default:
                //if (list > 0) {
                //    paramDict["source_ids"] = "ArgKeys.LIST + list";
                //    break;
                //}
                break;
            }

            NewsFeedType?feedType = parameters.FeedType;

            if (feedType.HasValue)
            {
                //paramDict["feed_type"] = feedType.Value.ToString();
                paramDict["forced_feed_type"] = feedType.Value.ToString();//только в разделах Новости и Сначала интересные новости
            }

            /*
             * if (list == 0 && isSmartNews != null)
             * {
             *    if (!TextUtils.equals(from, AppEventsConstants.EVENT_PARAM_VALUE_NO))
             *    {
             *        param("feed_type", isSmartNews.booleanValue() ? FEED_TYPE_TOP : FEED_TYPE_RECENT);
             *    }
             *    else if (isStartFromInterestingPending())
             *    {
             *        param("forced_feed_type", isSmartNews.booleanValue() ? FEED_TYPE_TOP : FEED_TYPE_RECENT);
             *    }
             *    if (position >= 0)
             *    {
             *        param("update_position", String.valueOf(position));
             *    }
             *    if (lastPostId >= 0 && lastPostOwnerId != 0)
             *    {
             *        param("update_post", lastPostOwnerId + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + lastPostId);
             *    }
             *    if (awayTimeSec >= 0)
             *    {
             *        param("update_away_time", String.valueOf(awayTimeSec));
             *    }
             * }
             * if (list != 0)
             * {
             *    param("is_not_newsfeed", 1);
             * }
             * this.promoList = promoList;
             * if (promoList != null)
             * {
             *    param("feed_id", promoList);
             * }
             * param(ServerKeys.PHOTO_SIZES, 1);
             * int last = VKApplication.context.getSharedPreferences(null, 0).getInt(UserNotification.LAST_GET_NOTIFY_APP, 0);
             * if (last != 0)
             * {
             *    param("last_request_notification_sec", (int)((System.currentTimeMillis() / 1000) - ((long)last)));
             * }*/
            //

            if (parameters.UpdatePosition > -1)
            {
                paramDict["update_position"] = parameters.UpdatePosition.ToString();
            }
            if (!string.IsNullOrEmpty(parameters.UpdatePost))
            {
                paramDict["update_post"] = parameters.UpdatePost;
            }
            if (parameters.UpdateAwayTime > 0)
            {
                paramDict["update_away_time"] = parameters.UpdateAwayTime.ToString();
            }
            //
            //paramDict["is_not_newsfeed"] = "1";//при единице истории не грузятся
            paramDict["photo_sizes"] = "1";
            paramDict["last_request_notification_sec"] = "3";
            paramDict["device_info"]    = new AdvertisingDeviceInfo().ToJsonString();
            paramDict["app_package_id"] = "com.vkontakte.android";
            NewsFeedService.DoLoadNewsFeed("execute.getNewsfeedSmart", paramDict, callback);
        }