PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/app/src/main/java/com/newtejasrecharge/utils/RestService.java

https://bitbucket.org/wbplatadmin/tejasrecharge
Java | 507 lines | 414 code | 86 blank | 7 comment | 18 complexity | 6c06a9540aabd0c16c81515efd1047e5 MD5 | raw file
  1. package com.newtejasrecharge.utils; /**
  2. * Created by Administrator on 22/01/2016.
  3. */
  4. import android.util.Log;
  5. import com.squareup.okhttp.OkHttpClient;
  6. import com.newtejasrecharge.money_transfer_spaisa.pojo.bank_list.BankBranchByCityList;
  7. import com.newtejasrecharge.pojo.balance.GetBalance;
  8. import com.newtejasrecharge.pojo.check_jio_bill.CheckJioBIll;
  9. import com.newtejasrecharge.pojo.creditanddebit.credittsummary.CreditReport;
  10. import com.newtejasrecharge.pojo.creditanddebit.debit_summary_report.DebitReport;
  11. import com.newtejasrecharge.pojo.giftcard_pojo.gift_card_category_list.GetGiftCategoryList;
  12. import com.newtejasrecharge.pojo.giftcard_pojo.gift_card_product.GiftCardProduct;
  13. import com.newtejasrecharge.pojo.giftcard_pojo.giftcard_placeorder.GetPlaceOrder;
  14. import com.newtejasrecharge.pojo.giftcard_pojo.giftcatd_product_details.ProductDetails;
  15. import com.newtejasrecharge.pojo.login_otp.LoginOTPVerifuy;
  16. import com.newtejasrecharge.pojo.news.NewsLine;
  17. import com.newtejasrecharge.pojo.operator.OperatorListServer;
  18. import com.newtejasrecharge.pojo.recharge_history.RechargeHistory;
  19. import com.newtejasrecharge.pojo.recharge_response.RechargeResponse;
  20. import com.newtejasrecharge.pojo.scheme_add_user.Schemes;
  21. import com.newtejasrecharge.pojo.userchildelist.UserChild;
  22. import com.newtejasrecharge.pojo.utility_bill.CheckUtilityBIll;
  23. import java.util.ArrayList;
  24. import java.util.List;
  25. import java.util.concurrent.TimeUnit;
  26. import retrofit.Callback;
  27. import retrofit.RestAdapter;
  28. import retrofit.RetrofitError;
  29. import retrofit.client.OkClient;
  30. import retrofit.client.Response;
  31. import retrofit.http.Field;
  32. import retrofit.http.FormUrlEncoded;
  33. import retrofit.http.POST;
  34. /**
  35. * Created by Belal on 11/3/2015.
  36. */
  37. public class RestService {
  38. private static final String TAG = "RestService";
  39. private static RestInterface restInterface;
  40. private List<MyCallback> callbacks = new ArrayList<>();
  41. public RestService() {
  42. final OkHttpClient okHttpClient = new OkHttpClient();
  43. okHttpClient.setReadTimeout(120, TimeUnit.SECONDS);
  44. okHttpClient.setConnectTimeout(120, TimeUnit.SECONDS);
  45. RestAdapter restAdapter = new RestAdapter.Builder()
  46. .setEndpoint(ApplicationConstant.WEBSERVICEURL)
  47. .setClient(new OkClient(okHttpClient))
  48. .setLogLevel(RestAdapter.LogLevel.FULL)
  49. .build();
  50. restInterface = restAdapter.create(RestInterface.class);
  51. }
  52. public void getnewsline(String userName, String password, RestCallback<NewsLine> restCallback) {
  53. restInterface.getNews(userName, password, new MyCallback<NewsLine, NewsLine>(restCallback) {
  54. @Override
  55. protected NewsLine processResponse(NewsLine utilitySubService) {
  56. return utilitySubService;
  57. }
  58. });
  59. }
  60. public void submitElectricityRequest(String userId, String password, String amount, String Number, String opcode,
  61. String CircleCode, String Mode, String params1, String params2, String Param3, String Param4, String Param5, String Param6,
  62. RestCallback<RechargeResponse> callback) {
  63. restInterface.submitElectricityRequest(userId, password, amount, Number, opcode, CircleCode, Mode, params1, params2,
  64. Param3, Param4, Param5, Param6, new MyCallback<RechargeResponse, RechargeResponse>(callback) {
  65. @Override
  66. protected RechargeResponse processResponse(RechargeResponse rechargePlansByOperatorResponse) {
  67. return rechargePlansByOperatorResponse;
  68. }
  69. });
  70. }
  71. public void doRecharge(String circle, String opcode, String amount, String number, String remark, String userId, String serviceType, String password, String acType, String acNumber, RestCallback<RechargeResponse> restCallback) {
  72. restInterface.doRecharge(userId, password, amount, number, opcode, circle, acType, acNumber, new MyCallback<RechargeResponse, RechargeResponse>(restCallback) {
  73. @Override
  74. protected RechargeResponse processResponse(RechargeResponse login) {
  75. return login;
  76. }
  77. });
  78. }
  79. public void getLoginInfo(String userName, String password,String imie, RestCallback<LoginOTPVerifuy> restCallback) {
  80. restInterface.getMainLoginUserInfo(userName, password,imie, new MyCallback<LoginOTPVerifuy, LoginOTPVerifuy>(restCallback) {
  81. @Override
  82. protected LoginOTPVerifuy processResponse(LoginOTPVerifuy moneyLoginCheck) {
  83. return moneyLoginCheck;
  84. }
  85. });
  86. }
  87. public void verifyOTP(String userName, String password,String imie,String otp, RestCallback<LoginOTPVerifuy> restCallback) {
  88. restInterface.verifyLoginOTP(userName, password,imie,otp, new MyCallback<LoginOTPVerifuy, LoginOTPVerifuy>(restCallback) {
  89. @Override
  90. protected LoginOTPVerifuy processResponse(LoginOTPVerifuy moneyLoginCheck) {
  91. return moneyLoginCheck;
  92. }
  93. });
  94. }
  95. public void loginresebtotp(String username, String password, RestCallback<LoginOTPVerifuy> restCallback) {
  96. restInterface.resendotplogin(username, password, new MyCallback<LoginOTPVerifuy, LoginOTPVerifuy>(restCallback) {
  97. @Override
  98. protected LoginOTPVerifuy processResponse(LoginOTPVerifuy moneyLoginCheck) {
  99. return moneyLoginCheck;
  100. }
  101. });
  102. }
  103. public void getUserBalance(String userId, String password, RestCallback<GetBalance> restCallback) {
  104. restInterface.getBalance(userId, password,
  105. new MyCallback<GetBalance, GetBalance>(restCallback) {
  106. @Override
  107. protected GetBalance processResponse(GetBalance getBalance) {
  108. return getBalance;
  109. }
  110. });
  111. }
  112. public void getRechargeHistory(String hpUserId, String password, String fromDate, String toDate, RestCallback<RechargeHistory> restCallback) {
  113. restInterface.getOrderHistory(hpUserId, password, fromDate, toDate, new MyCallback<RechargeHistory, RechargeHistory>(restCallback) {
  114. @Override
  115. protected RechargeHistory processResponse(RechargeHistory rechargeHistory) {
  116. return rechargeHistory;
  117. }
  118. });
  119. }
  120. public void changePassword(String hpUserId, String oldPw, String newPw, RestCallback<RechargeResponse> restCallback) {
  121. restInterface.changePassword(hpUserId, oldPw, newPw, new MyCallback<RechargeResponse, RechargeResponse>(restCallback) {
  122. @Override
  123. protected RechargeResponse processResponse(RechargeResponse exchangeRate) {
  124. return exchangeRate;
  125. }
  126. });
  127. }
  128. public void getRechargeHistoryById(String userName, String password, String transId, RestCallback<RechargeHistory> restCallback) {
  129. restInterface.getOrderHistoryById(userName, password, transId, new MyCallback<RechargeHistory, RechargeHistory>(restCallback) {
  130. @Override
  131. protected RechargeHistory processResponse(RechargeHistory rechargeHistory) {
  132. return rechargeHistory;
  133. }
  134. });
  135. }
  136. public void getUserScheme(String userName, String password, RestCallback<Schemes> restCallback) {
  137. restInterface.getUserScheme(userName, password, new MyCallback<Schemes, Schemes>(restCallback) {
  138. @Override
  139. protected Schemes processResponse(Schemes schemes) {
  140. return schemes;
  141. }
  142. });
  143. }
  144. public void addUser(String userName, String password, String name, String parentName, String mobileNumber, String pan, String farmName, String area, String address, String schemeId, String schemeAmount, String schemeType, RestCallback<RechargeResponse> restCallback) {
  145. restInterface.addUser(userName, password, name, name, parentName, mobileNumber, pan, farmName, area, address, schemeId, schemeAmount, schemeType, new MyCallback<RechargeResponse, RechargeResponse>(restCallback) {
  146. @Override
  147. protected RechargeResponse processResponse(RechargeResponse rechargeResponse) {
  148. return rechargeResponse;
  149. }
  150. });
  151. }
  152. public void transferBalace(String userName, String password, String name, String amount, String remarks, RestCallback<RechargeResponse> restCallback) {
  153. restInterface.transferBalace(userName, password, name, amount, remarks, new MyCallback<RechargeResponse, RechargeResponse>(restCallback) {
  154. @Override
  155. protected RechargeResponse processResponse(RechargeResponse rechargeResponse) {
  156. return rechargeResponse;
  157. }
  158. });
  159. }
  160. public void forgetPassword(String userName, RestCallback<RechargeResponse> restCallback) {
  161. restInterface.forgetPassword(userName, new MyCallback<RechargeResponse, RechargeResponse>(restCallback) {
  162. @Override
  163. protected RechargeResponse processResponse(RechargeResponse rechargeResponse) {
  164. return rechargeResponse;
  165. }
  166. });
  167. }
  168. public void getBankBranchName(String bankId, String bankCity, RestCallback<BankBranchByCityList> restCallback) {
  169. restInterface.getBankBranchName(bankId, bankCity, new MyCallback<BankBranchByCityList, BankBranchByCityList>(restCallback) {
  170. @Override
  171. protected BankBranchByCityList processResponse(BankBranchByCityList bankBranchesInState) {
  172. return bankBranchesInState;
  173. }
  174. });
  175. }
  176. public void validateUtilityBill(String userName, String password, String opcode, String subScriberId, String billingUnit, String cycleNumber, RestCallback<CheckUtilityBIll> restCallback) {
  177. restInterface.validateUtilityBill(userName, password, opcode, subScriberId, billingUnit, cycleNumber,
  178. new MyCallback<CheckUtilityBIll, CheckUtilityBIll>(restCallback) {
  179. @Override
  180. protected CheckUtilityBIll processResponse(CheckUtilityBIll checkUtilityBIll) {
  181. return checkUtilityBIll;
  182. }
  183. });
  184. }
  185. public void userChild(String userName, String password, RestCallback<UserChild> restCallback) {
  186. restInterface.userchildList(userName, password, new MyCallback<UserChild, UserChild>(restCallback) {
  187. @Override
  188. protected UserChild processResponse(UserChild rechargeResponse) {
  189. return rechargeResponse;
  190. }
  191. });
  192. }
  193. public void getDebitHistory(String hpUserId, String password, String fromDate, String toDate, RestCallback<DebitReport> restCallback) {
  194. restInterface.debitHistory(hpUserId, password, fromDate, toDate, new MyCallback<DebitReport, DebitReport>(restCallback) {
  195. @Override
  196. protected DebitReport processResponse(DebitReport rechargeHistory) {
  197. return rechargeHistory;
  198. }
  199. });
  200. }
  201. public void getCreditHistory(String hpUserId, String password, String fromDate, String toDate, RestCallback<CreditReport> restCallback) {
  202. restInterface.CreditHistory(hpUserId, password, fromDate, toDate, new MyCallback<CreditReport, CreditReport>(restCallback) {
  203. @Override
  204. protected CreditReport processResponse(CreditReport rechargeHistory) {
  205. return rechargeHistory;
  206. }
  207. });
  208. }
  209. public void getOperator(String serviceID, RestCallback<OperatorListServer> restCallback) {
  210. restInterface.getOperator(serviceID,
  211. new MyCallback<OperatorListServer, OperatorListServer>(restCallback) {
  212. @Override
  213. protected OperatorListServer processResponse(OperatorListServer operatorListServer) {
  214. return operatorListServer;
  215. }
  216. });
  217. }
  218. public void validateJioBill(String userName, String password, String opcode, String subScriberId, String billingUnit, String cycleNumber, RestCallback<CheckJioBIll> restCallback) {
  219. restInterface.validateJioBill(userName, password, opcode, subScriberId, billingUnit, cycleNumber,
  220. new MyCallback<CheckJioBIll, CheckJioBIll>(restCallback) {
  221. @Override
  222. protected CheckJioBIll processResponse(CheckJioBIll checkUtilityBIll) {
  223. return checkUtilityBIll;
  224. }
  225. });
  226. }
  227. // giftCard URL by Amol
  228. public void getGiftCardList(String userName, String password, RestCallback<GetGiftCategoryList> callback) {
  229. restInterface.giftcard(userName, password, new MyCallback<GetGiftCategoryList, GetGiftCategoryList>(callback) {
  230. @Override
  231. protected GetGiftCategoryList processResponse(GetGiftCategoryList getGiftCategoryList) {
  232. return getGiftCategoryList;
  233. }
  234. });
  235. }
  236. public void PurchadeOrder(String userName, String password, String p_ID, String Price, String Quantity, String Amount, String Sfname, String Slname, String Semailid, String Snumber, String Rfname, String Rlname, String Remailid, String Rnumber, String RechargeMode,
  237. RestCallback<GetPlaceOrder> callback) {
  238. restInterface.productPurchaseOrder(userName, password, p_ID,
  239. Price, Quantity, Amount, Sfname, Slname, Semailid, Snumber, Rfname, Rlname, Remailid, Rnumber, RechargeMode,
  240. new MyCallback<GetPlaceOrder, GetPlaceOrder>(callback) {
  241. @Override
  242. protected GetPlaceOrder processResponse(GetPlaceOrder getGiftCategoryList) {
  243. return getGiftCategoryList;
  244. }
  245. });
  246. }
  247. public void getproduct(String userName, String password, String category, RestCallback<GiftCardProduct> callback) {
  248. restInterface.giftProduct(userName, password, category, new MyCallback<GiftCardProduct, GiftCardProduct>(callback) {
  249. @Override
  250. protected GiftCardProduct processResponse(GiftCardProduct getGiftCategoryList) {
  251. return getGiftCategoryList;
  252. }
  253. });
  254. }
  255. public void getproductDet(String userName, String password, String p_ID, RestCallback<ProductDetails> callback) {
  256. restInterface.giftProductDetails(userName, password, p_ID, new MyCallback<ProductDetails, ProductDetails>(callback) {
  257. @Override
  258. protected ProductDetails processResponse(ProductDetails getGiftCategoryList) {
  259. return getGiftCategoryList;
  260. }
  261. });
  262. }
  263. private interface RestInterface {
  264. @FormUrlEncoded
  265. @POST("/Recharge/GetAllRecharge")
  266. void doRecharge(@Field("UserName") String userId, @Field("Password") String password, @Field("Amount") String amount,
  267. @Field("MobileNumber") String number, @Field("OPTID") String opcode, @Field("Circle") String circle,
  268. @Field("Type") String acType,
  269. @Field("AccountNo") String acNumber, MyCallback<RechargeResponse, RechargeResponse> myCallback);
  270. @FormUrlEncoded
  271. @POST("/Recharge/GetUtilityBillPay")
  272. void submitElectricityRequest(@Field("UserName") String userId,
  273. @Field("Password") String password,
  274. @Field("Amount") String amount,
  275. @Field("Number") String consumerId,
  276. @Field("OperatorCode") String opcode,
  277. @Field("CircleCode") String circleCode,
  278. @Field("Mode") String Mode,
  279. @Field("Param1") String CycleOrBillingUnit,
  280. @Field("Param2") String param2,
  281. @Field("Param3") String contactNumber,
  282. @Field("Param4") String param4,
  283. @Field("Param5") String Param5,
  284. @Field("Param6") String Param6, MyCallback<RechargeResponse, RechargeResponse> myCallback);
  285. @FormUrlEncoded
  286. @POST("/RGUSER/GetLoginDetailsNew")
  287. void getMainLoginUserInfo(@Field("UserName") String userName, @Field("Password") String password,@Field("IMEINO") String IMEINO, MyCallback<LoginOTPVerifuy, LoginOTPVerifuy> myCallback);
  288. @FormUrlEncoded
  289. @POST("/RGUSER/GetLoginOTPVerify")
  290. void verifyLoginOTP(@Field("UserName") String userName,
  291. @Field("Password") String passWord,
  292. @Field("IMEINO") String imeiNo,
  293. @Field("OTP") String otp, MyCallback<LoginOTPVerifuy, LoginOTPVerifuy> myCallback);
  294. @FormUrlEncoded
  295. @POST("/RGUSER/GetLoginReSendOTP")
  296. void resendotplogin(@Field("UserName") String userName,
  297. @Field("Password") String passWord,
  298. MyCallback<LoginOTPVerifuy, LoginOTPVerifuy> myCallback);
  299. @FormUrlEncoded
  300. @POST("/RGUSER/GetUserBalance")
  301. void getBalance(@Field("UserName") String userName, @Field("Password") String password, MyCallback<GetBalance, GetBalance> myCallback);
  302. @FormUrlEncoded
  303. @POST("/RGUSER/GetLastTransaction")
  304. void getOrderHistory(@Field("UserName") String hpUserId, @Field("Password") String password, @Field("FromDate") String fromDate, @Field("ToDate") String toDate, MyCallback<RechargeHistory, RechargeHistory> myCallback);
  305. @FormUrlEncoded
  306. @POST("/RGUSER/GetTransactionByMobileNo")
  307. void getOrderHistoryById(@Field("UserName") String userName, @Field("Password") String password, @Field("MobileNo") String transId, MyCallback<RechargeHistory, RechargeHistory> myCallback);
  308. @FormUrlEncoded
  309. @POST("/RGUSER/GetUtilityBillPayValidate")
  310. void validateJioBill(@Field("UserName") String userId, @Field("Password") String password, @Field("OperatorCode") String opcode, @Field("Number") String subScriberId,
  311. @Field("BillUnit") String billingUnit, @Field("CycleNo") String cycleNumber, MyCallback<CheckJioBIll, CheckJioBIll> myCallback);
  312. @FormUrlEncoded
  313. @POST("/RGUSER/GetChangePassword")
  314. void changePassword(@Field("UserName") String hpUserId, @Field("Password") String oldPw, @Field("NewPassword") String newPw, MyCallback<RechargeResponse, RechargeResponse> myCallback);
  315. @FormUrlEncoded
  316. @POST("/UserService/GetUserSchemes")
  317. void getUserScheme(@Field("UserName") String userName, @Field("Password") String password, MyCallback<Schemes, Schemes> myCallback);
  318. @FormUrlEncoded
  319. @POST("/UserService/AddNewUser")
  320. void addUser(@Field("UserName") String userName, @Field("Password") String password, @Field("CurrentUserName") String name,
  321. @Field("CurrentUserId") String currentUserId, @Field("OwnerName") String parentName,
  322. @Field("MobileNo") String mobileNumber, @Field("PanCard") String pan, @Field("FirmName") String farmName,
  323. @Field("Area") String area, @Field("Address") String address, @Field("SchemeId") String schemeId,
  324. @Field("SchemeAmount") String schemeAmount, @Field("UserType") String schemeType, MyCallback<RechargeResponse, RechargeResponse> myCallback);
  325. @FormUrlEncoded
  326. @POST("/UserService/GetWallettowalletcr")
  327. void transferBalace(@Field("UserName") String userName, @Field("Password") String password, @Field("CrUserName") String name,
  328. @Field("Amount") String amount, @Field("Remarks") String remarks, MyCallback<RechargeResponse, RechargeResponse> myCallback);
  329. @FormUrlEncoded
  330. @POST("/RGUSER/GetForgotPassword")
  331. void forgetPassword(@Field("UserName") String userName, MyCallback<RechargeResponse, RechargeResponse> myCallback);
  332. @FormUrlEncoded
  333. @POST("/MoneycbNew/GetBranchName")
  334. void getBankBranchName(@Field("bankid") String bankId, @Field("city") String bankCity, MyCallback<BankBranchByCityList, BankBranchByCityList> myCallback);
  335. @FormUrlEncoded
  336. @POST("/RGUSER/GetUtilityBillPayValidate")
  337. void validateUtilityBill(@Field("username") String userId, @Field("password") String password, @Field("OperatorCode") String opcode, @Field("Number") String subScriberId,
  338. @Field("BillUnit") String billingUnit, @Field("CycleNo") String cycleNumber, MyCallback<CheckUtilityBIll, CheckUtilityBIll> myCallback);
  339. @FormUrlEncoded
  340. @POST("/UserService/GetUserNews")
  341. void getNews(@Field("UserName") String userName, @Field("Password") String password, MyCallback<NewsLine, NewsLine> myCallback);
  342. @FormUrlEncoded
  343. @POST("/operatorServices/GetOperatorName")
  344. void getOperator(@Field("ServiceId") String serviceID, MyCallback<OperatorListServer, OperatorListServer> myCallback);
  345. @FormUrlEncoded
  346. @POST("/UserService/GetUserAllChild")
  347. void userchildList(@Field("UserName") String userName, @Field("Password") String password,
  348. MyCallback<UserChild, UserChild> myCallback);
  349. @FormUrlEncoded
  350. @POST("/ReportsServices/GetPaymentDebitReport")
  351. void debitHistory(@Field("UserName") String hpUserId, @Field("Password") String password, @Field("FromDate") String fromDate, @Field("ToDate") String toDate, MyCallback<DebitReport, DebitReport> myCallback);
  352. @FormUrlEncoded
  353. @POST("/ReportsServices/GetPaymentCreditReport")
  354. void CreditHistory(@Field("UserName") String hpUserId, @Field("Password") String password, @Field("FromDate") String fromDate, @Field("ToDate") String toDate, MyCallback<CreditReport, CreditReport> myCallback);
  355. // giftCard Services by am
  356. @FormUrlEncoded
  357. @POST("/GiftcardCServices/GetGiftCategoryList")
  358. void giftcard(@Field("UserName") String userId, @Field("Password") String password, MyCallback<GetGiftCategoryList, GetGiftCategoryList> myCallback);
  359. @FormUrlEncoded
  360. @POST("/GiftcardCServices/GetPlaceorder")
  361. void productPurchaseOrder(@Field("UserName") String userId, @Field("Password") String password, @Field("Productid") String productid, @Field("Price") String price, @Field("Quantity") String quantity, @Field("Amount") String amount, @Field("Sfname") String sfname, @Field("Slname") String slname, @Field("Semailid") String semailid, @Field("Snumber") String snumber, @Field("Rfname") String rfname, @Field("Rlname") String rlname, @Field("Remailid") String remailid, @Field("Rnumber") String rnumber,
  362. @Field("RechargeMode") String rechargeMode,
  363. MyCallback<GetPlaceOrder, GetPlaceOrder> myCallback);
  364. @FormUrlEncoded
  365. @POST("/GiftcardCServices/GetGiftProductList")
  366. void giftProduct(@Field("UserName") String userId, @Field("Password") String password, @Field("category") String category, MyCallback<GiftCardProduct, GiftCardProduct> myCallback);
  367. @FormUrlEncoded
  368. @POST("/GiftcardCServices/GetProductAndBrand")
  369. void giftProductDetails(@Field("UserName") String userId, @Field("Password") String password, @Field("Productid") String prod_id, MyCallback<ProductDetails, ProductDetails> myCallback);
  370. }
  371. private abstract class MyCallback<M, N> implements Callback<N> {
  372. private RestCallback<M> restCallback;
  373. private boolean isCanceled;
  374. protected MyCallback(RestCallback<M> restCallback) {
  375. this.restCallback = restCallback;
  376. callbacks.add(this);
  377. }
  378. final void cancel() {
  379. isCanceled = true;
  380. }
  381. @Override
  382. public final void success(N n, Response response) {
  383. if (!isCanceled && restCallback != null) {
  384. try {
  385. M m = processResponse(n);
  386. if (m != null) {
  387. Log.d(TAG, "success");
  388. restCallback.success(m);
  389. } else {
  390. Log.d(TAG, "invalid");
  391. restCallback.invalid();
  392. }
  393. } catch (Exception e) {
  394. Log.d(TAG, "parse failure");
  395. String errorMessage = e.getMessage();
  396. if (errorMessage != null && errorMessage.length() > 0) {
  397. Log.e(TAG, e.getMessage());
  398. } else {
  399. e.printStackTrace();
  400. }
  401. restCallback.invalid();
  402. }
  403. }
  404. }
  405. @Override
  406. public final void failure(RetrofitError error) {
  407. if (!isCanceled && restCallback != null) {
  408. Log.d(TAG, "failure");
  409. String errorMessage = error.getMessage();
  410. if (errorMessage != null && errorMessage.length() > 0) {
  411. Log.d(TAG, errorMessage);
  412. }
  413. if (error.getKind() == RetrofitError.Kind.NETWORK) {
  414. errorMessage = "Network is down! Try Again...";
  415. }
  416. restCallback.failure(errorMessage);
  417. }
  418. }
  419. protected abstract M processResponse(N n);
  420. }
  421. }