Commit 4fdda50c by Neeloy Ghosh

neeloy_commit

parent 6842f41b
......@@ -25,12 +25,25 @@ import com.bbps.fragment.pojo.BillersDataBySearch;
import com.bbps.fragment.pojo.RegisteredBillersPojo;
import com.bbps.fragment.pojo.TransactionData;
import com.bbps.interfaces.ApiInterface;
import com.bbps.interfaces.IDataListener;
import com.bbps.utils.ApiClient;
import com.bbps.utils.AppConstant;
import com.bbps.utils.ExpandableHeightListView;
import com.bbps.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import org.json.JSONObject;
import java.io.Reader;
import java.io.StringReader;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -160,6 +173,18 @@ public class AddBillerByCategory extends BaseFragment {
if (AppConstant.isNetworkAvailable(getActivity())) {
ApiInterface apiService =
ApiClient.getClient().create(ApiInterface.class);
// Call<Object> call = apiService.getBillerCategoryObject();
// AppConstant.getDataFromServer(getActivity(), call, new IDataListener() {
// @Override
// public void getResult(String errorMessage, Response<Object> response) {
// Object object=response.body();
// BillerCategory output = JsonUtils.get(object, BillerCategory.class);
// Log.e("output",output.getCategory()[0].toString());
//
//
//
// }
// });
Call<BillerCategory> call = apiService.getBillerCategory();
call.enqueue(new Callback<BillerCategory>() {
@Override
......@@ -192,4 +217,5 @@ public class AddBillerByCategory extends BaseFragment {
}
}
......@@ -55,6 +55,9 @@ public interface ApiInterface {
@GET("biller/categories")
Call<BillerCategory> getBillerCategory();
@GET("biller/categories")
Call<Object> getBillerCategoryObject();
@GET("biller/states")
Call<StatePojo> getStates();
......
......@@ -5,6 +5,8 @@ import android.os.Build;
import android.support.annotation.RequiresApi;
import com.bbps.R;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.io.InputStream;
......@@ -58,9 +60,12 @@ public class ApiClient {
});
OkHttpClient client = httpClient.build();
if (retrofit == null) {
Gson gson = new GsonBuilder()
.setLenient()
.create();
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.client(client)
.build();
}
......
......@@ -7,9 +7,14 @@ import android.net.NetworkInfo;
import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import com.bbps.R;
import com.bbps.fragment.pojo.BillerCategory;
import com.bbps.fragment.pojo.BillerRegistrations;
import com.bbps.fragment.pojo.BillerRegistrationsSave;
import com.bbps.interfaces.IDataListener;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
......@@ -32,6 +37,10 @@ import org.json.JSONObject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by neeloyg on 08-08-2017.
*/
......@@ -330,5 +339,34 @@ public class AppConstant {
return jsonObject;
}
public static void getDataFromServer(final Context context,Call<Object> call, final IDataListener iDataListener) {
call.enqueue(new Callback<Object>() {
@Override
public void onResponse(Call<Object> call, Response<Object> response) {
if (response != null && response.body() != null) {
iDataListener.getResult("",response);
}else {
//if (response.body().getErrorMessages() != null) {
// if(context!=null)
// Toast.makeText(context, response.body().getErrorMessages().get(0).getErrorDtl(), Toast.LENGTH_SHORT).show();
// }
}
}
@Override
public void onFailure(Call<Object> call, Throwable t) {
Log.e("error", t.toString());
if(context!=null)
Toast.makeText(context, context.getString(R.string.txt_networkcheck), Toast.LENGTH_SHORT).show();
iDataListener.getResult("ERROR",null);
}
});
}
}
......@@ -30,7 +30,7 @@
<Spinner
android:id="@+id/spinner_billercategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
......
......@@ -24,7 +24,7 @@
<Spinner
android:id="@+id/spinner_onlyselect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:layout_marginTop="@dimen/dp_10"
android:background="@drawable/selectbox" />
......@@ -44,7 +44,7 @@
<Spinner
android:id="@+id/spinner_biller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
<com.bbps.utils.CustomTextView
......@@ -63,7 +63,7 @@
<Spinner
android:id="@+id/spinner_subbiller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
<com.bbps.utils.CustomTextView
......
......@@ -32,10 +32,11 @@
<Spinner
android:id="@+id/spinner_reasons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:background="@drawable/selectbox" />
android:background="@drawable/selectbox"
/>
<ScrollView
......
......@@ -304,7 +304,7 @@
<Spinner
android:id="@+id/spinner_reasons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
<com.bbps.utils.CustomTextView
......
......@@ -44,7 +44,7 @@
<Spinner
android:id="@+id/spinner_agent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
<com.bbps.utils.CustomTextView
......@@ -62,7 +62,7 @@
<Spinner
android:id="@+id/spinner_reasons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
<com.bbps.utils.CustomTextView
......
......@@ -86,7 +86,7 @@
<Spinner
android:id="@+id/spinner_agent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/spinner_height"
android:background="@drawable/selectbox" />
<com.bbps.utils.CustomTextView
......
......@@ -48,4 +48,6 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="spinner_height">40dp</dimen>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment