xuxiuxi
2017-03-28 32464cca7655904f721e28f45fe5a71a894286c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.bsk.zhangbo.demoforbsk.service;
 
import android.widget.Toast;
 
import com.bsk.zhangbo.demoforbsk.base.BaseApplication;
import com.bsk.zhangbo.demoforbsk.util.AppApi;
 
import org.xutils.http.RequestParams;
import org.xutils.x;
 
import java.util.List;
 
import cn.com.basic.face.discern.common.ResultBean;
import cn.com.basic.face.discern.entity.Place;
 
/**
 * Created by xiuxi on 2017/3/28.
 */
 
public class PlaceMng {
    public static PlaceMng instance = new PlaceMng();
 
    public static final String authorationId = "101";
 
    public static PlaceMng getInstance() {
        return instance;
    }
 
    public void findPlace() {
        try {
            RequestParams params = new RequestParams(AppApi.BASEURL + AppApi.PLACE_LIST);
            params.addBodyParameter(Place.FieldNames.authorizationId, authorationId);
            ResultBean resultBean = x.http().postSync(params, ResultBean.class);
            List<Place> places = resultBean.getListBeanOfType(Place.class);
            if (places.size() > 0) {
                BaseApplication.getInstance().setPlace(places.get(0));
            } else {
                Toast.makeText(BaseApplication.getInstance(), "数据库中找不到该设备", Toast.LENGTH_SHORT).show();
            }
        } catch (Throwable e) {
            e.printStackTrace();
            Toast.makeText(BaseApplication.getInstance(), "数据库中找不到该设备", Toast.LENGTH_SHORT).show();
        }
    }
 
}