Skip to content

Instantly share code, notes, and snippets.

View vishalhalani's full-sized avatar

Vishal Thakkar vishalhalani

View GitHub Profile
@vishalhalani
vishalhalani / BaseDetailModel
Created January 2, 2019 06:40
base detail model pojo which contain common things which is have to sent in each request
public class BaseDetailModel implements Parcelable {
@SerializedName("api_token")
@Expose
private String api_token;
@SerializedName("udid")
@Expose
private String udid;
@SerializedName("device_type")
@vishalhalani
vishalhalani / LoginModel
Created January 2, 2019 06:39
pojo class to get and set value of web request
public class LoginModel extends BaseDetailModel {
@SerializedName("email")
@Expose
private String email;
@SerializedName("password")
@Expose
private String password;
@vishalhalani
vishalhalani / BaseModel
Created January 2, 2019 06:36
base model to post request
public class BaseModel<T> {
@SerializedName("request")
@Expose
private String requestName;
@SerializedName("para")
@Expose
private T model;
@vishalhalani
vishalhalani / LoginController
Created January 2, 2019 06:13
controller class to make web call to login and store neccessary data to preferences
public class LoginController {
ApiClient apiService = null;
OnWebAPIResponseListener mRepsonseListener;
Context context;
public LoginController(OnWebAPIResponseListener mRepsonseListener, Context context) {
this.context = context;
this.mRepsonseListener = mRepsonseListener;
apiService = AppController.getAppInstance().getApiClient();
@vishalhalani
vishalhalani / ApiClient
Created January 2, 2019 06:10
Interface for all webcall
public interface ApiClient {
String URL = ApiConst.BASE_URL;
@POST(URL + ApiConst.SUBSITE_URL)
Call<BaseResponse<MetaDataModel>> syncMetaData(@Body BaseModel model);
}
@vishalhalani
vishalhalani / OnWebAPIResponseListener
Created January 2, 2019 06:07
Call back handler interface
public interface OnWebAPIResponseListener {
void onCallComplete(BaseResponse baseResponse, int requestCode);
// void onCallComplete(List<?> obj, int requestCode);
void onCallError(ErrorResponse errorModel, int requestCode);
}
@vishalhalani
vishalhalani / AppController
Created November 29, 2018 07:50
Application class to create singltone instance of retrofit and use full instances
public class AppController extends Application {
public static final int DISK_CACHE_SIZE = 10 * 1024 * 1024; // 10 MB
private static AppController appInstance = null;
private static Retrofit retrofit;
private static MyDatabase database;
private static Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
// .setDateFormat(DATE_FORMATS)
@vishalhalani
vishalhalani / HTMLTagHandler
Created November 29, 2018 07:49
html tag handler when to show bulleted points in textview
public class HtmlTagHandler implements Html.TagHandler {
String parent = null;
boolean first = true;
int index = 1;
private int mListItemCount = 0;
private Vector<String> mListParents = new Vector<String>();
@Override
public void handleTag(final boolean opening, final String tag, Editable output, final XMLReader xmlReader) {
@vishalhalani
vishalhalani / Controller
Created November 29, 2018 07:45
Controller Class handle all web request and responses
import android.content.Context;
import java.util.List;
import retrofit2.Call;
@vishalhalani
vishalhalani / BaseResponse
Created November 29, 2018 07:35
This class is base response class which handle all web response
public class BaseResponse<T> {
@SerializedName("data")
@Expose
private T data;
@SerializedName("status")
@Expose