retrofit

Android custom dialog with MVVM

↘锁芯ラ 提交于 2019-12-25 18:57:22
问题 I am creating custom dialog and i want when the user click add button go and call retrofit and observe on changes but i don't know how to pass lifecycleowner to the observer private void observeViewModel(ProjectListViewModel viewModel) { // Update the list when the data changes viewModel.getProjectListObservable().observe( ***what to pass here ??*** , new Observer<List<Project>>() { @Override public void onChanged(@Nullable List<Project> projects) { if (projects != null) { //… projectAdapter

Response in 202 STATUS in Retrofit2.0

我的梦境 提交于 2019-12-25 18:34:30
问题 i want to convert the Response in to JSON and show it to the User .I was able to display 200 response but in 202,i am failed. { Log.d(TAG, "RESPONSE CODE" + response.code()); if (response.code() == 200) { Gson gson = new Gson(); SuccessResponse signupResponse = response.body(); String sSignupResponse = gson.toJson(signUpResponse, SuccessResponse.class); try { } catch (JSONException e) { e.printStackTrace(); } } else if (response.code() == 202) { Log.d(TAG,"RESPONSE CODE IS "+"202 RIGHT");

Retrofit + Otto + AA, How to do simple get request?

时光怂恿深爱的人放手 提交于 2019-12-25 18:32:58
问题 I am using Android Annotation for boilerplate, and Retrofit for Api calls, While doing post requests through retrofit I discovered a Some problems: When i am calling asynchronous call to "GET" request using Retrofit, I need to do some operation just after my call gets finished, and I can't use "onResponse()" because I am using "Bean" annotation It doesn't make sense right? have a look on code Example Bean class: @EBean public class someClass{ /* Suppose api is getting RestClient reference

My ProgressDialog is Not Disappearing

无人久伴 提交于 2019-12-25 17:52:11
问题 I am working on a project in android to upload a file to server using file chooser But there is a problem, when i am Uploading more than 500 kB file. The file is uploaded but My Progress Dialog is not disappearing and if i uploaded file 100 KB it's uploaded to server and i got a message file uploaded successfully. But I'm not able to get server response if i uploaded more than 500 kB file. Please Help me. Thank You. It's my UploadFile() Methods private void uploadFile() { dialog =

My ProgressDialog is Not Disappearing

南楼画角 提交于 2019-12-25 17:52:09
问题 I am working on a project in android to upload a file to server using file chooser But there is a problem, when i am Uploading more than 500 kB file. The file is uploaded but My Progress Dialog is not disappearing and if i uploaded file 100 KB it's uploaded to server and i got a message file uploaded successfully. But I'm not able to get server response if i uploaded more than 500 kB file. Please Help me. Thank You. It's my UploadFile() Methods private void uploadFile() { dialog =

Not Able to Fetch Data from server using Retrofit?

ε祈祈猫儿з 提交于 2019-12-25 09:19:21
问题 Not any errors are showing but data are not fetching form server. my Main Activity public class RetroMain extends AppCompatActivity implements ListView.OnItemClickListener { public static final String ROOT_URL = "http://www.myeducationhunt.com/api/v1/colleges"; //Strings to bind with intent will be used to send data to other activity public static final String KEY_BOOK_ID = "id"; public static final String KEY_BOOK_NAME = "name"; public static final String KEY_BOOK_ADDRESS = "address"; public

Retrofit, parsing JSON null exception at response

纵饮孤独 提交于 2019-12-25 08:12:03
问题 I'm using Retrofit in my app. I've got JSON response which looks like this: { "data": { "list": [ { "id": 58, "beacon_id": "58", "bridge_id": null, "mesh_id": null, "name": "eon_3c", "location": "abcdlk", "mac_address": "3c:cf:82:8a:e7:fe", "firmware": "2.1", "pcb_revision": "2.0", "battery_level": "99", "password": "0000", "ib": { "turn_on": "1", "major": "33", "minor": "344", "tx_power": "7", "interval": "400", "uuid": "dae19960-18ea-11e5-8ff0-0002a5d5c521", "secure_uuid": "0" }, "euid": {

Retrofit in android?

僤鯓⒐⒋嵵緔 提交于 2019-12-25 07:59:48
问题 I'm new to Retrofit. How can I send param and get Json from bellow url ? http://xxx:8087/courier.svc/login?username=jim&password=123456 I need to a link for tutorial . This code is in my MainActivity : private void loadJSON(String username, String password) { Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://192.168.8.11:8087/sample.svc/") .addConverterFactory(GsonConverterFactory.create()) .build(); RequestInterface_Login request = retrofit.create(RequestInterface_Login.class);

How to make multiple requests with reactive android and retrofit

最后都变了- 提交于 2019-12-25 07:50:13
问题 I have presenter which calls getShops() method. Observable<List<Shop>> observable = interactor.getData(); Subscription subscription = observable .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber<List<Shop>>() { @Override public void onCompleted() { view.hideProgress(); } @Override public void onError(Throwable e) { super.onError(e); view.hideProgress(); } @Override public void onNext(List<Shop> shops) { handleShops(shops); view.onSuccess

How to post json object using retrofit

瘦欲@ 提交于 2019-12-25 06:35:38
问题 i wanted to post the json object using retrofit. i have created following interface: public interface syncinter { @POST("url") void sync_data(@Body JSONObject ordObj, Callback<JsonObject> callback); } the following data i want it to post. final JSONObject ordJsonObj = new JSONObject(); JSONArray ordJsonArray = new JSONArray(); try { ordJsonObj.put("Order_Nos",mOrdArr.size()); for (int i=0; i<mOrdArr.size();i++) { JSONObject ordObj = new JSONObject(); ordObj.put("Order_No",mOrdArr.get(i)