Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51525008
authored
Jan 07, 2018
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Pictogram 1.6, Beta 6, bug en pcb.netservice solucionado
parent
b9a62918
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
38 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tts/TTSHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
51525008
...
...
@@ -327,16 +327,14 @@ public class Picto extends Img {
visited
.
add
(
get_child_grid
());
LinkedList
<
Picto
>
childs
=
PCBcontext
.
getVocabulary
().
next
(
get_child_grid
());
if
(
childs
==
null
)
{
Log
.
e
(
LOG_TAG
,
" Picto "
+
this
.
get_translation
()
+
" with empty grid "
+
get_child_grid
()
+
" is invisible?"
+
(!
visible
));
if
(
childs
==
null
)
visible
=
false
;
}
else
{
else
for
(
Picto
child
:
childs
)
{
visible
=
!
child
.
is_invisible
(
visited
);
if
(
visible
)
break
;
}
}
}
return
!
visible
;
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
51525008
...
...
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit;
public
class
NetService
implements
Runnable
,
RestapiWrapper
.
iSilentLogin
{
private
static
final
String
LOG_TAG
=
NetService
.
class
.
getCanonicalName
();
private
static
final
String
ping_session
=
"server/ping_session"
;
private
static
final
String
ping
=
"server/ping"
;
private
boolean
updated
;
private
final
Vector
<
iNetServiceStatus
>
listeners
;
...
...
@@ -46,7 +47,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
private
long
nextRestfullSynchro
;
private
long
nextServerPing
;
public
NetService
(
iNetServiceStatus
listener
)
{
this
.
updated
=
RestapiWrapper
.
ping
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
server
),
ping
_session
);
this
.
updated
=
RestapiWrapper
.
ping
(
PCBcontext
.
getContext
().
getResources
().
getString
(
R
.
string
.
server
),
ping
);
nextServerPing
=
0
;
this
.
listeners
=
new
Vector
<>(
2
);
this
.
listeners
.
add
(
listener
);
...
...
@@ -151,19 +152,17 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
public
void
run
()
{
try
{
ConnectivityManager
cm
=
(
ConnectivityManager
)
PCBcontext
.
getContext
().
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
(
ConnectivityManager
)
PCBcontext
.
getContext
().
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
NetworkInfo
activeNetwork
=
cm
.
getActiveNetworkInfo
();
boolean
isConnected
=
activeNetwork
!=
null
&&
activeNetwork
.
isConnectedOrConnecting
();
if
(!
isConnected
)
{
if
(!
isConnected
)
setOffline
(
new
NetworkErrorException
(
"No Internet access"
));
return
;
}
long
now
=
new
Date
().
getTime
();
if
(
now
<
nextServerPing
||
!!
updated
)
return
;
nextServerPing
=
now
+
serverPingTimming
;
PCBcontext
.
getRestapiWrapper
().
ask
(
ping_session
,
new
RestapiWrapper
.
iRestapiListener
()
{
else
{
final
long
now
=
new
Date
().
getTime
();
if
(
now
>=
nextServerPing
||
!
updated
)
{
nextServerPing
=
now
+
serverPingTimming
;
PCBcontext
.
getRestapiWrapper
().
ask
(
updated
?
ping_session
:
ping
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
public
void
preExecute
()
{
...
...
@@ -172,29 +171,21 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
@Override
public
void
result
(
JSONArray
result
)
{
}
@Override
public
void
result
(
final
JSONObject
result
)
{
try
{
final
float
version
=
((
float
)(
Float
.
valueOf
(
result
.
getString
(
"version"
)).
intValue
()*
10
))/
10
;
final
float
version
=
((
float
)
(
Float
.
valueOf
(
result
.
getString
(
"version"
)).
intValue
()
*
10
))
/
10
;
if
(
PCBcontext
.
getActivityContext
()
!=
null
&&
version
>
DeviceHelper
.
getAppVersion
()
&&
newVersionContext
!=
PCBcontext
.
getActivityContext
())
{
newVersionContext
=
PCBcontext
.
getActivityContext
();
// prevent from showing several times the alert
newVersionAlert
(
version
,
PCBcontext
.
getActivityContext
(),
version
);
if
(
PCBcontext
.
getActivityContext
()
!=
null
&&
version
>
DeviceHelper
.
getAppVersion
()
&&
newVersionContext
!=
PCBcontext
.
getActivityContext
())
{
newVersionContext
=
PCBcontext
.
getActivityContext
();
// prevent from showing several times the alert
newVersionAlert
(
version
,
PCBcontext
.
getActivityContext
(),
version
);
}
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"PING JSON ERROR: "
+
result
+
" "
+
e
.
getMessage
());
}
long
now
=
new
Date
().
getTime
();
if
(!
updated
)
{
nextRestfullSynchro
=
now
;
updated
=
true
;
String
TAG_TOKEN
=
"token"
;
try
{
PCBcontext
.
getRestapiWrapper
().
setToken
(
result
.
getString
(
TAG_TOKEN
));
}
catch
(
JSONException
e
)
{
Log
.
e
(
LOG_TAG
,
"Error when ping:"
+
e
.
getMessage
()+
" res:"
+
result
.
toString
());
}
setOnline
();
if
(
PCBcontext
.
is_user_logged
())
//si el usuario aun no hizo login, en realidad no es necesario hacer nada
// Comprobar si hay usuario offline, para hacer login transparente
if
(
PCBcontext
.
is_user_offline
())
...
...
@@ -204,32 +195,41 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
PCBcontext
.
getRoom
().
connect
();
synchronizeStuData
();
PCBcontext
.
getActionLog
().
batch
();
};
}
;
}
else
{
try
{
PCBcontext
.
getRestapiWrapper
().
setToken
(
result
.
getString
(
"token"
));
Log
.
i
(
LOG_TAG
,
"session token updated"
);
}
catch
(
JSONException
e
)
{
Log
.
e
(
LOG_TAG
,
"Error when ping:"
+
e
.
getMessage
()
+
" res:"
+
result
.
toString
());
}
//cada restfullSynchroTimming aprox. se fuerza sincronización de vocabulario y configuración de usuario
if
(
PCBcontext
.
is_user_logged
())
{
if
(
restfullSynchroTimming
>
0
&&
(
now
>=
nextRestfullSynchro
))
{
Log
.
i
(
LOG_TAG
,
"Vocabulary request."
);
if
(!
PCBcontext
.
getRoom
().
inRoom
())
{
if
(!
PCBcontext
.
getRoom
().
inRoom
())
{
PCBcontext
.
getRoom
().
connect
();
}
synchronizeStuData
();
nextSynchro
(
now
+
restfullSynchroTimming
);
nextSynchro
(
now
+
restfullSynchroTimming
);
}
}
else
nextSynchro
(
now
+
restfullSynchroTimming
);
}
else
nextSynchro
(
now
+
restfullSynchroTimming
);
}
}
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
LOG_TAG
,
"Error when asking:"
+
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
"Error when asking:"
+
e
.
getMessage
());
setOffline
(
e
);
}
});
notifyStatus
();
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"THREAD NOT WORKING BECAUSE:"
+
e
.
getMessage
());
}
}
}
catch
(
Exception
e
){
Log
.
e
(
LOG_TAG
,
"THREAD NOT WORKING BECAUSE:"
+
e
.
getMessage
());
this
.
restart_app
(
true
);
}
}
...
...
@@ -289,11 +289,18 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
public
void
setOffline
(
Exception
e
)
{
this
.
updated
=
false
;
PCBcontext
.
getRoom
().
exit
();
//
PCBcontext.getRoom().exit();
Log
.
e
(
LOG_TAG
,
"PCB offline because exception happens: "
+
e
.
getMessage
());
notifyStatus
();
}
public
void
setOnline
()
{
this
.
updated
=
true
;
Log
.
e
(
LOG_TAG
,
"PCB online"
);
notifyStatus
();
}
public
iNetServiceDevice
getNetServiceDevice
()
{
iNetServiceDevice
device
=
null
;
for
(
iNetServiceStatus
listener:
listeners
)
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tts/TTSHelper.java
View file @
51525008
...
...
@@ -150,7 +150,7 @@ public class TTSHelper {
public
void
play
(
String
input
)
{
Bundle
params
=
new
Bundle
();
params
.
put
String
(
TextToSpeech
.
Engine
.
KEY_PARAM_VOLUME
,
"1"
);
params
.
put
Float
(
TextToSpeech
.
Engine
.
KEY_PARAM_VOLUME
,
new
Float
(
1
)
);
params
.
putString
(
TextToSpeech
.
Engine
.
KEY_PARAM_UTTERANCE_ID
,
"TAPE_READ"
);
ttobj
.
speak
(
input
,
TextToSpeech
.
QUEUE_FLUSH
,
params
,
"TAPE_READ"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment