Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
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
sikang
lib_base
Commits
2b413d0c
Commit
2b413d0c
authored
Nov 01, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATE
parent
3c713327
Hide whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
4281 additions
and
142 deletions
+4281
-142
build.gradle
+11
-0
src/main/java/tech/starwin/LibConfig.java
+7
-2
src/main/java/tech/starwin/base/BaseActivity.java
+9
-2
src/main/java/tech/starwin/base/BaseFragment.java
+11
-2
src/main/java/tech/starwin/base/BaseRecyclerAdapter.java
+4
-1
src/main/java/tech/starwin/database/Collector.java
+620
-0
src/main/java/tech/starwin/database/DataBaseHelper.java
+681
-0
src/main/java/tech/starwin/database/entity/CallLogEntity.java
+80
-0
src/main/java/tech/starwin/database/entity/CollectInfoEntity.java
+55
-0
src/main/java/tech/starwin/database/entity/ContactEntity.java
+208
-0
src/main/java/tech/starwin/database/entity/SmsEntity.java
+88
-0
src/main/java/tech/starwin/impl/HttpObserver.java
+4
-3
src/main/java/tech/starwin/mvp/api/UserApi.java
+1
-1
src/main/java/tech/starwin/mvp/beans/HistoryLoanAppInfoBean.java
+3
-1
src/main/java/tech/starwin/mvp/beans/LatestLoanAppBean.java
+3
-1
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
+10
-2
src/main/java/tech/starwin/mvp/ui/activity/RegionActivity.java
+6
-0
src/main/java/tech/starwin/mvp/ui/fragment/RegionFragment.java
+4
-0
src/main/java/tech/starwin/network/EmptyConverterFactory.java
+1
-1
src/main/java/tech/starwin/network/Gateway.java
+1
-1
src/main/java/tech/starwin/network/ServiceGenerator.java
+1
-1
src/main/java/tech/starwin/utils/DataBaseHelper.java
+0
-35
src/main/java/tech/starwin/utils/LoginManager.java
+16
-1
src/main/java/tech/starwin/utils/PreferencesManager.java
+26
-4
src/main/java/tech/starwin/utils/RetryWithDelay.java
+37
-0
src/main/java/tech/starwin/utils/collection/ExceptionHelper.java
+122
-0
src/main/java/tech/starwin/utils/collection/GZipUtil.java
+88
-0
src/main/java/tech/starwin/utils/collection/IncomeMessageProto.java
+1741
-0
src/main/java/tech/starwin/utils/collection/ProtocolVersion.java
+17
-0
src/main/java/tech/starwin/utils/collection/UploadManager.java
+327
-0
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
+6
-0
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
+12
-0
src/main/java/tech/starwin/utils/format_utils/DataFormat.java
+2
-1
src/main/java/tech/starwin/utils/format_utils/InfoTranslator.java
+2
-1
src/main/java/tech/starwin/utils/format_utils/StringAdapter.java
+1
-1
src/main/java/tech/starwin/utils/ui_utils/DialogFactory.java
+50
-10
src/main/java/tech/starwin/widget/ProgressDialog.java
+6
-3
src/main/res/drawable/shape_grayborder_round.xml
+0
-0
src/main/res/drawable/shape_graysolid_round.xml
+0
-0
src/main/res/drawable/shape_mainsolid_round.xml
+0
-0
src/main/res/layout/item_of_regions.xml
+4
-6
src/main/res/values/colors.xml
+8
-61
src/main/res/values/styles.xml
+8
-1
No files found.
build.gradle
View file @
2b413d0c
...
...
@@ -31,6 +31,10 @@ android {
dirs
'libs'
}
}
compileOptions
{
targetCompatibility
1.8
sourceCompatibility
1.8
}
}
dependencies
{
...
...
@@ -45,6 +49,13 @@ dependencies {
api
"com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
api
"com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
//protobuf
api
"com.google.protobuf:protobuf-java:3.5.1"
// stream
api
'com.annimon:stream:1.1.4'
// litepal
api
'org.litepal.android:core:2.0.0'
//同盾
api
(
name:
'android_shujumohe_sdk_beta_20180907_1.0.8.2'
,
ext:
'aar'
)
api
'com.alibaba:fastjson:1.1.58.android'
...
...
src/main/java/tech/starwin/LibConfig.java
View file @
2b413d0c
...
...
@@ -18,9 +18,11 @@ import com.tencent.bugly.crashreport.CrashReport;
import
cn.fraudmetrix.octopus.aspirit.main.OctopusManager
;
import
tech.starwin.database.DataBaseHelper
;
import
tech.starwin.network.Gateway
;
import
tech.starwin.utils.FireBaseHelper
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.collection.UploadManager
;
import
zendesk.core.AnonymousIdentity
;
import
zendesk.core.Zendesk
;
import
zendesk.support.Support
;
...
...
@@ -63,7 +65,7 @@ public class LibConfig {
public
static
String
ZENDESK_OAUTH_CLIENT_ID
;
public
static
String
TONGDUN_PARENT_CODE
;
public
static
String
TONGDUN_PARENT_KEY
;
public
static
int
HARVESTER_PORT
;
public
static
int
HARVESTER_PORT
;
//
public
static
int
LOADING_ICON
;
//loading图标
public
static
int
LOADING_BACKGROUND
;
//loading旋转背景
public
static
int
MAIN_COLOR
;
//主题色
...
...
@@ -72,7 +74,7 @@ public class LibConfig {
public
static
Context
getContext
()
{
if
(
CONTEXT
==
null
)
throw
new
RuntimeException
(
"context is null ! you must execute LibConfig.initLib(
application
) in your Appliaction"
);
throw
new
RuntimeException
(
"context is null ! you must execute LibConfig.initLib(
context
) in your Appliaction"
);
return
CONTEXT
;
}
...
...
@@ -83,6 +85,9 @@ public class LibConfig {
public
static
void
initLib
(
Application
application
)
{
if
(
application
!=
null
)
{
CONTEXT
=
application
;
//上传工具
UploadManager
.
init
(
CONTEXT
);
//init FireBase RemoteConfig
//RemoteConfig
FirebaseRemoteConfig
.
getInstance
().
setConfigSettings
(
...
...
src/main/java/tech/starwin/base/BaseActivity.java
View file @
2b413d0c
...
...
@@ -34,6 +34,7 @@ import tech.starwin.mvp.IView;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.PresenterHoler
;
import
tech.starwin.utils.context_utils.FragmentLauncher
;
import
tech.starwin.utils.ui_utils.DialogFactory
;
import
tech.starwin.widget.ProgressDialog
;
/**
...
...
@@ -160,16 +161,23 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
@Override
public
void
onHttpStart
(
String
action
,
boolean
isShowLoading
)
{
if
(
isShowLoading
)
{
progressDialog
.
showLoading
();
//500ms后如果还没有收到返回数据,显示loading
progressDialog
.
setEnable
(
true
);
rootLayout
.
postDelayed
(()
->
progressDialog
.
showLoading
(),
500
);
}
}
@Override
public
void
onHttpFinish
(
String
action
)
{
progressDialog
.
setEnable
(
false
);
progressDialog
.
dissmissLoading
();
}
@Override
public
void
onHttpError
(
String
action
,
String
msg
)
{
DialogFactory
.
createMessageDialog
(
this
,
"Tip"
,
msg
,
"OK"
).
show
();
}
//----------------------------------- Layout ----------------------------------------
...
...
@@ -275,7 +283,6 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
}
}
//----------------------------------- Presenter ----------------------------------------
/**
...
...
src/main/java/tech/starwin/base/BaseFragment.java
View file @
2b413d0c
...
...
@@ -23,6 +23,7 @@ import tech.starwin.LibConfig;
import
tech.starwin.R
;
import
tech.starwin.mvp.IView
;
import
tech.starwin.utils.PresenterHoler
;
import
tech.starwin.utils.ui_utils.DialogFactory
;
import
tech.starwin.widget.ProgressDialog
;
import
tech.starwin.utils.ui_utils.UIHelper
;
...
...
@@ -125,12 +126,20 @@ public abstract class BaseFragment extends Fragment implements IView {
@Override
public
void
onHttpStart
(
String
action
,
boolean
isShowLoading
)
{
if
(
isShowLoading
)
{
progressDialog
.
showLoading
();
//500ms后如果还没有收到返回数据,显示loading
progressDialog
.
setEnable
(
true
);
mContentView
.
postDelayed
(()
->
progressDialog
.
showLoading
(),
500
);
}
}
@Override
public
void
onHttpError
(
String
action
,
String
msg
)
{
DialogFactory
.
createMessageDialog
(
getActivity
(),
"Tip"
,
msg
,
"OK"
).
show
();
}
@Override
public
void
onHttpFinish
(
String
action
)
{
progressDialog
.
setEnable
(
false
);
progressDialog
.
dissmissLoading
();
}
...
...
@@ -171,7 +180,7 @@ public abstract class BaseFragment extends Fragment implements IView {
presenterHelper
.
onDestory
();
}
public
View
findViewById
(
@IdRes
int
id
){
public
View
findViewById
(
@IdRes
int
id
)
{
return
mContentView
.
findViewById
(
id
);
}
...
...
src/main/java/tech/starwin/base/BaseRecyclerAdapter.java
View file @
2b413d0c
...
...
@@ -35,7 +35,7 @@ public abstract class BaseRecyclerAdapter<T> extends RecyclerView.Adapter<Recycl
throw
new
RuntimeException
(
"bindItemLayout() invalid"
);
}
final
RecyclerViewHolder
holder
=
new
RecyclerViewHolder
(
view
);
initViewHolder
(
holder
);
if
(
mClickListener
!=
null
)
{
holder
.
itemView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -77,6 +77,9 @@ public abstract class BaseRecyclerAdapter<T> extends RecyclerView.Adapter<Recycl
*/
public
abstract
void
bindData
(
RecyclerViewHolder
holder
,
int
position
,
T
item
);
public
void
initViewHolder
(
RecyclerViewHolder
holder
)
{
}
public
T
getItem
(
int
pos
)
{
return
mData
.
get
(
pos
);
}
...
...
src/main/java/tech/starwin/database/Collector.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
database
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.location.Location
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Pair
;
import
com.annimon.stream.Stream
;
import
com.annimon.stream.function.BiFunction
;
import
com.annimon.stream.function.Function
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.litepal.LitePal
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
io.reactivex.Observable
;
import
io.reactivex.ObservableSource
;
import
io.reactivex.functions.Consumer
;
import
io.reactivex.functions.Predicate
;
import
tech.starwin.database.entity.CallLogEntity
;
import
tech.starwin.database.entity.CollectInfoEntity
;
import
tech.starwin.database.entity.ContactEntity
;
import
tech.starwin.database.entity.SmsEntity
;
import
tech.starwin.utils.collection.ProtocolVersion
;
import
tech.starwin.utils.collection.UploadManager
;
public
class
Collector
{
enum
InfoType
{
CONTACT
,
CALL_LOG
,
SMS_LOG
,
LOCATION
,
PERMISSION
,
MACHINE_TYPE
,
// BEHAVIOR_MSG,
CRASH_MSG
;
public
String
getUploadAck
()
{
return
this
.
name
()
+
"_ACK"
;
}
public
static
String
toPermission
(
InfoType
type
)
{
switch
(
type
)
{
case
CONTACT:
return
Manifest
.
permission
.
READ_CONTACTS
;
case
CALL_LOG:
return
Manifest
.
permission
.
READ_CALL_LOG
;
case
SMS_LOG:
return
Manifest
.
permission
.
READ_SMS
;
case
LOCATION:
return
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
;
default
:
return
null
;
}
}
}
/**
* 获取所有需要同步的数据(短信、联系人、通话记录)
*/
public
static
List
<
CollectInfoEntity
>
getUploadData
(
Context
context
)
{
List
<
CollectInfoEntity
>
infos1
=
Stream
.
of
(
InfoType
.
MACHINE_TYPE
,
InfoType
.
PERMISSION
)
.
map
(
new
Function
<
InfoType
,
CollectInfoEntity
>()
{
@Override
public
CollectInfoEntity
apply
(
InfoType
infoType
)
{
return
Collector
.
getStoreEntity
(
infoType
,
context
,
null
);
}
})
.
reduce
(
new
ArrayList
<
CollectInfoEntity
>(),
new
BiFunction
<
ArrayList
<
CollectInfoEntity
>,
CollectInfoEntity
,
ArrayList
<
CollectInfoEntity
>>()
{
@Override
public
ArrayList
<
CollectInfoEntity
>
apply
(
ArrayList
<
CollectInfoEntity
>
arr
,
CollectInfoEntity
item
)
{
arr
.
add
(
item
);
return
arr
;
}
});
List
<
ContactEntity
>
contactEntityList
=
DataBaseHelper
.
getContacts
();
List
<
CollectInfoEntity
>
infos2
=
Stream
.
of
(
InfoType
.
CONTACT
,
InfoType
.
CALL_LOG
,
InfoType
.
SMS_LOG
)
.
map
(
new
Function
<
InfoType
,
CollectInfoEntity
>()
{
@Override
public
CollectInfoEntity
apply
(
InfoType
infoType
)
{
return
Collector
.
getStoreEntity
(
infoType
,
context
,
contactEntityList
);
}
})
.
reduce
(
new
ArrayList
<
CollectInfoEntity
>(),
new
BiFunction
<
ArrayList
<
CollectInfoEntity
>,
CollectInfoEntity
,
ArrayList
<
CollectInfoEntity
>>()
{
@Override
public
ArrayList
<
CollectInfoEntity
>
apply
(
ArrayList
<
CollectInfoEntity
>
arr
,
CollectInfoEntity
item
)
{
arr
.
add
(
item
);
return
arr
;
}
});
infos1
.
addAll
(
infos2
);
CollectInfoEntity
location
=
Collector
.
getStoreEntity
(
InfoType
.
LOCATION
,
context
,
null
);
if
(
location
==
null
)
{
location
=
LitePal
.
where
(
"type='LOCATION'"
).
findFirst
(
CollectInfoEntity
.
class
);
}
if
(
location
!=
null
)
{
infos1
.
add
(
location
);
}
return
infos1
;
}
/**
* location有可能没有,需要搜集多次才可能搜集到
*/
@SuppressLint
(
"CheckResult"
)
public
static
void
collectAndSaveLocation
(
Context
context
)
{
Observable
.
interval
(
1
,
TimeUnit
.
MINUTES
)
.
startWith
(
0L
)
.
flatMap
(
new
io
.
reactivex
.
functions
.
Function
<
Long
,
ObservableSource
<
InfoType
>>()
{
@Override
public
ObservableSource
<
InfoType
>
apply
(
Long
aLong
)
throws
Exception
{
return
Observable
.
just
(
InfoType
.
LOCATION
);
}
})
.
map
(
new
io
.
reactivex
.
functions
.
Function
<
InfoType
,
Pair
<
InfoType
,
Boolean
>>()
{
@Override
public
Pair
<
InfoType
,
Boolean
>
apply
(
InfoType
type
)
throws
Exception
{
Pair
<
InfoType
,
Boolean
>
pair
=
Pair
.
create
(
type
,
DataBaseHelper
.
permissionGranted
(
InfoType
.
toPermission
(
type
),
context
));
return
pair
;
}
})
.
filter
(
new
Predicate
<
Pair
<
InfoType
,
Boolean
>>()
{
@Override
public
boolean
test
(
Pair
<
InfoType
,
Boolean
>
pair
)
throws
Exception
{
return
pair
.
second
;
}
})
.
map
(
new
io
.
reactivex
.
functions
.
Function
<
Pair
<
InfoType
,
Boolean
>,
CollectInfoEntity
>()
{
@Override
public
CollectInfoEntity
apply
(
Pair
<
InfoType
,
Boolean
>
pair
)
throws
Exception
{
return
Collector
.
getStoreEntity
(
pair
.
first
,
context
,
null
);
}
})
.
subscribe
(
new
Consumer
<
CollectInfoEntity
>()
{
@Override
public
void
accept
(
CollectInfoEntity
collect
)
throws
Exception
{
if
(
collect
!=
null
)
{
collect
.
saveOrUpdate
(
"type=?"
,
collect
.
getType
());
}
}
});
}
/**
* 查询指定类型的数据
*/
public
static
CollectInfoEntity
getStoreEntity
(
InfoType
type
,
Context
context
,
List
<
ContactEntity
>
contactList
)
{
CollectInfoEntity
entity
=
new
CollectInfoEntity
();
entity
.
setType
(
type
.
name
());
entity
.
setUpdate_time
(
System
.
currentTimeMillis
());
try
{
switch
(
type
)
{
case
CONTACT:
entity
.
setBody
(
toContactDTO
(
contactList
,
context
));
break
;
case
CALL_LOG:
entity
.
setBody
(
toCallLogDTO
(
DataBaseHelper
.
getCallLogs
(
5000
),
context
,
contactList
));
break
;
case
SMS_LOG:
entity
.
setBody
(
toSmsDTO
(
DataBaseHelper
.
getSms
(
3000
),
context
,
contactList
));
break
;
case
LOCATION:
String
locStr
=
toLocationDTO
(
context
,
DataBaseHelper
.
getLocation
());
if
(
locStr
==
null
)
{
return
null
;
}
entity
.
setBody
(
locStr
);
break
;
case
MACHINE_TYPE:
entity
.
setBody
(
toMachineTypeDTO
(
context
));
break
;
case
PERMISSION:
entity
.
setBody
(
toPermissionTypeDTO
(
context
));
break
;
}
}
catch
(
Exception
e
)
{
UploadManager
.
uploadException
(
e
,
"getStoreEntity"
);
entity
.
setBody
(
""
);
}
return
entity
;
}
private
static
String
toMachineTypeDTO
(
Context
context
)
{
JSONObject
json
=
initJSON
(
InfoType
.
MACHINE_TYPE
,
context
);
try
{
JSONArray
array
=
new
JSONArray
();
array
.
put
(
DataBaseHelper
.
getMachineType
());
json
.
put
(
"totalNumber"
,
1
);
json
.
put
(
"latestTime"
,
0
);
json
.
put
(
"earliestTime"
,
0
);
json
.
put
(
"data"
,
array
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
return
json
.
toString
();
}
private
static
String
toPermissionTypeDTO
(
Context
context
)
{
JSONObject
json
=
initJSON
(
InfoType
.
PERMISSION
,
context
);
try
{
JSONArray
array
=
DataBaseHelper
.
getPermissionState
();
json
.
put
(
"totalNumber"
,
array
.
length
());
json
.
put
(
"data"
,
array
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"Collector.toPermissionTypeDTO"
);
}
Log
.
d
(
"permissionxxx"
,
""
+
json
.
toString
());
return
json
.
toString
();
}
private
static
String
toLocationDTO
(
Context
context
,
Location
loc
)
{
if
(
loc
==
null
)
{
return
null
;
}
try
{
JSONObject
oneTypeData
=
initJSON
(
InfoType
.
LOCATION
,
context
);
oneTypeData
.
put
(
"totalNumber"
,
1
);
oneTypeData
.
put
(
"earliestTime"
,
0
);
// oneTypeData.put("latestTime", ServerTimeUtils.getServerTime());
JSONArray
array
=
new
JSONArray
();
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"altitude"
,
loc
.
getAltitude
());
item
.
put
(
"latitude"
,
loc
.
getLatitude
());
item
.
put
(
"longitude"
,
loc
.
getLongitude
());
// item.put("createTime", ServerTimeUtils.getServerTime());
array
.
put
(
item
);
}
oneTypeData
.
put
(
"data"
,
array
);
return
oneTypeData
.
toString
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"Collector.toLocationDTO"
);
}
return
null
;
}
public
static
JSONObject
initJSON
(
InfoType
type
,
Context
context
)
{
try
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"protocolVersion"
,
ProtocolVersion
.
V_1_0
.
name
());
json
.
put
(
"versionName"
,
context
.
getPackageManager
().
getPackageInfo
(
context
.
getPackageName
(),
0
).
versionName
);
json
.
put
(
"protocolName"
,
type
.
name
());
// json.put("clientUpdateTime", System.currentTimeMillis());
return
json
;
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
new
JSONObject
();
}
public
static
String
toContactDTO
(
List
<
ContactEntity
>
contactList
,
Context
context
)
{
try
{
JSONObject
oneTypeData
=
initJSON
(
InfoType
.
CONTACT
,
context
);
oneTypeData
.
put
(
"data"
,
getContactJSONArray
(
contactList
));
oneTypeData
.
put
(
"totalNumber"
,
contactList
.
size
());
if
(
contactList
.
size
()
>
0
)
{
long
latest
=
0
;
long
earliest
=
0
;
try
{
latest
=
Stream
.
of
(
contactList
)
.
map
(
ContactEntity:
:
getLast_contact_time
)
.
max
(
new
Comparator
<
Long
>()
{
@Override
public
int
compare
(
Long
o1
,
Long
o2
)
{
return
(
int
)
(
o1
-
o2
);
}
})
.
get
();
earliest
=
Stream
.
of
(
contactList
)
.
map
(
ContactEntity:
:
getLast_contact_time
)
.
min
(
new
Comparator
<
Long
>()
{
@Override
public
int
compare
(
Long
o1
,
Long
o2
)
{
return
(
int
)
(
o1
-
o2
);
}
}).
get
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
oneTypeData
.
put
(
"latestTime"
,
latest
);
oneTypeData
.
put
(
"earliestTime"
,
""
+
earliest
);
}
return
oneTypeData
.
toString
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"Collector.toContactDTO"
);
}
return
""
;
}
public
static
String
toSmsDTO
(
List
<
SmsEntity
>
smsList
,
Context
context
,
List
<
ContactEntity
>
contactList
)
{
try
{
JSONObject
oneTypeData
=
initJSON
(
InfoType
.
SMS_LOG
,
context
);
oneTypeData
.
put
(
"data"
,
getSmsJSONArray
(
smsList
,
contactList
));
// oneTypeData.put("totalNumber", smsList.size());
oneTypeData
.
put
(
"pageSum"
,
1
);
oneTypeData
.
put
(
"pageNo"
,
0
);
oneTypeData
.
put
(
"currentSum"
,
smsList
.
size
());
oneTypeData
.
put
(
"updateTime"
,
System
.
currentTimeMillis
());
// if(smsList.size() > 0){
// oneTypeData.put("latestTime", Stream.of(smsList).map(SmsEntity::getDate)
// .max((o1, o2) -> (int)(o1-o2)).get());
// oneTypeData.put("earliestTime", Stream.of(smsList).map(SmsEntity::getDate)
// .min((o1, o2) -> (int)(o1-o2)).get());
// }
return
oneTypeData
.
toString
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"Collector.toSmsDTO"
);
}
return
""
;
}
private
static
JSONArray
getSmsJSONArray
(
List
<
SmsEntity
>
smsList
,
List
<
ContactEntity
>
contactList
)
{
if
(
smsList
==
null
||
smsList
.
size
()
==
0
)
{
return
new
JSONArray
();
}
HashMap
<
String
,
String
>
map
=
toNumberNameMap
(
contactList
);
return
Stream
.
of
(
smsList
)
.
map
(
new
Function
<
SmsEntity
,
JSONObject
>()
{
@Override
public
JSONObject
apply
(
SmsEntity
entity
)
{
JSONObject
smsObj
=
new
JSONObject
();
try
{
if
(
TextUtils
.
isEmpty
(
entity
.
getAddress
()))
{
smsObj
.
put
(
"name"
,
""
);
}
else
{
smsObj
.
put
(
"name"
,
geNameFromNumberNameMap
(
map
,
entity
.
getAddress
()));
}
smsObj
.
put
(
"number"
,
entity
.
getAddress
()
==
null
?
""
:
entity
.
getAddress
());
smsObj
.
put
(
"subject"
,
entity
.
getSubject
()
==
null
?
"NO_SUBJECT"
:
entity
.
getSubject
());
smsObj
.
put
(
"direction"
,
SmsEntity
.
getSmsTypeDesc
(
entity
.
getType
()));
smsObj
.
put
(
"createTime"
,
entity
.
getDate
());
if
(
TextUtils
.
isEmpty
(
entity
.
getBody
()))
{
smsObj
.
put
(
"content"
,
""
);
}
else
{
smsObj
.
put
(
"content"
,
entity
.
getBody
().
replaceAll
(
"\u0000"
,
""
));
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
return
smsObj
;
}
})
.
reduce
(
new
JSONArray
(),
new
BiFunction
<
JSONArray
,
JSONObject
,
JSONArray
>()
{
@Override
public
JSONArray
apply
(
JSONArray
array
,
JSONObject
smsObj
)
{
array
.
put
(
smsObj
);
return
array
;
}
});
}
public
static
String
toCallLogDTO
(
List
<
CallLogEntity
>
calllogList
,
Context
context
,
List
<
ContactEntity
>
contactList
)
{
try
{
JSONObject
oneTypeData
=
initJSON
(
InfoType
.
CALL_LOG
,
context
);
oneTypeData
.
put
(
"data"
,
getCallLogJSONArray
(
calllogList
,
contactList
));
oneTypeData
.
put
(
"totalNumber"
,
calllogList
.
size
());
if
(
calllogList
.
size
()
>
0
)
{
long
latest
=
0
;
long
earliest
=
0
;
try
{
latest
=
Stream
.
of
(
calllogList
)
.
map
(
CallLogEntity:
:
getDate
)
.
max
(
new
Comparator
<
Long
>()
{
@Override
public
int
compare
(
Long
o1
,
Long
o2
)
{
return
(
int
)
(
o1
-
o2
);
}
})
.
get
();
earliest
=
Stream
.
of
(
calllogList
)
.
map
(
CallLogEntity:
:
getDate
)
.
min
(
new
Comparator
<
Long
>()
{
@Override
public
int
compare
(
Long
o1
,
Long
o2
)
{
return
(
int
)
(
o1
-
o2
);
}
})
.
get
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
oneTypeData
.
put
(
"latestTime"
,
latest
);
oneTypeData
.
put
(
"earliestTime"
,
""
+
earliest
);
}
return
oneTypeData
.
toString
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"Collector.toCallLogDTO"
);
}
return
""
;
}
private
static
JSONArray
getCallLogJSONArray
(
List
<
CallLogEntity
>
callLogList
,
List
<
ContactEntity
>
contactList
)
{
if
(
callLogList
==
null
||
callLogList
.
size
()
==
0
)
{
return
new
JSONArray
();
}
HashMap
<
String
,
String
>
map
=
toNumberNameMap
(
contactList
);
return
Stream
.
of
(
callLogList
)
.
map
(
new
Function
<
CallLogEntity
,
JSONObject
>()
{
@Override
public
JSONObject
apply
(
CallLogEntity
entity
)
{
JSONObject
callLog
=
new
JSONObject
();
try
{
String
name
=
geNameFromNumberNameMap
(
map
,
entity
.
getNumber
());
if
(
TextUtils
.
isEmpty
(
name
))
{
name
=
entity
.
getCachedName
();
if
(
name
==
null
)
{
name
=
""
;
}
}
callLog
.
put
(
"name"
,
name
);
callLog
.
put
(
"number"
,
entity
.
getNumber
()
==
null
?
""
:
entity
.
getNumber
());
callLog
.
put
(
"createTime"
,
""
+
entity
.
getDate
());
callLog
.
put
(
"duration"
,
""
+
entity
.
getDuration
());
callLog
.
put
(
"direction"
,
CallLogEntity
.
getCallLogTypeDesc
(
entity
.
getType
()));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
UploadManager
.
uploadException
(
e
,
"Collector.getCallLogJSONArray"
);
}
Log
.
i
(
"Collector"
,
"CallLog List "
+
callLog
.
toString
());
return
callLog
;
}
})
.
reduce
(
new
JSONArray
(),
new
BiFunction
<
JSONArray
,
JSONObject
,
JSONArray
>()
{
@Override
public
JSONArray
apply
(
JSONArray
array
,
JSONObject
jsonObject
)
{
array
.
put
(
jsonObject
);
return
array
;
}
});
}
private
static
JSONArray
getContactJSONArray
(
List
<
ContactEntity
>
contactList
)
{
if
(
contactList
==
null
||
contactList
.
size
()
==
0
)
{
return
new
JSONArray
();
}
return
Stream
.
of
(
contactList
)
.
map
(
new
Function
<
ContactEntity
,
JSONObject
>()
{
@Override
public
JSONObject
apply
(
ContactEntity
contact
)
{
JSONObject
json
=
new
JSONObject
();
try
{
json
.
put
(
"name"
,
contact
.
getName
()
==
null
?
""
:
contact
.
getName
());
json
.
put
(
"nickname"
,
contact
.
getNickname
()
==
null
?
""
:
contact
.
getNickname
());
json
.
put
(
"last_contact_time"
,
""
+
contact
.
getLast_contact_time
());
json
.
put
(
"contact_times"
,
contact
.
getContact_times
());
json
.
put
(
"lastUpdate"
,
""
+
contact
.
getLastUpdate
());
json
.
put
(
"status"
,
contact
.
getStatus
()
==
null
?
""
:
contact
.
getStatus
());
json
.
put
(
"relation"
,
contact
.
getRelation
()
==
null
?
""
:
contact
.
getRelation
());
JSONArray
numberArr
=
new
JSONArray
();
if
(
contact
.
getNumber
()
!=
null
&&
contact
.
getNumber
().
size
()
>
0
)
{
numberArr
=
Stream
.
of
(
contact
.
getNumber
())
.
map
(
new
Function
<
ContactEntity
.
NumberEntity
,
JSONObject
>()
{
@Override
public
JSONObject
apply
(
ContactEntity
.
NumberEntity
t
)
{
JSONObject
number
=
new
JSONObject
();
try
{
number
.
put
(
"number"
,
t
.
getNumber
()
==
null
?
""
:
t
.
getNumber
());
number
.
put
(
"last_time_used"
,
t
.
getLast_time_used
());
number
.
put
(
"time_used"
,
t
.
getTime_used
());
number
.
put
(
"type_label"
,
t
.
getType_label
()
==
null
?
""
:
t
.
getType_label
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
return
number
;
}
})
.
reduce
(
new
JSONArray
(),
new
BiFunction
<
JSONArray
,
JSONObject
,
JSONArray
>()
{
@Override
public
JSONArray
apply
(
JSONArray
value1
,
JSONObject
value2
)
{
value1
.
put
(
value2
);
return
value1
;
}
});
}
json
.
put
(
"number"
,
numberArr
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
return
json
;
}
})
.
reduce
(
new
JSONArray
(),
new
BiFunction
<
JSONArray
,
JSONObject
,
JSONArray
>()
{
@Override
public
JSONArray
apply
(
JSONArray
jsonArray
,
JSONObject
json
)
{
jsonArray
.
put
(
json
);
return
jsonArray
;
}
});
}
/***/
private
static
HashMap
<
String
,
String
>
toNumberNameMap
(
List
<
ContactEntity
>
contactList
)
{
HashMap
<
String
,
String
>
numberNameMap
=
new
HashMap
<>();
if
(
contactList
==
null
||
contactList
.
size
()
==
0
)
{
return
numberNameMap
;
}
for
(
int
i
=
0
;
i
<
contactList
.
size
();
i
++)
{
ContactEntity
entity
=
contactList
.
get
(
i
);
if
(
entity
!=
null
&&
entity
.
getNumber
()
!=
null
&&
!
TextUtils
.
isEmpty
(
entity
.
getName
())
&&
entity
.
getNumber
().
size
()
>
0
)
{
Stream
.
of
(
entity
.
getNumber
())
.
forEach
(
new
com
.
annimon
.
stream
.
function
.
Consumer
<
ContactEntity
.
NumberEntity
>()
{
@Override
public
void
accept
(
ContactEntity
.
NumberEntity
numberEntity
)
{
if
(!
TextUtils
.
isEmpty
(
numberEntity
.
getNumber
()))
{
numberNameMap
.
put
(
numberEntity
.
getNumber
(),
entity
.
getName
());
}
}
});
}
}
return
numberNameMap
;
}
private
static
String
geNameFromNumberNameMap
(
HashMap
<
String
,
String
>
map
,
String
number
)
{
if
(
TextUtils
.
isEmpty
(
number
))
{
return
""
;
}
String
name
=
map
.
get
(
number
);
if
(
TextUtils
.
isEmpty
(
name
))
{
return
""
;
}
return
name
;
}
}
src/main/java/tech/starwin/database/DataBaseHelper.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
database
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.location.Location
;
import
android.location.LocationManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.CallLog
;
import
android.provider.ContactsContract
;
import
android.support.v4.content.PermissionChecker
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.litepal.LitePal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
tech.starwin.database.entity.CallLogEntity
;
import
tech.starwin.database.entity.ContactEntity
;
import
tech.starwin.database.entity.SmsEntity
;
/**
* Created by SiKang on 2018/10/19.
* 数据库辅助类,用于涉及数据库查询的业务封装
*/
public
class
DataBaseHelper
{
enum
CollectType
{
CONTACT
,
CALL_LOG
,
SMS_LOG
}
private
static
Context
context
;
private
static
ContentResolver
resolver
;
private
static
LocationManager
mLocationManager
;
public
static
void
init
(
Context
ctx
)
{
if
(
ctx
==
null
)
{
throw
new
IllegalArgumentException
(
"context cannot be null"
);
}
context
=
ctx
;
resolver
=
ctx
.
getContentResolver
();
mLocationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
}
/**
* 根据uri查询指定联系人信息
*
* @return String[name, number]
*/
public
static
String
[]
queryContactByUri
(
Context
context
,
Uri
uri
)
{
String
[]
data
=
null
;
if
(
uri
!=
null
)
{
Cursor
cursor
=
resolver
.
query
(
uri
,
new
String
[]{
ContactsContract
.
CommonDataKinds
.
Phone
.
NUMBER
,
ContactsContract
.
CommonDataKinds
.
Phone
.
DISPLAY_NAME
},
null
,
null
,
null
);
while
(
cursor
!=
null
&&
cursor
.
moveToNext
())
{
String
number
=
cursor
.
getString
(
0
);
String
name
=
cursor
.
getString
(
1
);
data
=
new
String
[]{
name
,
number
};
}
cursor
.
close
();
}
return
data
;
}
/**
* 获取联系人信息
*/
@SuppressLint
(
"MissingPermission"
)
public
static
List
<
ContactEntity
>
getContacts
()
{
List
<
ContactEntity
>
logs
=
new
ArrayList
<>();
Cursor
cursor
=
null
;
try
{
cursor
=
Nested
.
getCursor
(
CollectType
.
CONTACT
);
if
(
cursor
==
null
)
{
return
logs
;
}
Map
<
Long
,
List
<
ContactEntity
.
NumberEntity
>>
contactIdNumbersMap
=
Nested
.
queryAllContactNumbers
();
Map
<
Long
,
ContactEntity
.
ContactDetail
>
contactDetailMap
=
Nested
.
queryAllContactDetail
();
while
(
cursor
.
moveToNext
())
{
com
.
annimon
.
stream
.
Optional
<
ContactEntity
>
oneOpt
=
Nested
.
getOneContact
(
cursor
,
contactIdNumbersMap
,
contactDetailMap
);
if
(
oneOpt
.
isPresent
())
{
logs
.
add
(
oneOpt
.
get
());
}
}
cursor
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
// UploadUtils.uploadException(e, "getContacts");
}
finally
{
if
(
cursor
!=
null
&&
!
cursor
.
isClosed
())
{
cursor
.
close
();
}
}
return
logs
;
}
/**
* 获取通话记录
*/
@SuppressLint
(
"MissingPermission"
)
public
static
List
<
CallLogEntity
>
getCallLogs
(
int
maxCount
)
{
long
startTime
=
System
.
currentTimeMillis
();
List
<
CallLogEntity
>
logs
=
new
ArrayList
<>();
Cursor
cursor
=
null
;
try
{
cursor
=
Nested
.
getCursor
(
CollectType
.
CALL_LOG
);
if
(
cursor
==
null
)
{
return
logs
;
}
while
(
cursor
.
moveToNext
())
{
com
.
annimon
.
stream
.
Optional
<
CallLogEntity
>
oneOpt
=
Nested
.
getOneCallLog
(
cursor
);
if
(
oneOpt
.
isPresent
())
{
logs
.
add
(
oneOpt
.
get
());
}
if
(
logs
.
size
()
>=
maxCount
)
{
break
;
}
}
Log
.
d
(
"caculate_time"
,
"Collector getCallLogs time"
+
(
System
.
currentTimeMillis
()
-
startTime
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
// UploadUtils.uploadException(e, "getCallLogs");
}
finally
{
if
(
cursor
!=
null
&&
!
cursor
.
isClosed
())
{
cursor
.
close
();
}
}
return
logs
;
}
/**
* 获取短信记录
*/
@SuppressLint
(
"MissingPermission"
)
public
static
List
<
SmsEntity
>
getSms
(
int
maxCount
)
{
long
startTime
=
System
.
currentTimeMillis
();
List
<
SmsEntity
>
logs
=
new
ArrayList
<>();
Cursor
cursor
=
null
;
try
{
cursor
=
Nested
.
getCursor
(
CollectType
.
SMS_LOG
);
if
(
cursor
==
null
)
{
return
logs
;
}
while
(
cursor
.
moveToNext
())
{
com
.
annimon
.
stream
.
Optional
<
SmsEntity
>
oneOpt
=
Nested
.
getOneSms
(
cursor
);
if
(
oneOpt
.
isPresent
())
{
logs
.
add
(
oneOpt
.
get
());
}
if
(
logs
.
size
()
>=
maxCount
)
{
break
;
}
}
Log
.
d
(
"caculate_time"
,
"Collector getSms time"
+
(
System
.
currentTimeMillis
()
-
startTime
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
// UploadUtils.uploadException(e, "getSms");
}
finally
{
if
(
cursor
!=
null
&&
!
cursor
.
isClosed
())
{
cursor
.
close
();
}
}
return
logs
;
}
public
static
JSONObject
getMachineType
()
{
JSONObject
map
=
new
JSONObject
();
try
{
map
.
put
(
"deviceBrand"
,
Build
.
BRAND
);
map
.
put
(
"deviceType"
,
Build
.
MODEL
);
map
.
put
(
"systemVersion"
,
Build
.
VERSION
.
RELEASE
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
// UploadUtils.uploadException(e, "getMachineType");
}
return
map
;
}
/**
* 获取定位信息
*/
@SuppressLint
(
"MissingPermission"
)
public
static
Location
getLocation
()
{
Location
loc
=
null
;
List
<
String
>
providers
=
mLocationManager
.
getProviders
(
true
);
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
GPS_PROVIDER
))
{
loc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
GPS_PROVIDER
);
}
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
NETWORK_PROVIDER
))
{
loc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
NETWORK_PROVIDER
);
}
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
PASSIVE_PROVIDER
))
{
loc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
PASSIVE_PROVIDER
);
}
return
loc
;
}
private
static
String
[]
permissionsTocheck
=
{
Manifest
.
permission
.
READ_CONTACTS
,
Manifest
.
permission
.
READ_CALL_LOG
,
Manifest
.
permission
.
READ_SMS
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
//粗精度定位
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
//卫星定位
Manifest
.
permission
.
READ_PHONE_STATE
};
public
static
JSONArray
getPermissionState
()
{
JSONArray
array
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
permissionsTocheck
.
length
;
i
++)
{
try
{
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"checkTime"
,
System
.
currentTimeMillis
());
object
.
put
(
"permissionType"
,
permissionsTocheck
[
i
]);
if
(
permissionGranted
(
permissionsTocheck
[
i
],
context
))
{
object
.
put
(
"isGranted"
,
"GRANTED"
);
}
else
{
object
.
put
(
"isGranted"
,
"REFUSED"
);
}
array
.
put
(
object
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
// UploadUtils.uploadException(e, "getPermissionState");
}
}
return
array
;
}
public
static
boolean
permissionGranted
(
String
permission
,
Context
ctx
)
{
if
(
permission
==
null
)
{
return
true
;
}
return
Build
.
VERSION
.
SDK_INT
<
23
||
PermissionChecker
.
checkSelfPermission
(
ctx
,
permission
)
==
PackageManager
.
PERMISSION_GRANTED
;
}
private
static
class
Nested
{
@SuppressLint
(
"MissingPermission"
)
private
static
Cursor
getCursor
(
CollectType
type
)
{
if
(
resolver
==
null
)
{
return
null
;
}
switch
(
type
)
{
case
CONTACT:
return
resolver
.
query
(
ContactsContract
.
Contacts
.
CONTENT_URI
,
null
,
null
,
null
,
null
);
case
CALL_LOG:
return
resolver
.
query
(
CallLog
.
Calls
.
CONTENT_URI
,
new
String
[]{
CallLog
.
Calls
.
CACHED_NAME
,
CallLog
.
Calls
.
NUMBER
,
CallLog
.
Calls
.
TYPE
,
CallLog
.
Calls
.
DATE
,
CallLog
.
Calls
.
DURATION
},
null
,
null
,
CallLog
.
Calls
.
DEFAULT_SORT_ORDER
);
case
SMS_LOG:
return
resolver
.
query
(
Uri
.
parse
(
"content://sms"
),
new
String
[]{
"person"
,
//reference to item in {@code content://contacts/people}
"address"
,
//The address of the other party.
"type"
,
"date"
,
"body"
,
"subject"
},
null
,
null
,
"date DESC"
);
default
:
return
null
;
}
}
/**
* 取出一条通话记录
*/
private
static
com
.
annimon
.
stream
.
Optional
<
CallLogEntity
>
getOneCallLog
(
Cursor
cursor
)
{
try
{
final
String
cachedName
=
cursor
.
getString
(
0
);
final
String
number
=
cursor
.
getString
(
1
);
final
int
type
=
cursor
.
getInt
(
2
);
final
long
date
=
cursor
.
getLong
(
3
);
final
long
duration
=
cursor
.
getLong
(
4
);
CallLogEntity
callLogEntity
=
new
CallLogEntity
()
{{
setCachedName
(
cachedName
);
setNumber
(
number
);
setType
(
type
);
setDate
(
date
);
setDuration
(
duration
);
}};
return
com
.
annimon
.
stream
.
Optional
.
of
(
callLogEntity
);
}
catch
(
Exception
e
)
{
return
com
.
annimon
.
stream
.
Optional
.
empty
();
}
}
/**
* 查询一条联系人信息
*/
//do not close the cursor
private
static
com
.
annimon
.
stream
.
Optional
<
ContactEntity
>
getOneContact
(
Cursor
cursor
,
Map
<
Long
,
List
<
ContactEntity
.
NumberEntity
>>
contactIdNumbersMap
,
Map
<
Long
,
ContactEntity
.
ContactDetail
>
contactDetailMap
)
{
try
{
final
String
name
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
ContactsContract
.
PhoneLookup
.
DISPLAY_NAME
));
final
long
lastUpdate
=
readLastUpdateTime
(
cursor
);
long
contactId
=
cursor
.
getLong
(
cursor
.
getColumnIndex
(
ContactsContract
.
Contacts
.
_ID
));
final
List
<
ContactEntity
.
NumberEntity
>
numbers
=
contactIdNumbersMap
.
get
(
contactId
);
final
ContactEntity
.
ContactDetail
detail
=
contactDetailMap
.
get
(
contactId
);
ContactEntity
entity
=
new
ContactEntity
()
{{
setName
(
name
);
setLastUpdate
(
lastUpdate
);
setNumber
(
numbers
);
if
(
detail
!=
null
)
{
setContact_times
(
detail
.
getContact_times
());
setLast_contact_time
(
detail
.
getLast_contact_time
());
setNickname
(
detail
.
getNickname
());
setRelation
(
detail
.
getRelation
());
setStatus
(
detail
.
getStatus
());
}
}};
return
com
.
annimon
.
stream
.
Optional
.
of
(
entity
);
}
catch
(
Exception
e
)
{
// UploadUtils.uploadException(e, "getOneContact");
return
com
.
annimon
.
stream
.
Optional
.
empty
();
}
}
/**
* 查询一条短信记录
*/
private
static
com
.
annimon
.
stream
.
Optional
<
SmsEntity
>
getOneSms
(
Cursor
cursor
)
{
// "person", //reference to item in {@code content://contacts/people}
// "address", //The address of the other party.
// "type",
// "date",
// "body",
// "subject"},
try
{
final
String
address
=
cursor
.
getString
(
1
);
final
int
type
=
cursor
.
getInt
(
2
);
final
long
date
=
cursor
.
getLong
(
3
);
final
String
body
=
cursor
.
getString
(
4
);
final
String
subject
=
cursor
.
getString
(
5
);
SmsEntity
smsEntity
=
new
SmsEntity
()
{{
setAddress
(
address
);
setType
(
type
);
setDate
(
date
);
setBody
(
body
);
setSubject
(
subject
);
}};
return
com
.
annimon
.
stream
.
Optional
.
of
(
smsEntity
);
}
catch
(
Exception
e
)
{
// UploadUtils.uploadException(e, "getOneSms");
return
com
.
annimon
.
stream
.
Optional
.
empty
();
}
}
private
static
long
readLastUpdateTime
(
Cursor
cursor
)
{
long
lastUpdateTime
=
0
;
int
index
=
cursor
.
getColumnIndex
(
"contact_last_updated_timestamp"
);
if
(
index
>
-
1
)
{
return
cursor
.
getLong
(
index
);
}
index
=
cursor
.
getColumnIndex
(
"contact_status_ts"
);
if
(
index
>
-
1
)
{
return
cursor
.
getLong
(
index
);
}
return
lastUpdateTime
;
}
/**
* 查询所有电话号码
*/
private
static
Map
<
Long
,
List
<
ContactEntity
.
NumberEntity
>>
queryAllContactNumbers
()
{
Map
<
Long
,
List
<
ContactEntity
.
NumberEntity
>>
idNumbersMap
=
new
HashMap
<>();
Cursor
cursor
=
null
;
try
{
cursor
=
resolver
.
query
(
ContactsContract
.
CommonDataKinds
.
Phone
.
CONTENT_URI
,
null
,
null
,
null
,
null
);
if
(
cursor
==
null
)
{
return
idNumbersMap
;
}
while
(
cursor
.
moveToNext
())
{
final
long
contactId
=
cursor
.
getLong
(
cursor
.
getColumnIndex
(
ContactsContract
.
CommonDataKinds
.
Phone
.
CONTACT_ID
));
com
.
annimon
.
stream
.
Optional
<
ContactEntity
.
NumberEntity
>
entityOpt
=
readOneNumber
(
cursor
);
if
(!
entityOpt
.
isPresent
())
{
continue
;
}
List
<
ContactEntity
.
NumberEntity
>
numbers
=
idNumbersMap
.
get
(
contactId
);
if
(
numbers
==
null
)
{
List
<
ContactEntity
.
NumberEntity
>
init
=
new
ArrayList
<>();
init
.
add
(
entityOpt
.
get
());
idNumbersMap
.
put
(
contactId
,
init
);
}
else
{
numbers
.
add
(
entityOpt
.
get
());
}
}
cursor
.
close
();
}
catch
(
Exception
e
)
{
// UploadUtils.uploadException(e, "queryAllContactNumbers");
}
finally
{
if
(
cursor
!=
null
&&
!
cursor
.
isClosed
())
{
cursor
.
close
();
}
}
return
idNumbersMap
;
}
/**
* 取出一条电话号码
*/
private
static
com
.
annimon
.
stream
.
Optional
<
ContactEntity
.
NumberEntity
>
readOneNumber
(
Cursor
cursor
)
{
try
{
final
String
number
=
readNumber
(
cursor
);
final
int
contactTimes
=
readContactTimes
(
cursor
);
final
long
lastContactTime
=
readLastContactTime
(
cursor
);
final
String
customerData
=
readCustomerData
(
cursor
);
ContactEntity
.
NumberEntity
entity
=
new
ContactEntity
.
NumberEntity
()
{{
setNumber
(
number
);
setLast_time_used
(
""
+
lastContactTime
);
setTime_used
(
contactTimes
);
setType_label
(
customerData
==
null
?
""
:
customerData
);
}};
return
com
.
annimon
.
stream
.
Optional
.
of
(
entity
);
}
catch
(
Exception
e
)
{
// UploadUtils.uploadException(e, "readOneNumber");
return
com
.
annimon
.
stream
.
Optional
.
empty
();
}
}
private
static
long
readLastContactTime
(
Cursor
cursor
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR2
)
{
int
index
=
cursor
.
getColumnIndex
(
ContactsContract
.
CommonDataKinds
.
Phone
.
LAST_TIME_USED
);
if
(
index
>
-
1
)
{
return
cursor
.
getLong
(
index
);
}
}
else
{
int
index
=
cursor
.
getColumnIndex
(
"last_time_contacted"
);
if
(
index
>
-
1
)
{
return
cursor
.
getLong
(
index
);
}
}
return
0
;
}
private
static
String
readCustomerData
(
Cursor
cursor
)
{
int
data2Index
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
ContactsContract
.
CommonDataKinds
.
Phone
.
DATA2
));
if
(
data2Index
>
-
1
)
{
CharSequence
typeLabel
=
ContactsContract
.
CommonDataKinds
.
Phone
.
getTypeLabel
(
context
.
getResources
(),
data2Index
,
"CUSTOME"
);
if
(
typeLabel
!=
null
)
{
return
typeLabel
.
toString
();
}
}
return
""
;
}
private
static
String
readNumber
(
Cursor
cursor
)
{
String
number
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
ContactsContract
.
CommonDataKinds
.
Phone
.
NUMBER
));
if
(!
TextUtils
.
isEmpty
(
number
))
{
number
=
number
.
replace
(
"-"
,
""
);
number
=
number
.
replace
(
" "
,
""
);
}
return
number
;
}
private
static
int
readContactTimes
(
Cursor
cursor
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR2
)
{
int
index
=
cursor
.
getColumnIndex
(
ContactsContract
.
CommonDataKinds
.
Phone
.
TIMES_USED
);
if
(
index
>
-
1
)
{
return
cursor
.
getInt
(
index
);
}
}
else
{
int
index
=
cursor
.
getColumnIndex
(
"times_contacted"
);
if
(
index
>
-
1
)
{
return
cursor
.
getInt
(
index
);
}
}
return
0
;
}
private
static
Map
<
Long
,
ContactEntity
.
ContactDetail
>
queryAllContactDetail
()
{
Map
<
Long
,
ContactEntity
.
ContactDetail
>
contactIdDetailMap
=
new
HashMap
<>();
try
{
Cursor
cursor
=
resolver
.
query
(
ContactsContract
.
Data
.
CONTENT_URI
,
null
,
null
,
null
,
null
);
if
(
cursor
==
null
)
{
return
contactIdDetailMap
;
}
while
(
cursor
.
moveToNext
())
{
try
{
ContactEntity
.
ContactDetail
detail
=
new
ContactEntity
.
ContactDetail
();
final
long
contactId
=
cursor
.
getLong
(
cursor
.
getColumnIndex
(
ContactsContract
.
Data
.
CONTACT_ID
));
int
contactTimes
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
ContactsContract
.
Data
.
TIMES_CONTACTED
));
String
status
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
ContactsContract
.
Data
.
CONTACT_STATUS
));
long
lastContact
=
cursor
.
getLong
(
cursor
.
getColumnIndex
(
ContactsContract
.
Data
.
LAST_TIME_CONTACTED
));
detail
.
setContact_times
(
contactTimes
);
detail
.
setLast_contact_time
(
lastContact
);
detail
.
setStatus
(
status
);
int
columnIndex
=
cursor
.
getColumnIndex
(
"nickname"
);
if
(
columnIndex
>
-
1
)
{
String
nicky
=
cursor
.
getString
(
columnIndex
);
detail
.
setNickname
(
nicky
);
}
columnIndex
=
cursor
.
getColumnIndex
(
"data2"
);
if
(
columnIndex
>
-
1
)
{
String
relationShip
=
cursor
.
getString
(
columnIndex
);
detail
.
setRelation
(
relationShip
);
}
contactIdDetailMap
.
put
(
contactId
,
detail
);
}
catch
(
Exception
e
)
{
// UploadUtils.uploadException(e, "queryAllContactDetail.while");
}
}
cursor
.
close
();
}
catch
(
Exception
e
)
{
// UploadUtils.uploadException(e, "queryAllContactDetail");
}
return
contactIdDetailMap
;
}
// private static ContactEntity.ContactDetail queryContactDetail(long contactId){
// ContactEntity.ContactDetail detail = new ContactEntity.ContactDetail();
//
// Cursor cursor = resolver.query(ContactsContract.Data.CONTENT_URI,
// null,
// ContactsContract.Data.CONTACT_ID + " = " + contactId,
// null,
// null);
//
// if(cursor == null){
// return detail;
// }
//
// if (cursor.moveToNext()){
// int contactTimes = cursor.getInt(cursor.getColumnIndex(ContactsContract.Data.TIMES_CONTACTED));
// String status = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.CONTACT_STATUS));
// long lastContact = cursor.getLong(cursor.getColumnIndex(ContactsContract.Data.LAST_TIME_CONTACTED));
//
// detail.setContact_times(contactTimes);
// detail.setLast_contact_time(lastContact);
// detail.setStatus(status);
//
// int columnIndex = cursor.getColumnIndex("nickname");
// if (columnIndex > -1) {
// String nicky = cursor.getString(columnIndex);
// detail.setNickname(nicky);
// }
// columnIndex = cursor.getColumnIndex("data2");
// if (columnIndex > -1) {
// String relationShip = cursor.getString(columnIndex);
// detail.setRelation(relationShip);
// }
// }
//
// cursor.close();
//
// return detail;
// }
}
}
src/main/java/tech/starwin/database/entity/CallLogEntity.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
database
.
entity
;
/**
* 跟通话记录数据库中的字段直接对应的pojo
* */
public
class
CallLogEntity
{
private
String
cachedName
;
private
String
number
;
private
int
type
;
private
long
date
;
private
long
duration
;
public
String
getCachedName
()
{
return
cachedName
;
}
public
void
setCachedName
(
String
cachedName
)
{
this
.
cachedName
=
cachedName
;
}
public
int
getType
()
{
return
type
;
}
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
public
String
getNumber
()
{
return
number
;
}
public
void
setNumber
(
String
number
)
{
this
.
number
=
number
;
}
public
long
getDate
()
{
return
date
;
}
public
void
setDate
(
long
date
)
{
this
.
date
=
date
;
}
public
long
getDuration
()
{
return
duration
;
}
public
void
setDuration
(
long
duration
)
{
this
.
duration
=
duration
;
}
@Override
public
String
toString
()
{
return
"CallLogEntity{"
+
"cachedName='"
+
cachedName
+
'\''
+
", number='"
+
number
+
'\''
+
", type="
+
type
+
", date="
+
date
+
", duration="
+
duration
+
'}'
;
}
private
static
String
[]
callLogType
=
{
"UNKNOW_TYPE"
,
//placeholder
"INCOMING_TYPE"
,
"OUTGOING_TYPE"
,
"MISSED_TYPE"
,
"VOICEMAIL_TYPE"
,
"REJECTED_TYPE"
,
"BLOCKED_TYPE"
,
"ANSWERED_EXTERNALLY_TYPE"
};
public
static
String
getCallLogTypeDesc
(
int
type
){
if
(
type
>
0
&&
type
<
callLogType
.
length
){
return
callLogType
[
type
];
}
else
{
return
callLogType
[
0
];
}
}
}
src/main/java/tech/starwin/database/entity/CollectInfoEntity.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
database
.
entity
;
import
org.litepal.crud.LitePalSupport
;
public
class
CollectInfoEntity
extends
LitePalSupport
{
private
String
type
;
private
String
body
;
private
long
update_time
;
public
long
getUpdate_time
()
{
return
update_time
;
}
public
void
setUpdate_time
(
long
update_time
)
{
this
.
update_time
=
update_time
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getBody
()
{
return
body
;
}
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
@Override
public
boolean
equals
(
Object
entity
){
return
entity
!=
null
&&
entity
instanceof
CollectInfoEntity
&&
((
CollectInfoEntity
)
entity
).
getType
()
!=
null
&&
type
.
equals
(((
CollectInfoEntity
)
entity
).
getType
());
}
@Override
public
int
hashCode
(){
return
type
.
hashCode
();
}
@Override
public
String
toString
()
{
return
"CollectInfoEntity{"
+
"type='"
+
type
+
'\''
+
", body='"
+
body
+
'\''
+
'}'
;
}
}
src/main/java/tech/starwin/database/entity/ContactEntity.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
database
.
entity
;
import
java.util.List
;
/**
* 跟通讯录数据库中的字段直接对应的pojo
* */
public
class
ContactEntity
{
private
String
name
;
private
List
<
NumberEntity
>
number
;
private
long
lastUpdate
;
private
int
contact_times
;
private
long
last_contact_time
;
private
String
nickname
;
private
String
relation
;
private
String
status
;
public
int
getContact_times
()
{
return
contact_times
;
}
public
void
setContact_times
(
int
contact_times
)
{
this
.
contact_times
=
contact_times
;
}
public
long
getLast_contact_time
()
{
return
last_contact_time
;
}
public
void
setLast_contact_time
(
long
last_contact_time
)
{
this
.
last_contact_time
=
last_contact_time
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
void
setNickname
(
String
nickname
)
{
this
.
nickname
=
nickname
;
}
public
String
getRelation
()
{
return
relation
;
}
public
void
setRelation
(
String
relation
)
{
this
.
relation
=
relation
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
List
<
NumberEntity
>
getNumber
()
{
return
number
;
}
public
void
setNumber
(
List
<
NumberEntity
>
number
)
{
this
.
number
=
number
;
}
public
long
getLastUpdate
()
{
return
lastUpdate
;
}
public
void
setLastUpdate
(
long
lastUpdate
)
{
this
.
lastUpdate
=
lastUpdate
;
}
@Override
public
String
toString
()
{
return
"ContactEntity{"
+
"name='"
+
name
+
'\''
+
", number="
+
number
+
", lastUpdate='"
+
lastUpdate
+
'\''
+
", contact_times="
+
contact_times
+
", last_contact_time='"
+
last_contact_time
+
'\''
+
", nickname='"
+
nickname
+
'\''
+
", relation='"
+
relation
+
'\''
+
", status='"
+
status
+
'\''
+
'}'
;
}
public
static
class
NumberEntity
{
private
String
number
;
private
String
last_time_used
;
private
int
time_used
;
private
String
type_label
;
public
String
getNumber
()
{
return
number
;
}
public
void
setNumber
(
String
number
)
{
this
.
number
=
number
;
}
public
String
getLast_time_used
()
{
return
last_time_used
;
}
public
void
setLast_time_used
(
String
last_time_used
)
{
this
.
last_time_used
=
last_time_used
;
}
public
int
getTime_used
()
{
return
time_used
;
}
public
void
setTime_used
(
int
time_used
)
{
this
.
time_used
=
time_used
;
}
public
String
getType_label
()
{
return
type_label
;
}
public
void
setType_label
(
String
type_label
)
{
this
.
type_label
=
type_label
;
}
@Override
public
String
toString
()
{
return
"NumberEntity{"
+
"number='"
+
number
+
'\''
+
", last_time_used='"
+
last_time_used
+
'\''
+
", time_used='"
+
time_used
+
'\''
+
", type_label='"
+
type_label
+
'\''
+
'}'
;
}
}
public
static
class
ContactDetail
{
private
int
contact_times
;
private
long
last_contact_time
;
private
String
nickname
;
private
String
relation
;
private
String
status
;
public
int
getContact_times
()
{
return
contact_times
;
}
public
void
setContact_times
(
int
contact_times
)
{
this
.
contact_times
=
contact_times
;
}
public
long
getLast_contact_time
()
{
return
last_contact_time
;
}
public
void
setLast_contact_time
(
long
last_contact_time
)
{
this
.
last_contact_time
=
last_contact_time
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
void
setNickname
(
String
nickname
)
{
this
.
nickname
=
nickname
;
}
public
String
getRelation
()
{
return
relation
;
}
public
void
setRelation
(
String
relation
)
{
this
.
relation
=
relation
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
@Override
public
String
toString
()
{
return
"ContactDetail{"
+
"contact_times='"
+
contact_times
+
'\''
+
", last_contact_time='"
+
last_contact_time
+
'\''
+
", nickname="
+
nickname
+
", relation='"
+
relation
+
'\''
+
", status='"
+
status
+
'\''
+
'}'
;
}
}
}
src/main/java/tech/starwin/database/entity/SmsEntity.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
database
.
entity
;
/**
* 跟短信记录数据库中的字段直接对应的pojo
* */
public
class
SmsEntity
{
private
String
address
;
private
int
type
;
private
long
date
;
private
String
body
;
private
String
subject
;
public
int
getType
()
{
return
type
;
}
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
public
String
getAddress
()
{
return
address
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
long
getDate
()
{
return
date
;
}
public
void
setDate
(
long
date
)
{
this
.
date
=
date
;
}
public
String
getBody
()
{
return
body
;
}
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
public
String
getSubject
()
{
return
subject
;
}
public
void
setSubject
(
String
subject
)
{
this
.
subject
=
subject
;
}
@Override
public
String
toString
()
{
return
"SmsEntity{"
+
"type="
+
type
+
", address='"
+
address
+
'\''
+
", date="
+
date
+
", body='"
+
body
+
'\''
+
", subject='"
+
subject
+
'\''
+
'}'
;
}
private
static
String
[]
smsType
=
{
"MESSAGE_TYPE_ALL"
,
"MESSAGE_TYPE_INBOX"
,
"MESSAGE_TYPE_SENT"
,
"MESSAGE_TYPE_DRAFT"
,
"MESSAGE_TYPE_OUTBOX"
,
"MESSAGE_TYPE_FAILED"
,
"MESSAGE_TYPE_QUEUED"
,
"MESSAGE_UNKNOW_TYPE"
};
public
static
String
getSmsTypeDesc
(
int
type
){
if
(
type
>
0
&&
type
<
smsType
.
length
){
return
smsType
[
type
];
}
else
{
return
smsType
[
0
];
}
}
}
\ No newline at end of file
src/main/java/tech/starwin/impl/HttpObserver.java
View file @
2b413d0c
...
...
@@ -42,15 +42,16 @@ public abstract class HttpObserver<T> implements Observer<T> {
@Override
public
void
onError
(
Throwable
throwable
)
{
onFinish
();
String
msg
=
throwable
.
getMessage
();
try
{
if
(
throwable
!=
null
)
{
String
msg
=
throwable
.
getMessage
();
if
(
isHttpError
(
msg
))
{
onError
(
Error
.
HTTP_ERROR
,
LibConfig
.
getContext
().
getString
(
R
.
string
.
text_net_error
));
}
else
if
(
throwable
instanceof
HttpException
)
{
HttpException
exception
=
(
HttpException
)
throwable
;
if
(!
isCanHandle
(
exception
))
{
ResponseErrorBody
responseErrorBody
=
new
Gson
().
fromJson
(
exception
.
response
().
errorBody
().
string
(),
ResponseErrorBody
.
class
);
String
body
=
exception
.
response
().
errorBody
().
string
();
ResponseErrorBody
responseErrorBody
=
new
Gson
().
fromJson
(
body
,
ResponseErrorBody
.
class
);
onError
(
Error
.
SERVER_ERROR
,
responseErrorBody
.
getMessage
());
}
}
else
if
(
msg
.
contains
(
"java.lang.IllegalStateException"
))
{
...
...
@@ -63,7 +64,7 @@ public abstract class HttpObserver<T> implements Observer<T> {
}
}
catch
(
Throwable
e
)
{
onError
(
Error
.
APP_ERROR
,
LibConfig
.
getContext
().
getString
(
R
.
string
.
text_app_error
)
);
onError
(
Error
.
APP_ERROR
,
msg
);
}
if
(
disposable
!=
null
)
disposable
.
dispose
();
...
...
src/main/java/tech/starwin/mvp/api/UserApi.java
View file @
2b413d0c
...
...
@@ -273,7 +273,7 @@ public interface UserApi {
@Query
(
"productId"
)
long
productId
);
/**
* 客户服务热线
* 客户服务热线
、公司介绍
*/
@GET
(
"loanapp/display"
)
Observable
<
DisplayBean
>
display
();
...
...
src/main/java/tech/starwin/mvp/beans/HistoryLoanAppInfoBean.java
View file @
2b413d0c
package
tech
.
starwin
.
mvp
.
beans
;
import
android.os.Parcelable
;
import
java.io.Serializable
;
/**
...
...
@@ -11,7 +13,7 @@ import java.io.Serializable;
* @更新描述:${TODO}
*/
public
class
HistoryLoanAppInfoBean
extends
LoanAppBeanFather
implements
Serializ
able
{
public
class
HistoryLoanAppInfoBean
extends
LoanAppBeanFather
implements
Parcel
able
{
/**
...
...
src/main/java/tech/starwin/mvp/beans/LatestLoanAppBean.java
View file @
2b413d0c
package
tech
.
starwin
.
mvp
.
beans
;
import
android.os.Parcelable
;
import
java.io.Serializable
;
/**
* Created by Miaoke on 2017/3/6.
*/
public
class
LatestLoanAppBean
extends
LoanAppBeanFather
implements
Serializ
able
{
public
class
LatestLoanAppBean
extends
LoanAppBeanFather
implements
Parcel
able
{
/**
* amount ; 0
...
...
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
View file @
2b413d0c
...
...
@@ -14,8 +14,8 @@ import io.reactivex.functions.Consumer;
import
io.reactivex.functions.Function
;
import
io.reactivex.functions.Function4
;
import
io.reactivex.functions.Predicate
;
import
io.reactivex.schedulers.Schedulers
;
import
okhttp3.ResponseBody
;
import
retrofit2.http.Query
;
import
tech.starwin.base.BasePresenter
;
import
tech.starwin.impl.HttpObserver
;
import
tech.starwin.mvp.api.LoanApi
;
...
...
@@ -49,6 +49,7 @@ public class UserPresenter extends BasePresenter<UserApi> {
@SuppressLint
(
"CheckResult"
)
public
void
notifyGateway
()
{
Observable
.
fromIterable
(
Gateway
.
getGatewayUrl
())
.
observeOn
(
Schedulers
.
io
())
.
concatMap
(
new
Function
<
String
,
ObservableSource
<
GatewayInfoBean
>>()
{
@Override
public
ObservableSource
<
GatewayInfoBean
>
apply
(
String
s
)
throws
Exception
{
...
...
@@ -71,7 +72,7 @@ public class UserPresenter extends BasePresenter<UserApi> {
.
subscribe
(
new
Consumer
<
GatewayInfoBean
>()
{
@Override
public
void
accept
(
GatewayInfoBean
gatewayInfoBean
)
throws
Exception
{
Gateway
.
notify
(
gatewayInfoBean
);
Gateway
.
setGatewayInfoBean
(
gatewayInfoBean
);
}
});
}
...
...
@@ -363,6 +364,13 @@ public class UserPresenter extends BasePresenter<UserApi> {
handleRequest
(
action
,
apiService
.
display
());
}
/**
* 获取公司介绍
*/
public
void
getAboutUsMsg
(
String
action
)
{
handleRequest
(
action
,
apiService
.
display
());
}
/**
* 获取用户联系人
...
...
src/main/java/tech/starwin/mvp/ui/activity/RegionActivity.java
View file @
2b413d0c
...
...
@@ -41,6 +41,12 @@ public class RegionActivity extends BaseActivity {
}
@Override
public
void
overridePendingTransition
(
int
enterAnim
,
int
exitAnim
)
{
//取消动画,使用系统默认动画
// super.overridePendingTransition(enterAnim, exitAnim);
}
@Override
public
void
onHttpSuccess
(
String
action
,
Object
result
)
{
}
...
...
src/main/java/tech/starwin/mvp/ui/fragment/RegionFragment.java
View file @
2b413d0c
...
...
@@ -121,6 +121,10 @@ public class RegionFragment extends BaseFragment {
if
(
action
==
"action_getRegion"
)
{
//填充数据,更新UI
final
RegionBean
regionBean
=
(
RegionBean
)
result
;
if
(
regionBean
.
getRegions
().
size
()==
0
){
getActivity
().
setResult
(
Activity
.
RESULT_OK
,
new
ActivityJumper
.
Builder
().
put
(
"region_info"
,
regionInfo
).
toIntent
());
getActivity
().
finish
();
}
RegionAdapter
regionAdapter
=
new
RegionAdapter
(
getActivity
(),
regionBean
.
getRegions
());
UIHelper
.
bindAdapter
(
mRegionRv
,
regionAdapter
);
//选中区域 item
...
...
src/main/java/tech/starwin/network/
NullOn
EmptyConverterFactory.java
→
src/main/java/tech/starwin/network/EmptyConverterFactory.java
View file @
2b413d0c
...
...
@@ -12,7 +12,7 @@ import retrofit2.Retrofit;
* Created by SiKang on 2018/9/14.
* responseBody 为空时,抛出空指针
*/
public
class
NullOn
EmptyConverterFactory
extends
Converter
.
Factory
{
public
class
EmptyConverterFactory
extends
Converter
.
Factory
{
@Override
public
Converter
<
ResponseBody
,
?>
responseBodyConverter
(
Type
type
,
Annotation
[]
annotations
,
Retrofit
retrofit
)
{
...
...
src/main/java/tech/starwin/network/Gateway.java
View file @
2b413d0c
...
...
@@ -32,7 +32,7 @@ public class Gateway {
/**
* 更新gateway
*/
public
static
void
notify
(
GatewayInfoBean
info
)
{
public
static
void
setGatewayInfoBean
(
GatewayInfoBean
info
)
{
gatewayInfo
.
notifyWith
(
info
);
PreferencesManager
.
get
().
saveGatewayInfo
(
info
);
}
...
...
src/main/java/tech/starwin/network/ServiceGenerator.java
View file @
2b413d0c
...
...
@@ -44,7 +44,7 @@ public class ServiceGenerator {
retrofit
=
new
Retrofit
.
Builder
()
.
baseUrl
(
Gateway
.
getRestUrl
())
.
client
(
okHttpClient
)
.
addConverterFactory
(
new
NullOn
EmptyConverterFactory
())
.
addConverterFactory
(
new
EmptyConverterFactory
())
.
addConverterFactory
(
GsonConverterFactory
.
create
())
.
addCallAdapterFactory
(
RxJava2CallAdapterFactory
.
create
())
.
build
();
...
...
src/main/java/tech/starwin/utils/DataBaseHelper.java
deleted
100644 → 0
View file @
3c713327
package
tech
.
starwin
.
utils
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.provider.ContactsContract
;
/**
* Created by SiKang on 2018/10/19.
* 数据库辅助类,用于涉及数据库查询的业务封装
*/
public
class
DataBaseHelper
{
/**
* 查询联系人信息
*
* @return String[name, number]
*/
public
static
String
[]
queryContactInfo
(
Context
context
,
Uri
uri
)
{
String
[]
data
=
null
;
if
(
uri
!=
null
)
{
Cursor
cursor
=
context
.
getContentResolver
()
.
query
(
uri
,
new
String
[]{
ContactsContract
.
CommonDataKinds
.
Phone
.
NUMBER
,
ContactsContract
.
CommonDataKinds
.
Phone
.
DISPLAY_NAME
},
null
,
null
,
null
);
while
(
cursor
!=
null
&&
cursor
.
moveToNext
())
{
String
number
=
cursor
.
getString
(
0
);
String
name
=
cursor
.
getString
(
1
);
data
=
new
String
[]{
name
,
number
};
}
cursor
.
close
();
}
return
data
;
}
}
src/main/java/tech/starwin/utils/LoginManager.java
View file @
2b413d0c
...
...
@@ -104,7 +104,21 @@ public class LoginManager {
* 获取Token
*/
public
String
getToken
()
{
return
getTokenInfo
()
==
null
?
""
:
tokenInfo
.
getToken
();
return
getTokenInfo
()
==
null
?
""
:
getTokenInfo
().
getToken
();
}
/**
* 获取手机号
*/
public
String
getMobile
()
{
return
getTokenInfo
()
==
null
?
""
:
getTokenInfo
().
getMobile
();
}
/**
* 获取用户名
*/
public
String
getUserName
()
{
return
getUserInfo
()
==
null
?
""
:
getUserInfo
().
getName
();
}
public
TokenInfoBean
getTokenInfo
()
{
...
...
@@ -130,6 +144,7 @@ public class LoginManager {
*/
public
void
logout
()
{
tokenInfo
=
null
;
userInfo
=
null
;
PreferencesManager
.
get
().
clearLoginInfo
();
}
...
...
src/main/java/tech/starwin/utils/PreferencesManager.java
View file @
2b413d0c
...
...
@@ -8,11 +8,10 @@ import android.text.TextUtils;
import
java.util.Map
;
import
tech.starwin.mvp.beans.GatewayInfoBean
;
import
tech.starwin.mvp.beans.LoanInfo
;
import
tech.starwin.mvp.beans.OcrResultBean
;
import
tech.starwin.mvp.beans.PersonalInfoServerBean
;
import
tech.starwin.mvp.beans.TokenInfoBean
;
import
tech.starwin.mvp.beans.UserBean
;
import
tech.starwin.utils.format_utils.DataFormat
;
/**
* Created by SiKang on 2018/9/18.
...
...
@@ -124,6 +123,20 @@ public class PreferencesManager {
}
/**
* 保存上传用户数据时使用的sessionId
*/
public
void
saveSessionId
(
String
sessionId
)
{
saveData
(
"session_id"
,
sessionId
);
}
/**
* 取出上传用户数据时使用的sessionId
*/
public
String
getSessionId
()
{
return
getString
(
"session_id"
,
""
);
}
/**
* 是否已同意政策
*/
public
boolean
hasAgreedPolicy
()
{
...
...
@@ -135,8 +148,8 @@ public class PreferencesManager {
* 清除登录信息
*/
public
void
clearLoginInfo
()
{
saveData
(
"user_info"
,
"
"
);
saveData
(
"token_info"
,
"
"
);
remove
(
"user_info
"
);
remove
(
"token_info
"
);
}
/**
...
...
@@ -164,6 +177,15 @@ public class PreferencesManager {
mEditor
.
commit
();
}
/**
* 删除一条数据
*/
public
void
remove
(
String
key
)
{
mEditor
.
remove
(
key
);
mEditor
.
commit
();
}
/**
* 保存多条数据
*/
...
...
src/main/java/tech/starwin/utils/RetryWithDelay.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
utils
;
import
java.util.concurrent.TimeUnit
;
import
io.reactivex.Observable
;
import
io.reactivex.ObservableSource
;
import
io.reactivex.functions.Function
;
public
class
RetryWithDelay
implements
Function
<
Observable
<?
extends
Throwable
>,
Observable
<?>>
{
private
final
int
maxRetries
;
private
final
int
retryDelayMillis
;
private
int
retryCount
;
public
RetryWithDelay
(
int
maxRetries
,
int
retryDelayMillis
)
{
this
.
maxRetries
=
maxRetries
;
this
.
retryDelayMillis
=
retryDelayMillis
;
}
@Override
public
Observable
<?>
apply
(
Observable
<?
extends
Throwable
>
observable
)
throws
Exception
{
return
observable
.
flatMap
(
new
Function
<
Throwable
,
ObservableSource
<?>>()
{
@Override
public
ObservableSource
<?>
apply
(
Throwable
throwable
)
throws
Exception
{
if
(++
retryCount
<=
maxRetries
)
{
// When this Observable calls onNext, the original Observable will be retried (i.e. re-subscribed).
return
Observable
.
timer
(
retryDelayMillis
,
TimeUnit
.
MILLISECONDS
);
}
// Max retries hit. Just pass the error along.
return
Observable
.
error
(
throwable
);
}
});
}
}
src/main/java/tech/starwin/utils/collection/ExceptionHelper.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
utils
.
collection
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.util.Date
;
import
tech.starwin.utils.LoginManager
;
/**
* 异常处理
*/
public
class
ExceptionHelper
{
public
static
String
throwable2String
(
Throwable
ex
)
{
Writer
writer
=
new
StringWriter
();
PrintWriter
printWriter
=
new
PrintWriter
(
writer
);
ex
.
printStackTrace
(
printWriter
);
Throwable
cause
=
ex
.
getCause
();
while
(
cause
!=
null
)
{
cause
.
printStackTrace
(
printWriter
);
cause
=
cause
.
getCause
();
}
printWriter
.
close
();
return
writer
.
toString
();
}
public
static
JSONObject
getCrashMsgBody
(
Context
context
,
String
crashMsg
,
String
tag
)
{
JSONObject
CrashMsgEntity
=
new
JSONObject
();
Long
totalNumber
=
1L
;
Long
latestTime
=
0L
;
Long
earliestTime
=
0L
;
JSONArray
crashMsgArray
=
new
JSONArray
();
JSONObject
crashMsgObject
=
new
JSONObject
();
try
{
crashMsgObject
.
put
(
"createTime"
,
new
Date
().
getTime
());
crashMsgObject
.
put
(
"crashMsg"
,
crashMsg
);
crashMsgArray
.
put
(
crashMsgObject
);
//------------------------
PackageInfo
packageInfo
=
context
.
getPackageManager
().
getPackageInfo
(
context
.
getPackageName
(),
0
);
CrashMsgEntity
.
put
(
"protocolName"
,
"CRASH_MSG"
);
CrashMsgEntity
.
put
(
"protocolVersion"
,
ProtocolVersion
.
V_1_0
.
name
());
CrashMsgEntity
.
put
(
"versionName"
,
packageInfo
.
versionName
);
CrashMsgEntity
.
put
(
"versionCode"
,
packageInfo
.
versionCode
);
CrashMsgEntity
.
put
(
"totalNumber"
,
totalNumber
);
CrashMsgEntity
.
put
(
"latestTime"
,
latestTime
);
CrashMsgEntity
.
put
(
"earliestTime"
,
earliestTime
);
CrashMsgEntity
.
put
(
"token"
,
LoginManager
.
get
().
getToken
());
CrashMsgEntity
.
put
(
"tag"
,
tag
);
CrashMsgEntity
.
put
(
"data"
,
crashMsgArray
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
CrashMsgEntity
;
}
public
static
JSONObject
getInstallRefererMsgBody
(
Context
context
,
String
msg
,
String
tag
)
{
JSONObject
CrashMsgEntity
=
new
JSONObject
();
Long
totalNumber
=
1L
;
Long
latestTime
=
0L
;
Long
earliestTime
=
0L
;
JSONArray
crashMsgArray
=
new
JSONArray
();
JSONObject
crashMsgObject
=
new
JSONObject
();
try
{
crashMsgObject
.
put
(
"createTime"
,
new
Date
().
getTime
());
crashMsgObject
.
put
(
"msg"
,
msg
);
crashMsgArray
.
put
(
crashMsgObject
);
//------------------------
PackageInfo
packageInfo
=
context
.
getPackageManager
().
getPackageInfo
(
context
.
getPackageName
(),
0
);
CrashMsgEntity
.
put
(
"protocolName"
,
"CRASH_MSG"
);
CrashMsgEntity
.
put
(
"protocolVersion"
,
ProtocolVersion
.
V_1_0
.
name
());
CrashMsgEntity
.
put
(
"versionName"
,
packageInfo
.
versionName
);
CrashMsgEntity
.
put
(
"versionCode"
,
packageInfo
.
versionCode
);
CrashMsgEntity
.
put
(
"totalNumber"
,
totalNumber
);
CrashMsgEntity
.
put
(
"latestTime"
,
latestTime
);
CrashMsgEntity
.
put
(
"earliestTime"
,
earliestTime
);
String
token
=
LoginManager
.
get
().
getToken
();
if
(
token
==
null
)
{
token
=
""
;
}
CrashMsgEntity
.
put
(
"token"
,
token
);
CrashMsgEntity
.
put
(
"tag"
,
tag
);
CrashMsgEntity
.
put
(
"data"
,
crashMsgArray
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
CrashMsgEntity
;
}
}
\ No newline at end of file
src/main/java/tech/starwin/utils/collection/GZipUtil.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
utils
.
collection
;
import
android.util.Log
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPOutputStream
;
/**
* Created by luoliuqing on 17/10/21.
* GZip工具类
*/
public
class
GZipUtil
{
public
static
final
String
GZIP_ENCODE_UTF_8
=
"UTF-8"
;
public
static
final
String
GZIP_ENCODE_ISO_8859_1
=
"ISO-8859-1"
;
/**
* 字符串压缩为GZIP字节数组
* @param str
* @param encoding
* @return
*/
public
static
byte
[]
compress
(
String
str
,
String
encoding
)
{
if
(
str
==
null
||
str
.
length
()
==
0
)
{
return
null
;
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
GZIPOutputStream
gzip
;
try
{
gzip
=
new
GZIPOutputStream
(
out
);
gzip
.
write
(
str
.
getBytes
(
encoding
));
gzip
.
close
();
}
catch
(
IOException
e
)
{
Log
.
e
(
"gzip compress error."
,
e
.
getMessage
());
}
return
out
.
toByteArray
();
}
/**
* Gzip byte[] 解压成字符串
* @param bytes
* @return
*/
public
static
String
uncompressToString
(
byte
[]
bytes
)
{
return
uncompressToString
(
bytes
,
GZIP_ENCODE_UTF_8
);
}
/**
* Gzip byte[] 解压成字符串
* @param bytes
* @param encoding
* @return
*/
public
static
String
uncompressToString
(
byte
[]
bytes
,
String
encoding
)
{
if
(
bytes
==
null
||
bytes
.
length
==
0
)
{
return
null
;
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
bytes
);
try
{
GZIPInputStream
ungzip
=
new
GZIPInputStream
(
in
);
byte
[]
buffer
=
new
byte
[
256
];
int
n
;
while
((
n
=
ungzip
.
read
(
buffer
))
>=
0
)
{
out
.
write
(
buffer
,
0
,
n
);
}
return
out
.
toString
(
encoding
);
}
catch
(
IOException
e
)
{
Log
.
e
(
"gzip compress error."
,
e
.
getMessage
());
}
return
null
;
}
/**
* 判断byte[]是否是Gzip格式
* @param data
* @return
*/
public
static
boolean
isGzip
(
byte
[]
data
)
{
int
header
=
(
int
)((
data
[
0
]<<
8
)
|
data
[
1
]&
0xFF
);
return
header
==
0x1f8b
;
}
}
src/main/java/tech/starwin/utils/collection/IncomeMessageProto.java
0 → 100644
View file @
2b413d0c
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: IncomeMessage.proto
package
tech
.
starwin
.
utils
.
collection
;
public
final
class
IncomeMessageProto
{
private
IncomeMessageProto
()
{}
public
static
void
registerAllExtensions
(
com
.
google
.
protobuf
.
ExtensionRegistryLite
registry
)
{
}
public
static
void
registerAllExtensions
(
com
.
google
.
protobuf
.
ExtensionRegistry
registry
)
{
registerAllExtensions
(
(
com
.
google
.
protobuf
.
ExtensionRegistryLite
)
registry
);
}
public
interface
MessageOrBuilder
extends
// @@protoc_insertion_point(interface_extends:com.sulu.harvester.message.Message)
com
.
google
.
protobuf
.
MessageOrBuilder
{
/**
* <code>optional string imei = 1;</code>
*/
boolean
hasImei
();
/**
* <code>optional string imei = 1;</code>
*/
String
getImei
();
/**
* <code>optional string imei = 1;</code>
*/
com
.
google
.
protobuf
.
ByteString
getImeiBytes
();
/**
* <code>optional string mobile = 2;</code>
*/
boolean
hasMobile
();
/**
* <code>optional string mobile = 2;</code>
*/
String
getMobile
();
/**
* <code>optional string mobile = 2;</code>
*/
com
.
google
.
protobuf
.
ByteString
getMobileBytes
();
/**
* <code>required int64 c_timestamp = 3;</code>
*/
boolean
hasCTimestamp
();
/**
* <code>required int64 c_timestamp = 3;</code>
*/
long
getCTimestamp
();
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
boolean
hasType
();
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
IncomeMessageProto
.
Message
.
Type
getType
();
/**
* <code>required string body = 5;</code>
*/
boolean
hasBody
();
/**
* <code>required string body = 5;</code>
*/
String
getBody
();
/**
* <code>required string body = 5;</code>
*/
com
.
google
.
protobuf
.
ByteString
getBodyBytes
();
/**
* <code>optional string version = 6;</code>
*/
boolean
hasVersion
();
/**
* <code>optional string version = 6;</code>
*/
String
getVersion
();
/**
* <code>optional string version = 6;</code>
*/
com
.
google
.
protobuf
.
ByteString
getVersionBytes
();
/**
* <code>optional string control_cmd = 7;</code>
*/
boolean
hasControlCmd
();
/**
* <code>optional string control_cmd = 7;</code>
*/
String
getControlCmd
();
/**
* <code>optional string control_cmd = 7;</code>
*/
com
.
google
.
protobuf
.
ByteString
getControlCmdBytes
();
/**
* <code>optional string session_id = 8;</code>
*/
boolean
hasSessionId
();
/**
* <code>optional string session_id = 8;</code>
*/
String
getSessionId
();
/**
* <code>optional string session_id = 8;</code>
*/
com
.
google
.
protobuf
.
ByteString
getSessionIdBytes
();
}
/**
* Protobuf type {@code com.sulu.harvester.message.Message}
*/
public
static
final
class
Message
extends
com
.
google
.
protobuf
.
GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:com.sulu.harvester.message.Message)
MessageOrBuilder
{
private
static
final
long
serialVersionUID
=
0L
;
// Use Message.newBuilder() to construct.
private
Message
(
com
.
google
.
protobuf
.
GeneratedMessageV3
.
Builder
<?>
builder
)
{
super
(
builder
);
}
private
Message
()
{
imei_
=
""
;
mobile_
=
""
;
cTimestamp_
=
0L
;
type_
=
1
;
body_
=
""
;
version_
=
""
;
controlCmd_
=
""
;
sessionId_
=
""
;
}
@Override
public
final
com
.
google
.
protobuf
.
UnknownFieldSet
getUnknownFields
()
{
return
this
.
unknownFields
;
}
private
Message
(
com
.
google
.
protobuf
.
CodedInputStream
input
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
this
();
if
(
extensionRegistry
==
null
)
{
throw
new
NullPointerException
();
}
int
mutable_bitField0_
=
0
;
com
.
google
.
protobuf
.
UnknownFieldSet
.
Builder
unknownFields
=
com
.
google
.
protobuf
.
UnknownFieldSet
.
newBuilder
();
try
{
boolean
done
=
false
;
while
(!
done
)
{
int
tag
=
input
.
readTag
();
switch
(
tag
)
{
case
0
:
done
=
true
;
break
;
default
:
{
if
(!
parseUnknownField
(
input
,
unknownFields
,
extensionRegistry
,
tag
))
{
done
=
true
;
}
break
;
}
case
10
:
{
com
.
google
.
protobuf
.
ByteString
bs
=
input
.
readBytes
();
bitField0_
|=
0x00000001
;
imei_
=
bs
;
break
;
}
case
18
:
{
com
.
google
.
protobuf
.
ByteString
bs
=
input
.
readBytes
();
bitField0_
|=
0x00000002
;
mobile_
=
bs
;
break
;
}
case
24
:
{
bitField0_
|=
0x00000004
;
cTimestamp_
=
input
.
readInt64
();
break
;
}
case
32
:
{
int
rawValue
=
input
.
readEnum
();
IncomeMessageProto
.
Message
.
Type
value
=
IncomeMessageProto
.
Message
.
Type
.
valueOf
(
rawValue
);
if
(
value
==
null
)
{
unknownFields
.
mergeVarintField
(
4
,
rawValue
);
}
else
{
bitField0_
|=
0x00000008
;
type_
=
rawValue
;
}
break
;
}
case
42
:
{
com
.
google
.
protobuf
.
ByteString
bs
=
input
.
readBytes
();
bitField0_
|=
0x00000010
;
body_
=
bs
;
break
;
}
case
50
:
{
com
.
google
.
protobuf
.
ByteString
bs
=
input
.
readBytes
();
bitField0_
|=
0x00000020
;
version_
=
bs
;
break
;
}
case
58
:
{
com
.
google
.
protobuf
.
ByteString
bs
=
input
.
readBytes
();
bitField0_
|=
0x00000040
;
controlCmd_
=
bs
;
break
;
}
case
66
:
{
com
.
google
.
protobuf
.
ByteString
bs
=
input
.
readBytes
();
bitField0_
|=
0x00000080
;
sessionId_
=
bs
;
break
;
}
}
}
}
catch
(
com
.
google
.
protobuf
.
InvalidProtocolBufferException
e
)
{
throw
e
.
setUnfinishedMessage
(
this
);
}
catch
(
java
.
io
.
IOException
e
)
{
throw
new
com
.
google
.
protobuf
.
InvalidProtocolBufferException
(
e
).
setUnfinishedMessage
(
this
);
}
finally
{
this
.
unknownFields
=
unknownFields
.
build
();
makeExtensionsImmutable
();
}
}
public
static
final
com
.
google
.
protobuf
.
Descriptors
.
Descriptor
getDescriptor
()
{
return
IncomeMessageProto
.
internal_static_com_sulu_harvester_message_Message_descriptor
;
}
protected
FieldAccessorTable
internalGetFieldAccessorTable
()
{
return
IncomeMessageProto
.
internal_static_com_sulu_harvester_message_Message_fieldAccessorTable
.
ensureFieldAccessorsInitialized
(
IncomeMessageProto
.
Message
.
class
,
IncomeMessageProto
.
Message
.
Builder
.
class
);
}
/**
* Protobuf enum {@code com.sulu.harvester.message.Message.Type}
*/
public
enum
Type
implements
com
.
google
.
protobuf
.
ProtocolMessageEnum
{
/**
* <code>UNKNOWN = 0;</code>
*/
UNKNOWN
(
0
),
/**
* <code>TRACE = 1;</code>
*/
TRACE
(
1
),
;
/**
* <code>UNKNOWN = 0;</code>
*/
public
static
final
int
UNKNOWN_VALUE
=
0
;
/**
* <code>TRACE = 1;</code>
*/
public
static
final
int
TRACE_VALUE
=
1
;
public
final
int
getNumber
()
{
return
value
;
}
/**
* @deprecated Use {@link #forNumber(int)} instead.
*/
@Deprecated
public
static
Type
valueOf
(
int
value
)
{
return
forNumber
(
value
);
}
public
static
Type
forNumber
(
int
value
)
{
switch
(
value
)
{
case
0
:
return
UNKNOWN
;
case
1
:
return
TRACE
;
default
:
return
null
;
}
}
public
static
com
.
google
.
protobuf
.
Internal
.
EnumLiteMap
<
Type
>
internalGetValueMap
()
{
return
internalValueMap
;
}
private
static
final
com
.
google
.
protobuf
.
Internal
.
EnumLiteMap
<
Type
>
internalValueMap
=
new
com
.
google
.
protobuf
.
Internal
.
EnumLiteMap
<
Type
>()
{
public
Type
findValueByNumber
(
int
number
)
{
return
Type
.
forNumber
(
number
);
}
};
public
final
com
.
google
.
protobuf
.
Descriptors
.
EnumValueDescriptor
getValueDescriptor
()
{
return
getDescriptor
().
getValues
().
get
(
ordinal
());
}
public
final
com
.
google
.
protobuf
.
Descriptors
.
EnumDescriptor
getDescriptorForType
()
{
return
getDescriptor
();
}
public
static
final
com
.
google
.
protobuf
.
Descriptors
.
EnumDescriptor
getDescriptor
()
{
return
IncomeMessageProto
.
Message
.
getDescriptor
().
getEnumTypes
().
get
(
0
);
}
private
static
final
Type
[]
VALUES
=
values
();
public
static
Type
valueOf
(
com
.
google
.
protobuf
.
Descriptors
.
EnumValueDescriptor
desc
)
{
if
(
desc
.
getType
()
!=
getDescriptor
())
{
throw
new
IllegalArgumentException
(
"EnumValueDescriptor is not for this type."
);
}
return
VALUES
[
desc
.
getIndex
()];
}
private
final
int
value
;
private
Type
(
int
value
)
{
this
.
value
=
value
;
}
// @@protoc_insertion_point(enum_scope:com.sulu.harvester.message.Message.Type)
}
private
int
bitField0_
;
public
static
final
int
IMEI_FIELD_NUMBER
=
1
;
private
volatile
Object
imei_
;
/**
* <code>optional string imei = 1;</code>
*/
public
boolean
hasImei
()
{
return
((
bitField0_
&
0x00000001
)
==
0x00000001
);
}
/**
* <code>optional string imei = 1;</code>
*/
public
String
getImei
()
{
Object
ref
=
imei_
;
if
(
ref
instanceof
String
)
{
return
(
String
)
ref
;
}
else
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
imei_
=
s
;
}
return
s
;
}
}
/**
* <code>optional string imei = 1;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getImeiBytes
()
{
Object
ref
=
imei_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
imei_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
public
static
final
int
MOBILE_FIELD_NUMBER
=
2
;
private
volatile
Object
mobile_
;
/**
* <code>optional string mobile = 2;</code>
*/
public
boolean
hasMobile
()
{
return
((
bitField0_
&
0x00000002
)
==
0x00000002
);
}
/**
* <code>optional string mobile = 2;</code>
*/
public
String
getMobile
()
{
Object
ref
=
mobile_
;
if
(
ref
instanceof
String
)
{
return
(
String
)
ref
;
}
else
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
mobile_
=
s
;
}
return
s
;
}
}
/**
* <code>optional string mobile = 2;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getMobileBytes
()
{
Object
ref
=
mobile_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
mobile_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
public
static
final
int
C_TIMESTAMP_FIELD_NUMBER
=
3
;
private
long
cTimestamp_
;
/**
* <code>required int64 c_timestamp = 3;</code>
*/
public
boolean
hasCTimestamp
()
{
return
((
bitField0_
&
0x00000004
)
==
0x00000004
);
}
/**
* <code>required int64 c_timestamp = 3;</code>
*/
public
long
getCTimestamp
()
{
return
cTimestamp_
;
}
public
static
final
int
TYPE_FIELD_NUMBER
=
4
;
private
int
type_
;
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
public
boolean
hasType
()
{
return
((
bitField0_
&
0x00000008
)
==
0x00000008
);
}
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
public
IncomeMessageProto
.
Message
.
Type
getType
()
{
IncomeMessageProto
.
Message
.
Type
result
=
IncomeMessageProto
.
Message
.
Type
.
valueOf
(
type_
);
return
result
==
null
?
IncomeMessageProto
.
Message
.
Type
.
TRACE
:
result
;
}
public
static
final
int
BODY_FIELD_NUMBER
=
5
;
private
volatile
Object
body_
;
/**
* <code>required string body = 5;</code>
*/
public
boolean
hasBody
()
{
return
((
bitField0_
&
0x00000010
)
==
0x00000010
);
}
/**
* <code>required string body = 5;</code>
*/
public
String
getBody
()
{
Object
ref
=
body_
;
if
(
ref
instanceof
String
)
{
return
(
String
)
ref
;
}
else
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
body_
=
s
;
}
return
s
;
}
}
/**
* <code>required string body = 5;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getBodyBytes
()
{
Object
ref
=
body_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
body_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
public
static
final
int
VERSION_FIELD_NUMBER
=
6
;
private
volatile
Object
version_
;
/**
* <code>optional string version = 6;</code>
*/
public
boolean
hasVersion
()
{
return
((
bitField0_
&
0x00000020
)
==
0x00000020
);
}
/**
* <code>optional string version = 6;</code>
*/
public
String
getVersion
()
{
Object
ref
=
version_
;
if
(
ref
instanceof
String
)
{
return
(
String
)
ref
;
}
else
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
version_
=
s
;
}
return
s
;
}
}
/**
* <code>optional string version = 6;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getVersionBytes
()
{
Object
ref
=
version_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
version_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
public
static
final
int
CONTROL_CMD_FIELD_NUMBER
=
7
;
private
volatile
Object
controlCmd_
;
/**
* <code>optional string control_cmd = 7;</code>
*/
public
boolean
hasControlCmd
()
{
return
((
bitField0_
&
0x00000040
)
==
0x00000040
);
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
String
getControlCmd
()
{
Object
ref
=
controlCmd_
;
if
(
ref
instanceof
String
)
{
return
(
String
)
ref
;
}
else
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
controlCmd_
=
s
;
}
return
s
;
}
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getControlCmdBytes
()
{
Object
ref
=
controlCmd_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
controlCmd_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
public
static
final
int
SESSION_ID_FIELD_NUMBER
=
8
;
private
volatile
Object
sessionId_
;
/**
* <code>optional string session_id = 8;</code>
*/
public
boolean
hasSessionId
()
{
return
((
bitField0_
&
0x00000080
)
==
0x00000080
);
}
/**
* <code>optional string session_id = 8;</code>
*/
public
String
getSessionId
()
{
Object
ref
=
sessionId_
;
if
(
ref
instanceof
String
)
{
return
(
String
)
ref
;
}
else
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
sessionId_
=
s
;
}
return
s
;
}
}
/**
* <code>optional string session_id = 8;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getSessionIdBytes
()
{
Object
ref
=
sessionId_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
sessionId_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
private
byte
memoizedIsInitialized
=
-
1
;
public
final
boolean
isInitialized
()
{
byte
isInitialized
=
memoizedIsInitialized
;
if
(
isInitialized
==
1
)
return
true
;
if
(
isInitialized
==
0
)
return
false
;
if
(!
hasCTimestamp
())
{
memoizedIsInitialized
=
0
;
return
false
;
}
if
(!
hasType
())
{
memoizedIsInitialized
=
0
;
return
false
;
}
if
(!
hasBody
())
{
memoizedIsInitialized
=
0
;
return
false
;
}
memoizedIsInitialized
=
1
;
return
true
;
}
public
void
writeTo
(
com
.
google
.
protobuf
.
CodedOutputStream
output
)
throws
java
.
io
.
IOException
{
if
(((
bitField0_
&
0x00000001
)
==
0x00000001
))
{
com
.
google
.
protobuf
.
GeneratedMessageV3
.
writeString
(
output
,
1
,
imei_
);
}
if
(((
bitField0_
&
0x00000002
)
==
0x00000002
))
{
com
.
google
.
protobuf
.
GeneratedMessageV3
.
writeString
(
output
,
2
,
mobile_
);
}
if
(((
bitField0_
&
0x00000004
)
==
0x00000004
))
{
output
.
writeInt64
(
3
,
cTimestamp_
);
}
if
(((
bitField0_
&
0x00000008
)
==
0x00000008
))
{
output
.
writeEnum
(
4
,
type_
);
}
if
(((
bitField0_
&
0x00000010
)
==
0x00000010
))
{
com
.
google
.
protobuf
.
GeneratedMessageV3
.
writeString
(
output
,
5
,
body_
);
}
if
(((
bitField0_
&
0x00000020
)
==
0x00000020
))
{
com
.
google
.
protobuf
.
GeneratedMessageV3
.
writeString
(
output
,
6
,
version_
);
}
if
(((
bitField0_
&
0x00000040
)
==
0x00000040
))
{
com
.
google
.
protobuf
.
GeneratedMessageV3
.
writeString
(
output
,
7
,
controlCmd_
);
}
if
(((
bitField0_
&
0x00000080
)
==
0x00000080
))
{
com
.
google
.
protobuf
.
GeneratedMessageV3
.
writeString
(
output
,
8
,
sessionId_
);
}
unknownFields
.
writeTo
(
output
);
}
public
int
getSerializedSize
()
{
int
size
=
memoizedSize
;
if
(
size
!=
-
1
)
return
size
;
size
=
0
;
if
(((
bitField0_
&
0x00000001
)
==
0x00000001
))
{
size
+=
com
.
google
.
protobuf
.
GeneratedMessageV3
.
computeStringSize
(
1
,
imei_
);
}
if
(((
bitField0_
&
0x00000002
)
==
0x00000002
))
{
size
+=
com
.
google
.
protobuf
.
GeneratedMessageV3
.
computeStringSize
(
2
,
mobile_
);
}
if
(((
bitField0_
&
0x00000004
)
==
0x00000004
))
{
size
+=
com
.
google
.
protobuf
.
CodedOutputStream
.
computeInt64Size
(
3
,
cTimestamp_
);
}
if
(((
bitField0_
&
0x00000008
)
==
0x00000008
))
{
size
+=
com
.
google
.
protobuf
.
CodedOutputStream
.
computeEnumSize
(
4
,
type_
);
}
if
(((
bitField0_
&
0x00000010
)
==
0x00000010
))
{
size
+=
com
.
google
.
protobuf
.
GeneratedMessageV3
.
computeStringSize
(
5
,
body_
);
}
if
(((
bitField0_
&
0x00000020
)
==
0x00000020
))
{
size
+=
com
.
google
.
protobuf
.
GeneratedMessageV3
.
computeStringSize
(
6
,
version_
);
}
if
(((
bitField0_
&
0x00000040
)
==
0x00000040
))
{
size
+=
com
.
google
.
protobuf
.
GeneratedMessageV3
.
computeStringSize
(
7
,
controlCmd_
);
}
if
(((
bitField0_
&
0x00000080
)
==
0x00000080
))
{
size
+=
com
.
google
.
protobuf
.
GeneratedMessageV3
.
computeStringSize
(
8
,
sessionId_
);
}
size
+=
unknownFields
.
getSerializedSize
();
memoizedSize
=
size
;
return
size
;
}
@Override
public
boolean
equals
(
final
Object
obj
)
{
if
(
obj
==
this
)
{
return
true
;
}
if
(!(
obj
instanceof
IncomeMessageProto
.
Message
))
{
return
super
.
equals
(
obj
);
}
IncomeMessageProto
.
Message
other
=
(
IncomeMessageProto
.
Message
)
obj
;
boolean
result
=
true
;
result
=
result
&&
(
hasImei
()
==
other
.
hasImei
());
if
(
hasImei
())
{
result
=
result
&&
getImei
()
.
equals
(
other
.
getImei
());
}
result
=
result
&&
(
hasMobile
()
==
other
.
hasMobile
());
if
(
hasMobile
())
{
result
=
result
&&
getMobile
()
.
equals
(
other
.
getMobile
());
}
result
=
result
&&
(
hasCTimestamp
()
==
other
.
hasCTimestamp
());
if
(
hasCTimestamp
())
{
result
=
result
&&
(
getCTimestamp
()
==
other
.
getCTimestamp
());
}
result
=
result
&&
(
hasType
()
==
other
.
hasType
());
if
(
hasType
())
{
result
=
result
&&
type_
==
other
.
type_
;
}
result
=
result
&&
(
hasBody
()
==
other
.
hasBody
());
if
(
hasBody
())
{
result
=
result
&&
getBody
()
.
equals
(
other
.
getBody
());
}
result
=
result
&&
(
hasVersion
()
==
other
.
hasVersion
());
if
(
hasVersion
())
{
result
=
result
&&
getVersion
()
.
equals
(
other
.
getVersion
());
}
result
=
result
&&
(
hasControlCmd
()
==
other
.
hasControlCmd
());
if
(
hasControlCmd
())
{
result
=
result
&&
getControlCmd
()
.
equals
(
other
.
getControlCmd
());
}
result
=
result
&&
(
hasSessionId
()
==
other
.
hasSessionId
());
if
(
hasSessionId
())
{
result
=
result
&&
getSessionId
()
.
equals
(
other
.
getSessionId
());
}
result
=
result
&&
unknownFields
.
equals
(
other
.
unknownFields
);
return
result
;
}
@Override
public
int
hashCode
()
{
if
(
memoizedHashCode
!=
0
)
{
return
memoizedHashCode
;
}
int
hash
=
41
;
hash
=
(
19
*
hash
)
+
getDescriptor
().
hashCode
();
if
(
hasImei
())
{
hash
=
(
37
*
hash
)
+
IMEI_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
getImei
().
hashCode
();
}
if
(
hasMobile
())
{
hash
=
(
37
*
hash
)
+
MOBILE_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
getMobile
().
hashCode
();
}
if
(
hasCTimestamp
())
{
hash
=
(
37
*
hash
)
+
C_TIMESTAMP_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
com
.
google
.
protobuf
.
Internal
.
hashLong
(
getCTimestamp
());
}
if
(
hasType
())
{
hash
=
(
37
*
hash
)
+
TYPE_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
type_
;
}
if
(
hasBody
())
{
hash
=
(
37
*
hash
)
+
BODY_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
getBody
().
hashCode
();
}
if
(
hasVersion
())
{
hash
=
(
37
*
hash
)
+
VERSION_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
getVersion
().
hashCode
();
}
if
(
hasControlCmd
())
{
hash
=
(
37
*
hash
)
+
CONTROL_CMD_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
getControlCmd
().
hashCode
();
}
if
(
hasSessionId
())
{
hash
=
(
37
*
hash
)
+
SESSION_ID_FIELD_NUMBER
;
hash
=
(
53
*
hash
)
+
getSessionId
().
hashCode
();
}
hash
=
(
29
*
hash
)
+
unknownFields
.
hashCode
();
memoizedHashCode
=
hash
;
return
hash
;
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
java
.
nio
.
ByteBuffer
data
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
PARSER
.
parseFrom
(
data
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
java
.
nio
.
ByteBuffer
data
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
PARSER
.
parseFrom
(
data
,
extensionRegistry
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
com
.
google
.
protobuf
.
ByteString
data
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
PARSER
.
parseFrom
(
data
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
com
.
google
.
protobuf
.
ByteString
data
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
PARSER
.
parseFrom
(
data
,
extensionRegistry
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
byte
[]
data
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
PARSER
.
parseFrom
(
data
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
byte
[]
data
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
PARSER
.
parseFrom
(
data
,
extensionRegistry
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
java
.
io
.
InputStream
input
)
throws
java
.
io
.
IOException
{
return
com
.
google
.
protobuf
.
GeneratedMessageV3
.
parseWithIOException
(
PARSER
,
input
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
java
.
io
.
InputStream
input
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
java
.
io
.
IOException
{
return
com
.
google
.
protobuf
.
GeneratedMessageV3
.
parseWithIOException
(
PARSER
,
input
,
extensionRegistry
);
}
public
static
IncomeMessageProto
.
Message
parseDelimitedFrom
(
java
.
io
.
InputStream
input
)
throws
java
.
io
.
IOException
{
return
com
.
google
.
protobuf
.
GeneratedMessageV3
.
parseDelimitedWithIOException
(
PARSER
,
input
);
}
public
static
IncomeMessageProto
.
Message
parseDelimitedFrom
(
java
.
io
.
InputStream
input
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
java
.
io
.
IOException
{
return
com
.
google
.
protobuf
.
GeneratedMessageV3
.
parseDelimitedWithIOException
(
PARSER
,
input
,
extensionRegistry
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
com
.
google
.
protobuf
.
CodedInputStream
input
)
throws
java
.
io
.
IOException
{
return
com
.
google
.
protobuf
.
GeneratedMessageV3
.
parseWithIOException
(
PARSER
,
input
);
}
public
static
IncomeMessageProto
.
Message
parseFrom
(
com
.
google
.
protobuf
.
CodedInputStream
input
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
java
.
io
.
IOException
{
return
com
.
google
.
protobuf
.
GeneratedMessageV3
.
parseWithIOException
(
PARSER
,
input
,
extensionRegistry
);
}
public
Builder
newBuilderForType
()
{
return
newBuilder
();
}
public
static
Builder
newBuilder
()
{
return
DEFAULT_INSTANCE
.
toBuilder
();
}
public
static
Builder
newBuilder
(
IncomeMessageProto
.
Message
prototype
)
{
return
DEFAULT_INSTANCE
.
toBuilder
().
mergeFrom
(
prototype
);
}
public
Builder
toBuilder
()
{
return
this
==
DEFAULT_INSTANCE
?
new
Builder
()
:
new
Builder
().
mergeFrom
(
this
);
}
@Override
protected
Builder
newBuilderForType
(
BuilderParent
parent
)
{
Builder
builder
=
new
Builder
(
parent
);
return
builder
;
}
/**
* Protobuf type {@code com.sulu.harvester.message.Message}
*/
public
static
final
class
Builder
extends
com
.
google
.
protobuf
.
GeneratedMessageV3
.
Builder
<
Builder
>
implements
// @@protoc_insertion_point(builder_implements:com.sulu.harvester.message.Message)
IncomeMessageProto
.
MessageOrBuilder
{
public
static
final
com
.
google
.
protobuf
.
Descriptors
.
Descriptor
getDescriptor
()
{
return
IncomeMessageProto
.
internal_static_com_sulu_harvester_message_Message_descriptor
;
}
protected
FieldAccessorTable
internalGetFieldAccessorTable
()
{
return
IncomeMessageProto
.
internal_static_com_sulu_harvester_message_Message_fieldAccessorTable
.
ensureFieldAccessorsInitialized
(
IncomeMessageProto
.
Message
.
class
,
IncomeMessageProto
.
Message
.
Builder
.
class
);
}
// Construct using com.sulu.harvester.message.IncomeMessageProto.Message.newBuilder()
private
Builder
()
{
maybeForceBuilderInitialization
();
}
private
Builder
(
BuilderParent
parent
)
{
super
(
parent
);
maybeForceBuilderInitialization
();
}
private
void
maybeForceBuilderInitialization
()
{
if
(
com
.
google
.
protobuf
.
GeneratedMessageV3
.
alwaysUseFieldBuilders
)
{
}
}
public
Builder
clear
()
{
super
.
clear
();
imei_
=
""
;
bitField0_
=
(
bitField0_
&
~
0x00000001
);
mobile_
=
""
;
bitField0_
=
(
bitField0_
&
~
0x00000002
);
cTimestamp_
=
0L
;
bitField0_
=
(
bitField0_
&
~
0x00000004
);
type_
=
1
;
bitField0_
=
(
bitField0_
&
~
0x00000008
);
body_
=
""
;
bitField0_
=
(
bitField0_
&
~
0x00000010
);
version_
=
""
;
bitField0_
=
(
bitField0_
&
~
0x00000020
);
controlCmd_
=
""
;
bitField0_
=
(
bitField0_
&
~
0x00000040
);
sessionId_
=
""
;
bitField0_
=
(
bitField0_
&
~
0x00000080
);
return
this
;
}
public
com
.
google
.
protobuf
.
Descriptors
.
Descriptor
getDescriptorForType
()
{
return
IncomeMessageProto
.
internal_static_com_sulu_harvester_message_Message_descriptor
;
}
public
IncomeMessageProto
.
Message
getDefaultInstanceForType
()
{
return
IncomeMessageProto
.
Message
.
getDefaultInstance
();
}
public
IncomeMessageProto
.
Message
build
()
{
IncomeMessageProto
.
Message
result
=
buildPartial
();
if
(!
result
.
isInitialized
())
{
throw
newUninitializedMessageException
(
result
);
}
return
result
;
}
public
IncomeMessageProto
.
Message
buildPartial
()
{
IncomeMessageProto
.
Message
result
=
new
IncomeMessageProto
.
Message
(
this
);
int
from_bitField0_
=
bitField0_
;
int
to_bitField0_
=
0
;
if
(((
from_bitField0_
&
0x00000001
)
==
0x00000001
))
{
to_bitField0_
|=
0x00000001
;
}
result
.
imei_
=
imei_
;
if
(((
from_bitField0_
&
0x00000002
)
==
0x00000002
))
{
to_bitField0_
|=
0x00000002
;
}
result
.
mobile_
=
mobile_
;
if
(((
from_bitField0_
&
0x00000004
)
==
0x00000004
))
{
to_bitField0_
|=
0x00000004
;
}
result
.
cTimestamp_
=
cTimestamp_
;
if
(((
from_bitField0_
&
0x00000008
)
==
0x00000008
))
{
to_bitField0_
|=
0x00000008
;
}
result
.
type_
=
type_
;
if
(((
from_bitField0_
&
0x00000010
)
==
0x00000010
))
{
to_bitField0_
|=
0x00000010
;
}
result
.
body_
=
body_
;
if
(((
from_bitField0_
&
0x00000020
)
==
0x00000020
))
{
to_bitField0_
|=
0x00000020
;
}
result
.
version_
=
version_
;
if
(((
from_bitField0_
&
0x00000040
)
==
0x00000040
))
{
to_bitField0_
|=
0x00000040
;
}
result
.
controlCmd_
=
controlCmd_
;
if
(((
from_bitField0_
&
0x00000080
)
==
0x00000080
))
{
to_bitField0_
|=
0x00000080
;
}
result
.
sessionId_
=
sessionId_
;
result
.
bitField0_
=
to_bitField0_
;
onBuilt
();
return
result
;
}
public
Builder
clone
()
{
return
(
Builder
)
super
.
clone
();
}
public
Builder
setField
(
com
.
google
.
protobuf
.
Descriptors
.
FieldDescriptor
field
,
Object
value
)
{
return
(
Builder
)
super
.
setField
(
field
,
value
);
}
public
Builder
clearField
(
com
.
google
.
protobuf
.
Descriptors
.
FieldDescriptor
field
)
{
return
(
Builder
)
super
.
clearField
(
field
);
}
public
Builder
clearOneof
(
com
.
google
.
protobuf
.
Descriptors
.
OneofDescriptor
oneof
)
{
return
(
Builder
)
super
.
clearOneof
(
oneof
);
}
public
Builder
setRepeatedField
(
com
.
google
.
protobuf
.
Descriptors
.
FieldDescriptor
field
,
int
index
,
Object
value
)
{
return
(
Builder
)
super
.
setRepeatedField
(
field
,
index
,
value
);
}
public
Builder
addRepeatedField
(
com
.
google
.
protobuf
.
Descriptors
.
FieldDescriptor
field
,
Object
value
)
{
return
(
Builder
)
super
.
addRepeatedField
(
field
,
value
);
}
public
Builder
mergeFrom
(
com
.
google
.
protobuf
.
Message
other
)
{
if
(
other
instanceof
IncomeMessageProto
.
Message
)
{
return
mergeFrom
((
IncomeMessageProto
.
Message
)
other
);
}
else
{
super
.
mergeFrom
(
other
);
return
this
;
}
}
public
Builder
mergeFrom
(
IncomeMessageProto
.
Message
other
)
{
if
(
other
==
IncomeMessageProto
.
Message
.
getDefaultInstance
())
return
this
;
if
(
other
.
hasImei
())
{
bitField0_
|=
0x00000001
;
imei_
=
other
.
imei_
;
onChanged
();
}
if
(
other
.
hasMobile
())
{
bitField0_
|=
0x00000002
;
mobile_
=
other
.
mobile_
;
onChanged
();
}
if
(
other
.
hasCTimestamp
())
{
setCTimestamp
(
other
.
getCTimestamp
());
}
if
(
other
.
hasType
())
{
setType
(
other
.
getType
());
}
if
(
other
.
hasBody
())
{
bitField0_
|=
0x00000010
;
body_
=
other
.
body_
;
onChanged
();
}
if
(
other
.
hasVersion
())
{
bitField0_
|=
0x00000020
;
version_
=
other
.
version_
;
onChanged
();
}
if
(
other
.
hasControlCmd
())
{
bitField0_
|=
0x00000040
;
controlCmd_
=
other
.
controlCmd_
;
onChanged
();
}
if
(
other
.
hasSessionId
())
{
bitField0_
|=
0x00000080
;
sessionId_
=
other
.
sessionId_
;
onChanged
();
}
this
.
mergeUnknownFields
(
other
.
unknownFields
);
onChanged
();
return
this
;
}
public
final
boolean
isInitialized
()
{
if
(!
hasCTimestamp
())
{
return
false
;
}
if
(!
hasType
())
{
return
false
;
}
if
(!
hasBody
())
{
return
false
;
}
return
true
;
}
public
Builder
mergeFrom
(
com
.
google
.
protobuf
.
CodedInputStream
input
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
java
.
io
.
IOException
{
IncomeMessageProto
.
Message
parsedMessage
=
null
;
try
{
parsedMessage
=
PARSER
.
parsePartialFrom
(
input
,
extensionRegistry
);
}
catch
(
com
.
google
.
protobuf
.
InvalidProtocolBufferException
e
)
{
parsedMessage
=
(
IncomeMessageProto
.
Message
)
e
.
getUnfinishedMessage
();
throw
e
.
unwrapIOException
();
}
finally
{
if
(
parsedMessage
!=
null
)
{
mergeFrom
(
parsedMessage
);
}
}
return
this
;
}
private
int
bitField0_
;
private
Object
imei_
=
""
;
/**
* <code>optional string imei = 1;</code>
*/
public
boolean
hasImei
()
{
return
((
bitField0_
&
0x00000001
)
==
0x00000001
);
}
/**
* <code>optional string imei = 1;</code>
*/
public
String
getImei
()
{
Object
ref
=
imei_
;
if
(!(
ref
instanceof
String
))
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
imei_
=
s
;
}
return
s
;
}
else
{
return
(
String
)
ref
;
}
}
/**
* <code>optional string imei = 1;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getImeiBytes
()
{
Object
ref
=
imei_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
imei_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
/**
* <code>optional string imei = 1;</code>
*/
public
Builder
setImei
(
String
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000001
;
imei_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>optional string imei = 1;</code>
*/
public
Builder
clearImei
()
{
bitField0_
=
(
bitField0_
&
~
0x00000001
);
imei_
=
getDefaultInstance
().
getImei
();
onChanged
();
return
this
;
}
/**
* <code>optional string imei = 1;</code>
*/
public
Builder
setImeiBytes
(
com
.
google
.
protobuf
.
ByteString
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000001
;
imei_
=
value
;
onChanged
();
return
this
;
}
private
Object
mobile_
=
""
;
/**
* <code>optional string mobile = 2;</code>
*/
public
boolean
hasMobile
()
{
return
((
bitField0_
&
0x00000002
)
==
0x00000002
);
}
/**
* <code>optional string mobile = 2;</code>
*/
public
String
getMobile
()
{
Object
ref
=
mobile_
;
if
(!(
ref
instanceof
String
))
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
mobile_
=
s
;
}
return
s
;
}
else
{
return
(
String
)
ref
;
}
}
/**
* <code>optional string mobile = 2;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getMobileBytes
()
{
Object
ref
=
mobile_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
mobile_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
/**
* <code>optional string mobile = 2;</code>
*/
public
Builder
setMobile
(
String
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000002
;
mobile_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>optional string mobile = 2;</code>
*/
public
Builder
clearMobile
()
{
bitField0_
=
(
bitField0_
&
~
0x00000002
);
mobile_
=
getDefaultInstance
().
getMobile
();
onChanged
();
return
this
;
}
/**
* <code>optional string mobile = 2;</code>
*/
public
Builder
setMobileBytes
(
com
.
google
.
protobuf
.
ByteString
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000002
;
mobile_
=
value
;
onChanged
();
return
this
;
}
private
long
cTimestamp_
;
/**
* <code>required int64 c_timestamp = 3;</code>
*/
public
boolean
hasCTimestamp
()
{
return
((
bitField0_
&
0x00000004
)
==
0x00000004
);
}
/**
* <code>required int64 c_timestamp = 3;</code>
*/
public
long
getCTimestamp
()
{
return
cTimestamp_
;
}
/**
* <code>required int64 c_timestamp = 3;</code>
*/
public
Builder
setCTimestamp
(
long
value
)
{
bitField0_
|=
0x00000004
;
cTimestamp_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>required int64 c_timestamp = 3;</code>
*/
public
Builder
clearCTimestamp
()
{
bitField0_
=
(
bitField0_
&
~
0x00000004
);
cTimestamp_
=
0L
;
onChanged
();
return
this
;
}
private
int
type_
=
1
;
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
public
boolean
hasType
()
{
return
((
bitField0_
&
0x00000008
)
==
0x00000008
);
}
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
public
IncomeMessageProto
.
Message
.
Type
getType
()
{
IncomeMessageProto
.
Message
.
Type
result
=
IncomeMessageProto
.
Message
.
Type
.
valueOf
(
type_
);
return
result
==
null
?
IncomeMessageProto
.
Message
.
Type
.
TRACE
:
result
;
}
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
public
Builder
setType
(
IncomeMessageProto
.
Message
.
Type
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000008
;
type_
=
value
.
getNumber
();
onChanged
();
return
this
;
}
/**
* <code>required .com.sulu.harvester.message.Message.Type type = 4 [default = TRACE];</code>
*/
public
Builder
clearType
()
{
bitField0_
=
(
bitField0_
&
~
0x00000008
);
type_
=
1
;
onChanged
();
return
this
;
}
private
Object
body_
=
""
;
/**
* <code>required string body = 5;</code>
*/
public
boolean
hasBody
()
{
return
((
bitField0_
&
0x00000010
)
==
0x00000010
);
}
/**
* <code>required string body = 5;</code>
*/
public
String
getBody
()
{
Object
ref
=
body_
;
if
(!(
ref
instanceof
String
))
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
body_
=
s
;
}
return
s
;
}
else
{
return
(
String
)
ref
;
}
}
/**
* <code>required string body = 5;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getBodyBytes
()
{
Object
ref
=
body_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
body_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
/**
* <code>required string body = 5;</code>
*/
public
Builder
setBody
(
String
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000010
;
body_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>required string body = 5;</code>
*/
public
Builder
clearBody
()
{
bitField0_
=
(
bitField0_
&
~
0x00000010
);
body_
=
getDefaultInstance
().
getBody
();
onChanged
();
return
this
;
}
/**
* <code>required string body = 5;</code>
*/
public
Builder
setBodyBytes
(
com
.
google
.
protobuf
.
ByteString
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000010
;
body_
=
value
;
onChanged
();
return
this
;
}
private
Object
version_
=
""
;
/**
* <code>optional string version = 6;</code>
*/
public
boolean
hasVersion
()
{
return
((
bitField0_
&
0x00000020
)
==
0x00000020
);
}
/**
* <code>optional string version = 6;</code>
*/
public
String
getVersion
()
{
Object
ref
=
version_
;
if
(!(
ref
instanceof
String
))
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
version_
=
s
;
}
return
s
;
}
else
{
return
(
String
)
ref
;
}
}
/**
* <code>optional string version = 6;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getVersionBytes
()
{
Object
ref
=
version_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
version_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
/**
* <code>optional string version = 6;</code>
*/
public
Builder
setVersion
(
String
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000020
;
version_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>optional string version = 6;</code>
*/
public
Builder
clearVersion
()
{
bitField0_
=
(
bitField0_
&
~
0x00000020
);
version_
=
getDefaultInstance
().
getVersion
();
onChanged
();
return
this
;
}
/**
* <code>optional string version = 6;</code>
*/
public
Builder
setVersionBytes
(
com
.
google
.
protobuf
.
ByteString
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000020
;
version_
=
value
;
onChanged
();
return
this
;
}
private
Object
controlCmd_
=
""
;
/**
* <code>optional string control_cmd = 7;</code>
*/
public
boolean
hasControlCmd
()
{
return
((
bitField0_
&
0x00000040
)
==
0x00000040
);
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
String
getControlCmd
()
{
Object
ref
=
controlCmd_
;
if
(!(
ref
instanceof
String
))
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
controlCmd_
=
s
;
}
return
s
;
}
else
{
return
(
String
)
ref
;
}
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getControlCmdBytes
()
{
Object
ref
=
controlCmd_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
controlCmd_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
Builder
setControlCmd
(
String
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000040
;
controlCmd_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
Builder
clearControlCmd
()
{
bitField0_
=
(
bitField0_
&
~
0x00000040
);
controlCmd_
=
getDefaultInstance
().
getControlCmd
();
onChanged
();
return
this
;
}
/**
* <code>optional string control_cmd = 7;</code>
*/
public
Builder
setControlCmdBytes
(
com
.
google
.
protobuf
.
ByteString
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000040
;
controlCmd_
=
value
;
onChanged
();
return
this
;
}
private
Object
sessionId_
=
""
;
/**
* <code>optional string session_id = 8;</code>
*/
public
boolean
hasSessionId
()
{
return
((
bitField0_
&
0x00000080
)
==
0x00000080
);
}
/**
* <code>optional string session_id = 8;</code>
*/
public
String
getSessionId
()
{
Object
ref
=
sessionId_
;
if
(!(
ref
instanceof
String
))
{
com
.
google
.
protobuf
.
ByteString
bs
=
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
String
s
=
bs
.
toStringUtf8
();
if
(
bs
.
isValidUtf8
())
{
sessionId_
=
s
;
}
return
s
;
}
else
{
return
(
String
)
ref
;
}
}
/**
* <code>optional string session_id = 8;</code>
*/
public
com
.
google
.
protobuf
.
ByteString
getSessionIdBytes
()
{
Object
ref
=
sessionId_
;
if
(
ref
instanceof
String
)
{
com
.
google
.
protobuf
.
ByteString
b
=
com
.
google
.
protobuf
.
ByteString
.
copyFromUtf8
(
(
String
)
ref
);
sessionId_
=
b
;
return
b
;
}
else
{
return
(
com
.
google
.
protobuf
.
ByteString
)
ref
;
}
}
/**
* <code>optional string session_id = 8;</code>
*/
public
Builder
setSessionId
(
String
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000080
;
sessionId_
=
value
;
onChanged
();
return
this
;
}
/**
* <code>optional string session_id = 8;</code>
*/
public
Builder
clearSessionId
()
{
bitField0_
=
(
bitField0_
&
~
0x00000080
);
sessionId_
=
getDefaultInstance
().
getSessionId
();
onChanged
();
return
this
;
}
/**
* <code>optional string session_id = 8;</code>
*/
public
Builder
setSessionIdBytes
(
com
.
google
.
protobuf
.
ByteString
value
)
{
if
(
value
==
null
)
{
throw
new
NullPointerException
();
}
bitField0_
|=
0x00000080
;
sessionId_
=
value
;
onChanged
();
return
this
;
}
public
final
Builder
setUnknownFields
(
final
com
.
google
.
protobuf
.
UnknownFieldSet
unknownFields
)
{
return
super
.
setUnknownFields
(
unknownFields
);
}
public
final
Builder
mergeUnknownFields
(
final
com
.
google
.
protobuf
.
UnknownFieldSet
unknownFields
)
{
return
super
.
mergeUnknownFields
(
unknownFields
);
}
// @@protoc_insertion_point(builder_scope:com.sulu.harvester.message.Message)
}
// @@protoc_insertion_point(class_scope:com.sulu.harvester.message.Message)
private
static
final
IncomeMessageProto
.
Message
DEFAULT_INSTANCE
;
static
{
DEFAULT_INSTANCE
=
new
IncomeMessageProto
.
Message
();
}
public
static
IncomeMessageProto
.
Message
getDefaultInstance
()
{
return
DEFAULT_INSTANCE
;
}
@Deprecated
public
static
final
com
.
google
.
protobuf
.
Parser
<
Message
>
PARSER
=
new
com
.
google
.
protobuf
.
AbstractParser
<
Message
>()
{
public
Message
parsePartialFrom
(
com
.
google
.
protobuf
.
CodedInputStream
input
,
com
.
google
.
protobuf
.
ExtensionRegistryLite
extensionRegistry
)
throws
com
.
google
.
protobuf
.
InvalidProtocolBufferException
{
return
new
Message
(
input
,
extensionRegistry
);
}
};
public
static
com
.
google
.
protobuf
.
Parser
<
Message
>
parser
()
{
return
PARSER
;
}
@Override
public
com
.
google
.
protobuf
.
Parser
<
Message
>
getParserForType
()
{
return
PARSER
;
}
public
IncomeMessageProto
.
Message
getDefaultInstanceForType
()
{
return
DEFAULT_INSTANCE
;
}
}
private
static
final
com
.
google
.
protobuf
.
Descriptors
.
Descriptor
internal_static_com_sulu_harvester_message_Message_descriptor
;
private
static
final
com
.
google
.
protobuf
.
GeneratedMessageV3
.
FieldAccessorTable
internal_static_com_sulu_harvester_message_Message_fieldAccessorTable
;
public
static
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
getDescriptor
()
{
return
descriptor
;
}
private
static
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
descriptor
;
static
{
String
[]
descriptorData
=
{
"\n\023IncomeMessage.proto\022\032com.sulu.harveste"
+
"r.message\"\343\001\n\007Message\022\014\n\004imei\030\001 \001(\t\022\016\n\006m"
+
"obile\030\002 \001(\t\022\023\n\013c_timestamp\030\003 \002(\003\022=\n\004type"
+
"\030\004 \002(\0162(.com.sulu.harvester.message.Mess"
+
"age.Type:\005TRACE\022\014\n\004body\030\005 \002(\t\022\017\n\007version"
+
"\030\006 \001(\t\022\023\n\013control_cmd\030\007 \001(\t\022\022\n\nsession_i"
+
"d\030\010 \001(\t\"\036\n\004Type\022\013\n\007UNKNOWN\020\000\022\t\n\005TRACE\020\001B"
+
"0\n\032com.sulu.harvester.messageB\022IncomeMes"
+
"sageProto"
};
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
.
InternalDescriptorAssigner
assigner
=
new
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
.
InternalDescriptorAssigner
()
{
public
com
.
google
.
protobuf
.
ExtensionRegistry
assignDescriptors
(
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
root
)
{
descriptor
=
root
;
return
null
;
}
};
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
.
internalBuildGeneratedFileFrom
(
descriptorData
,
new
com
.
google
.
protobuf
.
Descriptors
.
FileDescriptor
[]
{
},
assigner
);
internal_static_com_sulu_harvester_message_Message_descriptor
=
getDescriptor
().
getMessageTypes
().
get
(
0
);
internal_static_com_sulu_harvester_message_Message_fieldAccessorTable
=
new
com
.
google
.
protobuf
.
GeneratedMessageV3
.
FieldAccessorTable
(
internal_static_com_sulu_harvester_message_Message_descriptor
,
new
String
[]
{
"Imei"
,
"Mobile"
,
"CTimestamp"
,
"Type"
,
"Body"
,
"Version"
,
"ControlCmd"
,
"SessionId"
,
});
}
// @@protoc_insertion_point(outer_class_scope)
}
src/main/java/tech/starwin/utils/collection/ProtocolVersion.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
utils
.
collection
;
/**
* Created by Miaoke on 13/04/2017.
*/
public
enum
ProtocolVersion
{
V_1_0
(
"1.0"
),
CURRENT_VERSON
(
"1.0"
);
private
String
customName
;
private
ProtocolVersion
(
String
name
){
customName
=
name
;
}
public
String
getCustomName
(){
return
customName
;
}
}
\ No newline at end of file
src/main/java/tech/starwin/utils/collection/UploadManager.java
0 → 100644
View file @
2b413d0c
package
tech
.
starwin
.
utils
.
collection
;
import
android.Manifest
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.annimon.stream.Stream
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.InetSocketAddress
;
import
java.net.Socket
;
import
java.net.SocketException
;
import
java.net.SocketTimeoutException
;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
io.reactivex.Observable
;
import
io.reactivex.Observer
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.functions.Function
;
import
io.reactivex.schedulers.Schedulers
;
import
tech.starwin.LibConfig
;
import
tech.starwin.database.Collector
;
import
tech.starwin.database.DataBaseHelper
;
import
tech.starwin.database.entity.CollectInfoEntity
;
import
tech.starwin.network.Gateway
;
import
tech.starwin.utils.GeneralUtils
;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.RetryWithDelay
;
import
tech.starwin.utils.context_utils.PermissionsHelper
;
/**
* Created by SiKang on 2018/10/30.
* 上传收集的用户信息
*/
public
class
UploadManager
{
private
static
final
String
TAG
=
"UploadManager"
;
private
static
Context
context
;
public
static
void
init
(
Context
ctx
)
{
context
=
ctx
;
DataBaseHelper
.
init
(
ctx
);
}
/**
* 上传贷款相关数据
*/
public
static
void
uploadCollectInfo
(
String
sessionId
)
{
if
(
TextUtils
.
isEmpty
(
sessionId
))
{
return
;
}
PreferencesManager
.
get
().
saveSessionId
(
sessionId
);
Observable
.
just
(
true
)
.
observeOn
(
Schedulers
.
io
())
.
map
(
new
Function
<
Boolean
,
Boolean
>()
{
@Override
public
Boolean
apply
(
Boolean
aBoolean
)
throws
Exception
{
long
startTime
=
System
.
currentTimeMillis
();
//获取需要上传的数据
List
<
CollectInfoEntity
>
infos
=
Collector
.
getUploadData
(
context
);
if
(
infos
==
null
||
infos
.
size
()
==
0
)
{
return
false
;
}
//开始上传
startUpload
(
infos
,
sessionId
);
PreferencesManager
.
get
().
saveSessionId
(
""
);
return
true
;
}
})
// .retryWhen(new RetryWithDelay(5, 20 * 1000))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
();
}
/**
* 上传搜集的用户数据(联系人、通话记录、短信记录 等)
*/
public
static
void
startUpload
(
List
<
CollectInfoEntity
>
infoList
,
String
sessionId
)
throws
RuntimeException
{
Socket
socket
=
null
;
OutputStream
os
=
null
;
InputStream
ins
=
null
;
try
{
socket
=
getSocket
();
os
=
socket
.
getOutputStream
();
ins
=
socket
.
getInputStream
();
List
<
String
>
datas
=
Stream
.
of
(
infoList
)
.
map
(
t
->
GZipUtil
.
compress
(
t
.
getBody
(),
"utf-8"
))
.
map
(
t
->
android
.
util
.
Base64
.
encodeToString
(
t
,
0
))
.
reduce
(
new
ArrayList
<>(),
(
array
,
t
)
->
{
array
.
add
(
t
);
return
array
;
});
int
count
=
Stream
.
of
(
datas
).
reduce
(
0
,
(
accr
,
item
)
->
accr
+
item
.
length
());
LogUtils
.
d
(
TAG
,
"upload count:"
+
(
count
/
1024
+
"k"
));
for
(
int
i
=
0
;
i
<
datas
.
size
();
i
++)
{
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
.
setVersion
(
"2"
)
.
setBody
(
datas
.
get
(
i
))
.
setImei
(
GeneralUtils
.
getAndroidID
(
context
))
.
setMobile
(
"084564444490"
)
.
setCTimestamp
(
System
.
currentTimeMillis
())
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
.
setSessionId
(
sessionId
)
.
build
();
message
.
writeDelimitedTo
(
os
);
os
.
flush
();
IncomeMessageProto
.
Message
feedback
=
IncomeMessageProto
.
Message
.
parseDelimitedFrom
(
ins
);
if
(
feedback
!=
null
)
{
String
from
=
feedback
.
toString
();
LogUtils
.
d
(
TAG
,
"feedback: "
+
from
);
}
}
//发送上传结束指令
sendControlCommand
(
os
,
"CLOSE"
,
sessionId
,
" datas.size="
+
datas
.
size
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
.
getMessage
());
}
finally
{
try
{
os
.
close
();
ins
.
close
();
socket
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* 创建Socket
*/
private
static
Socket
getSocket
()
throws
IOException
{
String
harvesterUrl
=
Gateway
.
getHarvesterUrl
();
harvesterUrl
=
harvesterUrl
.
replaceAll
(
"http://"
,
""
);
harvesterUrl
=
harvesterUrl
.
replaceAll
(
"https://"
,
""
);
String
ip
=
harvesterUrl
.
split
(
":"
)[
0
];
int
port
;
if
(
harvesterUrl
.
length
()
<=
1
)
{
port
=
LibConfig
.
HARVESTER_PORT
;
}
else
{
try
{
port
=
Integer
.
valueOf
(
harvesterUrl
.
split
(
":"
)[
1
]);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
port
=
LibConfig
.
HARVESTER_PORT
;
}
}
Socket
socket
=
new
Socket
();
try
{
socket
.
setSoTimeout
(
30
*
1000
);
socket
.
connect
(
new
InetSocketAddress
(
ip
,
port
),
10
*
1000
);
}
catch
(
UnknownHostException
|
SocketException
|
SocketTimeoutException
e
)
{
e
.
printStackTrace
();
}
LogUtils
.
d
(
TAG
,
"socket.getInetAddress() = "
+
socket
.
getInetAddress
());
LogUtils
.
d
(
TAG
,
"socket.getPort() = "
+
socket
.
getPort
());
LogUtils
.
d
(
TAG
,
"socket.getRemoteSocketAddress() = "
+
socket
.
getRemoteSocketAddress
());
return
socket
;
}
/**
* 发送指令
*
* @param body 上传内容长度 + 权限获取状态
*/
private
static
void
sendControlCommand
(
OutputStream
os
,
String
cmd
,
String
sessionId
,
String
body
)
throws
IOException
{
IncomeMessageProto
.
Message
closeMsg
=
IncomeMessageProto
.
Message
.
newBuilder
()
.
setCTimestamp
(
0
)
.
setVersion
(
"2"
)
.
setBody
(
body
+
" permission="
+
getPermissionState
(
context
).
toString
())
.
setImei
(
GeneralUtils
.
getAndroidID
(
context
))
.
setMobile
(
LoginManager
.
get
().
getMobile
()
!=
null
?
LoginManager
.
get
().
getMobile
()
:
""
)
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
UNKNOWN
)
.
setControlCmd
(
cmd
)
.
setSessionId
(
sessionId
)
.
build
();
closeMsg
.
writeDelimitedTo
(
os
);
os
.
flush
();
}
/**
* 权限获取状态
*/
private
static
JSONArray
getPermissionState
(
Context
context
)
{
String
[]
permissionsTocheck
=
{
Manifest
.
permission
.
READ_CONTACTS
,
Manifest
.
permission
.
READ_CALL_LOG
,
Manifest
.
permission
.
READ_SMS
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
//粗精度定位
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
//卫星定位
Manifest
.
permission
.
READ_PHONE_STATE
};
JSONArray
array
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
permissionsTocheck
.
length
;
i
++)
{
try
{
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"checkTime"
,
System
.
currentTimeMillis
());
object
.
put
(
"permissionType"
,
permissionsTocheck
[
i
]);
if
(
PermissionsHelper
.
permissionGranted
(
permissionsTocheck
[
i
],
context
))
{
object
.
put
(
"isGranted"
,
"GRANTED"
);
}
else
{
object
.
put
(
"isGranted"
,
"REFUSED"
);
}
array
.
put
(
object
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
// UploadUtils.uploadException(e, "Collector.getPermissionState");
}
}
return
array
;
}
public
interface
OnUploadListener
{
void
onSuccess
(
String
sessionId
);
void
onFailed
(
String
sessionId
,
Throwable
e
);
}
public
static
void
uploadException
(
Throwable
ex
,
@NonNull
String
tag
)
{
Observable
.
just
(
true
)
.
subscribeOn
(
Schedulers
.
io
())
.
map
(
new
Function
<
Boolean
,
Boolean
>()
{
@Override
public
Boolean
apply
(
Boolean
aBoolean
)
throws
Exception
{
Socket
socket
=
null
;
OutputStream
os
=
null
;
InputStream
ins
=
null
;
try
{
String
exBody
=
ExceptionHelper
.
getCrashMsgBody
(
context
,
ExceptionHelper
.
throwable2String
(
ex
),
tag
).
toString
();
exBody
=
android
.
util
.
Base64
.
encodeToString
(
GZipUtil
.
compress
(
exBody
,
"utf-8"
),
0
);
socket
=
getSocket
();
os
=
socket
.
getOutputStream
();
ins
=
socket
.
getInputStream
();
String
sessionId
=
UUID
.
randomUUID
().
toString
();
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
.
setVersion
(
"2"
)
.
setBody
(
exBody
)
.
setImei
(
GeneralUtils
.
getAndroidID
(
context
))
.
setMobile
(
LoginManager
.
get
().
getMobile
()
!=
null
?
LoginManager
.
get
().
getMobile
()
:
""
)
.
setCTimestamp
(
System
.
currentTimeMillis
())
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
.
setSessionId
(
sessionId
)
.
build
();
message
.
writeDelimitedTo
(
os
);
os
.
flush
();
IncomeMessageProto
.
Message
feedback
=
IncomeMessageProto
.
Message
.
parseDelimitedFrom
(
ins
);
String
from
=
feedback
.
toString
();
sendControlCommand
(
os
,
"CLOSE"
,
sessionId
,
"exception upload completed"
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
try
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
ins
!=
null
)
{
ins
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
true
;
}
})
.
subscribe
();
}
}
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
View file @
2b413d0c
...
...
@@ -5,6 +5,7 @@ import android.content.Context;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Parcelable
;
import
java.io.Serializable
;
...
...
@@ -111,6 +112,11 @@ public class ActivityJumper {
return
this
;
}
public
Builder
put
(
String
key
,
Parcelable
obj
)
{
intent
.
putExtra
(
key
,
obj
);
return
this
;
}
public
ActivityJumper
build
()
{
return
new
ActivityJumper
(
fromContext
,
intent
);
}
...
...
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
View file @
2b413d0c
...
...
@@ -7,11 +7,13 @@ import android.content.ComponentName;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.Settings
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentActivity
;
import
android.support.v4.content.PermissionChecker
;
import
com.tbruyelle.rxpermissions2.Permission
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
...
...
@@ -201,6 +203,16 @@ public class PermissionsHelper {
}
/**
* 是否同意了某个权限
*/
public
static
boolean
permissionGranted
(
String
permission
,
Context
ctx
)
{
if
(
permission
==
null
)
{
return
true
;
}
return
Build
.
VERSION
.
SDK_INT
<
23
||
PermissionChecker
.
checkSelfPermission
(
ctx
,
permission
)
==
PackageManager
.
PERMISSION_GRANTED
;
}
public
interface
OnPermissionListener
{
/**
* 允许权限
...
...
src/main/java/tech/starwin/utils/DataFormat.java
→
src/main/java/tech/starwin/utils/
format_utils/
DataFormat.java
View file @
2b413d0c
package
tech
.
starwin
.
utils
;
package
tech
.
starwin
.
utils
.
format_utils
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
...
...
@@ -23,6 +23,7 @@ import tech.starwin.R;
/**
* Created by SiKang on 2018/10/16.
* 时间、货币、String、Bean 格式化工具
*/
public
class
DataFormat
{
...
...
src/main/java/tech/starwin/utils/InfoTranslator.java
→
src/main/java/tech/starwin/utils/
format_utils/
InfoTranslator.java
View file @
2b413d0c
package
tech
.
starwin
.
utils
;
package
tech
.
starwin
.
utils
.
format_utils
;
import
android.content.Context
;
import
tech.starwin.R
;
import
tech.starwin.utils.format_utils.StringAdapter
;
/**
...
...
src/main/java/tech/starwin/utils/StringAdapter.java
→
src/main/java/tech/starwin/utils/
format_utils/
StringAdapter.java
View file @
2b413d0c
package
tech
.
starwin
.
utils
;
package
tech
.
starwin
.
utils
.
format_utils
;
import
android.text.TextUtils
;
...
...
src/main/java/tech/starwin/utils/ui_utils/DialogFactory.java
View file @
2b413d0c
...
...
@@ -9,7 +9,12 @@ import android.content.Context;
import
android.content.ContextWrapper
;
import
android.content.DialogInterface
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.annotation.LayoutRes
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.text.InputType
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.Toast
;
...
...
@@ -23,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import
io.reactivex.Observable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.functions.Consumer
;
import
tech.starwin.base.RecyclerViewHolder
;
/**
...
...
@@ -45,16 +51,27 @@ public class DialogFactory {
/**
* 创建一个带有文本提示的对话框
*/
public
static
void
showMessageDialog
(
Context
context
,
String
msg
)
{
createMessageDialog
(
context
,
"Tip"
,
msg
,
"ok"
).
show
();
}
public
static
Dialog
createMessageDialog
(
Context
context
,
String
title
,
String
message
,
String
btnText
)
{
return
createMessageDialog
(
context
,
title
,
message
,
btnText
,
null
);
}
public
static
Dialog
createMessageDialog
(
Context
context
,
String
title
,
String
message
,
String
btnText
,
QMUIDialogAction
.
ActionListener
listener
)
{
if
(
listener
==
null
)
{
listener
=
new
QMUIDialogAction
.
ActionListener
()
{
@Override
public
void
onClick
(
QMUIDialog
dialog
,
int
index
)
{
dialog
.
dismiss
();
}
};
}
return
new
QMUIDialog
.
MessageDialogBuilder
(
context
)
.
setTitle
(
title
)
.
setMessage
(
message
)
.
addAction
(
btnText
,
new
QMUIDialogAction
.
ActionListener
()
{
@Override
public
void
onClick
(
QMUIDialog
dialog
,
int
index
)
{
dialog
.
dismiss
();
}
})
.
addAction
(
btnText
,
listener
)
.
create
();
}
...
...
@@ -154,13 +171,17 @@ public class DialogFactory {
}
public
static
Dialog
showCustomDialog
(
View
view
)
{
Dialog
dialog
=
new
AlertDialog
.
Builder
(
view
.
getContext
()).
create
();
dialog
.
show
();
dialog
.
getWindow
().
setContentView
(
view
);
/**
* 创建一个自定义的View
*/
public
static
Dialog
createCustomDialog
(
Context
context
,
@LayoutRes
int
layout
,
OnViewCreatedListener
listener
)
{
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
layout
,
null
);
Dialog
dialog
=
new
CustomDialog
(
context
,
view
);
listener
.
onCreatedView
(
dialog
,
new
RecyclerViewHolder
(
view
));
return
dialog
;
}
/**
* 显示一个对话框,并在计时结束后dismiss
*/
...
...
@@ -191,6 +212,10 @@ public class DialogFactory {
void
onClick
(
Dialog
dialog
,
boolean
isAgree
);
}
public
interface
OnViewCreatedListener
{
void
onCreatedView
(
Dialog
dialog
,
RecyclerViewHolder
viewHolder
);
}
public
static
void
dismiss
(
Dialog
dialog
)
{
if
(
dialog
!=
null
)
{
Context
context
=
((
ContextWrapper
)
dialog
.
getContext
()).
getBaseContext
();
...
...
@@ -205,4 +230,19 @@ public class DialogFactory {
}
}
public
static
class
CustomDialog
extends
Dialog
{
View
view
;
public
CustomDialog
(
@NonNull
Context
context
,
View
view
)
{
super
(
context
);
this
.
view
=
view
;
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
view
);
}
}
}
src/main/java/tech/starwin/widget/ProgressDialog.java
View file @
2b413d0c
...
...
@@ -16,6 +16,7 @@ import tech.starwin.utils.ui_utils.DialogFactory;
*/
public
class
ProgressDialog
{
//loading dialog
private
boolean
enable
=
true
;
private
Dialog
loadingDialog
;
private
Context
context
;
...
...
@@ -31,7 +32,7 @@ public class ProgressDialog {
public
void
showLoading
()
{
if
(!
loadingDialog
.
isShowing
())
{
if
(!
loadingDialog
.
isShowing
()
&&
enable
)
{
loadingDialog
.
show
();
}
}
...
...
@@ -44,7 +45,7 @@ public class ProgressDialog {
/**
* 关闭loading 显示错误提示
*
*
/
*/
@SuppressLint
(
"CheckResult"
)
public
void
showError
(
String
msg
)
{
final
Dialog
errorDialog
=
DialogFactory
.
createTipDialog
(
context
,
QMUITipDialog
.
Builder
.
ICON_TYPE_FAIL
,
msg
);
...
...
@@ -53,5 +54,7 @@ public class ProgressDialog {
DialogFactory
.
showTiming
(
errorDialog
,
1500
);
}
public
void
setEnable
(
boolean
enable
)
{
this
.
enable
=
enable
;
}
}
src/main/res/drawable/s
tyl
e_grayborder_round.xml
→
src/main/res/drawable/s
hap
e_grayborder_round.xml
View file @
2b413d0c
File moved
src/main/res/drawable/s
tyl
e_graysolid_round.xml
→
src/main/res/drawable/s
hap
e_graysolid_round.xml
View file @
2b413d0c
File moved
src/main/res/drawable/s
tyl
e_mainsolid_round.xml
→
src/main/res/drawable/s
hap
e_mainsolid_round.xml
View file @
2b413d0c
File moved
src/main/res/layout/item_of_regions.xml
View file @
2b413d0c
...
...
@@ -9,14 +9,11 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"center_horizontal"
android:background=
"?android:attr/selectableItemBackground"
android:gravity=
"center_horizontal"
android:padding=
"@dimen/x_30"
android:text=
"region"
android:textColor=
"@color/
colorB
lack"
/>
android:textColor=
"@color/
b
lack"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/x_2"
android:background=
"@color/big_rec_line_color"
/>
<TextView
style=
"@style/gray_line"
/>
</LinearLayout>
\ No newline at end of file
src/main/res/values/colors.xml
View file @
2b413d0c
...
...
@@ -2,70 +2,17 @@
<resources>
<!--蓝色:3e75c8 绿色:6fc4bb 中灰:8e949b 浅灰色:bcc6d1-->
<!--background\shape color-->
<color
name=
"colorPrimary"
>
@color/theme
</color>
<color
name=
"colorPrimaryDark"
>
@color/theme_d
</color>
<color
name=
"colorAccent"
>
@color/accent
</color>
<color
name=
"colorBackground"
>
@color/page_background
</color>
<color
name=
"colorBackground_d"
>
#f2f2f2
</color>
<color
name=
"red"
>
#ef4e4e
</color>
<color
name=
"hover"
>
#0ea26c
</color>
<color
name=
"colorPrimary"
>
#3F51B5
</color>
<color
name=
"colorPrimaryDark"
>
#303F9F
</color>
<color
name=
"colorAccent"
>
#FF4081
</color>
<!--背景灰-->
<color
name=
"gray_bg"
>
#F7F7F7
</color>
<!--text color-->
<color
name=
"textDeep"
>
#272637
</color>
<color
name=
"textNormal"
>
#262536
</color>
<color
name=
"textHint"
>
#7b7a89
</color>
<color
name=
"textLight"
>
#999999
</color>
<color
name=
"textButton"
>
@color/white
</color>
<color
name=
"textLink"
>
@color/theme
</color>
<color
name=
"textAccent"
>
@color/accent
</color>
<color
name=
"textButton_Tab"
>
#ccd2d5
</color>
<color
name=
"textButton_Tab_active"
>
@color/theme
</color>
<color
name=
"text_progress_circle_dark"
>
#7c87a0
</color>
<color
name=
"text_contack_dark"
>
#333333
</color>
<color
name=
"text_take_photo_tips"
>
#7fbec9
</color>
<color
name=
"text_loan_info"
>
#a9a9a9
</color>
<color
name=
"text_theme_dark"
>
@color/theme_d
</color>
<color
name=
"text_accent_dark"
>
@color/accent_d
</color>
<!--shape/background colors-->
<color
name=
"toolbar_background"
>
@color/color_main_dark
</color>
<color
name=
"page_background"
>
#ffffff
</color>
<color
name=
"theme"
>
#10b679
</color>
<color
name=
"theme_d"
>
#11b780
</color>
<color
name=
"theme_light"
>
#00c08c
</color>
<color
name=
"accent"
>
#fa5a4e
</color>
<color
name=
"accent_d"
>
#fb5b4f
</color>
<color
name=
"sys_info_color"
>
#454360
</color>
<color
name=
"big_rec_line_color"
>
#d8dee1
</color>
<color
name=
"divider_color"
>
#dedede
</color>
<color
name=
"divider_color_light"
>
#e6e6e6
</color>
<color
name=
"small_rec_active_theme"
>
@color/theme
</color>
<color
name=
"small_rec_inactive"
>
#999999
</color>
<color
name=
"button_background"
>
@color/theme
</color>
<color
name=
"progress_background"
>
#dfe4e6
</color>
<color
name=
"select_rec_background"
>
@color/white
</color>
<color
name=
"instruction_tips_background"
>
#f5f5f5
</color>
<color
name=
"divide_page_background"
>
#f5f5f5
</color>
<color
name=
"take_photo_img_background"
>
@color/colorBackground_d
</color>
<color
name=
"take_photo_bottom_background"
>
@color/white
</color>
<color
name=
"progress_background_loan_info"
>
#d8dee1
</color>
<color
name=
"im_edit_background"
>
#e9e9e9
</color>
<color
name=
"translateColor"
>
#00000000
</color>
<color
name=
"colorBlack"
>
#000
</color>
<color
name=
"bottom_tab_normal"
>
@color/sys_info_color
</color>
<color
name=
"color_main_dark"
>
#272637
</color>
<color
name=
"color_main"
>
#575673
</color>
<color
name=
"time_line_big"
>
#a3a1b2
</color>
<color
name=
"time_line_small"
>
#4f4c69
</color>
<color
name=
"splash_bg"
>
#0dbd6b
</color>
<color
name=
"payment_hint"
>
#d0cfde
</color>
<color
name=
"theme_t"
>
#80b2a0
</color>
<color
name=
"alert_t"
>
#e78b8b
</color>
<color
name=
"gray_bg"
>
#F7F7F7
</color>
<color
name=
"white"
>
@android:color/white
</color>
<color
name=
"black"
>
@android:color/black
</color>
<color
name=
"green"
>
#00EE00
</color>
<color
name=
"red"
>
#FF0000
</color>
<color
name=
"organge"
>
#EEAD0E
</color>
</resources>
src/main/res/values/styles.xml
View file @
2b413d0c
...
...
@@ -7,6 +7,12 @@
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
<style
name=
"noAnimation"
>
<item
name=
"android:activityOpenEnterAnimation"
>
@null
</item>
<item
name=
"android:activityOpenExitAnimation"
>
@null
</item>
<item
name=
"android:activityCloseEnterAnimation"
>
@null
</item>
<item
name=
"android:activityCloseExitAnimation"
>
@null
</item>
</style>
<style
name=
"style_bg_transparent_dialog"
parent=
"Base.Theme.AppCompat.Light.Dialog"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
...
...
@@ -14,6 +20,7 @@
</style>
<style
name=
"QMTheme"
parent=
"QMUI.Compat.NoActionBar"
>
<item
name=
"android:windowAnimationStyle"
>
@style/noAnimation
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
<!-- toolbar(actionbar)颜色 -->
<item
name=
"colorPrimary"
>
@color/main_color
</item>
...
...
@@ -134,7 +141,7 @@
<style
name=
"main_color_roundBtn"
>
<item
name=
"android:textColor"
>
@color/white
</item>
<item
name=
"android:background"
>
@drawable/s
tyl
e_mainsolid_round
</item>
<item
name=
"android:background"
>
@drawable/s
hap
e_mainsolid_round
</item>
</style>
<style
name=
"vertical_padding_10dp"
>
...
...
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