Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
Z
zxhc
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
zxhc
Commits
86747623
Commit
86747623
authored
Apr 09, 2021
by
王雪伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入初始化环境切换
parent
e83c498b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
13 deletions
+43
-13
vcs.xml
.idea/vcs.xml
+6
-0
MainActivity.java
app/src/main/java/com/ym/zxhcsdkaar/MainActivity.java
+1
-1
AppliContext.java
zxhcsdk/src/main/java/com/ym/zxhcsdk/AppliContext.java
+19
-1
HttpClientUtils.java
zxhcsdk/src/main/java/com/ym/zxhcsdk/HttpClientUtils.java
+6
-3
PhoneUtils.java
zxhcsdk/src/main/java/com/ym/zxhcsdk/PhoneUtils.java
+5
-1
ZXHCADManager.java
...k/src/main/java/com/ym/zxhcsdk/manager/ZXHCADManager.java
+3
-4
ZXHCSplashAD.java
zxhcsdk/src/main/java/com/ym/zxhcsdk/view/ZXHCSplashAD.java
+3
-3
No files found.
.idea/vcs.xml
0 → 100644
View file @
86747623
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
""
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/src/main/java/com/ym/zxhcsdkaar/MainActivity.java
View file @
86747623
...
@@ -32,7 +32,7 @@ public class MainActivity extends Activity {
...
@@ -32,7 +32,7 @@ public class MainActivity extends Activity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
ZXHCADManager
.
getInstance
().
InitAd
(
this
,
"1000127"
);
ZXHCADManager
.
getInstance
().
InitAd
(
this
,
"1000127"
,
false
);
String
url
=
"http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads?pid=2100154&type=api&ad_type=3&ad_w=480&ad_h=720&app_package=com.popcap.pvz2cthd&app_id=1000127&app_name=com.popcap.pvz2cthd&app_versionid=1005&device_geo_lat=&device_geo_lon=&device_imei=X6GNU17524105082&device_adid=d0cf1c3d5280f16b&device_mac=F0:C8:50:A1:4E:8E&device_width=1920&device_height=1132&device_imsi=460000501365163&device_carrier=&device_network=1&device_os=Android&device_os_version=24&device_density=2.0&device_ppi=2.0&device_ip=183.211.87.156&device_ua=Dalvik%2F2.1.0+%28Linux%3B+U%3B+Android+9%3B+Redmi+Note+8+Pro+MIUI%2FV10.4.9.0.PGGCNXM%29&device_type=0&is_mobile=1&device_model=FLA-AL10&device_brand=HUAWEI"
;
String
url
=
"http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads?pid=2100154&type=api&ad_type=3&ad_w=480&ad_h=720&app_package=com.popcap.pvz2cthd&app_id=1000127&app_name=com.popcap.pvz2cthd&app_versionid=1005&device_geo_lat=&device_geo_lon=&device_imei=X6GNU17524105082&device_adid=d0cf1c3d5280f16b&device_mac=F0:C8:50:A1:4E:8E&device_width=1920&device_height=1132&device_imsi=460000501365163&device_carrier=&device_network=1&device_os=Android&device_os_version=24&device_density=2.0&device_ppi=2.0&device_ip=183.211.87.156&device_ua=Dalvik%2F2.1.0+%28Linux%3B+U%3B+Android+9%3B+Redmi+Note+8+Pro+MIUI%2FV10.4.9.0.PGGCNXM%29&device_type=0&is_mobile=1&device_model=FLA-AL10&device_brand=HUAWEI"
;
String
BaseUrl
=
"http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads"
;
String
BaseUrl
=
"http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads"
;
new
OaidUtils
().
GetOaid
(
MainActivity
.
this
,
new
IOaidListener
()
{
new
OaidUtils
().
GetOaid
(
MainActivity
.
this
,
new
IOaidListener
()
{
...
...
zxhcsdk/src/main/java/com/ym/zxhcsdk/AppliContext.java
View file @
86747623
...
@@ -9,6 +9,8 @@ import android.text.TextUtils;
...
@@ -9,6 +9,8 @@ import android.text.TextUtils;
import
android.util.Log
;
import
android.util.Log
;
import
android.webkit.WebView
;
import
android.webkit.WebView
;
import
java.net.URLEncoder
;
public
class
AppliContext
{
public
class
AppliContext
{
...
@@ -38,7 +40,7 @@ public class AppliContext {
...
@@ -38,7 +40,7 @@ public class AppliContext {
ZXHCConstant
.
screen_size
=
PhoneUtils
.
getInstance
().
getScreenSize
(
context
)
+
""
;
ZXHCConstant
.
screen_size
=
PhoneUtils
.
getInstance
().
getScreenSize
(
context
)
+
""
;
ZXHCConstant
.
device_ip
=
PhoneUtils
.
getInstance
().
getIPAddress
(
false
)
+
""
;
ZXHCConstant
.
device_ip
=
PhoneUtils
.
getInstance
().
getIPAddress
(
false
)
+
""
;
ZXHCConstant
.
device_ua
=
new
WebView
(
context
).
getSettings
().
getUserAgentString
(
);
ZXHCConstant
.
device_ua
=
toURLEncoded
(
new
WebView
(
context
).
getSettings
().
getUserAgentString
()
);
ZXHCConstant
.
device_type
=
"0"
;
ZXHCConstant
.
device_type
=
"0"
;
ZXHCConstant
.
is_mobile
=
"1"
;
ZXHCConstant
.
is_mobile
=
"1"
;
ZXHCConstant
.
device_model
=
PhoneUtils
.
getInstance
().
getModel
();
ZXHCConstant
.
device_model
=
PhoneUtils
.
getInstance
().
getModel
();
...
@@ -68,4 +70,20 @@ public class AppliContext {
...
@@ -68,4 +70,20 @@ public class AppliContext {
}
}
}
}
public
static
String
toURLEncoded
(
String
paramString
)
{
if
(
paramString
==
null
||
paramString
.
equals
(
""
))
{
return
""
;
}
try
{
String
str
=
new
String
(
paramString
.
getBytes
(),
"UTF-8"
);
str
=
URLEncoder
.
encode
(
str
,
"UTF-8"
);
return
str
;
}
catch
(
Exception
localException
)
{
}
return
""
;
}
}
}
\ No newline at end of file
zxhcsdk/src/main/java/com/ym/zxhcsdk/HttpClientUtils.java
View file @
86747623
...
@@ -11,6 +11,7 @@ import java.io.OutputStreamWriter;
...
@@ -11,6 +11,7 @@ import java.io.OutputStreamWriter;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -67,11 +68,12 @@ public class HttpClientUtils {
...
@@ -67,11 +68,12 @@ public class HttpClientUtils {
connection
.
setConnectTimeout
(
50000
);
connection
.
setConnectTimeout
(
50000
);
connection
.
setReadTimeout
(
50000
);
connection
.
setReadTimeout
(
50000
);
// User-Agent IE9的标识
// User-Agent IE9的标识
connection
.
setRequestProperty
(
"User-Agent"
,
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;"
);
//
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;");
connection
.
setRequestProperty
(
"Accept-Language"
,
"zh-CN"
);
connection
.
setRequestProperty
(
"Accept-Language"
,
"zh-CN"
);
connection
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
connection
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
/*
/*Zx
* 当我们要获取我们请求的http地址访问的数据时就是使用connection.getInputStream().read()方式时我们就需要setDoInput(true),
* 当我们要获取我们请求的http地址访问的数据时就是使用connection.getInputStream().read()方式时我们就需要setDoInput(true),
* 根据api文档我们可知doInput默认就是为true。我们可以不用手动设置了,如果不需要读取输入流的话那就setDoInput(false)。
* 根据api文档我们可知doInput默认就是为true。我们可以不用手动设置了,如果不需要读取输入流的话那就setDoInput(false)。
* 当我们要采用非get请求给一个http网络地址传参 就是使用connection.getOutputStream().write() 方法时我们就需要setDoOutput(true), 默认是false
* 当我们要采用非get请求给一个http网络地址传参 就是使用connection.getOutputStream().write() 方法时我们就需要setDoOutput(true), 默认是false
...
@@ -82,6 +84,8 @@ public class HttpClientUtils {
...
@@ -82,6 +84,8 @@ public class HttpClientUtils {
//connection.setDoOutput(true);//Android 4.0 GET时候 用这句会变成POST 报错java.io.FileNotFoundException
//connection.setDoOutput(true);//Android 4.0 GET时候 用这句会变成POST 报错java.io.FileNotFoundException
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
connect
();
//
connection
.
connect
();
//
Log
.
d
(
"wxw"
,
"connection.getURL(); "
+
connection
.
getURL
());
int
contentLength
=
connection
.
getContentLength
();
int
contentLength
=
connection
.
getContentLength
();
if
(
connection
.
getResponseCode
()
==
200
)
{
if
(
connection
.
getResponseCode
()
==
200
)
{
inputStream
=
connection
.
getInputStream
();
//会隐式调用connect()
inputStream
=
connection
.
getInputStream
();
//会隐式调用connect()
...
@@ -341,5 +345,4 @@ public class HttpClientUtils {
...
@@ -341,5 +345,4 @@ public class HttpClientUtils {
return
str
;
return
str
;
}
}
}
}
zxhcsdk/src/main/java/com/ym/zxhcsdk/PhoneUtils.java
View file @
86747623
...
@@ -756,7 +756,11 @@ public class PhoneUtils {
...
@@ -756,7 +756,11 @@ public class PhoneUtils {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
(
result
!=
null
&&
result
.
size
()>
0
){
return
result
.
get
(
0
).
getLocality
();
return
result
.
get
(
0
).
getLocality
();
}
else
{
return
""
;
}
}
}
}
else
{
}
else
{
//ToastUtils.showToast(this, "GPS未定位到位置");
//ToastUtils.showToast(this, "GPS未定位到位置");
...
...
zxhcsdk/src/main/java/com/ym/zxhcsdk/manager/ZXHCADManager.java
View file @
86747623
...
@@ -22,15 +22,14 @@ public class ZXHCADManager {
...
@@ -22,15 +22,14 @@ public class ZXHCADManager {
}
}
return
sInstance
;
return
sInstance
;
}
}
public
boolean
InitAd
(
Activity
context
,
String
appId
){
public
boolean
InitAd
(
Activity
context
,
String
appId
,
boolean
isDebug
){
Log
.
d
(
"wxw"
,
"appid"
+
appId
);
ZXHCConstant
.
ZXHC_APPID
=
appId
;
ZXHCConstant
.
ZXHC_APPID
=
appId
;
AppliContext
.
init
(
context
);
AppliContext
.
init
(
context
);
ZXHCConstant
.
IS_DEBUG
=
true
;
ZXHCConstant
.
IS_DEBUG
=
isDebug
;
if
(
ZXHCConstant
.
IS_DEBUG
){
if
(
ZXHCConstant
.
IS_DEBUG
){
ZXHCConstant
.
BASE_URL
=
"http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads"
;
ZXHCConstant
.
BASE_URL
=
"http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads"
;
}
else
{
}
else
{
ZXHCConstant
.
BASE_URL
=
""
;
ZXHCConstant
.
BASE_URL
=
"
http://sspv2.zhangxinhuichuan.com/ssp/v1/ads
"
;
}
}
return
true
;
return
true
;
...
...
zxhcsdk/src/main/java/com/ym/zxhcsdk/view/ZXHCSplashAD.java
View file @
86747623
...
@@ -72,7 +72,6 @@ public class ZXHCSplashAD {
...
@@ -72,7 +72,6 @@ public class ZXHCSplashAD {
adBean
.
setClickReport
(
false
);
adBean
.
setClickReport
(
false
);
adBean
.
setClickDpLinkSucReport
(
false
);
adBean
.
setClickDpLinkSucReport
(
false
);
adBean
.
setClickDpLinkfailReport
(
false
);
adBean
.
setClickDpLinkfailReport
(
false
);
Log
.
d
(
"wxw"
,
"ad.getSrcUrls().size()"
+
adBean
.
getSrcUrls
().
size
());
if
(
adBean
.
getSrcUrls
().
size
()
>
0
)
{
if
(
adBean
.
getSrcUrls
().
size
()
>
0
)
{
HttpClientUtils
.
LoadImg
(
adBean
.
getSrcUrls
().
get
(
0
),
new
HttpClientUtils
.
OnRequestImgCallBack
()
{
HttpClientUtils
.
LoadImg
(
adBean
.
getSrcUrls
().
get
(
0
),
new
HttpClientUtils
.
OnRequestImgCallBack
()
{
@Override
@Override
...
@@ -96,6 +95,8 @@ public class ZXHCSplashAD {
...
@@ -96,6 +95,8 @@ public class ZXHCSplashAD {
Log
.
d
(
"wxw"
,
"bitmaperrorMsg"
+
errorMsg
);
Log
.
d
(
"wxw"
,
"bitmaperrorMsg"
+
errorMsg
);
}
}
});
});
}
else
{
listener
.
OnError
(
"广告数据为0"
);
}
}
}
}
...
@@ -145,7 +146,6 @@ public class ZXHCSplashAD {
...
@@ -145,7 +146,6 @@ public class ZXHCSplashAD {
private
ViewGroup
splashView
;
private
ViewGroup
splashView
;
public
void
showAd
(
ViewGroup
vp
)
{
public
void
showAd
(
ViewGroup
vp
)
{
splashView
=
vp
;
splashView
=
vp
;
Log
.
d
(
"wxw"
,
"showAd"
);
context
.
runOnUiThread
(
new
Runnable
()
{
context
.
runOnUiThread
(
new
Runnable
()
{
@SuppressLint
(
"ClickableViewAccessibility"
)
@SuppressLint
(
"ClickableViewAccessibility"
)
@Override
@Override
...
@@ -160,7 +160,7 @@ public class ZXHCSplashAD {
...
@@ -160,7 +160,7 @@ public class ZXHCSplashAD {
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
if
(
delayTime
<=
0
)
{
if
(
delayTime
<=
0
)
{
listener
.
OnAdClosed
();
//
listener.OnAdClosed();
ZXHCAdViewManager
.
getInstance
().
removeAdView
(
context
,
vp
);
ZXHCAdViewManager
.
getInstance
().
removeAdView
(
context
,
vp
);
mHandler
.
removeMessages
(
SPLASH_CODE
);
mHandler
.
removeMessages
(
SPLASH_CODE
);
}
}
...
...
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