Skip to content

Commit 578b2a5

Browse files
committed
add alipay
1 parent 42618e0 commit 578b2a5

25 files changed

+1362
-44
lines changed

.idea/misc.xml

Lines changed: 0 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ def releaseTime() {
55
}
66

77
android {
8+
lintOptions{
9+
checkReleaseBuilds false
10+
abortOnError false
11+
}
812
signingConfigs {
913
myconfig {
1014
keyAlias 'com.code4a'
@@ -88,7 +92,9 @@ dependencies {
8892
compile "com.squareup.okhttp3:okhttp:${okhttpVersion}"
8993
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
9094
compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
95+
compile "com.squareup.retrofit2:converter-scalars:${retrofitVersion}"
9196
compile "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
97+
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
9298
compile "com.android.support:appcompat-v7:${supportVersion}"
9399
compile "com.android.support:recyclerview-v7:${supportVersion}"
94100
compile "com.android.support:support-v4:${supportVersion}"
@@ -115,4 +121,5 @@ dependencies {
115121
compile 'com.daimajia.androidviewhover:library:1.0.4@aar'
116122
compile 'com.makeramen:roundedimageview:1.3.0'
117123
compile 'com.squareup.picasso:picasso:2.5.2'
124+
compile 'com.tsy:pay:1.0.0'
118125
}

app/src/main/AndroidManifest.xml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
package="com.code4a.jlibrarydemo">
55

66
<uses-permission android:name="android.permission.INTERNET"/>
7+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
9+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
710
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
811

912
<application
@@ -14,7 +17,6 @@
1417
android:label="@string/app_name"
1518
android:supportsRtl="true"
1619
android:theme="@style/AppTheme">
17-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
1820
<meta-data
1921
android:name="com.code4a.jlibrarydemo.data.CustomCachingGlideModule"
2022
android:value="GlideModule" />
@@ -26,7 +28,7 @@
2628
<!--<category android:name="android.intent.category.LAUNCHER" />-->
2729
<!--</intent-filter>-->
2830
<!--</activity>-->
29-
<activity android:name=".WebViewActivity" />
31+
<activity android:name=".webview.WebViewActivity" />
3032
<activity
3133
android:name=".splash.SplashActivity">
3234
<intent-filter>
@@ -36,6 +38,32 @@
3638
</intent-filter>
3739
</activity>
3840
<activity android:name=".home.HomeActivity" />
41+
<activity android:name=".pay.PayActivity" />
42+
43+
<!-- 微信支付 -->
44+
<activity
45+
android:name="com.tsy.sdk.pay.weixin.WXPayCallbackActivity"
46+
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
47+
android:launchMode="singleTop"
48+
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
49+
50+
<activity-alias
51+
android:name=".wxapi.WXPayEntryActivity"
52+
android:exported="true"
53+
android:targetActivity="com.tsy.sdk.pay.weixin.WXPayCallbackActivity" />
54+
55+
<!-- 支付宝支付 -->
56+
<activity
57+
android:name="com.alipay.sdk.app.H5PayActivity"
58+
android:configChanges="orientation|keyboardHidden|navigation"
59+
android:exported="false"
60+
android:screenOrientation="behind"></activity>
61+
<activity
62+
android:name="com.alipay.sdk.auth.AuthActivity"
63+
android:configChanges="orientation|keyboardHidden|navigation"
64+
android:exported="false"
65+
android:screenOrientation="behind"></activity>
66+
3967
</application>
4068

4169
</manifest>

app/src/main/java/com/code4a/jlibrarydemo/JLibraryApp.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.code4a.jlibrarydemo;
22

33
import android.app.Application;
4+
import android.util.Log;
45

56
import com.code4a.jlibrary.bugly.JBuglyManager;
67

78
import java.util.concurrent.TimeUnit;
89

910
import okhttp3.OkHttpClient;
11+
import okhttp3.logging.HttpLoggingInterceptor;
1012

1113
/**
1214
* Created by code4a on 2016/12/24.
@@ -28,13 +30,26 @@ public void onCreate() {
2830

2931
public static OkHttpClient defaultOkHttpClient() {
3032
OkHttpClient client = new OkHttpClient.Builder()
33+
.addInterceptor(getHttpLoggingInterceptor())
3134
.connectTimeout(3, TimeUnit.SECONDS)
3235
.writeTimeout(3, TimeUnit.SECONDS)
3336
.readTimeout(3, TimeUnit.SECONDS)
3437
.build();
3538
return client;
3639
}
3740

41+
private static HttpLoggingInterceptor getHttpLoggingInterceptor(){
42+
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
43+
@Override
44+
public void log(String message) {
45+
//打印retrofit日志
46+
Log.i("RetrofitLog","retrofitBack = "+message);
47+
}
48+
});
49+
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
50+
return loggingInterceptor;
51+
}
52+
3853
public static JLibraryApp getInstance(){
3954
return mApp;
4055
}

app/src/main/java/com/code4a/jlibrarydemo/commoninteractor/GankCommonInteractorImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import com.code4a.jlibrarydemo.data.GirlsBean;
66
import com.code4a.jlibrarydemo.http.GirlsService;
7-
import com.code4a.jlibrarydemo.http.SplashRetrofit;
7+
import com.code4a.jlibrarydemo.http.GankRetrofit;
88

99
import rx.Observer;
1010
import rx.android.schedulers.AndroidSchedulers;
@@ -22,7 +22,7 @@ public class GankCommonInteractorImpl implements GankCommonInteractor {
2222
@Override
2323
public void getRes(String type, int page, int count, final LoadSplashResListener listener) {
2424
isCanceled = false;
25-
SplashRetrofit.getRetrofit()
25+
GankRetrofit.getRetrofit()
2626
.create(GirlsService.class)
2727
.getGirls(type, count, page)
2828
.subscribeOn(Schedulers.io())
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.code4a.jlibrarydemo.data;
2+
3+
/**
4+
* Created by code4a on 2017/2/6.
5+
*/
6+
7+
public class AlipayBean {
8+
9+
/**
10+
* appid : 2017020605534265
11+
* privateKey : 0000
12+
*/
13+
14+
private String appid;
15+
private String privateKey;
16+
17+
public String getAppid() {
18+
return appid;
19+
}
20+
21+
public void setAppid(String appid) {
22+
this.appid = appid;
23+
}
24+
25+
public String getPrivateKey() {
26+
return privateKey;
27+
}
28+
29+
public void setPrivateKey(String privateKey) {
30+
this.privateKey = privateKey;
31+
}
32+
}

app/src/main/java/com/code4a/jlibrarydemo/home/frag/mine/MineFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
import com.code4a.jlibrary.tasks.Tasks;
1414
import com.code4a.jlibrary.utils.DataCleanUtil;
1515
import com.code4a.jlibrary.utils.ToastUtil;
16+
import com.code4a.jlibrarydemo.pay.PayActivity;
1617
import com.code4a.jlibrarydemo.R;
17-
import com.code4a.jlibrarydemo.WebViewActivity;
18+
import com.code4a.jlibrarydemo.webview.WebViewActivity;
1819
import com.code4a.jlibrarydemo.home.frag.HomeBaseFragment;
1920
import com.code4a.jlibrarydemo.utils.Constants;
2021

@@ -89,6 +90,7 @@ public void onClick(View v) {
8990
case R.id.feedback:
9091
break;
9192
case R.id.user:
93+
openActivity(PayActivity.class);
9294
break;
9395
case R.id.cache:
9496
cleanCache();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.code4a.jlibrarydemo.http;
2+
3+
import com.code4a.jlibrarydemo.JLibraryApp;
4+
import com.code4a.jlibrarydemo.utils.Constants;
5+
6+
import retrofit2.Retrofit;
7+
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
8+
import retrofit2.converter.scalars.ScalarsConverterFactory;
9+
10+
/**
11+
* Created by code4a on 2017/1/12.
12+
*/
13+
14+
public class Code4aRetrofit {
15+
16+
private static Retrofit retrofit;
17+
18+
public static Retrofit getRetrofit() {
19+
if (retrofit == null) {
20+
synchronized (Code4aRetrofit.class) {
21+
if (retrofit == null) {
22+
retrofit = new Retrofit.Builder()
23+
.baseUrl(Constants.CODE4A_API)
24+
.addConverterFactory(ScalarsConverterFactory.create())
25+
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
26+
.client(JLibraryApp.defaultOkHttpClient())
27+
.build();
28+
}
29+
}
30+
}
31+
return retrofit;
32+
}
33+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.code4a.jlibrarydemo.http;
2+
3+
import retrofit2.http.GET;
4+
import retrofit2.http.Path;
5+
import rx.Observable;
6+
7+
/**
8+
* Created by gaohailong on 2016/5/17.
9+
*/
10+
public interface Code4aService {
11+
12+
@GET("{key}")
13+
Observable<String> getAlipayInfo(
14+
@Path("key") String key
15+
);
16+
17+
}

app/src/main/java/com/code4a/jlibrarydemo/http/SplashRetrofit.java renamed to app/src/main/java/com/code4a/jlibrarydemo/http/GankRetrofit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
* Created by code4a on 2017/1/12.
1212
*/
1313

14-
public class SplashRetrofit {
14+
public class GankRetrofit {
1515

1616
private static Retrofit retrofit;
1717

1818
public static Retrofit getRetrofit() {
1919
if (retrofit == null) {
20-
synchronized (SplashRetrofit.class) {
20+
synchronized (GankRetrofit.class) {
2121
if (retrofit == null) {
2222
retrofit = new Retrofit.Builder()
2323
.baseUrl(Constants.GANHUO_API)

0 commit comments

Comments
 (0)