Skip to content

Commit

Permalink
Merge pull request #61 from Gamhub-io/develop
Browse files Browse the repository at this point in the history
1.2 Atlas | rev 1
  • Loading branch information
bricefriha committed Aug 24, 2022
2 parents b76e6f7 + 6bc2d35 commit 6203adf
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 67 deletions.
2 changes: 1 addition & 1 deletion AresNews/AresNews.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="666668" android:versionName="1.2 Atlas" package="com.bricefriha.aresgaming" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="666668" android:versionName="1.2.1 Atlas" package="com.bricefriha.aresgaming" android:installLocation="auto">
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="31" />
<application android:label="GamHub" android:theme="@style/MainTheme" android:usesCleartextTraffic="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
6 changes: 3 additions & 3 deletions AresNews/AresNews.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>15.0</string>
<string>15.4</string>
<key>CFBundleDisplayName</key>
<string>GamHub</string>
<key>CFBundleIdentifier</key>
Expand All @@ -34,13 +34,13 @@
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.2.1</string>
<key>UIMainStoryboardFile</key>
<string>LaunchScreen</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<false/>
</dict>
</dict>
</plist>
7 changes: 5 additions & 2 deletions AresNews/AresNews/Controls/ArticlePreview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
Padding="0"
xct:TouchEffect.NativeAnimation="True"
xct:TouchEffect.ShouldMakeChildrenInputTransparent="False"
xct:TouchEffect.Command="{Binding TapCommand}"
xct:TouchEffect.CommandParameter="{Binding TapCommandParameter}"
>

<Frame.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapCommand}"
CommandParameter="{Binding TapCommandParameter}" />
</Frame.GestureRecognizers>
<Grid >

<!-- Backgournd -->
Expand Down
101 changes: 42 additions & 59 deletions AresNews/AresNews/ViewModels/NewsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class NewsViewModel : BaseViewModel

private bool _isLaunching = true;
private string _prevSearch;
private string _lastCallDateTime;

private int _wifiRestartCount = 0;
private bool _isInCustomFeed;
Expand Down Expand Up @@ -301,7 +302,7 @@ public async void FetchArticles(bool isFullRefresh = false)
_isLaunching = false;
Articles = articles;
// Register date of the refresh
Preferences.Set("lastRefresh", _articles[0].FullPublishDate.ToString("dd-MM-yyy_HH:mm"));
//Preferences.Set("lastRefresh", _articles[0].FullPublishDate.ToString("dd-MM-yyy_HH:mm"));
IsRefreshing = false;
IsSearchOpen = false;
return;
Expand All @@ -312,49 +313,42 @@ public async void FetchArticles(bool isFullRefresh = false)

try
{
var lastCall = Preferences.Get("lastRefresh", null);

if (_articles?.Count() > 0)
_lastCallDateTime = _articles?.First().FullPublishDate.ToUniversalTime().ToString("dd-MM-yyy_HH:mm:ss");//Preferences.Get("lastRefresh", null);
;
// If we want to fetch the articles via search
if (_searchText != null && IsSearching == true )
{
SearchArticles(articles.ToList());
return;
}
if (lastCall == null)
if (string.IsNullOrEmpty(_lastCallDateTime))
{

Articles = await App.WService.Get<ObservableCollection<Article>>("feeds");
IsRefreshing = false;
_isLaunching = false;
Preferences.Set("lastRefresh", _articles[0].FullPublishDate.ToString("dd-MM-yyy_HH:mm"));
await RefreshDB();
return ;
}
if (_articles?.Count() > 0)
{

if (lastCall != null)
articles = await App.WService.Get<ObservableCollection<Article>>("feeds", "update", parameters: new string[] { lastCall });
else
articles = await App.WService.Get<ObservableCollection<Article>>("feeds");
articles = await App.WService.Get<ObservableCollection<Article>>("feeds", "update", parameters: new string[] { _lastCallDateTime });

}


}
else
{
if (_isLaunching)
{
Articles = await App.WService.Get<ObservableCollection<Article>>("feeds");
try
{
// Manage backuo
Articles = await App.WService.Get<ObservableCollection<Article>>("feeds");

await Task.Factory.StartNew(async () =>
{
await Task.Run(() => {
App.BackUpConn.DeleteAll<Article>();
App.BackUpConn.InsertAllWithChildren(_articles);
});
});
// Manage backuo
await RefreshDB();

}
catch
Expand All @@ -363,8 +357,6 @@ public async void FetchArticles(bool isFullRefresh = false)

_isLaunching = false;
IsRefreshing = false;
// Register date of the refresh
Preferences.Set("lastRefresh", _articles[0].FullPublishDate.ToString("dd-MM-yyy_HH:mm"));
return;
}
articles = await App.WService.Get<ObservableCollection<Article>>("feeds");
Expand Down Expand Up @@ -395,15 +387,6 @@ public async void FetchArticles(bool isFullRefresh = false)
var page = (NewsPage)((IShellSectionController)Shell.Current?.CurrentItem?.CurrentItem).PresentedPage;
page.DisplayOfflineMessage(ex.Message);
}
//// Reload if the list is empty of if the current list is too old
//if (!_articles.Any() || DateTime.Now - _articles[0].FullPublishDate > TimeSpan.FromDays(29))
//{
// IsRefreshing = false;
// Articles = new ObservableCollection<Article>(articles.OrderBy(a => a.Time));
// return;
//}
// Count the number of new elements
//int nbNewItems = articles.Count() - _articles.Count();

// To avoid crashs: if this number is out of range we end the process
if (articles == null || articles.Count() <= 0)
Expand All @@ -412,9 +395,6 @@ public async void FetchArticles(bool isFullRefresh = false)
return;
}

// Get all the new items
//var newItems = articles.Except(_articles.Where(a => articles.Any(na => na.Equals(a)))).ToList();//articles.Take(nbNewItems).ToList();

await Task.Factory.StartNew(() =>
{
// Update list of articles
Expand Down Expand Up @@ -443,40 +423,43 @@ public async void FetchArticles(bool isFullRefresh = false)
}
});
try
{
// Manage backuo
await RefreshDB();

}
catch
{
}
//finally
//{
// _isLaunching = false;
//}

//if (_isLaunching && articles.Count > 0)
//{
// try
// {
// // Manage backuo

// await Task.Factory.StartNew(async () =>
// {
// await Task.Run(() => {

// App.BackUpConn.DeleteAll<Article>();
// App.BackUpConn.InsertAllWithChildren(_articles, recursive: true);
// });
// });

// }
// catch
// {
// }
// //finally
// //{
// // _isLaunching = false;
// //}

//}
_isLaunching = false;
IsRefreshing = false;


// Register date of the refresh
Preferences.Set("lastRefresh", _articles[0].FullPublishDate.ToString("dd-MM-yyy_HH:mm"));


}

private async Task RefreshDB()
{
await Task.Factory.StartNew(async () =>
{
await Task.Run(() =>
{
App.BackUpConn.DeleteAll<Article>();
App.BackUpConn.InsertAllWithChildren(_articles);
});
});
}

/// <summary>
/// Load articles via search
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

# GamHub
<!-- <p align="center" class="container" >
<img width="200px" src="https://user-images.githubusercontent.com/37577669/168440018-94d3e00b-5ddf-485a-94b7-c6488addface.png" />
</p> -->
Expand Down Expand Up @@ -38,7 +37,7 @@ The app has been built using [Xamarin Forms](https://github.com/xamarin/Xamarin.

## Status

Platform | Test | Production |
Platform | Testing | Production |
--- | ----- | ------|
| **Android**| [![Build status](https://build.appcenter.ms/v0.1/apps/af152970-a78b-4dc4-9435-c88d5bc7a5d8/branches/master/badge)](https://appcenter.ms)|[![Build status](https://build.appcenter.ms/v0.1/apps/af152970-a78b-4dc4-9435-c88d5bc7a5d8/branches/master/badge)](https://appcenter.ms)
| **iOS**| [![Build status](https://build.appcenter.ms/v0.1/apps/ccbb4d7f-7e53-41ca-8da6-be665b7eeeb4/branches/develop/badge)](https://appcenter.ms)|[![Build status](https://build.appcenter.ms/v0.1/apps/ccbb4d7f-7e53-41ca-8da6-be665b7eeeb4/branches/master/badge)](https://appcenter.ms)|
Expand Down

0 comments on commit 6203adf

Please sign in to comment.