Пример #1
0
        public async void LoadFeedDetail(string id)
        {
            JObject detail = await CoolApkSDK.GetFeedDetailById(id);

            FeedDetailList.ItemsSource = new Feed[] { new Feed(detail) };
            TitleTextBlock.Text        = detail["title"].ToString();
            if (detail["feedTypeName"].ToString() == "提问")
            {
                AnswerList.Visibility  = Visibility.Visible;
                AnswerList.ItemsSource = answers;
                JArray array = await CoolApkSDK.GetAnswerListById(id, answerSortType, $"{++answerpage}", answerfirstItem, answerlastItem);

                if (!(array is null) && array.Count != 0)
                {
                    foreach (JObject item in array)
                    {
                        answers.Add(new Feed(item));
                    }
                    answerfirstItem = array.First["id"].ToString();
                    answerlastItem  = array.Last["id"].ToString();
                }
                else
                {
                    answerpage--;
                }
            }
Пример #2
0
        async Task <bool> GetUrlPage(int page, string url, ObservableCollection <Feed> FeedsCollection)
        {
            mainPage.ActiveProgressRing();
            if (page == 1)
            {
                string s = await CoolApkSDK.GetCoolApkMessage($"{url}&page={page}");

                JObject jObject = (JObject)JsonConvert.DeserializeObject(s);
                JArray  Root    = (JArray)jObject["data"];
                int     n       = 0;
                if (FeedsCollection.Count > 0)
                {
                    var needDeleteItems = (from b in FeedsCollection
                                           from c in Root
                                           where b.GetValue("entityId") == c["entityId"].ToString()
                                           select b).ToArray();
                    foreach (var item in needDeleteItems)
                    {
                        Collection.Remove(item);
                    }
                    n = (from b in FeedsCollection
                         where b.GetValue("entityFixed") == "1"
                         select b).Count();
                }
                int k = 0;
                for (int i = 0; i < Root.Count; i++)
                {
                    if (index == -1 && (Root[i] as JObject).TryGetValue("entityTemplate", out JToken t) && t.ToString() == "configCard")
                    {
                        JObject j = JObject.Parse(Root[i]["extraData"].ToString());
                        title.Text = j["pageTitle"].ToString();
                        continue;
                    }
                    if ((Root[i] as JObject).TryGetValue("entityTemplate", out JToken tt) && tt.ToString() == "fabCard")
                    {
                        continue;
                    }
                    FeedsCollection.Insert(n + k, new Feed((JObject)Root[i]));
                    k++;
                }
                mainPage.DeactiveProgressRing();
                return(true);
            }
            else
            {
                string r = await CoolApkSDK.GetCoolApkMessage($"{url}&page={page}");

                JArray Root = JObject.Parse(r)["data"] as JArray;
                if (!(Root is null) && Root.Count != 0)
                {
                    foreach (JObject i in Root)
                    {
                        FeedsCollection.Add(new Feed(i));
                    }
                    mainPage.DeactiveProgressRing();
                    return(true);
                }
Пример #3
0
        public async void LoadProfile()
        {
            ImageSource getImage(string uri)
            {
                ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

                if (Convert.ToBoolean(localSettings.Values["IsNoPicsMode"]))
                {
                    if (Convert.ToBoolean(localSettings.Values["IsDarkMode"]))
                    {
                        return new BitmapImage(new Uri("ms-appx:/Assets/img_placeholder_night.png"))
                               {
                                   DecodePixelHeight = 150, DecodePixelWidth = 150
                               }
                    }
                    ;
                    else
                    {
                        return new BitmapImage(new Uri("ms-appx:/Assets/img_placeholder.png"))
                               {
                                   DecodePixelHeight = 150, DecodePixelWidth = 150
                               }
                    };
                }
                return(new BitmapImage(new Uri(uri)));
            }

            JObject detail = await CoolApkSDK.GetUserProfileByID(uid);

            if (!(detail is null))
            {
                UserDetailGrid.DataContext = new
                {
                    UserFace   = getImage(detail["userAvatar"].ToString()),
                    UserName   = detail["username"].ToString(),
                    FollowNum  = detail["follow"].ToString(),
                    FansNum    = detail["fans"].ToString(),
                    Level      = detail["level"].ToString(),
                    bio        = detail["bio"].ToString(),
                    Backgeound = new ImageBrush {
                        ImageSource = getImage(detail["cover"].ToString()), Stretch = Stretch.UniformToFill
                    },
                    verify_title = detail["verify_title"].ToString(),
                    gender       = int.Parse(detail["gender"].ToString()) == 1 ? "♂" : (int.Parse(detail["gender"].ToString()) == 0 ? "♀" : string.Empty),
                    city         = $"{detail["province"].ToString()} {detail["city"].ToString()}",
                    astro        = detail["astro"].ToString(),
                    logintime    = $"{Process.ConvertTime(detail["logintime"].ToString())}活跃"
                };
                TitleTextBlock.Text    = detail["username"].ToString();
                ListHeader.DataContext = new { FeedNum = detail["feed"].ToString() };
            }
Пример #4
0
        public async Task LoadFeeds(dynamic uid)
        {
            //绑定一个列表
            ObservableCollection <DataItem> FeedsCollection = new ObservableCollection <DataItem>();

            listView.ItemsSource = FeedsCollection;

            FeedRoot feedRoot = await CoolApkSDK.GetFeedListByID(uid, 1, "");

            foreach (DataItem i in feedRoot.data)
            {
                FeedsCollection.Add(i);
            }
        }
Пример #5
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            switch (button.Tag as string)
            {
            case "0":
                Frame.Navigate(typeof(TestPage), mainPage);
                break;

            case "1":
                MainPage.CheckUpdate(true);
                break;

            case "fakeLogin":
                try
                {
                    ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
                    if (string.IsNullOrEmpty(uidTextBox.Text))
                    {
                        localSettings.Values["UserName"] = localSettings.Values["Uid"] = localSettings.Values["UserAvatar"] = string.Empty;
                    }
                    else
                    {
                        string uid = await CoolApkSDK.GetUserIDByName(uidTextBox.Text);

                        JObject r = await CoolApkSDK.GetUserProfileByID(uid);

                        localSettings.Values["UserName"]   = r["username"].ToString();
                        localSettings.Values["Uid"]        = uid;
                        localSettings.Values["UserAvatar"] = r["userAvatar"].ToString();
                    }
                    mainPage.UpdateUserInfo(localSettings);
                }
                catch (Exception ex) { await new MessageDialog($"出现错误,可能是用户名不正确。\n{ex}").ShowAsync(); }
                break;
            }
        }
Пример #6
0
        public async void LoadUserProfile()
        {
            //本地信息
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

            try
            {
                if (localSettings.Values["login"].ToString().Contains("1"))
                {
                    User_Name.Text        = localSettings.Values["name"].ToString();
                    User_Face.ImageSource = new BitmapImage(new Uri(localSettings.Values["face"].ToString(), UriKind.RelativeOrAbsolute));
                }
            }
            catch (Exception)
            {
                localSettings.Values["login"] = "******";
                levelGrid.Visibility          = Visibility.Collapsed;
            }

            try
            {
                user = await CoolApkSDK.GetUserProfileByName(localSettings.Values["name"].ToString());

                if (user != null)
                {
                    dt.Text              = user.feed.ToString();
                    gz.Text              = user.follow.ToString();
                    fs.Text              = user.fans.ToString();
                    level.Text           = "Lv." + user.level.ToString();
                    levelGrid.Visibility = Visibility.Visible;
                }
            }
            catch (Exception)
            {
                localSettings.Values["name"] = "null";
            }
        }
Пример #7
0
        async void SearchFeeds(string keyWord)
        {
            mainPage.ActiveProgressRing();
            string feedType = string.Empty;
            string sortType = string.Empty;

            switch (SearchFeedTypeComboBox.SelectedIndex)
            {
            case 0:
                feedType = "all";
                break;

            case 1:
                feedType = "feed";
                break;

            case 2:
                feedType = "feedArticle";
                break;

            case 3:
                feedType = "rating";
                break;

            case 4:
                feedType = "picture";
                break;

            case 5:
                feedType = "question";
                break;

            case 6:
                feedType = "answer";
                break;

            case 7:
                feedType = "video";
                break;

            case 8:
                feedType = "ershou";
                break;

            case 9:
                feedType = "vote";
                break;
            }
            switch (SearchFeedSortTypeComboBox.SelectedIndex)
            {
            case 0:
                sortType = "default";
                break;

            case 1:
                sortType = "hot";
                break;

            case 2:
                sortType = "reply";
                break;
            }
            string r = await CoolApkSDK.GetCoolApkMessage($"/search?type=feed&feedType={feedType}&sort={sortType}&searchValue={keyWord}&page={++pages[0]}{(pages[0] > 1 ? "&lastItem=" + lastItems[0] : string.Empty)}&showAnonymous=-1");

            JArray Root = JObject.Parse(r)["data"] as JArray;
            ObservableCollection <Feed> FeedsCollection = FeedList.ItemsSource as ObservableCollection <Feed>;

            if (pages[0] == 1)
            {
                FeedsCollection.Clear();
            }
            if (!(Root is null) && Root.Count != 0)
            {
                lastItems[0] = Root.Last["id"].ToString();
                foreach (JObject i in Root)
                {
                    FeedsCollection.Add(new Feed(i));
                }
            }
Пример #8
0
        private async void LaunchAppViewLoad(String str)
        {
            try { jstr = Web.ReplaceHtml(Regex.Split(Regex.Split(Regex.Split(str, "应用简介</p>")[1], @"<div class=""apk_left_title_info"">")[1], "</div>")[0].Trim()); } catch (Exception) { }
            try { vmstr = Web.ReplaceHtml(Regex.Split(Regex.Split(str, @"<p class=""apk_left_title_info"">")[2], "</p>")[0].Replace("<br />", "").Replace("<br/>", "").Trim()); } catch (Exception) { }
            try { dstr = Web.ReplaceHtml(Regex.Split(Regex.Split(str, @"<p class=""apk_left_title_info"">")[1], "</p>")[0].Replace("<br />", "").Replace("<br/>", "").Trim()); } catch (Exception) { }
            vstr  = Regex.Split(str, @"<p class=""detail_app_title"">")[1].Split('>')[1].Split('<')[0].Trim();
            mstr  = Regex.Split(str, @"<p class=""apk_topba_message"">")[1].Split('<')[0].Trim().Replace("\n", "").Replace(" ", "");
            nstr  = Regex.Split(str, @"<p class=""detail_app_title"">")[1].Split('<')[0].Trim();
            iurl  = Regex.Split(str, @"<div class=""apk_topbar"">")[1].Split('"')[1].Trim();
            vtstr = Regex.Split(str, "更新时间:")[1].Split('<')[0].Trim();
            rstr  = Regex.Split(str, @"<p class=""rank_num"">")[1].Split('<')[0].Trim();
            pstr  = Regex.Split(str, @"<p class=""apk_rank_p1"">")[1].Split('<')[0].Trim();

            //Download URI
            ddstr = Regex.Split(Regex.Split(Regex.Split(str, "function onDownloadApk")[1], "window.location.href")[1], @"""")[1];

            AppIconImage.Source = new BitmapImage(new Uri(iurl, UriKind.RelativeOrAbsolute));
            AppTitleText.Text   = nstr;
            AppVTText.Text      = vtstr;
            AppV2Text.Text      = vstr;
            AppVText.Text       = vstr;
            AppMText.Text       = Regex.Split(mstr, "/")[2] + " " + Regex.Split(mstr, "/")[3] + " " + rstr + "分";
            AppXText.Text       = Regex.Split(mstr, "/")[1] + " · " + Regex.Split(mstr, "/")[0];

            if (Regex.Split(str, @"<p class=""apk_left_title_info"">").Length > 3)
            {
                //当应用有点评
                AppVMText.Text    = vmstr;
                AppDText.Text     = dstr;
                DPanel.Visibility = Visibility.Visible;
            }
            else
            {
                //当应用无点评的时候(小编要是一个一个全好好点评我就不用加判断了嘛!)
                AppVMText.Text = dstr;
                AppDText.Text  = "";
            }
            if (dstr.Contains("更新时间") && dstr.Contains("ROM") && dstr.Contains("名称"))
            {
                UPanel.Visibility = Visibility.Collapsed;
            }


            //加载截图!
            String images = Regex.Split(Regex.Split(str, @"<div class=""ex-screenshot-thumb-carousel"">")[1], "</div>")[0];

            String[] imagearray = Regex.Split(images, "<img");
            for (int i = 0; i < imagearray.Length - 1; i++)
            {
                String imageUrl = imagearray[i + 1].Split('"')[1];
                if (!imageUrl.Equals(""))
                {
                    Image newImage = new Image
                    {
                        Height = 100,
                        //获得图片
                        Source = new BitmapImage(new Uri(imageUrl, UriKind.RelativeOrAbsolute))
                    };
                    //添加到缩略视图
                    ScreenShotView.Items.Add(newImage);
                }
            }
            images     = Regex.Split(Regex.Split(str, @"<div class=""carousel-inner"">")[1], @"<a class=""left carousel-control""")[0];
            imagearray = Regex.Split(images, "<img");
            for (int i = 0; i < imagearray.Length - 1; i++)
            {
                String imageurl = imagearray[i + 1].Split('"')[1];
                Image  newImage = new Image
                {
                    //获得图片
                    Source = new BitmapImage(new Uri(imageurl, UriKind.RelativeOrAbsolute))
                };
                //添加到视图
                ScreenShotFlipView.Items.Add(newImage);
            }

            //还有简介(丧心病狂啊)
            AppJText.Text = jstr;

            //评分。。
            AppRText.Text = rstr;
            AppPText.Text = pstr;
            //星星
            double rdob = Double.Parse(rstr);

            if (rdob > 4.5)
            {
            }
            else if (rdob > 3.0)
            {
                star5.Symbol = Symbol.OutlineStar;
            }
            else if (rdob > 4.0)
            {
                star4.Symbol = Symbol.OutlineStar;
                star5.Symbol = Symbol.OutlineStar;
            }
            else if (rdob > 3.0)
            {
                star3.Symbol = Symbol.OutlineStar;
                star4.Symbol = Symbol.OutlineStar;
                star5.Symbol = Symbol.OutlineStar;
            }
            else if (rdob < 2.0)
            {
                //没有评分那么差的应用吧233
                star2.Symbol = Symbol.OutlineStar;
                star3.Symbol = Symbol.OutlineStar;
                star4.Symbol = Symbol.OutlineStar;
                star5.Symbol = Symbol.OutlineStar;
            }


            //获取开发者
            String knstr = Web.ReplaceHtml(Regex.Split(Regex.Split(str, "开发者名称:")[1], "</p>")[0]);

            try
            {
                AppKNText.Text   = knstr;
                AppKImage.Source = new BitmapImage(new Uri(await CoolApkSDK.GetCoolApkUserFaceUri(knstr), UriKind.RelativeOrAbsolute));
            }
            catch (Exception)
            {
                KPanel.Visibility = Visibility.Collapsed;
            }
        }
Пример #9
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     mainPage.Frame.Navigate(typeof(UserPage), new object[] { await CoolApkSDK.GetUserIDByName(uid.Text), mainPage });
 }
Пример #10
0
 private async void Button_Click_5(object sender, RoutedEventArgs e)
 {
     txb1.Text = await CoolApkSDK.GetCoolApkMessage(url.Text);
 }
Пример #11
0
        private async void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Pivot pivot = MainPivot;

            if (pivot.Items.Count == 1 && (pivot.Items[0] as PivotItem).Tag as string == "-1")
            {
                pivot.Items.Clear();
                string r = await CoolApkSDK.GetCoolApkMessage("/main/init");

                JArray array = JObject.Parse(r)["data"] as JArray;
                foreach (var item in array)
                {
                    if (item["entityTemplate"].ToString() == "configCard")
                    {
                        JArray jArray = item["entities"] as JArray;
                        foreach (var it in jArray)
                        {
                            switch (it["title"].ToString())
                            {
                            case "酷品":
                            case "看看号":
                            case "直播": continue;

                            default:
                                break;
                            }
                            PivotItem i = new PivotItem
                            {
                                Header  = it["title"].ToString(),
                                Tag     = it["title"].ToString() == "头条" ? string.Empty : it["url"].ToString() + "&title=" + it["title"].ToString(),
                                Content = new Frame()
                            };
                            if (it["title"].ToString() == "关注")
                            {
                                Button button = new Button {
                                    Content = new TextBlock {
                                        Text = "▼"
                                    }, Background = null, Name = "moreB"
                                };
                                MenuFlyout flyout = new MenuFlyout();
                                foreach (var ite in it["entities"])
                                {
                                    if (ite["entityType"].ToString() == "page")
                                    {
                                        MenuFlyoutItem menuFlyoutItem = new MenuFlyoutItem {
                                            Text = ite["title"].ToString(), Tag = ite["url"].ToString() + "&title=" + ite["title"].ToString()
                                        };
                                        menuFlyoutItem.Tapped += (s, _) =>
                                        {
                                            MenuFlyoutItem fI        = s as MenuFlyoutItem;
                                            TextBlock      textBlock = FindName("TitleTextBlock") as TextBlock;
                                            textBlock.Text = fI.Text;
                                            foreach (MenuFlyoutItem j in ((FindName("moreB") as Button).Flyout as MenuFlyout).Items)
                                            {
                                                j.Icon = null;
                                            }
                                            fI.Icon = new SymbolIcon(Symbol.Accept);
                                            string pageUrl = fI.Tag as string;
                                            if (pageUrl.IndexOf("/page") == -1)
                                            {
                                                pageUrl = "/page/dataList?url=" + pageUrl;
                                            }
                                            else if (pageUrl.IndexOf("/page") == 0 && !pageUrl.Contains("/page/dataList"))
                                            {
                                                pageUrl = pageUrl.Replace("/page", "/page/dataList");
                                            }
                                            pageUrl = pageUrl.Replace("#", "%23");
                                            PivotItem p    = MainPivot.SelectedItem as PivotItem;
                                            Frame     f    = p.Content as Frame;
                                            IndexPage page = f.Content as IndexPage;
                                            page.ChangeTabView(pageUrl);
                                        };
                                        flyout.Items.Add(menuFlyoutItem);
                                    }
                                }
                                MenuFlyoutItem flyoutItem = flyout.Items[0] as MenuFlyoutItem;
                                flyoutItem.Icon = new SymbolIcon(Symbol.Accept);
                                button.Flyout   = flyout;
                                StackPanel stackPanel = new StackPanel {
                                    Orientation = Orientation.Horizontal
                                };
                                stackPanel.Children.Add(new TextBlock {
                                    Text = flyoutItem.Text, Name = "TitleTextBlock"
                                });
                                stackPanel.Children.Add(button);
                                i.Header = stackPanel;
                                i.Name   = "FollowPivot";
                            }
                            pivot.Items.Add(i);
                        }
                        pivot.SelectedIndex = 1;
                    }
                }
            }
            PivotItem pivotItem = e.AddedItems[0] as PivotItem;
            Frame     frame     = pivotItem.Content as Frame;

            if (!(frame is null) && !frame.CanGoBack)
            {
                frame.Navigate(typeof(IndexPage), new object[] { mainPage, pivotItem.Tag, true });
            }
        }