Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StoreListFragment : Fragment() {
- fun onCreateView(inflater: LayoutInflater, container: ViewGroup,
- savedInstanceState: Bundle): View {
- // Inflate the layout for this fragment
- val view = inflater.inflate(R.layout.fragment_store_list, container, false)
- if (ConnectivityUtil.isConnected(getActivity())) {
- loadStores()
- } else {
- PopupUtil.showMsg(getActivity(), "No Internet connection", PopupUtil.SHORT)
- }
- return view
- }
- private fun loadStores() {
- PopupUtil.showLoading(getActivity(), "", "Loading stores....")
- val apiEndPoint = ApiClient.getClient().create(ApiEndPoint::class.java)
- val call = apiEndPoint.getStore(java.lang.Double.toString(mLat).toDouble(), java.lang.Double.toString(mLng).toDouble())
- call.enqueue(object : Callback<StoreResponse>() {
- fun onResponse(call: Call<StoreResponse>, response: Response<StoreResponse>) {
- PopupUtil.dismissDialog()
- val storeResponse = response.body()
- if (storeResponse != null) {
- if (storeResponse!!.success!!) {
- Log.d("StoreListFragment", "Jumlah store:" + storeResponse!!.store!!.size)
- }
- } else {
- Log.d("StoreListFragment", "response is null")
- }
- }
- fun onFailure(call: Call<StoreResponse>, t: Throwable) {
- PopupUtil.dismissDialog()
- }
- })
- }
- }//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement