summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2013-04-01 12:05:02 +0400
committerGravatar Vitaly Takmazov2013-04-01 12:05:02 +0400
commit0623943dccad5c44831b2ad4a803eab2436e45e6 (patch)
treedf9ea217f9dbfef53a82b4a7e7fc98117d1c11b3
parent4c92def17fef70c35e578ffb2c5e6acde3b9247d (diff)
Using WPToolkit LongListSelector
-rw-r--r--Juick/App.xaml.cs4
-rw-r--r--Juick/Classes/DelegateCommand.cs6
-rw-r--r--Juick/Classes/InvokeDelegateCommandAction.cs151
-rw-r--r--Juick/Classes/LowProfileImageLoader.cs4
-rw-r--r--Juick/Classes/ScrollViewerMonitor.cs64
-rw-r--r--Juick/Controls/MessageList.xaml78
-rw-r--r--Juick/Juick.csproj14
-rw-r--r--Juick/MainPage.xaml.cs9
-rw-r--r--Juick/ThreadView.xaml.cs2
-rw-r--r--Juick/Toolkit.Content/ApplicationBar.Cancel.pngbin0 -> 350 bytes
-rw-r--r--Juick/Toolkit.Content/ApplicationBar.Check.pngbin0 -> 414 bytes
-rw-r--r--Juick/Toolkit.Content/ApplicationBar.Delete.pngbin0 -> 445 bytes
-rw-r--r--Juick/Toolkit.Content/ApplicationBar.Select.pngbin0 -> 863 bytes
-rw-r--r--Juick/ViewModels/ViewModelBase.cs40
-rw-r--r--Juick/packages.config1
15 files changed, 258 insertions, 115 deletions
diff --git a/Juick/App.xaml.cs b/Juick/App.xaml.cs
index 194e6fe..e20feec 100644
--- a/Juick/App.xaml.cs
+++ b/Juick/App.xaml.cs
@@ -11,6 +11,10 @@ namespace Juick
{
public partial class App : Application
{
+ public void NavigateTo(Uri param) {
+ var current = ((App)App.Current).RootFrame;
+ current.Navigate(param);
+ }
private static ViewModelBase _myfeed = null;
/// <summary>
diff --git a/Juick/Classes/DelegateCommand.cs b/Juick/Classes/DelegateCommand.cs
index cc7adcd..40256e5 100644
--- a/Juick/Classes/DelegateCommand.cs
+++ b/Juick/Classes/DelegateCommand.cs
@@ -5,10 +5,10 @@ namespace Juick.Classes
{
public class DelegateCommand : ICommand
{
- readonly Action action;
+ readonly Action<object> action;
readonly Func<bool> canExecute;
- public DelegateCommand(Action execute, Func<bool> canExecute)
+ public DelegateCommand(Action<object> execute, Func<bool> canExecute)
{
this.action = execute;
this.canExecute = canExecute;
@@ -23,7 +23,7 @@ namespace Juick.Classes
public void Execute(object parameter)
{
- action();
+ action(parameter);
}
public void NotifyCanExecuteChanged()
diff --git a/Juick/Classes/InvokeDelegateCommandAction.cs b/Juick/Classes/InvokeDelegateCommandAction.cs
new file mode 100644
index 0000000..24861cf
--- /dev/null
+++ b/Juick/Classes/InvokeDelegateCommandAction.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.Windows.Interactivity;
+using System.Reflection;
+using System.Linq;
+
+namespace Juick.Classes
+{
+ public sealed class InvokeDelegateCommandAction : TriggerAction<DependencyObject>
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ public static readonly DependencyProperty CommandParameterProperty =
+ DependencyProperty.Register("CommandParameter", typeof(object), typeof(InvokeDelegateCommandAction), null);
+
+ /// <summary>
+ ///
+ /// </summary>
+ public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
+ "Command", typeof(ICommand), typeof(InvokeDelegateCommandAction), null);
+
+ /// <summary>
+ ///
+ /// </summary>
+ public static readonly DependencyProperty InvokeParameterProperty = DependencyProperty.Register(
+ "InvokeParameter", typeof(object), typeof(InvokeDelegateCommandAction), null);
+
+ private string commandName;
+
+ /// <summary>
+ ///
+ /// </summary>
+ public object InvokeParameter
+ {
+ get
+ {
+ return this.GetValue(InvokeParameterProperty);
+ }
+ set
+ {
+ this.SetValue(InvokeParameterProperty, value);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public ICommand Command
+ {
+ get
+ {
+ return (ICommand)this.GetValue(CommandProperty);
+ }
+ set
+ {
+ this.SetValue(CommandProperty, value);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public string CommandName
+ {
+ get
+ {
+ return this.commandName;
+ }
+ set
+ {
+ if (this.CommandName != value)
+ {
+ this.commandName = value;
+ }
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public object CommandParameter
+ {
+ get
+ {
+ return this.GetValue(CommandParameterProperty);
+ }
+ set
+ {
+ this.SetValue(CommandParameterProperty, value);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="parameter"></param>
+ protected override void Invoke(object parameter)
+ {
+ this.InvokeParameter = parameter;
+
+ if (this.AssociatedObject != null)
+ {
+ ICommand command = this.ResolveCommand();
+ if ((command != null) && command.CanExecute(this.CommandParameter))
+ {
+ command.Execute(this.CommandParameter);
+ }
+ }
+ }
+
+ private ICommand ResolveCommand()
+ {
+ ICommand command = null;
+ if (this.Command != null)
+ {
+ return this.Command;
+ }
+ var frameworkElement = this.AssociatedObject as FrameworkElement;
+ if (frameworkElement != null)
+ {
+ object dataContext = frameworkElement.DataContext;
+ if (dataContext != null)
+ {
+ PropertyInfo commandPropertyInfo = dataContext
+ .GetType()
+ .GetProperties(BindingFlags.Public | BindingFlags.Instance)
+ .FirstOrDefault(
+ p =>
+ typeof(ICommand).IsAssignableFrom(p.PropertyType) &&
+ string.Equals(p.Name, this.CommandName, StringComparison.Ordinal)
+ );
+
+ if (commandPropertyInfo != null)
+ {
+ command = (ICommand)commandPropertyInfo.GetValue(dataContext, null);
+ }
+ }
+ }
+ return command;
+ }
+ }
+}
diff --git a/Juick/Classes/LowProfileImageLoader.cs b/Juick/Classes/LowProfileImageLoader.cs
index d1eb3da..a69c386 100644
--- a/Juick/Classes/LowProfileImageLoader.cs
+++ b/Juick/Classes/LowProfileImageLoader.cs
@@ -51,7 +51,7 @@ namespace Juick.Classes
[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "UriSource is applicable only to Image elements.")]
public static void SetUriSource(Image obj, Uri value)
{
- if (null == obj)
+ if (null == obj || null == value)
{
throw new ArgumentNullException("obj");
}
@@ -146,6 +146,8 @@ namespace Juick.Classes
pendingRequests[index] = pendingRequests[count - 1];
pendingRequests.RemoveAt(count - 1);
count--;
+ if (pendingRequest.Uri == null)
+ continue;
if (pendingRequest.Uri.IsAbsoluteUri)
{
// Download from network
diff --git a/Juick/Classes/ScrollViewerMonitor.cs b/Juick/Classes/ScrollViewerMonitor.cs
deleted file mode 100644
index 4e96797..0000000
--- a/Juick/Classes/ScrollViewerMonitor.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Input;
-using System.Windows.Media;
-
-namespace Juick.Classes
-{
- public class ScrollViewerMonitor
- {
- public static DependencyProperty AtEndCommandProperty =
- DependencyProperty.RegisterAttached("AtEndCommand", typeof(ICommand), typeof(ScrollViewerMonitor), new PropertyMetadata(OnAtEndCommandChanged));
-
- public static ICommand GetAtEndCommand(DependencyObject obj)
- {
- return (ICommand)obj.GetValue(AtEndCommandProperty);
- }
-
- public static void SetAtEndCommand(DependencyObject obj, ICommand value)
- {
- obj.SetValue(AtEndCommandProperty, value);
- }
-
- public static void OnAtEndCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var element = (FrameworkElement)d;
- if (element != null)
- {
- element.Loaded -= element_Loaded;
- element.Loaded += element_Loaded;
- }
- }
-
- static void element_Loaded(object sender, RoutedEventArgs e)
- {
- var element = (FrameworkElement)sender;
- element.Loaded -= element_Loaded;
- var scrollViewer = (ScrollViewer)element.Parent;
- if (scrollViewer == null)
- {
- throw new InvalidOperationException("ScrollViewer not found.");
- }
-
- var listener = new DependencyPropertyListener();
- listener.Changed += (s, eArgs) =>
- {
- var atBottom = scrollViewer.VerticalOffset >= scrollViewer.ScrollableHeight - scrollViewer.ScrollableHeight/3;
- if (atBottom)
- {
- var atEnd = GetAtEndCommand(element);
- if (atEnd != null && atEnd.CanExecute(null))
- {
- atEnd.Execute(null);
- }
- }
- };
- var binding = new Binding("VerticalOffset") { Source = scrollViewer };
- listener.Attach(scrollViewer, binding);
- }
- }
-}
diff --git a/Juick/Controls/MessageList.xaml b/Juick/Controls/MessageList.xaml
index 7a5882f..96cd81b 100644
--- a/Juick/Controls/MessageList.xaml
+++ b/Juick/Controls/MessageList.xaml
@@ -5,8 +5,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bindings="clr-namespace:Juick.Classes"
xmlns:usercontrols="clr-namespace:Juick.Controls"
- xmlns:converters="clr-namespace:Juick.Converters"
+ xmlns:converters="clr-namespace:Juick.Converters"
+ xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
+ xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
@@ -16,55 +18,57 @@
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
- <ScrollViewer>
- <ItemsControl Margin="0, 0, -12, 0"
- ItemsSource="{Binding Items}"
- bindings:ScrollViewerMonitor.AtEndCommand="{Binding LoadMessagesPageCommand}">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <HyperlinkButton NavigateUri="{Binding MID, Converter={StaticResource uriConverter}}">
- <HyperlinkButton.Template>
- <ControlTemplate>
- <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0 0 0 1">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Image bindings:LowProfileImageLoader.UriSource="{Binding AvatarUri}" Grid.Row="0" Grid.Column="0" Margin="3" />
- <TextBlock Text="{Binding Username}" Grid.Row="0" Grid.Column="1"
+ <toolkit:LongListSelector x:Name="longList" Margin="0, 0, -12, 0"
+ ItemsSource="{Binding Items}" IsFlatList="true">
+ <i:Interaction.Triggers>
+ <i:EventTrigger EventName="Link">
+ <bindings:InvokeDelegateCommandAction Command="{Binding LoadMessagesPageCommand}"
+ CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}"/>
+ </i:EventTrigger>
+ <i:EventTrigger EventName="SelectionChanged">
+ <bindings:InvokeDelegateCommandAction Command="{Binding NavigateNextCommand}"
+ CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}"/>
+ </i:EventTrigger>
+ </i:Interaction.Triggers>
+ <toolkit:LongListSelector.ItemTemplate>
+ <DataTemplate>
+ <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0 0 0 1">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+ <Image bindings:LowProfileImageLoader.UriSource="{Binding AvatarUri}" Grid.Row="0" Grid.Column="0" Margin="3" />
+ <TextBlock Text="{Binding Username}" Grid.Row="0" Grid.Column="1"
Margin="5,0,5,5" VerticalAlignment="Top"
HorizontalAlignment="Left"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"
FontSize="{StaticResource PhoneFontSizeLarge}"
Style="{StaticResource PhoneTextAccentStyle}" />
- <!--Style="{StaticResource PhoneTextNormalStyle}"-->
- <usercontrols:HyperLinkRichTextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
+ <!--Style="{StaticResource PhoneTextNormalStyle}"-->
+ <usercontrols:HyperLinkRichTextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
TextWrapping="Wrap" HorizontalAlignment="Left"
Foreground="{StaticResource PhoneForegroundBrush}"
Margin="5,0,5,5" VerticalAlignment="Top"
IsReadOnly="True" Text="{Binding MessageText}" />
- <Image bindings:LowProfileImageLoader.UriSource="{Binding Attachment}" Grid.Row="2" Grid.Column="0" Margin="3" Grid.ColumnSpan="2" />
- <TextBlock Text="{Binding Status}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
+ <Image bindings:LowProfileImageLoader.UriSource="{Binding Attachment}" Grid.Row="2" Grid.Column="0" Margin="3" Grid.ColumnSpan="2" />
+ <TextBlock Text="{Binding Status}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
Foreground="{StaticResource PhoneForegroundBrush}"
Style="{StaticResource PhoneTextAccentStyle}"
FontSize="{StaticResource PhoneFontSizeSmall}"
Margin="5,0,5,5" VerticalAlignment="Top"
TextWrapping="Wrap" HorizontalAlignment="Left"/>
- </Grid>
- </Border>
- </ControlTemplate>
- </HyperlinkButton.Template>
- </HyperlinkButton>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
+ </Grid>
+ </Border>
+
+ </DataTemplate>
+ </toolkit:LongListSelector.ItemTemplate>
+ </toolkit:LongListSelector>
</Grid>
</UserControl>
diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj
index 8e47876..173aef8 100644
--- a/Juick/Juick.csproj
+++ b/Juick/Juick.csproj
@@ -25,6 +25,8 @@
<SilverlightAppEntry>Juick.App</SilverlightAppEntry>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -51,6 +53,9 @@
<ItemGroup>
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Controls" />
+ <Reference Include="Microsoft.Phone.Controls.Toolkit">
+ <HintPath>..\packages\WPtoolkit.4.2012.10.30\lib\sl4-windowsphone71\Microsoft.Phone.Controls.Toolkit.dll</HintPath>
+ </Reference>
<Reference Include="Microsoft.Phone.Interop" />
<Reference Include="Microsoft.Xna.Framework" />
<Reference Include="RestSharp.WindowsPhone, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -62,6 +67,7 @@
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
+ <Reference Include="System.Windows.Interactivity, Version=3.8.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml" />
<Reference Include="mscorlib.extensions" />
<Reference Include="System.Xml.Serialization" />
@@ -80,8 +86,8 @@
<Compile Include="Classes\DelegateCommand.cs" />
<Compile Include="Classes\DependencyPropertyListener.cs" />
<Compile Include="Classes\ExpressionHelper.cs" />
+ <Compile Include="Classes\InvokeDelegateCommandAction.cs" />
<Compile Include="Classes\LowProfileImageLoader.cs" />
- <Compile Include="Classes\ScrollViewerMonitor.cs" />
<Compile Include="Classes\TileHelper.cs" />
<Compile Include="Controls\HyperLinkRichTextBox.cs" />
<Compile Include="Controls\MessageList.xaml.cs">
@@ -142,6 +148,10 @@
<Content Include="ApplicationIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Resource Include="Toolkit.Content\ApplicationBar.Cancel.png" />
+ <Resource Include="Toolkit.Content\ApplicationBar.Check.png" />
+ <Resource Include="Toolkit.Content\ApplicationBar.Delete.png" />
+ <Resource Include="Toolkit.Content\ApplicationBar.Select.png" />
<Resource Include="Images\appbar.add.rest.png" />
<Resource Include="Images\appbar.back.rest.png" />
<Resource Include="Images\appbar.basecircle.rest.png" />
@@ -179,6 +189,7 @@
<Resource Include="Images\appbar.transport.rew.rest.png" />
<Resource Include="Images\appbar.upload.rest.png" />
<Content Include="Images\appbar.send.png" />
+ <Content Include="README_FIRST.txt" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
@@ -191,4 +202,5 @@
</Target>
-->
<ProjectExtensions />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project> \ No newline at end of file
diff --git a/Juick/MainPage.xaml.cs b/Juick/MainPage.xaml.cs
index d6b0b08..503c023 100644
--- a/Juick/MainPage.xaml.cs
+++ b/Juick/MainPage.xaml.cs
@@ -110,6 +110,11 @@ namespace Juick
{
NavigationService.Navigate(new Uri(navigateUri, UriKind.Relative));
}
+ else
+ {
+ ((ViewModels.ViewModelBase)Home.DataContext).LoadData(null);
+ ((ViewModels.ViewModelBase)Last.DataContext).LoadData(null);
+ }
}
void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
@@ -163,8 +168,8 @@ namespace Juick
{
App.MyFeedView.Items.Clear();
App.LastView.Items.Clear();
- App.MyFeedView.LoadData();
- App.LastView.LoadData();
+ App.MyFeedView.LoadData(null);
+ App.LastView.LoadData(null);
}
private void ApplicationBarMenuItemClick(object sender, EventArgs e)
diff --git a/Juick/ThreadView.xaml.cs b/Juick/ThreadView.xaml.cs
index d17f8f5..be6db02 100644
--- a/Juick/ThreadView.xaml.cs
+++ b/Juick/ThreadView.xaml.cs
@@ -27,7 +27,7 @@ namespace Juick
if (NavigationContext.QueryString.TryGetValue("mid", out _mid))
{
Model.Mid = int.Parse(_mid);
- Model.LoadData();
+ Model.LoadData(null);
}
}
diff --git a/Juick/Toolkit.Content/ApplicationBar.Cancel.png b/Juick/Toolkit.Content/ApplicationBar.Cancel.png
new file mode 100644
index 0000000..4dd724f
--- /dev/null
+++ b/Juick/Toolkit.Content/ApplicationBar.Cancel.png
Binary files differ
diff --git a/Juick/Toolkit.Content/ApplicationBar.Check.png b/Juick/Toolkit.Content/ApplicationBar.Check.png
new file mode 100644
index 0000000..7a07466
--- /dev/null
+++ b/Juick/Toolkit.Content/ApplicationBar.Check.png
Binary files differ
diff --git a/Juick/Toolkit.Content/ApplicationBar.Delete.png b/Juick/Toolkit.Content/ApplicationBar.Delete.png
new file mode 100644
index 0000000..95bb16d
--- /dev/null
+++ b/Juick/Toolkit.Content/ApplicationBar.Delete.png
Binary files differ
diff --git a/Juick/Toolkit.Content/ApplicationBar.Select.png b/Juick/Toolkit.Content/ApplicationBar.Select.png
new file mode 100644
index 0000000..995deaa
--- /dev/null
+++ b/Juick/Toolkit.Content/ApplicationBar.Select.png
Binary files differ
diff --git a/Juick/ViewModels/ViewModelBase.cs b/Juick/ViewModels/ViewModelBase.cs
index 2427a80..80d3d8b 100644
--- a/Juick/ViewModels/ViewModelBase.cs
+++ b/Juick/ViewModels/ViewModelBase.cs
@@ -9,6 +9,10 @@ using System.Windows.Media.Imaging;
using Juick.Classes;
using JuickApi;
using RestSharp;
+using System.Diagnostics;
+using System.Windows.Navigation;
+using Microsoft.Phone.Controls;
+using System.Windows.Controls;
namespace Juick.ViewModels
{
@@ -21,11 +25,14 @@ namespace Juick.ViewModels
{
Items = new ObservableCollection<PostItem>();
LoadMessagesPageCommand = new DelegateCommand(LoadData, () => !IsDataLoading);
+ NavigateNextCommand = new DelegateCommand(NavigateToThread, () => true);
}
public string RestUri { get; set; }
public virtual string Caption { get { return "juick"; } }
+ public string SelectedId { get; set; }
+
/// <summary>
/// A collection for MessageViewModel objects.
/// </summary>
@@ -33,6 +40,8 @@ namespace Juick.ViewModels
public DelegateCommand LoadMessagesPageCommand { get; private set; }
+ public DelegateCommand NavigateNextCommand { get; private set; }
+
public bool IsDataLoading
{
get { return isDataLoading; }
@@ -44,16 +53,36 @@ namespace Juick.ViewModels
}
}
+ public void NavigateToThread(object param)
+ {
+ var selectionChangedEventArgs = param as SelectionChangedEventArgs;
+ if (param != null)
+ {
+ ((App)App.Current).NavigateTo(new Uri(string.Format("/ThreadView.xaml?mid={0}", ((PostItem)selectionChangedEventArgs.AddedItems[0]).MID), UriKind.Relative));
+ }
+
+ }
+
/// <summary>
/// Creates and adds a few MessageViewModel objects into the Items collection.
/// </summary>
- public void LoadData()
+ public void LoadData(object EventArgs)
{
- if (IsDataLoading) {
+ const int offset = 5;
+ if (IsDataLoading)
+ {
return;
}
+ if (EventArgs != null)
+ {
+ var item = (EventArgs as LinkUnlinkEventArgs).ContentPresenter.Content;
+ if (!item.Equals(Items[Items.Count - offset])) {
+ return;
+ }
+ }
- const int PageSize = 1;
+ int count = Items.Count;
+
if (string.IsNullOrEmpty(RestUri))
{
@@ -65,12 +94,12 @@ namespace Juick.ViewModels
else if (RestUri.StartsWith("/home?", StringComparison.InvariantCulture) && Items.Count > 0)
{
var lastItem = Items[Items.Count - 1];
- RestUri = string.Format("/home?before_mid={0}&page={1}", lastItem.MID, PageSize);
+ RestUri = string.Format("/home?before_mid={0}", lastItem.MID);
}
else if (RestUri.StartsWith("/messages?", StringComparison.InvariantCulture) && Items.Count > 0)
{
var lastItem = Items[Items.Count - 1];
- RestUri = string.Format("/messages?before_mid={0}&page={1}", lastItem.MID, PageSize);
+ RestUri = string.Format("/messages?before_mid={0}", lastItem.MID);
}
var request = new RestRequest(RestUri + "&rnd=" + Environment.TickCount);
@@ -90,7 +119,6 @@ namespace Juick.ViewModels
//Items.Clear();
response.Data.Select(x => new PostItem(x)).ToList().ForEach(i => Items.Add(i));
-
}
diff --git a/Juick/packages.config b/Juick/packages.config
index 051648d..73aeefe 100644
--- a/Juick/packages.config
+++ b/Juick/packages.config
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="104.1" targetFramework="sl40-wp71" />
+ <package id="WPtoolkit" version="4.2012.10.30" targetFramework="sl40-wp71" />
</packages> \ No newline at end of file