From a8a9b07b3fa5344c183e2a98b61606df57031e40 Mon Sep 17 00:00:00 2001 From: Carsten Hilmer Date: Tue, 20 Sep 2016 01:44:22 +0200 Subject: [PATCH] Detail-Navigation eingebaut, Sprung auf aktualisierte List nach Bilder download --- www/js/app.js | 2 +- www/templates/imagedownload/js/controllers.js | 30 +++++++- .../pokemonliste/html/pokemon-detail.html | 12 ++-- www/templates/pokemonliste/js/controllers.js | 50 ++++++++++++- www/templates/pokemonliste/js/services.js | 70 +++++++++++++++++++ 5 files changed, 155 insertions(+), 9 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 6bdff46..30add48 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -35,7 +35,7 @@ window.globalVariable = { instagram: "your_api_key",//Use for Instagram API clientID. googlePlus: "your_api_key",//Use for Google API clientID. }, - adMob: "your_api_key" //Use for AdMob API clientID. + adMob: "ca-app-pub-3940256099942544/6300978111" //Use for AdMob API clientID. };// End Global variable diff --git a/www/templates/imagedownload/js/controllers.js b/www/templates/imagedownload/js/controllers.js index 316fee6..9204b0f 100644 --- a/www/templates/imagedownload/js/controllers.js +++ b/www/templates/imagedownload/js/controllers.js @@ -13,7 +13,7 @@ // http://ngcordova.com/docs/plugins/sqlite/ // // Controller of Contract List Page. -appControllers.controller('imageDownloadCtrl', function ($scope, $stateParams, $mdBottomSheet, $timeout, $mdDialog, $cordovaFileTransfer, $cordovaFile, $state, pokedexDB) { +appControllers.controller('imageDownloadCtrl', function ($scope, $stateParams, $mdBottomSheet, $timeout, $mdDialog, $cordovaFileTransfer, $ionicViewSwitcher, $ionicHistory, $cordovaFile, $state, pokedexDB, dataShare) { $scope.progressval = 0; $scope.currentfile = ''; @@ -100,6 +100,9 @@ appControllers.controller('imageDownloadCtrl', function ($scope, $stateParams, $ $scope.progressprozent = 'Download abgeschlossen! ' + $scope.progressprozent; $scope.DownloadisVisible=true; $scope.AbbrechenisVisible=false; + $timeout(function(){ + $scope.refreshData(); + }, 1000); } if ( $scope.startdownloadtimer==false){ @@ -129,6 +132,31 @@ appControllers.controller('imageDownloadCtrl', function ($scope, $stateParams, $ downloadtimer(); }; + $scope.refreshData=function(){ + var data='refresh'; + dataShare.sendData(data); + $scope.navigateTo('app.pokemonlist', {isAnimated:false}); + }; + + // navigateTo is for navigate to other page + // by using targetPage to be the destination state. + // Parameter : + // stateNames = target state to go. + // objectData = Object data will send to destination state. + $scope.navigateTo = function (stateName,objectData) { + if ($ionicHistory.currentStateName() != stateName) { + $ionicHistory.nextViewOptions({ + disableAnimate: false, + disableBack: true + }); + + //Next view animate will display in back direction + $ionicViewSwitcher.nextDirection('back'); + $state.go(stateName, { + isAnimated: objectData.isAnimated + }); + } + }; $scope.downloadabbrechen = function() { $scope.DownloadisVisible=true; diff --git a/www/templates/pokemonliste/html/pokemon-detail.html b/www/templates/pokemonliste/html/pokemon-detail.html index 909e954..8fa0e92 100644 --- a/www/templates/pokemonliste/html/pokemon-detail.html +++ b/www/templates/pokemonliste/html/pokemon-detail.html @@ -89,21 +89,21 @@

- +
- {{ pokemonentwicklung.pokemonname }} - (engl. {{ pokemonentwicklung.pokemonnameeng }}) + {{ pokemonentwicklung.pokemonname }} + (engl. {{ pokemonentwicklung.pokemonnameeng }})
- +
- {{ pokemonentwicklung.pokemonname }} + {{ pokemonentwicklung.pokemonname }}
- (engl. {{ pokemonentwicklung.pokemonnameeng }}) + (engl. {{ pokemonentwicklung.pokemonnameeng }})
diff --git a/www/templates/pokemonliste/js/controllers.js b/www/templates/pokemonliste/js/controllers.js index 9c903f9..6b8e23c 100644 --- a/www/templates/pokemonliste/js/controllers.js +++ b/www/templates/pokemonliste/js/controllers.js @@ -52,6 +52,11 @@ appControllers.controller('pokemonListCtrl', function ($scope, $stateParams,$ion $scope.isLoading = false; }, 1000);// End loading progress. + $scope.admob_key = window.globalVariable.adMob; + + // Calling to initial AdMob. + $scope.initAdMob(); + };// End initialForm. @@ -102,13 +107,32 @@ appControllers.controller('pokemonListCtrl', function ($scope, $stateParams,$ion } }); + // initAdMob for initial AdMob + $scope.initAdMob = function () { + + if (! AdMob ) { alert( 'admob plugin not ready' ); return; } + $scope.createAdMobBanner(); + + };//End initAdMob. + + //createAdMobBanner is for create new adMob banner. + $scope.createAdMobBanner = function () { + AdMob.createBanner( { + adId: $scope.admob_key, + isTesting: true, + position: AdMob.AD_POSITION.BOTTOM_CENTER // Set AdMob.AD_POSITION.TOP_CENTER for show banner at top section + } ); + }; + });// End of Pokemon List Page Controller. // Controller of pokemon Detail Page. -appControllers.controller('pokemonDetailCtrl', function ($mdBottomSheet, $mdToast, $scope, $stateParams, $filter, $mdDialog, $ionicHistory,$timeout, pokedexDB) { +appControllers.controller('pokemonDetailCtrl', function ($mdBottomSheet, $mdToast, $scope, $stateParams, $state, $filter, $mdDialog, $ionicHistory,$timeout, pokedexDB) { + + var dummypokemon=[]; // initialForm is the first activity in the controller. // It will initial all variable data and let the function works when page load. $scope.initialForm = function () { @@ -259,6 +283,30 @@ appControllers.controller('pokemonDetailCtrl', function ($mdBottomSheet, $mdToas }); };// End showing the bottom sheet. + $scope.loadpokemondetail=function(pokedexid){ + var dummypokemon = pokedexDB.getPokemon(pokedexid); + $timeout(function(){ + + var index; + for (index = 0; index < dummypokemon.length; ++index) { + $scope.navigateTo('app.pokemondetail',dummypokemon[index]); + }//for2 + + + },400); + + } + + $scope.navigateTo = function (targetPage, objectData) { + $timeout(function(){ + console.log('Controller Ausgabe'); + console.debug(objectData); + $state.go(targetPage, { + pokemondetail: objectData + }); + },100); + };// End navigateTo. + $scope.initialForm(); });// End Contract Detail page Controller. diff --git a/www/templates/pokemonliste/js/services.js b/www/templates/pokemonliste/js/services.js index d8cef68..a2a2ba1 100644 --- a/www/templates/pokemonliste/js/services.js +++ b/www/templates/pokemonliste/js/services.js @@ -46,6 +46,7 @@ appServices.factory('pokedexDB', function ($cordovaSQLite) var pokemonentladeattackenliste = []; var pokemonname = []; var pokemonnameeng = []; + pokemondata=[]; return { @@ -159,7 +160,76 @@ appServices.factory('pokedexDB', function ($cordovaSQLite) }); return pokemonList; },// End select all data. + getPokemon: function (pokedexid) + { + pokemondata=[]; + // Variable for prepare query statement to select all contracts. + var query = "SELECT * FROM tblPokemon WHERE POKEDEXID=?"; + + // Execute query statement from query variable. + $cordovaSQLite.execute(db, query,[pokedexid]).then(function (res) + { + if (res.rows.length > 0) + { + + for (var i = 0; i < res.rows.length; i++) + { + var dummypokedexid=''; + var dummyfundort=''; + + dummypokedexid=res.rows.item(i).POKEDEXID.toString(); + + if (dummypokedexid.length==1){ + dummypokedexid='00' + dummypokedexid; + } + + if (dummypokedexid.length==2){ + dummypokedexid='0' + dummypokedexid; + } + + if (res.rows.item(i).POKEMONTYPA > 0 ){ + dummyfundort=dummyfundort + pokemonfundorte[res.rows.item(i).POKEMONTYPA]; + } + + if (res.rows.item(i).POKEMONTYPB > 0 ){ + dummyfundort=dummyfundort + " " + pokemonfundorte[res.rows.item(i).POKEMONTYPB]; + } + + var dataItem = { + id : res.rows.item(i).ID , + pokedexid : res.rows.item(i).POKEDEXID , + pokedexidString : dummypokedexid , + pokemonname : res.rows.item(i).POKEMONNAME , + pokemonnameeng : res.rows.item(i).POKEMONNAMEENG , + pokemontypa : res.rows.item(i).POKEMONTYPA , + pokemontypb : res.rows.item(i).POKEMONTYPB , + pokemontypaString : pokemontypen[res.rows.item(i).POKEMONTYPA] , + pokemontypbString : pokemontypen[res.rows.item(i).POKEMONTYPB] , + pokemonfangchance : res.rows.item(i).POKEMONFANGCHANCE , + pokemonfluchtchance : res.rows.item(i).POKEMONFLUCHTCHANCE , + pokemonfundort : dummyfundort , + pokemoneidistanz : res.rows.item(i).POKEMONEIDISTANZ , + pokemonentwicklungtext : res.rows.item(i).POKEMONENTWICKLUNGTEXT , + pokemonentwicklung : res.rows.item(i).POKEMONENTWICKLUNG , + pokemonentwicklungkosten : res.rows.item(i).POKEMONENTWICKLUNGKOSTEN , + pokemonkp : res.rows.item(i).POKEMONKP , + pokemonattack : res.rows.item(i).POKEMONATTACK , + pokemondefense : res.rows.item(i).POKEMONDEFENSE , + pokemonsumme : res.rows.item(i).POKEMONKP + res.rows.item(i).POKEMONATTACK + res.rows.item(i).POKEMONDEFENSE , + pokemontext : res.rows.item(i).POKEMONTEXT , + pokemonnote : res.rows.item(i).POKEMONNOTE , + pokemonimage : res.rows.item(i).POKEMONIMAGE + }; + pokemondata.push(dataItem); + //pokemondata=dataItem; + console.log('Service ausgabe'); + console.debug(pokemondata); + } + } + }); + return pokemondata; + },// End select all data. getTypenEffekte: function (pokedexid) {