| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.text.TextUtils; |
| | | |
| | | |
| | | import com.dayu.baselibrary.business.BusinessProvider; |
| | | import com.dayu.qiheonlinelibrary.bean.BaseResult; |
| | | import com.dayu.qiheonlinelibrary.net.subscribers.BaseProgressSubscriber; |
| | | import com.dayu.qiheonlinelibrary.net.subscribers.ProgressSubscriber; |
| | | import com.dayu.qiheonlinelibrary.net.subscribers.SubscriberListener; |
| | |
| | | BaseResponse tem = (BaseResponse) o; |
| | | BaseResponse<T> response = new BaseResponse<>(); |
| | | //未登录或登录超时,请重新登录 |
| | | if (tem.getCode()==100401){ |
| | | if (BusinessProvider.getBusinessProvider()!=null){ |
| | | if (tem.getCode() == 100401) { |
| | | if (BusinessProvider.getBusinessProvider() != null) { |
| | | BusinessProvider.getBusinessProvider().startLoginNavigotor.navigateToLogin(context); |
| | | } |
| | | |
| | |
| | | |
| | | response.setCode(tem.getCode()); |
| | | response.setMsg(tem.getMsg()); |
| | | if (tClass!= null) { |
| | | if ( tem.getData() instanceof Map) { |
| | | try { |
| | | if (tClass != null) { |
| | | if (TextUtils.isEmpty(tem.getData().toString()) && BaseResult.class.isAssignableFrom(tClass)) { |
| | | response.setData(null); |
| | | return response; |
| | | } |
| | | if (tem.getData() instanceof Map) { |
| | | try { |
| | | // response.setData(MyJsonParser.getBeanFromMap((Map<String, Object>) tem.getData(), tClass)); |
| | | String jsonData = MyJsonParser.getJsontoMap((Map) tem.getData()); |
| | | response.setData(MyJsonParser.getBeanFromJson(jsonData, tClass)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else if ( tem.getData() instanceof List) { |
| | | try { |
| | | response.setData((T) MyJsonParser.getListByJson(MyJsonParser.getJsonbyList((List) tem.getData()), tClass)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else if ( tem.getData() instanceof Integer) { |
| | | response.setData((T) tem.getData()); |
| | | } else if (tem.getData() instanceof Boolean){ |
| | | response.setData((T) tem.getData()); |
| | | } |
| | | if ( tClass.getName() instanceof String && tem.getData() instanceof String) { |
| | | try { |
| | | String jsonData = MyJsonParser.getJsontoMap((Map) tem.getData()); |
| | | response.setData(MyJsonParser.getBeanFromJson(jsonData, tClass)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else if (tem.getData() instanceof List) { |
| | | try { |
| | | response.setData((T) MyJsonParser.getListByJson(MyJsonParser.getJsonbyList((List) tem.getData()), tClass)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else if (tem.getData() instanceof Integer) { |
| | | response.setData((T) tem.getData()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } else if (tem.getData() instanceof Boolean) { |
| | | response.setData((T) tem.getData()); |
| | | } |
| | | if (tClass.getName() instanceof String && tem.getData() instanceof String) { |
| | | try { |
| | | response.setData((T) tem.getData()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | return response; |
| | | }} |
| | | } |
| | | |
| | | return null; |
| | | } |