Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odakyuToiletSignage
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kddi
odakyuToiletSignage
Commits
21083efb
Commit
21083efb
authored
Dec 25, 2017
by
Kim Jinsung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
アプリログ出力
parent
e2ddc8a9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
861 additions
and
34 deletions
+861
-34
app/build.gradle
+1
-1
app/src/main/java/jp/odakyu/toiletsignage/activity/MainActivity.java
+7
-6
app/src/main/java/jp/odakyu/toiletsignage/activity/ParentActivity.java
+2
-1
app/src/main/java/jp/odakyu/toiletsignage/activity/SignageActivity.java
+3
-1
app/src/main/java/jp/odakyu/toiletsignage/application/ToiletApplication.java
+14
-4
app/src/main/java/jp/odakyu/toiletsignage/connection/ToiletServerConnection.java
+1
-0
app/src/main/java/jp/odakyu/toiletsignage/constants/ToiletConstants.java
+2
-0
app/src/main/java/jp/odakyu/toiletsignage/log/AbstractLogger.java
+14
-0
app/src/main/java/jp/odakyu/toiletsignage/log/Logger.java
+296
-0
app/src/main/java/jp/odakyu/toiletsignage/logic/MainLogic.java
+8
-5
app/src/main/java/jp/odakyu/toiletsignage/task/UpdateToiletInfoTask.java
+6
-5
app/src/main/java/jp/odakyu/toiletsignage/util/DateTimeFormat.java
+267
-0
app/src/main/java/jp/odakyu/toiletsignage/util/DateTimeUtil.java
+0
-0
app/src/main/java/jp/odakyu/toiletsignage/util/FileUtil.java
+0
-0
app/src/main/java/jp/odakyu/toiletsignage/util/NumericUtil.java
+225
-0
app/src/main/java/jp/odakyu/toiletsignage/util/StringUtil.java
+0
-0
app/src/main/res/layout/activity_signage_1.xml
+1
-1
app/src/main/res/layout/activity_signage_3.xml
+13
-9
app/src/main/res/values/strings.xml
+1
-1
No files found.
app/build.gradle
View file @
21083efb
...
@@ -7,7 +7,7 @@ android {
...
@@ -7,7 +7,7 @@ android {
minSdkVersion
23
minSdkVersion
23
targetSdkVersion
26
targetSdkVersion
26
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0
.0
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
}
buildTypes
{
buildTypes
{
...
...
app/src/main/java/jp/odakyu/toiletsignage/activity/MainActivity.java
View file @
21083efb
...
@@ -13,6 +13,7 @@ import android.widget.Toast;
...
@@ -13,6 +13,7 @@ import android.widget.Toast;
import
jp.odakyu.toiletsignage.R
;
import
jp.odakyu.toiletsignage.R
;
import
jp.odakyu.toiletsignage.constants.ToiletConstants
;
import
jp.odakyu.toiletsignage.constants.ToiletConstants
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.log.Logger
;
import
jp.odakyu.toiletsignage.logic.MainLogic
;
import
jp.odakyu.toiletsignage.logic.MainLogic
;
import
jp.odakyu.toiletsignage.application.ToiletApplication
;
import
jp.odakyu.toiletsignage.application.ToiletApplication
;
...
@@ -50,12 +51,12 @@ public class MainActivity extends ParentActivity {
...
@@ -50,12 +51,12 @@ public class MainActivity extends ParentActivity {
int
result
=
MainLogic
.
getToiletDefaultInfo
(
getApplicationContext
());
int
result
=
MainLogic
.
getToiletDefaultInfo
(
getApplicationContext
());
if
(
result
==
ToiletConstants
.
VALUE_GET_USB_INFO_VALIDATION_FAIL
)
{
if
(
result
==
ToiletConstants
.
VALUE_GET_USB_INFO_VALIDATION_FAIL
)
{
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_DEFAULT_TOILET_VALIDATION_FAIL
));
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_DEFAULT_TOILET_VALIDATION_FAIL
));
Log
.
w
(
TAG
,
"USBToiletDefaultJson validation fail"
);
Log
ger
.
w
(
TAG
,
"USBToiletDefaultJson validation fail"
);
return
;
return
;
}
}
if
(
result
==
ToiletConstants
.
VALUE_GET_USB_INFO_FAIL
)
{
if
(
result
==
ToiletConstants
.
VALUE_GET_USB_INFO_FAIL
)
{
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_DEFAULT_TOILET_NULL
));
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_DEFAULT_TOILET_NULL
));
Log
.
w
(
TAG
,
"ToiletDefaultArray NULL"
);
Log
ger
.
w
(
TAG
,
"ToiletDefaultArray NULL"
);
return
;
return
;
}
}
...
@@ -65,7 +66,7 @@ public class MainActivity extends ParentActivity {
...
@@ -65,7 +66,7 @@ public class MainActivity extends ParentActivity {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_DEFAULT_TOILET_NULL
));
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_DEFAULT_TOILET_NULL
));
Log
.
e
(
TAG
,
e
.
getLocalizedMessage
(),
e
);
Log
ger
.
e
(
TAG
,
e
.
getLocalizedMessage
(),
e
);
}
}
}
}
...
@@ -115,7 +116,7 @@ public class MainActivity extends ParentActivity {
...
@@ -115,7 +116,7 @@ public class MainActivity extends ParentActivity {
@Override
@Override
protected
void
reloadDisplayView
(
final
int
errorCount
,
final
boolean
isNetworkConnect
)
{
protected
void
reloadDisplayView
(
final
int
errorCount
,
final
boolean
isNetworkConnect
)
{
Log
.
d
(
TAG
,
"reloadDisplayView"
);
Log
ger
.
d
(
TAG
,
"reloadDisplayView"
);
runOnUiThread
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -130,9 +131,9 @@ public class MainActivity extends ParentActivity {
...
@@ -130,9 +131,9 @@ public class MainActivity extends ParentActivity {
}
}
}
else
{
}
else
{
if
(
isNetworkConnect
)
{
if
(
isNetworkConnect
)
{
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_NETWORK_DIS_CONNECT
));
}
else
{
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_TOILET_SERVER_CONNECT_FAIL
));
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_TOILET_SERVER_CONNECT_FAIL
));
}
else
{
mMessageTextView
.
setText
(
getString
(
R
.
string
.
initDisplayStringError
,
ToiletInfo
.
VALUE_NETWORK_DIS_CONNECT
));
}
}
}
}
}
}
...
...
app/src/main/java/jp/odakyu/toiletsignage/activity/ParentActivity.java
View file @
21083efb
...
@@ -14,6 +14,7 @@ import android.view.Window;
...
@@ -14,6 +14,7 @@ import android.view.Window;
import
jp.odakyu.toiletsignage.application.ToiletApplication
;
import
jp.odakyu.toiletsignage.application.ToiletApplication
;
import
jp.odakyu.toiletsignage.constants.ToiletConstants
;
import
jp.odakyu.toiletsignage.constants.ToiletConstants
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.log.Logger
;
/**
/**
* Created by agentec on 2017/12/11.
* Created by agentec on 2017/12/11.
...
@@ -70,7 +71,7 @@ public class ParentActivity extends AppCompatActivity {
...
@@ -70,7 +71,7 @@ public class ParentActivity extends AppCompatActivity {
ToiletApplication
application
=
(
ToiletApplication
)
getApplication
();
ToiletApplication
application
=
(
ToiletApplication
)
getApplication
();
//アプリがバックグラウンドのなった時のみタスクを停止
//アプリがバックグラウンドのなった時のみタスクを停止
if
(!
application
.
isForeground
(
this
))
{
if
(!
application
.
isForeground
(
this
))
{
Log
.
i
(
TAG
,
"Application Background"
);
Log
ger
.
i
(
TAG
,
"Application Background"
);
application
.
stopTimer
();
application
.
stopTimer
();
}
}
...
...
app/src/main/java/jp/odakyu/toiletsignage/activity/SignageActivity.java
View file @
21083efb
...
@@ -17,6 +17,7 @@ import jp.odakyu.toiletsignage.constants.ToiletConstants;
...
@@ -17,6 +17,7 @@ import jp.odakyu.toiletsignage.constants.ToiletConstants;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.json.ResultToiletJson
;
import
jp.odakyu.toiletsignage.json.ResultToiletJson
;
import
jp.odakyu.toiletsignage.json.USBToiletDefaultJson
;
import
jp.odakyu.toiletsignage.json.USBToiletDefaultJson
;
import
jp.odakyu.toiletsignage.log.Logger
;
/**
/**
* Created by agentec on 2017/11/30.
* Created by agentec on 2017/11/30.
...
@@ -62,6 +63,7 @@ public class SignageActivity extends ParentActivity {
...
@@ -62,6 +63,7 @@ public class SignageActivity extends ParentActivity {
if
(
toiletDefaultJson
.
getPriority
()
==
ToiletInfo
.
VALUE_PRIORITY_SUB_LEFT
)
{
if
(
toiletDefaultJson
.
getPriority
()
==
ToiletInfo
.
VALUE_PRIORITY_SUB_LEFT
)
{
leftGateNameJPTextView
.
setText
(
toiletDefaultJson
.
getToiletNameJP
());
leftGateNameJPTextView
.
setText
(
toiletDefaultJson
.
getToiletNameJP
());
leftGateNameENTextView
.
setText
(
toiletDefaultJson
.
getToiletNameEN
());
leftGateNameENTextView
.
setText
(
toiletDefaultJson
.
getToiletNameEN
());
}
else
if
(
toiletDefaultJson
.
getPriority
()
==
ToiletInfo
.
VALUE_PRIORITY_SUB_RIGHT
)
{
}
else
if
(
toiletDefaultJson
.
getPriority
()
==
ToiletInfo
.
VALUE_PRIORITY_SUB_RIGHT
)
{
rightGateNameJPTextView
.
setText
(
toiletDefaultJson
.
getToiletNameJP
());
rightGateNameJPTextView
.
setText
(
toiletDefaultJson
.
getToiletNameJP
());
rightGateNameENTextView
.
setText
(
toiletDefaultJson
.
getToiletNameEN
());
rightGateNameENTextView
.
setText
(
toiletDefaultJson
.
getToiletNameEN
());
...
@@ -129,7 +131,7 @@ public class SignageActivity extends ParentActivity {
...
@@ -129,7 +131,7 @@ public class SignageActivity extends ParentActivity {
*/
*/
@Override
@Override
protected
void
reloadDisplayView
(
final
int
errorCount
,
final
boolean
isNetworkConnect
)
{
protected
void
reloadDisplayView
(
final
int
errorCount
,
final
boolean
isNetworkConnect
)
{
Log
.
i
(
TAG
,
"reloadDisplayView"
);
Log
ger
.
i
(
TAG
,
"reloadDisplayView"
);
//バックグラウンドスレッドからメーイン
//バックグラウンドスレッドからメーイン
runOnUiThread
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
...
...
app/src/main/java/jp/odakyu/toiletsignage/application/ToiletApplication.java
View file @
21083efb
...
@@ -11,7 +11,11 @@ import java.util.List;
...
@@ -11,7 +11,11 @@ import java.util.List;
import
java.util.Timer
;
import
java.util.Timer
;
import
jp.odakyu.toiletsignage.activity.MainActivity
;
import
jp.odakyu.toiletsignage.activity.MainActivity
;
import
jp.odakyu.toiletsignage.log.Logger
;
import
jp.odakyu.toiletsignage.task.UpdateToiletInfoTask
;
import
jp.odakyu.toiletsignage.task.UpdateToiletInfoTask
;
import
jp.odakyu.toiletsignage.util.FileUtil
;
import
static
jp
.
odakyu
.
toiletsignage
.
constants
.
ToiletConstants
.
APP_LOG_PATH
;
/**
/**
* Created by agentec on 2017/12/13.
* Created by agentec on 2017/12/13.
...
@@ -25,21 +29,27 @@ public class ToiletApplication extends Application {
...
@@ -25,21 +29,27 @@ public class ToiletApplication extends Application {
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
Logger
logger
=
new
Logger
();
String
logPath
=
getApplicationContext
().
getCacheDir
().
getPath
()
+
"/"
+
APP_LOG_PATH
;
logger
.
setLogPathFormat
(
logPath
);
FileUtil
.
createParentDirectory
(
logPath
);
Logger
.
i
(
TAG
,
"onCreate"
);
}
}
public
synchronized
void
stopTimer
()
{
public
synchronized
void
stopTimer
()
{
Log
.
i
(
TAG
,
"stopTimer"
);
Log
ger
.
i
(
TAG
,
"stopTimer"
);
if
(
updateToiletInfoTimer
!=
null
)
{
if
(
updateToiletInfoTimer
!=
null
)
{
Log
.
i
(
TAG
,
"stopTimer STOP"
);
Log
ger
.
i
(
TAG
,
"stopTimer STOP"
);
updateToiletInfoTimer
.
cancel
();
updateToiletInfoTimer
.
cancel
();
updateToiletInfoTimer
=
null
;
updateToiletInfoTimer
=
null
;
}
}
}
}
public
synchronized
void
startTimer
()
{
public
synchronized
void
startTimer
()
{
Log
.
i
(
TAG
,
"startTimer"
);
Log
ger
.
i
(
TAG
,
"startTimer"
);
if
(
updateToiletInfoTimer
==
null
)
{
if
(
updateToiletInfoTimer
==
null
)
{
Log
.
i
(
TAG
,
"startTimer Start"
);
Log
ger
.
i
(
TAG
,
"startTimer Start"
);
updateToiletInfoTimer
=
new
Timer
();
updateToiletInfoTimer
=
new
Timer
();
// スケジュール開始と同時にすぐ新着更新を開始する
// スケジュール開始と同時にすぐ新着更新を開始する
int
interval
=
10000
;
//10秒
int
interval
=
10000
;
//10秒
...
...
app/src/main/java/jp/odakyu/toiletsignage/connection/ToiletServerConnection.java
View file @
21083efb
package
jp
.
odakyu
.
toiletsignage
.
connection
;
package
jp
.
odakyu
.
toiletsignage
.
connection
;
import
android.util.Base64
;
import
android.util.Base64
;
import
android.util.Log
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
...
...
app/src/main/java/jp/odakyu/toiletsignage/constants/ToiletConstants.java
View file @
21083efb
...
@@ -19,4 +19,6 @@ public interface ToiletConstants {
...
@@ -19,4 +19,6 @@ public interface ToiletConstants {
String
MEIRIO_FONT_NAME
=
"meiryo.ttf"
;
String
MEIRIO_FONT_NAME
=
"meiryo.ttf"
;
String
MEIRIO_BOLD_FONT_NAME
=
"meiryob.ttf"
;
String
MEIRIO_BOLD_FONT_NAME
=
"meiryob.ttf"
;
String
APP_LOG_PATH
=
"log/appLogcat_%s.log"
;
}
}
app/src/main/java/jp/odakyu/toiletsignage/log/AbstractLogger.java
0 → 100644
View file @
21083efb
package
jp
.
odakyu
.
toiletsignage
.
log
;
public
abstract
class
AbstractLogger
{
// protectedメソッドにするためinterfaceからabstract classに変更
protected
abstract
void
verbose
(
String
tag
,
String
log
);
protected
abstract
void
verbose
(
String
tag
,
String
log
,
Throwable
t
);
protected
abstract
void
debug
(
String
tag
,
String
log
);
protected
abstract
void
debug
(
String
tag
,
String
log
,
Throwable
t
);
protected
abstract
void
info
(
String
tag
,
String
log
);
protected
abstract
void
info
(
String
tag
,
String
log
,
Throwable
t
);
protected
abstract
void
warn
(
String
tag
,
String
log
);
protected
abstract
void
warn
(
String
tag
,
String
log
,
Throwable
t
);
protected
abstract
void
error
(
String
tag
,
String
log
);
protected
abstract
void
error
(
String
tag
,
String
log
,
Throwable
t
);
}
app/src/main/java/jp/odakyu/toiletsignage/log/Logger.java
0 → 100644
View file @
21083efb
package
jp
.
odakyu
.
toiletsignage
.
log
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.PrintStream
;
import
java.util.Date
;
import
jp.odakyu.toiletsignage.util.DateTimeFormat
;
import
jp.odakyu.toiletsignage.util.DateTimeUtil
;
import
jp.odakyu.toiletsignage.util.FileUtil
;
public
class
Logger
extends
AbstractLogger
{
private
static
AbstractLogger
logger
=
new
Logger
();
private
static
PrintStream
ps
=
System
.
out
;
private
static
String
logPathFormat
;
private
String
currentDay
;
private
int
retentionPeriod
=
1
;
public
Logger
()
{
}
public
static
AbstractLogger
getLogger
()
{
return
logger
;
}
public
void
setLogPathFormat
(
String
logPathFormat
)
{
this
.
logPathFormat
=
logPathFormat
;
}
public
static
void
setLogger
(
AbstractLogger
abstractLogger
)
{
logger
=
abstractLogger
;
}
public
void
setRetentionPeriod
(
int
retentionPeriod
)
{
this
.
retentionPeriod
=
retentionPeriod
;
}
// public static void v(String log) {
// v(env.defaultLogName, log);
// }
public
static
void
v
(
String
tag
,
String
log
)
{
if
(
isVerboseEnabled
())
{
logger
.
verbose
(
tag
,
log
);
}
}
public
static
void
v
(
String
tag
,
String
log
,
Object
...
param
)
{
if
(
isVerboseEnabled
())
{
v
(
tag
,
String
.
format
(
log
,
param
));
}
}
// public static void v(String log, Throwable t) {
// v(env.defaultLogName, log, t);
// }
public
static
void
v
(
String
tag
,
String
log
,
Throwable
t
)
{
if
(
isVerboseEnabled
())
{
logger
.
verbose
(
tag
,
log
,
t
);
}
}
// public static void d(String log) {
// d(env.defaultLogName, log);
// }
public
static
void
d
(
String
tag
,
String
log
)
{
if
(
isDebugEnabled
())
{
logger
.
debug
(
tag
,
log
);
}
}
public
static
void
d
(
String
tag
,
String
log
,
Object
...
param
)
{
if
(
isDebugEnabled
())
{
d
(
tag
,
String
.
format
(
log
,
param
));
}
}
// public static void d(String log, Throwable t) {
// d(env.defaultLogName, log, t);
// }
public
static
void
d
(
String
tag
,
String
log
,
Throwable
t
)
{
if
(
isDebugEnabled
())
{
logger
.
debug
(
tag
,
log
,
t
);
}
}
// public static void i(String log) {
// i(env.defaultLogName, log);
// }
public
static
void
i
(
String
tag
,
String
log
)
{
if
(
isInfoEnabled
())
{
logger
.
info
(
tag
,
log
);
}
}
public
static
void
i
(
String
tag
,
String
log
,
Object
...
param
)
{
if
(
isInfoEnabled
())
{
i
(
tag
,
String
.
format
(
log
,
param
));
}
}
// public static void i(String log, Throwable t) {
// i(env.defaultLogName, log, t);
// }
public
static
void
i
(
String
tag
,
String
log
,
Throwable
t
)
{
if
(
isInfoEnabled
())
{
logger
.
info
(
tag
,
log
,
t
);
}
}
// public static void w(String log) {
// w(env.defaultLogName, log);
// }
public
static
void
w
(
String
tag
,
String
log
)
{
if
(
isWarnEnabled
())
{
logger
.
warn
(
tag
,
log
);
}
}
public
static
void
w
(
String
tag
,
String
log
,
Object
...
param
)
{
if
(
isWarnEnabled
())
{
w
(
tag
,
String
.
format
(
log
,
param
));
}
}
// public static void w(String log, Throwable t) {
// w(env.defaultLogName, log, t);
// }
public
static
void
w
(
String
tag
,
String
log
,
Throwable
t
)
{
if
(
isWarnEnabled
())
{
logger
.
warn
(
tag
,
log
,
t
);
}
}
// public static void e(String log) {
// e(env.defaultLogName, log);
// }
public
static
void
e
(
String
tag
,
String
log
)
{
if
(
isErrorEnabled
())
{
logger
.
error
(
tag
,
log
);
}
}
public
static
void
e
(
String
tag
,
String
log
,
Object
...
param
)
{
if
(
isErrorEnabled
())
{
e
(
tag
,
String
.
format
(
log
,
param
));
}
}
// public static void e(String log, Throwable t) {
// e(env.defaultLogName, log, t);
// }
public
static
void
e
(
String
tag
,
String
log
,
Throwable
t
)
{
if
(
isErrorEnabled
())
{
logger
.
error
(
tag
,
log
,
t
);
}
}
/**
* #26344 端末ログファイル削除方式改善のため
*/
private
boolean
isDeletable
(
File
file
)
{
long
toTime
=
retentionPeriod
*
24
*
60
*
60
*
1000
;
// [retentionPeriod] 日
long
fromTime
=
(
retentionPeriod
+
7
)
*
24
*
60
*
60
*
1000
;
// [retentionPeriod + 7] 日
// fromTime < file.lastModified() < toTime
if
(
file
.
lastModified
()
>
System
.
currentTimeMillis
()
-
fromTime
&&
file
.
lastModified
()
<
System
.
currentTimeMillis
()
-
toTime
)
{
return
true
;
}
// ファイルのサイズが5Mを超えている場合
if
(
file
.
lastModified
()
<
System
.
currentTimeMillis
()
-
fromTime
&&
file
.
length
()
>
5
*
1024
*
1024
)
{
return
true
;
}
return
false
;
}
private
void
log
(
String
level
,
String
tag
,
String
log
)
{
Date
date
=
new
Date
();
String
day
=
DateTimeUtil
.
toString
(
date
,
DateTimeFormat
.
MMdd_none
);
if
(
logPathFormat
!=
null
)
{
if
(
currentDay
==
null
||
!
currentDay
.
equals
(
day
))
{
File
dir
=
new
File
(
FileUtil
.
getParentPath
(
logPathFormat
));
if
(
dir
.
exists
())
{
File
[]
files
=
dir
.
listFiles
();
if
(
files
!=
null
)
{
for
(
File
file
:
files
)
{
// 同一ディレクトリの旧ファイル(retentionPeriod日前)をすべて削除する
// if (file.lastModified() < System.currentTimeMillis() - retentionPeriod * 24 * 60 * 60 * 1000) {
if
(
isDeletable
(
file
))
{
file
.
delete
();
}
}
}
}
currentDay
=
day
;
try
{
ps
=
new
PrintStream
(
new
FileOutputStream
(
String
.
format
(
logPathFormat
,
day
),
true
));
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
}
}
String
time
=
DateTimeUtil
.
toString
(
date
,
DateTimeFormat
.
MMddHHmmssSSS_hyphen
);
System
.
out
.
println
(
time
+
": ["
+
level
+
"] "
+
tag
+
"("
+
Thread
.
currentThread
().
getId
()
+
"): "
+
log
);
}
private
void
log
(
String
level
,
String
defaultLogName
,
String
log
,
Throwable
e
)
{
log
(
level
,
defaultLogName
,
log
);
e
.
printStackTrace
(
ps
);
}
@Override
protected
void
verbose
(
String
tag
,
String
log
)
{
log
(
"VERBOSE"
,
tag
,
log
);
}
@Override
protected
void
verbose
(
String
tag
,
String
log
,
Throwable
t
)
{
log
(
"VERBOSE"
,
tag
,
log
,
t
);
}
@Override
protected
void
debug
(
String
tag
,
String
log
)
{
log
(
"DEBUG"
,
tag
,
log
);
}
@Override
protected
void
debug
(
String
tag
,
String
log
,
Throwable
t
)
{
log
(
"DEBUG"
,
tag
,
log
,
t
);
}
@Override
protected
void
info
(
String
tag
,
String
log
)
{
log
(
"INFO"
,
tag
,
log
);
}
@Override
protected
void
info
(
String
tag
,
String
log
,
Throwable
t
)
{
log
(
"INFO"
,
tag
,
log
,
t
);
}
@Override
protected
void
warn
(
String
tag
,
String
log
)
{
log
(
"WARN"
,
tag
,
log
);
}
@Override
protected
void
warn
(
String
tag
,
String
log
,
Throwable
t
)
{
log
(
"WARN"
,
tag
,
log
,
t
);
}
@Override
protected
void
error
(
String
tag
,
String
log
)
{
log
(
"ERROR"
,
tag
,
log
);
}
@Override
protected
void
error
(
String
tag
,
String
log
,
Throwable
t
)
{
log
(
"ERROR"
,
tag
,
log
,
t
);
}
private
static
boolean
isLoggable
(
int
level
)
{
return
true
;
}
public
static
boolean
isVerboseEnabled
()
{
return
true
;
}
public
static
boolean
isDebugEnabled
()
{
return
true
;
}
public
static
boolean
isInfoEnabled
()
{
return
true
;
}
public
static
boolean
isWarnEnabled
()
{
return
true
;
}
public
static
boolean
isErrorEnabled
()
{
return
true
;
}
}
app/src/main/java/jp/odakyu/toiletsignage/logic/MainLogic.java
View file @
21083efb
...
@@ -17,6 +17,7 @@ import jp.odakyu.toiletsignage.constants.ToiletConstants;
...
@@ -17,6 +17,7 @@ import jp.odakyu.toiletsignage.constants.ToiletConstants;
import
jp.odakyu.toiletsignage.file.FileUtil
;
import
jp.odakyu.toiletsignage.file.FileUtil
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.json.USBToiletDefaultJson
;
import
jp.odakyu.toiletsignage.json.USBToiletDefaultJson
;
import
jp.odakyu.toiletsignage.log.Logger
;
/**
/**
* Created by agentec on 2017/12/08.
* Created by agentec on 2017/12/08.
...
@@ -46,14 +47,14 @@ public class MainLogic {
...
@@ -46,14 +47,14 @@ public class MainLogic {
for
(
String
directoryName:
rootStorageDirectory
)
{
for
(
String
directoryName:
rootStorageDirectory
)
{
String
jsonFilePath
=
directoryName
+
TOILET_INFO_JSON
;
String
jsonFilePath
=
directoryName
+
TOILET_INFO_JSON
;
Log
.
d
(
TAG
,
jsonFilePath
);
Log
ger
.
d
(
TAG
,
jsonFilePath
);
File
uspJsonFile
=
new
File
(
jsonFilePath
);
File
uspJsonFile
=
new
File
(
jsonFilePath
);
if
(
uspJsonFile
.
exists
()
&&
uspJsonFile
.
isFile
())
{
if
(
uspJsonFile
.
exists
()
&&
uspJsonFile
.
isFile
())
{
FileUtil
.
fileCopy
(
jsonFilePath
,
copyFilePath
);
FileUtil
.
fileCopy
(
jsonFilePath
,
copyFilePath
);
break
;
break
;
}
else
{
}
else
{
Log
.
w
(
TAG
,
"usb json file not exists = "
+
jsonFilePath
);
Log
ger
.
w
(
TAG
,
"usb json file not exists = "
+
jsonFilePath
);
}
}
}
}
...
@@ -80,7 +81,10 @@ public class MainLogic {
...
@@ -80,7 +81,10 @@ public class MainLogic {
}
else
{
}
else
{
return
ToiletConstants
.
VALUE_GET_USB_INFO_FAIL
;
return
ToiletConstants
.
VALUE_GET_USB_INFO_FAIL
;
}
}
}
else
{
return
ToiletConstants
.
VALUE_GET_USB_INFO_FAIL
;
}
}
return
ToiletConstants
.
VALUE_GET_USB_INFO_SUCCESS
;
return
ToiletConstants
.
VALUE_GET_USB_INFO_SUCCESS
;
}
}
...
@@ -95,7 +99,7 @@ public class MainLogic {
...
@@ -95,7 +99,7 @@ public class MainLogic {
if
(
file
!=
null
)
{
if
(
file
!=
null
)
{
int
index
=
file
.
getAbsolutePath
().
lastIndexOf
(
"/Android/data"
);
int
index
=
file
.
getAbsolutePath
().
lastIndexOf
(
"/Android/data"
);
if
(
index
<
0
)
{
if
(
index
<
0
)
{
Log
.
w
(
"AmazeFileUtils"
,
"Unexpected external file dir: "
+
file
.
getAbsolutePath
());
Log
ger
.
w
(
"AmazeFileUtils"
,
"Unexpected external file dir: "
+
file
.
getAbsolutePath
());
}
else
{
}
else
{
String
path
=
file
.
getAbsolutePath
().
substring
(
0
,
index
);
String
path
=
file
.
getAbsolutePath
().
substring
(
0
,
index
);
try
{
try
{
...
@@ -103,9 +107,8 @@ public class MainLogic {
...
@@ -103,9 +107,8 @@ public class MainLogic {
pathList
.
add
(
canonicalPath
);
pathList
.
add
(
canonicalPath
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// Keep non-canonical path.
// Keep non-canonical path.
Log
.
e
(
TAG
,
e
.
getLocalizedMessage
(),
e
);
Log
ger
.
e
(
TAG
,
e
.
getLocalizedMessage
(),
e
);
}
}
}
}
}
}
}
}
...
...
app/src/main/java/jp/odakyu/toiletsignage/task/UpdateToiletInfoTask.java
View file @
21083efb
...
@@ -16,6 +16,7 @@ import jp.odakyu.toiletsignage.constants.ToiletConstants;
...
@@ -16,6 +16,7 @@ import jp.odakyu.toiletsignage.constants.ToiletConstants;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.info.ToiletInfo
;
import
jp.odakyu.toiletsignage.json.ResultToiletJson
;
import
jp.odakyu.toiletsignage.json.ResultToiletJson
;
import
jp.odakyu.toiletsignage.json.USBToiletDefaultJson
;
import
jp.odakyu.toiletsignage.json.USBToiletDefaultJson
;
import
jp.odakyu.toiletsignage.log.Logger
;
/**
/**
* Created by agentec on 2017/12/11.
* Created by agentec on 2017/12/11.
...
@@ -37,7 +38,7 @@ public class UpdateToiletInfoTask extends TimerTask {
...
@@ -37,7 +38,7 @@ public class UpdateToiletInfoTask extends TimerTask {
*/
*/
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Log
.
i
(
TAG
,
"Thread Start"
);
Log
ger
.
i
(
TAG
,
"Thread Start"
);
boolean
isNetworkConnect
=
true
;
boolean
isNetworkConnect
=
true
;
//インターネット接続チェック
//インターネット接続チェック
if
(
isNetworkAvailable
(
applicationContext
))
{
if
(
isNetworkAvailable
(
applicationContext
))
{
...
@@ -47,11 +48,11 @@ public class UpdateToiletInfoTask extends TimerTask {
...
@@ -47,11 +48,11 @@ public class UpdateToiletInfoTask extends TimerTask {
try
{
try
{
String
jsonString
=
ToiletServerConnection
.
connectionToiletServer
(
toiletDefaultJson
.
getToiletId
());
String
jsonString
=
ToiletServerConnection
.
connectionToiletServer
(
toiletDefaultJson
.
getToiletId
());
if
(
jsonString
==
null
)
{
if
(
jsonString
==
null
)
{
Log
.
w
(
TAG
,
"json object null jsonString"
);
Log
ger
.
w
(
TAG
,
"json object null jsonString"
);
isError
=
true
;
isError
=
true
;
break
;
break
;
}
}
Log
.
d
(
TAG
,
"jsonString = "
+
jsonString
);
Log
ger
.
d
(
TAG
,
"jsonString = "
+
jsonString
);
JSONObject
jsonObject
=
new
JSONObject
(
jsonString
);
JSONObject
jsonObject
=
new
JSONObject
(
jsonString
);
ArrayList
<
ResultToiletJson
>
resultToiletJsonArray
=
new
ArrayList
<>();
ArrayList
<
ResultToiletJson
>
resultToiletJsonArray
=
new
ArrayList
<>();
...
@@ -63,7 +64,7 @@ public class UpdateToiletInfoTask extends TimerTask {
...
@@ -63,7 +64,7 @@ public class UpdateToiletInfoTask extends TimerTask {
ToiletInfo
.
getInstance
().
setResultToiletJsonMap
(
toiletDefaultJson
.
getToiletId
(),
resultToiletJsonArray
);
ToiletInfo
.
getInstance
().
setResultToiletJsonMap
(
toiletDefaultJson
.
getToiletId
(),
resultToiletJsonArray
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
e
.
getLocalizedMessage
(),
e
);
Log
ger
.
e
(
TAG
,
e
.
getLocalizedMessage
(),
e
);
isError
=
true
;
isError
=
true
;
break
;
break
;
}
}
...
@@ -84,7 +85,7 @@ public class UpdateToiletInfoTask extends TimerTask {
...
@@ -84,7 +85,7 @@ public class UpdateToiletInfoTask extends TimerTask {
intent
.
putExtra
(
ToiletConstants
.
KEY_NETWORK_CONNECT
,
isNetworkConnect
);
intent
.
putExtra
(
ToiletConstants
.
KEY_NETWORK_CONNECT
,
isNetworkConnect
);
applicationContext
.
sendBroadcast
(
intent
);
applicationContext
.
sendBroadcast
(
intent
);
Log
.
d
(
TAG
,
"Thread End"
);
Log
ger
.
d
(
TAG
,
"Thread End"
);
}
}
/**
/**
...
...
app/src/main/java/jp/odakyu/toiletsignage/util/DateTimeFormat.java
0 → 100644
View file @
21083efb
package
jp
.
odakyu
.
toiletsignage
.
util
;
/**
* 日付や時刻を表すフォーマットの集合です。
* @author Taejin Hong
* @version
*/
public
class
DateTimeFormat
{
/**
* 4桁の年を示します。"yyyy"
* @since 1.0.0
*/
public
static
final
String
yyyy
=
"yyyy"
;
/**
* 2桁の月を示します。"MM"
* @since 1.0.0
*/
public
static
final
String
MM
=
"MM"
;
/**
* 2桁の日を示します。"dd"
* @since 1.0.0
*/
public
static
final
String
dd
=
"dd"
;
/**
* 2桁の時を示します。"HH"
* @since 1.0.0
*/
public
static
final
String
HH
=
"HH"
;
/**
* 2桁の分を示します。"mm"
* @since 1.0.0
*/
public
static
final
String
mm
=
"mm"
;
/**
* 2桁の秒を示します。"ss"
* @since 1.0.0
*/
public
static
final
String
ss
=
"ss"
;
/**
* 3桁の秒を示します。"SSS"
* @since 1.0.0
*/
public
static
final
String
SSS
=
"SSS"
;
/**
* 日付を示します。"yyyymm"
* @since 1.0.0
*/
public
static
final
String
yyyyMM_none
=
"yyyymm"
;
/**
* 日付を示します。"yyyy/mm"
* @since 1.0.0
*/
public
static
final
String
yyyyMM_slash
=
"yyyy/mm"
;
/**
* 日付を示します。"yyyy-mm"
* @since 1.0.0
*/
public
static
final
String
yyyyMM_hyphen
=
"yyyy-mm"
;
/**
* 日付を示します。"yyyyMMdd"
* @since 1.0.0
*/
public
static
final
String
yyyyMMdd_none
=
"yyyyMMdd"
;
/**
* 日付を示します。"yyyy/MM/dd"
* @since 1.0.0
*/
public
static
final
String
yyyyMMdd_slash
=
"yyyy/MM/dd"
;
/**
* 日付を示します。"yyyy-MM-dd"
* @since 1.0.0
*/
public
static
final
String
yyyyMMdd_hyphen
=
"yyyy-MM-dd"
;
/**
* 日付を示します。"yyyy.MM.dd"
* @since 1.0.0
*/
public
static
final
String
yyyyMMdd_dot
=
"yyyy.MM.dd"
;
/**
* 日付を示します。"MMdd"
* @since 1.0.0
*/
public
static
final
String
MMdd_none
=
"MMdd"
;
/**
* 日付を示します。"MM/dd"
* @since 1.0.0
*/
public
static
final
String
MMdd_slash
=
"MM/dd"
;
/**
* 日付を示します。"MM-dd"
* @since 1.0.0
*/
public
static
final
String
MMdd_hyphen
=
"MM-dd"
;
/**
* 日付を示します。"MM-dd"
* @since 1.0.0
*/
public
static
final
String
MMddHHmm_hyphen
=
"MM-dd HH:mm"
;
/**
* 日付を示します。"yyyyMMddHH"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHH_none
=
"yyyyMMddHH"
;
/**
* 日付を示します。"yyyy/MM/dd HH"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHH_slash
=
"yyyy/MM/dd HH"
;
/**
* 日付を示します。"yyyy-MM-dd HH"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHH_hyphen
=
"yyyy-MM-dd HH"
;
/**
* 日付を示します。"yyyyMMddHH00"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHH00_none
=
"yyyyMMddHH00"
;
/**
* 日付を示します。"yyyy/MM/dd HH:00"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHH00_slash
=
"yyyy/MM/dd HH:00"
;
/**
* 日付を示します。"yyyy-MM-dd HH:00"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHH00_hyphen
=
"yyyy-MM-dd HH:00"
;
/**
* 日付を示します。"yyyyMMddHHmm"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmm_none
=
"yyyyMMddHHmm"
;
/**
* 日付を示します。"yyyy/MM/dd HH:mm"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmm_slash
=
"yyyy/MM/dd HH:mm"
;
/**
* 日付を示します。"yyyy-MM-dd HH:mm"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmm_hyphen
=
"yyyy-MM-dd HH:mm"
;
/**
* 日付を示します。"yyyyMMddHHmm00"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmm00_none
=
"yyyyMMddHHmm00"
;
/**
* 日付を示します。"yyyy/MM/dd HH:mm:00"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmm00_slash
=
"yyyy/MM/dd HH:mm:00"
;
/**
* 日付を示します。"yyyy-MM-dd HH:mm:00"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmm00_hyphen
=
"yyyy-MM-dd HH:mm:00"
;
/**
* 日付を示します。"yyyyMMddHHmmss"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss_none
=
"yyyyMMddHHmmss"
;
/**
* 日付を示します。"yyyy/MM/dd HH:mm:ss"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss_slash
=
"yyyy/MM/dd HH:mm:ss"
;
/**
* 日付を示します。"yyyy-MM-dd HH:mm:ss"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss_hyphen
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
MMddHHmmssSSS_hyphen
=
"MM-dd HH:mm:ss.SSS"
;
/**
* 日付を示します。"yyyyMMddHHmmss000"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss000_none
=
"yyyyMMddHHmmss000"
;
/**
* 日付を示します。"yyyy/MM/dd HH:mm:ss.000"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss000_slash
=
"yyyy/MM/dd HH:mm:ss.000"
;
/**
* 日付を示します。"yyyy-MM-dd HH:mm:ss.000"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss000_hyphen
=
"yyyy-MM-dd HH:mm:ss.000"
;
/**
* 日付を示します。"yyyyMMddHHmmssSSS"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmssSSS_none
=
"yyyyMMddHHmmssSSS"
;
/**
* 日付を示します。"yyyy/MM/dd HH:mm:ss.SSS"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmssSSS_slash
=
"yyyy/MM/dd HH:mm:ss.SSS"
;
/**
* 日付を示します。"yyyy-MM-dd HH:mm:ss.SSS"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmssSSS_hyphen
=
"yyyy-MM-dd HH:mm:ss.SSS"
;
/**
* 日付を示します。"yyyy-MM-dd HH:mm:ss"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmss_TZ
=
"yyyy-MM-dd'T'HH:mm:ss'Z'"
;
/**
* 日付を示します。"yyyy-MM-ddTHH:mm:ss.SSS"
* @since 1.0.0
*/
public
static
final
String
yyyyMMddHHmmssSSS_TZ
=
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
;
/**
* 日付を示します。 "EEE, dd MMM yyyy HH:mm:ss"
* @since 1.0.0
*/
public
static
final
String
ifModifiedSinceType
=
"EEE, dd MMM yyyy HH:mm:ss"
;
/**
* 時間を示します。"HHmm"
* @since 1.0.0
*/
public
static
final
String
HHmm_none
=
"HHmm"
;
/**
* 時間を示します。"HH:mm"
* @since 1.0.0
*/
public
static
final
String
HHmm_colon
=
"HH:mm"
;
/**
* 時間を示します。"HHmmss"
* @since 1.0.0
*/
public
static
final
String
HHmmss_none
=
"HHmmss"
;
/**
* 時間を示します。"HH:mm:ss"
* @since 1.0.0
*/
public
static
final
String
HHmmss_colon
=
"HH:mm:ss"
;
/**
* 時間を示します。"HHmmssSSS"
* @since 1.0.0
*/
public
static
final
String
HHmmssSSS_none
=
"HHmmssSSS"
;
/**
* 時間を示します。"HH:mm:ss.SSS"
* @since 1.0.0
*/
public
static
final
String
HHmmssSSS_colon
=
"HH:mm:ss.SSS"
;
}
app/src/main/java/jp/odakyu/toiletsignage/util/DateTimeUtil.java
0 → 100644
View file @
21083efb
This diff is collapsed.
Click to expand it.
app/src/main/java/jp/odakyu/toiletsignage/util/FileUtil.java
0 → 100644
View file @
21083efb
This diff is collapsed.
Click to expand it.
app/src/main/java/jp/odakyu/toiletsignage/util/NumericUtil.java
0 → 100644
View file @
21083efb
package
jp
.
odakyu
.
toiletsignage
.
util
;
/**
* 数字型を扱う機能を提供します。
* @author Taejin Hong
* @version 1.0.0
*/
public
class
NumericUtil
{
/**
* 指定したクラスが数字型かどうかを示します。
* @param type テストするクラスです。
* @return typeがBigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short又はbyte, double, float, int, long, shortのクラスだとtrueを返します。
* @see Number
* @since 1.0.0
*/
public
static
boolean
isNumberType
(
Class
<?>
type
)
{
boolean
isNumber
=
false
;
if
(
type
!=
null
)
{
if
((
type
.
getSuperclass
()
!=
null
&&
type
.
getSuperclass
().
equals
(
Number
.
class
))
||
type
.
equals
(
int
.
class
)
||
type
.
equals
(
long
.
class
)
||
type
.
equals
(
double
.
class
)
||
type
.
equals
(
float
.
class
)
||
type
.
equals
(
byte
.
class
)
||
type
.
equals
(
short
.
class
))
{
isNumber
=
true
;
}
}
return
isNumber
;
}
/**
* 指定した値が数字かどうかを示します。
* @param value テストする値です。
* @return valueが数字であればtrueを返します。
* @since 1.0.0
*/
@Deprecated
public
static
boolean
isNumber
(
Object
value
)
{
boolean
isNumber
=
false
;
if
(
value
!=
null
)
{
isNumber
=
(
value
instanceof
Number
||
isNumberType
(
value
.
getClass
()));
}
return
isNumber
;
}
/**
* 指定した文字列をint型に変換します。
* @param s 数字に変換する文字列です。
* @return 変換した数字を返します。文字列が数字に変換することができない場合、0を返します。
* @since 1.0.0
*/
public
static
int
parseInt
(
String
s
)
{
return
parseInt
(
s
,
0
);
}
/**
* 指定した文字列をint型に変換します。
* @param s 数字に変換する文字列です。
* @param defaultValue 文字列が数字に変換することができない場合、使用するデフォルト値です。
* @return 変換した数字を返します。文字列が数字に変換することができない場合、defaultValueを返します。
* @since 1.0.0
*/
public
static
int
parseInt
(
String
s
,
int
defaultValue
)
{
int
result
=
defaultValue
;
if
(!
StringUtil
.
isNullOrWhiteSpace
(
s
))
{
try
{
result
=
Integer
.
parseInt
(
s
);
}
catch
(
Exception
e
)
{
}
}
return
result
;
}
/**
* {@link Integer} 型をint型に変換します。
* @param n 変換する数字です。
* @return 変換した数字を返します。nがnullである場合、0を返します。
* @since 1.0.0
*/
public
static
int
parseInt
(
Integer
n
)
{
return
parseInt
(
n
,
0
);
}
/**
* {@link Integer} 型をint型に変換します。
* @param n 変換する数字です。
* @param defaultValue nがnullである場合、使用するデフォルト値です。
* @return 変換した数字を返します。nがnullである場合、defaultValueを返します。
* @since 1.0.0
*/
public
static
int
parseInt
(
Integer
n
,
int
defaultValue
)
{
if
(
n
!=
null
)
{
return
n
;
}
else
{
return
defaultValue
;
}
}
/**
* 指定した文字列をlong型に変換します。
* @param s 数字に変換する文字列です。
* @return 変換した数字を返します。文字列が数字に変換することができない場合、0を返します。
* @since 1.0.0
*/
public
static
long
parseLong
(
String
s
)
{
return
parseLong
(
s
,
0
);
}
/**
* 指定した文字列をlong型に変換します。
* @param s 数字に変換する文字列です。
* @param defaultValue 文字列が数字に変換することができない場合、使用するデフォルト値です。
* @return 変換した数字を返します。文字列が数字に変換することができない場合、defaultValueを返します。
* @since 1.0.0
*/
public
static
long
parseLong
(
String
s
,
int
defaultValue
)
{
long
result
=
defaultValue
;
if
(!
StringUtil
.
isNullOrWhiteSpace
(
s
))
{
try
{
result
=
Long
.
parseLong
(
s
);
}
catch
(
Exception
e
)
{
}
}
return
result
;
}
/**
* {@link Long} 型をint型に変換します。
* @param n 変換する数字です。
* @return 変換した数字を返します。nがnullである場合、0を返します。
* @since 1.0.0
*/
public
static
long
parseInt
(
Long
n
)
{
return
parseInt
(
n
,
0
);
}
/**
* {@link Long} 型をint型に変換します。
* @param n 変換する数字です。
* @param defaultValue nがnullである場合、使用するデフォルト値です。
* @return 変換した数字を返します。nがnullである場合、defaultValueを返します。
* @since 1.0.0
*/
public
static
long
parseInt
(
Long
n
,
int
defaultValue
)
{
if
(
n
!=
null
)
{
return
n
;
}
else
{
return
defaultValue
;
}
}
/**
* {@link Boolean} 型をint型に変換します。
* @param b 変換する値です。
* @return 変換した数字を返します。bがnullである場合、0を返します。
* @since 1.0.0
*/
public
static
int
parseInt
(
Boolean
b
)
{
if
(
b
!=
null
)
{
return
(
b
?
1
:
0
);
}
else
{
return
0
;
}
}
/**
* 指定した文字列をshort型に変換します。
* @param s 数字に変換する文字列です。
* @return 変換した数字を返します。文字列が数字に変換することができない場合、0を返します。
* @since 1.0.0
*/
public
static
short
parseShort
(
String
s
)
{
return
parseShort
(
s
,
(
short
)
0
);
}
/**
* 指定した文字列をshort型に変換します。
* @param s 数字に変換する文字列です。
* @param defaultValue 文字列が数字に変換することができない場合、使用するデフォルト値です。
* @return 変換した数字を返します。文字列が数字に変換することができない場合、defaultValueを返します。
* @since 1.0.0
*/
public
static
short
parseShort
(
String
s
,
short
defaultValue
)
{
short
result
=
defaultValue
;
if
(!
StringUtil
.
isNullOrWhiteSpace
(
s
))
{
try
{
result
=
Short
.
parseShort
(
s
);
}
catch
(
Exception
e
)
{
}
}
return
result
;
}
/**
* {@link Short} 型をshort型に変換します。
* @param n 変換する数字です。
* @return 変換した数字を返します。nがnullである場合、0を返します。
* @since 1.0.0
*/
public
static
short
parseShort
(
Short
n
)
{
return
parseShort
(
n
,
(
short
)
0
);
}
/**
* {@link Short} 型をshort型に変換します。
* @param n 変換する数字です。
* @param defaultValue nがnullである場合、使用するデフォルト値です。
* @return 変換した数字を返します。nがnullである場合、defaultValueを返します。
* @since 1.0.0
*/
public
static
short
parseShort
(
Short
n
,
short
defaultValue
)
{
if
(
n
!=
null
)
{
return
n
;
}
else
{
return
defaultValue
;
}
}
}
app/src/main/java/jp/odakyu/toiletsignage/util/StringUtil.java
0 → 100644
View file @
21083efb
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/activity_signage_1.xml
View file @
21083efb
...
@@ -105,7 +105,7 @@
...
@@ -105,7 +105,7 @@
android:id=
"@+id/vacantTitleENTextView"
android:id=
"@+id/vacantTitleENTextView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/
total
_en"
android:text=
"@string/
vacant
_en"
android:textAlignment=
"center"
android:textAlignment=
"center"
android:textColor=
"#746661"
android:textColor=
"#746661"
android:textSize=
"30sp"
android:textSize=
"30sp"
...
...
app/src/main/res/layout/activity_signage_3.xml
View file @
21083efb
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
<View
<View
android:id=
"@+id/separator"
android:id=
"@+id/separator"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
3
dip"
android:layout_height=
"
4
dip"
android:layout_marginEnd=
"50dp"
android:layout_marginEnd=
"50dp"
android:layout_marginStart=
"50dp"
android:layout_marginStart=
"50dp"
...
@@ -209,6 +209,7 @@
...
@@ -209,6 +209,7 @@
android:layout_marginBottom=
"1dp"
android:layout_marginBottom=
"1dp"
android:layout_marginTop=
"20dp"
android:layout_marginTop=
"20dp"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:paddingEnd=
"60dp"
android:text=
"@string/near_toilet_info_jp"
android:text=
"@string/near_toilet_info_jp"
android:textAlignment=
"textEnd"
android:textAlignment=
"textEnd"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
...
@@ -222,16 +223,17 @@
...
@@ -222,16 +223,17 @@
android:layout_marginBottom=
"1dp"
android:layout_marginBottom=
"1dp"
android:layout_marginTop=
"20dp"
android:layout_marginTop=
"20dp"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:paddingStart=
"10dp"
android:text=
"@string/near_toilet_info_en"
android:text=
"@string/near_toilet_info_en"
android:textAlignment=
"textStart"
android:textAlignment=
"textStart"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
android:textSize=
"3
5
sp"
/>
android:textSize=
"3
7
sp"
/>
</LinearLayout>
</LinearLayout>
<View
<View
android:id=
"@+id/separator3"
android:id=
"@+id/separator3"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
3
dip"
android:layout_height=
"
4
dip"
android:layout_marginEnd=
"50dp"
android:layout_marginEnd=
"50dp"
android:layout_marginStart=
"50dp"
android:layout_marginStart=
"50dp"
android:background=
"#FFFFFF"
/>
android:background=
"#FFFFFF"
/>
...
@@ -265,8 +267,7 @@
...
@@ -265,8 +267,7 @@
android:textAlignment=
"center"
android:textAlignment=
"center"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
android:textSize=
"40sp"
android:textSize=
"40sp"
android:textStyle=
"bold"
android:textStyle=
"bold"
/>
/>
<TextView
<TextView
android:id=
"@+id/leftGateNameENTextView"
android:id=
"@+id/leftGateNameENTextView"
...
@@ -291,11 +292,11 @@
...
@@ -291,11 +292,11 @@
<View
<View
android:id=
"@+id/separator4"
android:id=
"@+id/separator4"
android:layout_width=
"
3
dip"
android:layout_width=
"
4
dip"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginStart=
"
1
0dp"
android:layout_marginStart=
"
2
0dp"
android:layout_marginTop=
"1
5
dp"
android:layout_marginTop=
"1
8
dp"
android:layout_marginBottom=
"1
5
dp"
android:layout_marginBottom=
"1
8
dp"
android:background=
"#FFFFFF"
/>
android:background=
"#FFFFFF"
/>
</LinearLayout>
</LinearLayout>
...
@@ -317,6 +318,7 @@
...
@@ -317,6 +318,7 @@
android:id=
"@+id/rightGateNameJPTextView"
android:id=
"@+id/rightGateNameJPTextView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"20dp"
android:ellipsize=
"end"
android:ellipsize=
"end"
android:singleLine=
"true"
android:singleLine=
"true"
android:maxLines=
"1"
android:maxLines=
"1"
...
@@ -330,6 +332,7 @@
...
@@ -330,6 +332,7 @@
android:id=
"@+id/rightGateNameENTextView"
android:id=
"@+id/rightGateNameENTextView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"20dp"
android:ellipsize=
"end"
android:ellipsize=
"end"
android:singleLine=
"true"
android:singleLine=
"true"
android:text=
"@string/right_toilet_info_en"
android:text=
"@string/right_toilet_info_en"
...
@@ -343,6 +346,7 @@
...
@@ -343,6 +346,7 @@
android:id=
"@+id/rightStatusIconImageView"
android:id=
"@+id/rightStatusIconImageView"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"50dp"
android:layout_marginEnd=
"50dp"
android:layout_marginTop=
"22dp"
android:layout_marginTop=
"22dp"
app:srcCompat=
"@drawable/icon_full_sub"
/>
app:srcCompat=
"@drawable/icon_full_sub"
/>
...
...
app/src/main/res/values/strings.xml
View file @
21083efb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<string
name=
"total_jp"
>
総数
</string>
<string
name=
"total_jp"
>
総数
</string>
<string
name=
"total_en"
>
TOTAL
</string>
<string
name=
"total_en"
>
TOTAL
</string>
<string
name=
"near_toilet_info_jp"
>
お近くのトイレ情報
</string>
<string
name=
"near_toilet_info_jp"
>
お近くのトイレ情報
</string>
<string
name=
"near_toilet_info_en"
>
Other Toilets Nearby
</string>
<string
name=
"near_toilet_info_en"
>
Other Toilets Nearby
</string>
<string
name=
"left_toilet_info_jp"
>
西口地下改札外
</string>
<string
name=
"left_toilet_info_jp"
>
西口地下改札外
</string>
<string
name=
"left_toilet_info_en"
>
The West Underground Gate(Outside)
</string>
<string
name=
"left_toilet_info_en"
>
The West Underground Gate(Outside)
</string>
...
...
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