Commit 9694e76e by jeffrey

调试接口

parent 459da4cb
......@@ -17,6 +17,7 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList;
import com.yuqirong.listenwechatnotification.askhttp.UpdateApk;
import com.yuqirong.listenwechatnotification.broadcastReceiver.MyCashReceiver;
import com.yuqirong.listenwechatnotification.service.WeChatNotificationListenerService;
......@@ -124,6 +125,14 @@ public class MainActivity extends ParentActivity {
}
});
findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userName = Save2SharedPreferences.read(ALIPAYNAME,MainActivity.this);
ActivePullCashList pullCashList = new ActivePullCashList();
pullCashList.pullList(Utils.payChannelZFB,userName);
}
});
// QRCodeFunction qrThread = new QRCodeFunction("QRCodeFunction---ZFB", Utils.ZFBImgPath);
// qrThread.start();
......
package com.yuqirong.listenwechatnotification.askhttp;
import android.util.Log;
import com.google.gson.Gson;
import com.yuqirong.listenwechatnotification.bean.PullMoneyResp;
import com.yuqirong.listenwechatnotification.function.QRCodeFunction;
import com.yuqirong.listenwechatnotification.http.HttpService;
import com.yuqirong.listenwechatnotification.uitl.FileUtils;
import com.yuqirong.listenwechatnotification.uitl.PayTypeSingleTon;
import com.yuqirong.listenwechatnotification.uitl.Utils;
import com.yuqirong.listenwechatnotification.http.PayHttp;
import org.greenrobot.eventbus.EventBus;
import java.math.BigDecimal;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
/**
* 获取金额数据
......@@ -25,7 +23,10 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;
public class ActivePullCashList {
/**
*固定的 在服务器后台配置的
*/
private static final String token ="9908506dc651b6ce6e488c838c118354";
......@@ -91,40 +92,30 @@ public class ActivePullCashList {
public void pullList(String channel,String username){
Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpService.base_url)
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持
.addConverterFactory(ScalarsConverterFactory.create())
//添加GSON转换支持
.addConverterFactory(GsonConverterFactory.create())
.build();
//获取接口
HttpService service = retrofit.create(HttpService.class);
Call<ArrayList<String>> call = service.pullZFBCashList(channel,username);
HttpService httpService = PayHttp.get();
Call<PullMoneyResp> call = httpService.pullZFBCashList(channel,username,token);
call.enqueue(new Callback<ArrayList<String>>() {
call.enqueue(new Callback<PullMoneyResp>() {
@Override
public void onResponse(Call<ArrayList<String>> call, Response<ArrayList<String>> response) {
ArrayList<String> object = response.body();
public void onResponse(Call<PullMoneyResp> call, Response<PullMoneyResp> response) {
PullMoneyResp object = response.body();
Log.d("fei",new Gson().toJson(object));
//1.当根据类型请求的金额列表数字为空的时候,不需要用eventbus来发送数据
//2.只需要替换一下请求类型就可以了
//3.删除文件夹下所有内容
if (object.size() == 0){
if (PayTypeSingleTon.newInstance().getPayType().equals(Utils.payTypeZFB)){
PayTypeSingleTon.newInstance().setPayType(Utils.payTypeWeiXin);
}else{
PayTypeSingleTon.newInstance().setPayType(Utils.payTypeZFB);
}
}else{
EventBus.getDefault().post(object);
}
// if (object.size() == 0){
// if (PayTypeSingleTon.newInstance().getPayType().equals(Utils.payTypeZFB)){
// PayTypeSingleTon.newInstance().setPayType(Utils.payTypeWeiXin);
// }else{
// PayTypeSingleTon.newInstance().setPayType(Utils.payTypeZFB);
// }
// }else{
// EventBus.getDefault().post(object);
// }
}
@Override
public void onFailure(Call<ArrayList<String>> call, Throwable t) {
public void onFailure(Call<PullMoneyResp> call, Throwable t) {
}
});
......
package com.yuqirong.listenwechatnotification.bean;
import java.util.List;
/**
* 创建日期:2018/3/15 on 16:48
* 描述:
* 作者:Li
*/
public class PullMoneyResp {
/**
* status_code : 422
* message : data不能为空
* data : {"data":["data不能为空"]}
*/
private int status_code;
private String message;
private DataBean data;
public int getStatus_code() {
return status_code;
}
public void setStatus_code(int status_code) {
this.status_code = status_code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public DataBean getData() {
return data;
}
public void setData(DataBean data) {
this.data = data;
}
public static class DataBean {
private List<String> data;
public List<String> getData() {
return data;
}
public void setData(List<String> data) {
this.data = data;
}
}
}
package com.yuqirong.listenwechatnotification.http;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.bean.PullMoneyResp;
import com.yuqirong.listenwechatnotification.bean.UpdateBean;
import java.util.ArrayList;
......@@ -8,7 +9,9 @@ import java.util.List;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
......@@ -19,19 +22,23 @@ import retrofit2.http.Query;
public interface HttpService {
// public String base_url = "http://test.haoyiwangluo.com/";
public String base_url = "http://www.haoyiwangluo.com/";
public String base_url = "http://test.fourth-pay.checheng.net/";
// public String base_url = "http://www.haoyiwangluo.com/";
public String test_base_url = "http://test.fourth-pay.checheng.net/app-api/";
public String test_base_url = "http://test.fourth-pay.checheng.net/";
@GET("app/status")
@GET("/app-api/app/status")
Call<UpdateBean> postSoftVersion(@Query("version") String version);
@POST("amounts")
Call<ArrayList<String>> pullZFBCashList(@Field("channel") String channel,@Field("username") String username);
@POST("/app-api/amounts")
@FormUrlEncoded
@Headers({
"Accept: application/json"
})
Call<PullMoneyResp> pullZFBCashList(@Field("channel") String channel, @Field("username") String username, @Field("token") String token);
@POST("amounts/submit")
@POST("/app-api/amounts/submit")
Call<String> pushZFBCashList(@Field("channel") String channel,@Field("list") ArrayList<ImageBean> imageBeans);
}
package com.yuqirong.listenwechatnotification.http;
import com.yuqirong.listenwechatnotification.MyApplication;
import com.yuqirong.listenwechatnotification.askhttp.HttpLoggingInterceptor;
import com.yuqirong.listenwechatnotification.http.HttpService;
import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences;
import com.yuqirong.listenwechatnotification.uitl.Utils;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
import static com.yuqirong.listenwechatnotification.MainActivity.API;
/**
* 创建日期:2018/3/15 on 16:41
* 描述:
* 作者:Li
*/
public class PayHttp {
private static HttpService httpService;
public static HttpService get(){
synchronized (HttpService.class){
if (httpService == null){
httpService = init();
}
return httpService;
}
}
private static HttpService init(){
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.addInterceptor(new HttpLoggingInterceptor())
.build();
String url = Save2SharedPreferences.read(API,MyApplication.get());
//建立retrofit对象
Retrofit retrofit = new Retrofit.Builder().baseUrl(url)
// //添加返回字符串的支持--不知道返回的是什么,添加字符串支持
// .addConverterFactory(ScalarsConverterFactory.create())
//添加GSON转换支持
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
//获取接口
HttpService service = retrofit.create(HttpService.class);
return service;
}
}
......@@ -21,6 +21,12 @@ public class Utils {
//支付宝支付类型
public static String payTypeZFB = "1";
//支付宝支付类型
public static String payChannelZFB = "alipay_personal";
public static String payChannelWX = "wechat_personal";
public static int getLocalVersion(Context ctx) {
int localVersion = 0;
try {
......
......@@ -119,7 +119,11 @@
android:layout_height="50dp"
android:text="监听" />
<Button
android:id="@+id/btn_test"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试" />
<TextView
android:id="@+id/tv_version_name"
android:layout_width="match_parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment