Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #1

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Created TMDb Service
Felipe Gonçalves committed May 12, 2019
commit 470a9b7d4fc54b8368100e1517ac4f9066a32252
25 changes: 25 additions & 0 deletions ArcMovies.sln
Original file line number Diff line number Diff line change
@@ -8,6 +8,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArcMovies.iOS", "ArcMovies.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArcMovies", "ArcMovies\ArcMovies.csproj", "{06638CEF-F2B1-44A2-9054-329465D4BE57}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HTTPClient", "HTTPClient", "{8E12E930-58D9-4511-9F31-8430CE27D71A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient", "HttpClient\HttpClient.csproj", "{66246690-59F8-4453-85A3-DC5366407867}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -77,6 +81,24 @@ Global
{06638CEF-F2B1-44A2-9054-329465D4BE57}.Release|iPhone.Build.0 = Release|Any CPU
{06638CEF-F2B1-44A2-9054-329465D4BE57}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{06638CEF-F2B1-44A2-9054-329465D4BE57}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Debug|iPhone.Build.0 = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Gorilla|Any CPU.ActiveCfg = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Gorilla|Any CPU.Build.0 = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Gorilla|iPhone.ActiveCfg = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Gorilla|iPhone.Build.0 = Debug|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Gorilla|iPhoneSimulator.ActiveCfg = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Gorilla|iPhoneSimulator.Build.0 = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Release|Any CPU.Build.0 = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Release|iPhone.ActiveCfg = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Release|iPhone.Build.0 = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{66246690-59F8-4453-85A3-DC5366407867}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -89,4 +111,7 @@ Global
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{66246690-59F8-4453-85A3-DC5366407867} = {8E12E930-58D9-4511-9F31-8430CE27D71A}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions ArcMovies/ArcMovies.csproj
Original file line number Diff line number Diff line change
@@ -27,12 +27,15 @@
<PackageReference Include="UXDivers.GorillaPlayer.Common" Version="0.9.1.2" />
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.9.961" />
<PackageReference Include="CarouselView.FormsPlugin" Version="5.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
<Folder Include="ExtendedControl\" />
<Folder Include="Converter\" />
<Folder Include="Helper\" />
<Folder Include="Service\" />
<Folder Include="Service\Abstraction\" />
<Folder Include="Service\Implementation\" />
</ItemGroup>
<ItemGroup>
@@ -48,4 +51,10 @@
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Remove="ArcMovies.csproj.orig" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HttpClient\HttpClient.csproj" />
</ItemGroup>
</Project>
61 changes: 61 additions & 0 deletions ArcMovies/ArcMovies.csproj.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ProduceAssemblyReference>true</ProduceAssemblyReference>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Gorilla|AnyCPU' ">
<DebugType></DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Gorilla</OutputPath>
<DefineConstants></DefineConstants>
<WarningLevel>4</WarningLevel>
<IntermediateOutputPath>obj\Gorilla</IntermediateOutputPath>
<NoWarn></NoWarn>
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.6.0.264807" />
<PackageReference Include="Xamarin.Essentials" Version="1.0.1" />
<PackageReference Include="UXDivers.GorillaPlayer.SDK" Version="1.5.0" />
<PackageReference Include="UXDivers.GorillaPlayer.Common" Version="0.9.1.2" />
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.9.961" />
<PackageReference Include="CarouselView.FormsPlugin" Version="5.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
<Folder Include="ExtendedControl\" />
<Folder Include="Converter\" />
<Folder Include="Helper\" />
<<<<<<< Updated upstream
=======
<Folder Include="Service\" />
<Folder Include="Service\Abstraction\" />
>>>>>>> Stashed changes
<Folder Include="Service\Implementation\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="View\Template\MovieItemTemplate %28copy%29.xaml.cs" />
</ItemGroup>
<ItemGroup>
<<<<<<< Updated upstream
<Compile Update="View\Template\DetailBannerTemplate.xaml.cs">
<DependentUpon>DetailBannerTemplate.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="View\DetailPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
=======
<ProjectReference Include="..\HttpClient\HttpClient.csproj" />
>>>>>>> Stashed changes
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions ArcMovies/Helper/AppConst.cs
Original file line number Diff line number Diff line change
@@ -5,5 +5,6 @@ public static class AppConst
{
public static readonly string TMDbRootURL = "https://api.themoviedb.org/";
public static readonly string TMDbRootImageURL = "https://image.tmdb.org/t/p/";
public static readonly string TMDbApiKey = "1f54bd990f1cdfb230adb312546d765d";
}
}
14 changes: 14 additions & 0 deletions ArcMovies/Model/Cast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace ArcMovies.Model
{
public class Cast
{
public int cast_id { get; set; }
public string character { get; set; }
public string credit_id { get; set; }
public int gender { get; set; }
public int id { get; set; }
public string name { get; set; }
public int order { get; set; }
public string profile_path { get; set; }
}
}
6 changes: 6 additions & 0 deletions ArcMovies/Model/Credits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ArcMovies.Model
{
public class Credits
{
}
}
6 changes: 6 additions & 0 deletions ArcMovies/Model/Crew.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ArcMovies.Model
{
public class Crew
{
}
}
6 changes: 6 additions & 0 deletions ArcMovies/Model/Dates.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ArcMovies.Model
{
public class Dates
{
}
}
6 changes: 6 additions & 0 deletions ArcMovies/Model/Genre.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ArcMovies.Model
{
public class Genre
{
}
}
34 changes: 33 additions & 1 deletion ArcMovies/Model/Movie.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
using System;
using System.Collections.Generic;

namespace ArcMovies.Model
{
public class Movie
{
{
public bool adult { get; set; }
public string backdrop_path { get; set; }
public object belongs_to_collection { get; set; }
public int budget { get; set; }
public List<Genre> genres { get; set; }
public string homepage { get; set; }
public int id { get; set; }
public string imdb_id { get; set; }
public string original_language { get; set; }
public string original_title { get; set; }
public string overview { get; set; }
public double popularity { get; set; }
public string poster_path { get; set; }
public List<ProductionCompany> production_companies { get; set; }
public List<ProductionCountry> production_countries { get; set; }
public string release_date { get; set; }
public int revenue { get; set; }
public int runtime { get; set; }
public List<SpokenLanguage> spoken_languages { get; set; }
public string status { get; set; }
public string tagline { get; set; }
public string title { get; set; }
public bool video { get; set; }
public double vote_average { get; set; }
public int vote_count { get; set; }
public Credits credits { get; set; }
public Videos videos { get; set; }
public List<int> genre_ids { get; set; }


}
}
10 changes: 10 additions & 0 deletions ArcMovies/Model/ProductionCompany.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ArcMovies.Model
{
public class ProductionCompany
{
public int id { get; set; }
public string logo_path { get; set; }
public string name { get; set; }
public string origin_country { get; set; }
}
}
6 changes: 6 additions & 0 deletions ArcMovies/Model/ProductionCountry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ArcMovies.Model
{
public class ProductionCountry
{
}
}
14 changes: 14 additions & 0 deletions ArcMovies/Model/Result.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace ArcMovies.Model
{
public class Result
{
public string id { get; set; }
public string iso_639_1 { get; set; }
public string iso_3166_1 { get; set; }
public string key { get; set; }
public string name { get; set; }
public string site { get; set; }
public int size { get; set; }
public string type { get; set; }
}
}
10 changes: 6 additions & 4 deletions ArcMovies/Model/Section.cs
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@ namespace ArcMovies.Model
{
public class Section
{
public int Page { get; set; }
public int Total_Results { get; set; }
public int Total_Pages { get; set; }
public List<Movie> Results { get; set; }
public int page { get; set; }
public int total_results { get; set; }
public int total_pages { get; set; }
public List<Movie> results { get; set; }
public Dates dates { get; set; }

}
}
8 changes: 8 additions & 0 deletions ArcMovies/Model/SpokenLanguage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace ArcMovies.Model
{
public class SpokenLanguage
{
public string iso_639_1 { get; set; }
public string name { get; set; }
}
}
6 changes: 6 additions & 0 deletions ArcMovies/Model/Videos.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ArcMovies.Model
{
public class Videos
{
}
}
10 changes: 10 additions & 0 deletions ArcMovies/Service/Abstraction/ITMDbConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Threading.Tasks;

namespace ArcMovies.Service.Abstraction
{
public interface ITMDbConfig
{
string Build();
}
}
13 changes: 13 additions & 0 deletions ArcMovies/Service/Abstraction/ITMDbService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ArcMovies.Model;

namespace ArcMovies.Service.Abstraction
{
public interface ITMDbService
{
Task<Section> GetSection(ITMDbConfig config);
Task<Movie> GetMovieDetail(ITMDbConfig config);
}
}
49 changes: 49 additions & 0 deletions ArcMovies/Service/Implementation/TMDbConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using ArcMovies.Service.Abstraction;

namespace ArcMovies.Service.Implementation
{
public abstract class TMDbConfig : ITMDbConfig
{
private string _path = "";

protected string _action = "";

protected List<string> _lstAppend;

public TMDbConfig(string path)
{
this._path = path;
this._lstAppend = new List<string>();
}

public virtual string Build()
{
if (string.IsNullOrWhiteSpace(_path))
{
throw new NotImplementedException("No config set.");
}

if (string.IsNullOrWhiteSpace(_action))
{
throw new NotImplementedException("No action set.");
}

this._path += _action;

this._path += $"api_key={Helper.AppConst.TMDbApiKey}";

string appends = String.Join(",", this._lstAppend);
if (!string.IsNullOrWhiteSpace(appends))
{
this._path += this._path.Substring(this._path.Length - 1) == "?"
? $"append_to_response={appends}"
: $"&append_to_response={appends}";
}


return this._path;
}
}
}
52 changes: 52 additions & 0 deletions ArcMovies/Service/Implementation/TMDbConfigMovie.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;

using System.Text;
using ArcMovies.Service.Abstraction;

namespace ArcMovies.Service.Implementation
{
public class TMDbConfigMovie : TMDbConfig
{

public TMDbConfigMovie() : base(Helper.AppConst.TMDbRootURL+"3/movie")
{
}

public TMDbConfigMovie ActionUpcoming()
{
this._action = "/upcoming?";
return this;
}

public TMDbConfigMovie ActionPopular()
{
this._action = "/popular?";
return this;
}

public TMDbConfigMovie ActionTopRated()
{
this._action = "/top_rated?";
return this;
}

public TMDbConfigMovie ActionById(string id)
{
this._action = id;
return this;
}

public TMDbConfigMovie WithCredits()
{
this._lstAppend.Add("credits");
return this;
}

public TMDbConfigMovie WithVideos()
{
this._lstAppend.Add("videos");
return this;
}
}
}
43 changes: 43 additions & 0 deletions ArcMovies/Service/Implementation/TMDbService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ArcMovies.Model;
using ArcMovies.Service.Abstraction;
using ArcMovies.Service.Implementation;
using HttpClient.Abstraction;
using HttpClient.Implementation;
using Newtonsoft.Json;
using Xamarin.Forms;

[assembly: Dependency(typeof(TMDbService))]
namespace ArcMovies.Service.Implementation
{
public class TMDbService : ITMDbService
{
public TMDbService()
{
}

public async Task<Section> GetSection(ITMDbConfig config)
{
IHttpClient httpClient = new HttpClient.Implementation.HttpClient();

string uri = config.Build();

ServiceRequest serviceRequest = new ServiceRequest(httpClient);
var response = await serviceRequest.Request<Section>(uri);
return response;
}

public async Task<Movie> GetMovieDetail(ITMDbConfig config)
{
IHttpClient httpClient = new HttpClient.Implementation.HttpClient();

string uri = config.Build();

ServiceRequest serviceRequest = new ServiceRequest(httpClient);
var response = await serviceRequest.Request<Movie>(uri);
return response;
}
}
}
25 changes: 25 additions & 0 deletions ArcMovies/Service/ServiceRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Threading.Tasks;
using HttpClient.Abstraction;
using Newtonsoft.Json;

namespace ArcMovies.Service
{
public class ServiceRequest
{
readonly IHttpClient _httpclient;
public ServiceRequest(IHttpClient httpClient)
{
this._httpclient = httpClient;
}

public async Task<T> Request<T>(string uri
, string authorizationToken = null
, string authorizationMethod = null) where T : class
{
var response = await this._httpclient.GetStringAsync(uri, authorizationToken, authorizationMethod);
T result = JsonConvert.DeserializeObject<T>(response);
return result;
}
}
}
18 changes: 10 additions & 8 deletions ArcMovies/View/HomePage.xaml
Original file line number Diff line number Diff line change
@@ -48,12 +48,14 @@
</Grid.RowDefinitions>

<!--Upcoming Banner-->
<carousel:CarouselViewControl ItemsSource="{Binding UpcomingList.results}"
<carousel:CarouselViewControl ItemsSource="{Binding UpcomingList}"
Grid.Row="0"
ShowArrows="true"
ShowIndicators="true"
IndicatorsShape="Circle"
BackgroundColor="Red"
IsSwipeEnabled="true"

>
<carousel:CarouselViewControl.ItemTemplate>
<DataTemplate>
@@ -68,7 +70,7 @@
<StackLayout Grid.Row="1" Style="{x:StaticResource SectionListStyle}">
<Label Text="Home Page" Style="{x:StaticResource SectionTitleStyle}"/>
<control:StackLayoutExtended
ItemSource="{Binding UpcomingList.results}"
ItemSource="{Binding UpcomingList}"
BackgroundColor="Blue"
Orientation="Horizontal">
<control:StackLayoutExtended.ItemTemplate>
@@ -80,11 +82,11 @@
</StackLayout>
<!--Upcoming List-->

<!--Upcoming List-->
<!--TopRatedList List-->
<StackLayout Grid.Row="2" Style="{x:StaticResource SectionListStyle}">
<Label Text="Home Page" Style="{x:StaticResource SectionTitleStyle}"/>
<control:StackLayoutExtended
ItemSource="{Binding UpcomingList.results}"
ItemSource="{Binding TopRatedList}"
BackgroundColor="Blue"
Orientation="Horizontal">
<control:StackLayoutExtended.ItemTemplate>
@@ -94,13 +96,13 @@
</control:StackLayoutExtended.ItemTemplate>
</control:StackLayoutExtended>
</StackLayout>
<!--Upcoming List-->
<!--TopRatedList List-->

<!--Upcoming List-->
<!--PopularList List-->
<StackLayout Grid.Row="3" Style="{x:StaticResource SectionListStyle}">
<Label Text="Home Page" Style="{x:StaticResource SectionTitleStyle}"/>
<control:StackLayoutExtended
ItemSource="{Binding UpcomingList.results}"
ItemSource="{Binding PopularList}"
BackgroundColor="Blue"
Orientation="Horizontal">
<control:StackLayoutExtended.ItemTemplate>
@@ -110,7 +112,7 @@
</control:StackLayoutExtended.ItemTemplate>
</control:StackLayoutExtended>
</StackLayout>
<!--Upcoming List-->
<!--PopularList List-->
</Grid>
</ScrollView>
</Grid>
4 changes: 3 additions & 1 deletion ArcMovies/View/HomePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xamarin.Forms;
using ArcMovies.ViewModel;
using Xamarin.Forms;

namespace ArcMovies.View
{
@@ -7,6 +8,7 @@ public partial class HomePage : ContentPage
public HomePage()
{
InitializeComponent();
this.BindingContext = new HomeViewModel();
}
}
}
21 changes: 20 additions & 1 deletion ArcMovies/ViewModel/BaseViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ArcMovies.ViewModel
{
public class BaseViewModel : ObservableObject
public abstract class BaseViewModel : ObservableObject
{
private bool _isLoading;

@@ -22,6 +23,24 @@ public bool HasError
set { _hasError = value; SetProperty(ref _hasError, value); }
}

protected virtual async Task Load(Func<Task> func)
{
try
{
IsLoading = true;
HasError = false;
await func.Invoke();
}
catch
{
HasError = true;
}
finally
{
IsLoading = false;
}
}


}
}
111 changes: 111 additions & 0 deletions ArcMovies/ViewModel/HomeViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using ArcMovies.Model;
using ArcMovies.Service.Abstraction;
using ArcMovies.Service.Implementation;
using Xamarin.Forms;

namespace ArcMovies.ViewModel
{
public class HomeViewModel : BaseViewModel
{
#region Binding Properties
ObservableCollection<Movie> _upcomingList;
public ObservableCollection<Movie> UpcomingList
{
get { return _upcomingList; }
set
{
if (value != _upcomingList)
{
SetProperty(ref _upcomingList, value);
}
}
}

ObservableCollection<Movie> _topRatedList;
public ObservableCollection<Movie> TopRatedList
{
get { return _topRatedList; }
set
{
if (value != _topRatedList)
{
SetProperty(ref _topRatedList, value);
}
}
}
ObservableCollection<Movie> _popularList;
public ObservableCollection<Movie> PopularList
{
get { return _popularList; }
set
{
if (value != _popularList)
{
SetProperty(ref _popularList, value);
}
}
}
#endregion Binding Properties

private Task Load()
{
return Task.Run(() =>
{
LoadUpcoming();
LoadPopular();
LoadTopRated();

});


}
private async Task LoadUpcoming()
{
var serviceResult = await DependencyService.Get<ITMDbService>().GetSection(new TMDbConfigMovie()
.ActionUpcoming()
.WithVideos()
.WithCredits());
if (serviceResult != null && serviceResult.results != null)
{
this.UpcomingList = new ObservableCollection<Movie>(serviceResult.results.Take(5));
}
}

private async Task LoadTopRated()
{
var serviceResult = await DependencyService.Get<ITMDbService>().GetSection(new TMDbConfigMovie()
.ActionTopRated()
.WithVideos()
.WithCredits());
if (serviceResult != null && serviceResult.results != null)
{
this.TopRatedList = new ObservableCollection<Movie>(serviceResult.results);
}
}

private async Task LoadPopular()
{
var serviceResult = await DependencyService.Get<ITMDbService>().GetSection(new TMDbConfigMovie()
.ActionPopular()
.WithVideos()
.WithCredits());
if (serviceResult != null && serviceResult.results != null)
{
this.PopularList = new ObservableCollection<Movie>(serviceResult.results);
}
}

public HomeViewModel()
{
this._popularList = new ObservableCollection<Movie>();
this._topRatedList = new ObservableCollection<Movie>();
this._upcomingList = new ObservableCollection<Movie>();

this.Load();
}
}
}
17 changes: 17 additions & 0 deletions HttpClient/Abstraction/IHttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace HttpClient.Abstraction
{
public interface IHttpClient
{
Task<string> GetStringAsync(string uri, string authorizationToken = null, string authorizationMethod = "Bearer");

Task<HttpResponseMessage> PostAsync<T>(string uri, T item, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer");

Task<HttpResponseMessage> PutAsync<T>(string uri, T item, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer");

Task<HttpResponseMessage> DeleteAsync(string uri, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer");
}
}
8 changes: 8 additions & 0 deletions HttpClient/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace HttpClient
{
public class Class1
{
}
}
48 changes: 48 additions & 0 deletions HttpClient/Implementation/HttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using HttpClient.Abstraction;

namespace HttpClient.Implementation
{
public class HttpClient : IHttpClient
{
readonly System.Net.Http.HttpClient _httpClient;
public HttpClient()
{
this._httpClient = new System.Net.Http.HttpClient();
}

public Task<HttpResponseMessage> DeleteAsync(string uri
,string authorizationToken = null
,string requestId = null
,string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}

public async Task<string> GetStringAsync(string uri, string authorizationToken = null, string authorizationMethod = "Bearer")
{
string result = string.Empty;
var requestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
if (authorizationToken != null)
{
requestMessage.Headers.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue(authorizationMethod, authorizationToken);
}
var response = await this._httpClient.SendAsync(requestMessage);
result = await response.Content.ReadAsStringAsync();
return result;
}

public Task<HttpResponseMessage> PostAsync<T>(string uri, T item, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}

public Task<HttpResponseMessage> PutAsync<T>(string uri, T item, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}
}
}
34 changes: 34 additions & 0 deletions HttpClient/Implementation/ResilientHttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using HttpClient.Abstraction;

namespace HttpClient.Implementation
{
public class ResilientHttpClient : IHttpClient
{
public ResilientHttpClient()
{
}

public Task<HttpResponseMessage> DeleteAsync(string uri, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}

public Task<string> GetStringAsync(string uri, string authorizationToken = null, string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}

public Task<HttpResponseMessage> PostAsync<T>(string uri, T item, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}

public Task<HttpResponseMessage> PutAsync<T>(string uri, T item, string authorizationToken = null, string requestId = null, string authorizationMethod = "Bearer")
{
throw new NotImplementedException();
}
}
}