Commit e6f19928 by Kunj Gupta

Initial Commit

parents
Showing with 4394 additions and 0 deletions
#built application files
app/*.apk
app/*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Eclipse project files
.classpath
.project
# Android Studio
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
*~
._*
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
signingConfigs {
config {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('/home/chaukadev/.android/debug.keystore')
storePassword 'android'
}
}
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.vsoft.uofl_catalogue"
minSdkVersion 9
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
applicationIdSuffix ".debug"
buildConfigField "int", "BUILD_TYPE_INT", "1"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "int", "BUILD_TYPE_INT", "2"
signingConfig signingConfigs.config
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.squareup.retrofit2:retrofit:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/chaukadev/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vsoft.uofl_catalogue">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:name=".CatalogueApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ui.LoginScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.HomeScreen"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.CatalogueScreen"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.CatalogueItemScreen"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.CatalogueVariableScreen"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"/>
</application>
</manifest>
package com.vsoft.uofl_catalogue;
import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.vsoft.uofl_catalogue.db.DBManager;
public class CatalogueApplication extends Application {
private static DBManager sDBManager;
private ConnectivityManager mConMgr;
private static Context mContext;
@Override
public void onCreate() {
super.onCreate();
mContext = getApplicationContext();
/*Database is created*/
initializeDatabase();
}
public static Context getContext() {
return mContext;
}
/*DataBase is created*/
public void initializeDatabase() {
if(sDBManager == null) {
sDBManager = new DBManager(this);
sDBManager.getWritableDatabase();
}
}
public static SQLiteDatabase getDatabase() {
if(sDBManager != null) {
return sDBManager.getWritableDatabase();
}
return null;
}
public boolean isNetConnected() {
if(mConMgr==null)
mConMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = mConMgr.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnected();
}
}
package com.vsoft.uofl_catalogue.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.db.models.Catalogue;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kunj on 11/8/16.
*/
public class CatalogueCategoryAdapter extends BaseAdapter {
private Context mContext;
private final List<Catalogue> mCatalogueList = new ArrayList<>(0);
private LayoutInflater mInflater;
public CatalogueCategoryAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setCatalogueList(List<Catalogue> catalogueList) {
mCatalogueList.clear();
if(catalogueList!=null)
mCatalogueList.addAll(catalogueList);
notifyDataSetChanged();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mCatalogueList.size();
}
@Override
public Catalogue getItem(int position) {
// TODO Auto-generated method stub
return mCatalogueList.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.catalogue_category_adapter, parent, false);
holder = new ViewHolder();
holder.titleTextView = (TextView) convertView.findViewById(R.id.catalogue_category_adapter_title_tv);
holder.desTextView = (TextView) convertView.findViewById(R.id.catalogue_category_adapter_des_tv);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Catalogue catalogue = mCatalogueList.get(position);
holder.titleTextView.setText(catalogue.getTitle());
holder.desTextView.setText(catalogue.getDescription());
return convertView;
}
static class ViewHolder {
private TextView titleTextView;
private TextView desTextView;
private ImageView imageView;
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kunj on 11/8/16.
*/
public class CatalogueCategoryItemAdapter extends BaseAdapter {
private Context mContext;
private final List<CatalogueItem> mCatalogueItemList = new ArrayList<>(0);
private LayoutInflater mInflater;
public CatalogueCategoryItemAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setCatalogueList(List<CatalogueItem> catalogueList) {
mCatalogueItemList.clear();
if(catalogueList!=null)
mCatalogueItemList.addAll(catalogueList);
notifyDataSetChanged();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mCatalogueItemList.size();
}
@Override
public CatalogueItem getItem(int position) {
// TODO Auto-generated method stub
return mCatalogueItemList.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.catalogue_category_item_adapter, parent, false);
holder = new ViewHolder();
holder.nameTextView = (TextView) convertView.findViewById(R.id.catalogue_category_item_adapter_name_tv);
holder.desTextView = (TextView) convertView.findViewById(R.id.catalogue_category_item_adapter_des_tv);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
CatalogueItem catalogueItem = mCatalogueItemList.get(position);
holder.nameTextView.setText(catalogueItem.getName());
holder.desTextView.setText(catalogueItem.getShortDescription());
return convertView;
}
static class ViewHolder {
private TextView nameTextView;
private TextView desTextView;
private ImageView imageView;
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.vsoft.uofl_catalogue.R;
/**
* Created by kunj on 18/8/16.
*/
public class HomeScreenAdapter extends BaseAdapter {
private final LayoutInflater mInflater;
private final String[] mGridValues;
//Constructor to initialize values
public HomeScreenAdapter(Context mContext, String[ ] mGridValues) {
this.mGridValues = mGridValues;
mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// Number of times getView method call depends upon mGridValues.length
return mGridValues.length;
}
@Override
public String getItem(int position) {
return mGridValues[position];
}
@Override
public long getItemId(int position) {
return position;
}
// Number of times getView method call depends upon mGridValues.length
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.home_screen_adapter, parent, false);
holder = new ViewHolder();
holder.textview = (TextView) convertView.findViewById(R.id.home_screen_adapter_text_view);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String value = mGridValues[position];
holder.textview.setText(value);
return convertView;
}
static class ViewHolder {
private TextView textview;
}
}
package com.vsoft.uofl_catalogue.api;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
/**
* @author Kunj on 11/8/16.
*
*/
public class GsonStringConverterFactory extends Converter.Factory {
private static final MediaType MEDIA_TYPE = MediaType.parse("application/json");
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
if(String.class.equals(type)) {
return new Converter<String, RequestBody>() {
@Override
public RequestBody convert(String value) throws IOException {
return RequestBody.create(MEDIA_TYPE, value);
}
};
}
return super.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit);
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.api;
import android.text.TextUtils;
import android.util.Base64;
import com.vsoft.uofl_catalogue.utils.Constants;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* @author Kunj on 11/8/16.
*
*/
public class RestClient {
public static Retrofit getInitializedRestAdapter(final String accessToken) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder();
if(!TextUtils.isEmpty(accessToken)) {
final String bearer = "Bearer " + accessToken;
requestBuilder.header(Constants.API_HEADER_PARAM_AUTHORIZATION, bearer);
}
requestBuilder.header("Accept", "application/json");
requestBuilder.header("Content-Type", "application/json");
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
try {
return chain.proceed(request);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
};
httpClient.interceptors().add(interceptor);
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.interceptors().add(logging);
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(Constants.DOMAIN)
.client(httpClient.build())
.addConverterFactory(new GsonStringConverterFactory())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
public static Retrofit getInitializedRestAdapter(String username, String password) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
String credentials = username + ":" + password;
final String basic =
"Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
// add your other interceptors
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
.header(Constants.API_HEADER_PARAM_AUTHORIZATION, basic);
requestBuilder.header("Accept", "application/json");
requestBuilder.header("Content-Type", "application/json");
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
try {
return chain.proceed(request);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
};
httpClient.interceptors().add(interceptor);
// add logging as last interceptor
httpClient.interceptors().add(logging); // <-- this is the important line!
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(Constants.DOMAIN)
.client(httpClient.build())
.addConverterFactory(new GsonStringConverterFactory())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
public static Retrofit getInitializedRestAdapterWithOutHeader(String username, String password) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
String credentials = username + ":" + password;
final String basic =
"Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
// add your other interceptors
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
.header(Constants.API_HEADER_PARAM_AUTHORIZATION, basic);
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
try {
return chain.proceed(request);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
};
httpClient.interceptors().add(interceptor);
// add logging as last interceptor
httpClient.interceptors().add(logging); // <-- this is the important line!
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(Constants.DOMAIN)
.client(httpClient.build())
.addConverterFactory(new GsonStringConverterFactory())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
}
package com.vsoft.uofl_catalogue.api.interfaces;
import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import com.vsoft.uofl_catalogue.db.models.CatalogueVariable;
import com.vsoft.uofl_catalogue.db.models.Reference;
import com.vsoft.uofl_catalogue.utils.Constants;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* @since 1.0
* @author Kunj on 11/8/16.
*
*/
public interface CatalogueApi {
// Get Catalogue API
@GET(Constants.URL_GET_CATALOGUE)
Call<ResponseBody> getCatalogue(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery,
@Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields);
// Get Catalogue Item API
@GET(Constants.URL_GET_CATALOGUE_ITEM)
Call<ResponseBody> getCatalogueItem(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery,
@Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields);
// Get Variable API
@GET(Constants.URL_GET_VARIABLE)
Call<ResponseBody> getVariable(@Query(CatalogueVariable.Json.SYS_ID) String sysId);
// Get Variable Choices API
@GET(Constants.URL_GET_VARIABLE_CHOICE)
Call<ResponseBody> getVariableChoice(@Query(Constants.URL_PARAM_SYSPRM_QUERY) String sysparmQuery,
@Query(Constants.URL_PARAM_SYSPRM_FIELDS) String sysParmFields);
// Post catalogue item API
@POST(Constants.URL_POST_CATALOGUE_ITEM)
Call<ResponseBody> postCatalogueItem(@Query(CatalogueItem.Json.SYS_ID) String sysId,
@Body String catalogueItemJson);
// Get Reference API
@GET
Call<ResponseBody> getReference(@Url String url, @Query(Reference.Json.FIRST_NAME) String firstName);
}
package com.vsoft.uofl_catalogue.api.listeners.get;
import com.vsoft.uofl_catalogue.db.models.Catalogue;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetCatalogueApiListener {
void onDoneApiCall(List<Catalogue> catalogueList);
}
package com.vsoft.uofl_catalogue.api.listeners.get;
import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetCatalogueItemApiListener {
void onDoneApiCall(List<CatalogueItem> catalogueItemList);
}
package com.vsoft.uofl_catalogue.api.listeners.get;
import com.vsoft.uofl_catalogue.db.models.CatalogueVariable;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetCatalogueVariableApiListener {
void onDoneApiCall(List<CatalogueVariable> catalogueVariableList);
}
package com.vsoft.uofl_catalogue.api.listeners.get;
import com.vsoft.uofl_catalogue.db.models.Reference;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetReferenceApiListener {
void onDoneApiCall(List<Reference> referenceList);
}
package com.vsoft.uofl_catalogue.api.listeners.get;
import com.vsoft.uofl_catalogue.db.models.VariableChoice;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetVariableChoiceApiListener {
void onDoneApiCall(List<VariableChoice> variableChoiceList);
}
package com.vsoft.uofl_catalogue.api.managers;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.vsoft.uofl_catalogue.api.RestClient;
import com.vsoft.uofl_catalogue.db.models.Catalogue;
import com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi;
import com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueApiListener;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* @author Kunj on 11/8/16.
*
*/
public class CatalogueApiManager {
public static SyncStatus getCatalogues(GetCatalogueApiListener listener) {
CatalogueLog.d("CatalogueApiManager: getCatalogues: ");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(Catalogue.Json.URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE);
stringBuilder.append("=e0d08b13c3330100c8b837659bba8fb4");
stringBuilder.append("^active=true");
CatalogueLog.d("CatalogueApiManager: getCatalogues: request parameter: "+stringBuilder.toString());
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueApi.class).getCatalogue(stringBuilder.toString(), "sys_id,title,description");
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) {
try {
JSONObject jsonObject = new JSONObject(response.body().string());
JSONObject error = jsonObject.optJSONObject(Constants.RESPONSE_ERROR_OBJECT_NAME);
if (error == null) {
JSONArray catalogueJsonArray = jsonObject.getJSONArray(Constants.RESPONSE_RESULT_OBJECT_NAME);
if(catalogueJsonArray.length() > 0) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(long.class, new JsonDeserializer<Long>() {
@Override
public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
long value = 0;
try {
value = json.getAsLong();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueApiManager: getCatalogues: deserialize: long.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(int.class, new JsonDeserializer<Integer>() {
@Override
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
int value = 0;
try {
value = json.getAsInt();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueApiManager: getCatalogues: deserialize: int.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(float.class, new JsonDeserializer<Float>() {
@Override
public Float deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
float value = 0;
try {
value = json.getAsFloat();
} catch (NumberFormatException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: deserialize: float.class: NumberFormatException: ", e);
}
return value;
}
})
.create();
List<Catalogue> catalogueList = new ArrayList<>(catalogueJsonArray.length());
for (int i = 0; i < catalogueJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueJsonArray.getJSONObject(i);
Catalogue catalogue = gson.fromJson(expenseJsonObject.toString(), Catalogue.class);
catalogueList.add(catalogue);
}
listener.onDoneApiCall(catalogueList);
} else {
listener.onDoneApiCall(new ArrayList<Catalogue>(0));
}
return SyncStatus.SUCCESS;
} else
return SyncStatus.FAIL;
} catch (JSONException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: onResponse: ", e);
return SyncStatus.FAIL;
} catch (IOException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: onResponse: ", e);
return SyncStatus.FAIL;
}
} else {
return SyncStatus.FAIL;
}
} catch (IOException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: IOException: ", e);
return SyncStatus.FAIL;
} catch (NullPointerException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: NullPointerException: ", e);
return SyncStatus.FAIL;
}
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.api.managers;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.vsoft.uofl_catalogue.api.RestClient;
import com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi;
import com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueItemApiListener;
import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* @author Kunj on 11/8/16.
*
*/
public class CatalogueItemApiManager {
public static SyncStatus getCatalogueItems(String catalogueSysId, GetCatalogueItemApiListener listener) {
CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: ");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(CatalogueItem.Json.URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE);
stringBuilder.append("=");
stringBuilder.append(catalogueSysId);
CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: request parameter: "+stringBuilder.toString());
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueApi.class).getCatalogueItem(stringBuilder.toString(), "sys_id,short_description,name,description");
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) {
try {
JSONObject jsonObject = new JSONObject(response.body().string());
JSONObject error = jsonObject.optJSONObject(Constants.RESPONSE_ERROR_OBJECT_NAME);
if (error == null) {
JSONArray catalogueItemJsonArray = jsonObject.getJSONArray(Constants.RESPONSE_RESULT_OBJECT_NAME);
if(catalogueItemJsonArray.length() > 0) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(long.class, new JsonDeserializer<Long>() {
@Override
public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
long value = 0;
try {
value = json.getAsLong();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: deserialize: long.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(int.class, new JsonDeserializer<Integer>() {
@Override
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
int value = 0;
try {
value = json.getAsInt();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: deserialize: int.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(float.class, new JsonDeserializer<Float>() {
@Override
public Float deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
float value = 0;
try {
value = json.getAsFloat();
} catch (NumberFormatException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: deserialize: float.class: NumberFormatException: ", e);
}
return value;
}
})
.create();
List<CatalogueItem> catalogueItemList = new ArrayList<>(catalogueItemJsonArray.length());
for (int i = 0; i < catalogueItemJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueItemJsonArray.getJSONObject(i);
CatalogueItem catalogueItem = gson.fromJson(expenseJsonObject.toString(), CatalogueItem.class);
catalogueItemList.add(catalogueItem);
}
listener.onDoneApiCall(catalogueItemList);
} else {
listener.onDoneApiCall(new ArrayList<CatalogueItem>(0));
}
return SyncStatus.SUCCESS;
} else
return SyncStatus.FAIL;
} catch (JSONException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: onResponse: ", e);
return SyncStatus.FAIL;
} catch (IOException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: onResponse: ", e);
return SyncStatus.FAIL;
}
} else {
return SyncStatus.FAIL;
}
} catch (IOException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: IOException: ", e);
return SyncStatus.FAIL;
} catch (NullPointerException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: NullPointerException: ", e);
return SyncStatus.FAIL;
}
}
public static SyncStatus submitCatalogueItem(String catalogueItemSysId, JSONArray catalogueJsonArray) {
CatalogueLog.d("submitCatalogueItem: " + catalogueJsonArray);
String expenseJsonString = catalogueJsonArray.toString();
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueApi.class).postCatalogueItem(catalogueItemSysId, expenseJsonString);
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) {
return SyncStatus.SUCCESS;
} else {
return SyncStatus.FAIL;
}
} catch (IOException e) {
CatalogueLog.e("CatalogueItemApiManager: submitCatalogueItem: IOException: ", e);
return SyncStatus.FAIL;
} catch (NullPointerException e){
CatalogueLog.e("CatalogueItemApiManager: submitCatalogueItem: IOException: ", e);
return SyncStatus.FAIL;
}
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.api.managers;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.vsoft.uofl_catalogue.api.RestClient;
import com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi;
import com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueVariableApiListener;
import com.vsoft.uofl_catalogue.db.models.CatalogueVariable;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* @author Kunj on 11/8/16.
*
*/
public class CatalogueVariableApiManager {
public static SyncStatus getCatalogueVariable(String catalogueItemSysId, GetCatalogueVariableApiListener listener) {
CatalogueLog.d("CatalogueVariableApiManager: getCatalogueVariable: ");
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueApi.class).getVariable(catalogueItemSysId);
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) {
try {
JSONObject jsonObject = new JSONObject(response.body().string());
JSONObject error = jsonObject.optJSONObject(Constants.RESPONSE_ERROR_OBJECT_NAME);
if (error == null) {
JSONArray catalogueVariableJsonArray = jsonObject.getJSONArray(Constants.RESPONSE_RESULT_OBJECT_NAME);
if(catalogueVariableJsonArray.length() > 0) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(long.class, new JsonDeserializer<Long>() {
@Override
public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
long value = 0;
try {
value = json.getAsLong();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueVariableApiManager: getCatalogueVariable: deserialize: long.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(int.class, new JsonDeserializer<Integer>() {
@Override
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
int value = 0;
try {
value = json.getAsInt();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueVariableApiManager: getCatalogueVariable: deserialize: int.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(float.class, new JsonDeserializer<Float>() {
@Override
public Float deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
float value = 0;
try {
value = json.getAsFloat();
} catch (NumberFormatException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: deserialize: float.class: NumberFormatException: ", e);
}
return value;
}
})
.create();
List<CatalogueVariable> catalogueVariableList = new ArrayList<>(catalogueVariableJsonArray.length());
for (int i = 0; i < catalogueVariableJsonArray.length(); i++) {
JSONObject variableJsonObject = catalogueVariableJsonArray.getJSONObject(i);
CatalogueVariable catalogueVariable = gson.fromJson(variableJsonObject.toString(), CatalogueVariable.class);
catalogueVariable.parseJson(variableJsonObject);
// if(catalogueVariable.getName()!=null)
catalogueVariableList.add(catalogueVariable);
}
listener.onDoneApiCall(catalogueVariableList);
} else {
listener.onDoneApiCall(new ArrayList<CatalogueVariable>(0));
}
return SyncStatus.SUCCESS;
} else
return SyncStatus.FAIL;
} catch (JSONException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: onResponse: ", e);
return SyncStatus.FAIL;
} catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: onResponse: ", e);
return SyncStatus.FAIL;
}
} else {
return SyncStatus.FAIL;
}
} catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: IOException: ", e);
return SyncStatus.FAIL;
} catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: NullPointerException: ", e);
return SyncStatus.FAIL;
}
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.db;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.preference.PreferenceManager;
import com.vsoft.uofl_catalogue.utils.Constants;
import com.vsoft.uofl_catalogue.utils.DBConstants;
/**
*
* @author Kunj on 11-08-2016.
*/
public class DBManager extends SQLiteOpenHelper implements DBConstants {
private static final String DATABASE_NAME = "uofl.db";
private static final int DATABASE_VERSION = 1;
private Context mContext;
public DBManager(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
mContext = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
createCatalogueTable(db);
createCatalogueItemsTable(db);
createVariableTable(db);
createVariableChoiceTable(db);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit();
editor.putInt(Constants.PREFS_OLD_VERSION_NUMBER, oldVersion);
editor.putInt(Constants.PREFS_NEW_VERSION_NUMBER, newVersion);
editor.apply();
onCreate(db);
}
private void createCatalogueTable(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_CATALOGUE + "("
+ CATALOGUE_ID + " integer primary key autoincrement, "
+ CATALOGUE_TITLE + " text, "
+ CATALOGUE_DESCRIPTION + " text, "
+ CATALOGUE_SYS_ID + " text, "
+ CATALOGUE_SYNC_DIRTY + " integer default " + SYNC_FLAG_NONE
+ ");");
}
private void createCatalogueItemsTable(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_CATALOGUE_ITEM + "("
+ CATALOGUE_ITEM_ID + " integer primary key autoincrement, "
+ CATALOGUE_ITEM_CATALOGUE_ID + " integer default -1, "
+ CATALOGUE_ITEM_NAME + " integer, "
+ CATALOGUE_ITEM_SHORT_DESCRIPTION + " text, "
+ CATALOGUE_ITEM_DESCRIPTION + " text, "
+ CATALOGUE_ITEM_SYS_ID + " text, "
+ CATALOGUE_ITEM_SYNC_DIRTY + " integer default " + SYNC_FLAG_NONE
+ ");");
}
private void createVariableTable(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_CATALOGUE_VARIABLES + "("
+ CATALOGUE_VARIABLE_ID + " integer primary key autoincrement, "
+ CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID + " integer default -1, "
+ CATALOGUE_VARIABLE_NAME + " text, "
+ CATALOGUE_VARIABLE_QUESTION_TEXT + " text, "
+ CATALOGUE_VARIABLE_TYPE + " integer, "
+ CATALOGUE_VARIABLE_MANDATORY + " integer, "
+ CATALOGUE_VARIABLE_NONE_REQUIRED + " integer, "
+ CATALOGUE_VARIABLE_REFERENCE_TABLE + " text, "
+ CATALOGUE_VARIABLE_SYS_ID + " text, "
+ CATALOGUE_VARIABLE_SYNC_DIRTY + " integer default " + SYNC_FLAG_NONE
+ ");");
}
private void createVariableChoiceTable(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_VARIABLE_CHOICES + "("
+ VARIABLE_CHOICE_ID + " integer primary key autoincrement, "
+ VARIABLE_CHOICE_VARIABLE_ID + " integer default -1, "
+ VARIABLE_CHOICE_TEXT + " text, "
+ VARIABLE_CHOICE_VALUE + " integer, "
+ VARIABLE_CHOICE_ORDER + " integer, "
+ VARIABLE_CHOICE_MISC + " real);");
}
}
package com.vsoft.uofl_catalogue.db.managers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.db.models.Catalogue;
import com.vsoft.uofl_catalogue.utils.DBConstants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
*
* @author Kunj on 11-08-2016.
*/
public class CatalogueManager implements DBConstants {
public static long save(Catalogue catalogue, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
catalogue.setSyncDirty(syncDirty);
long id = db.insert(TABLE_CATALOGUE, null, getContentValues(catalogue));
catalogue.setId(id);
return id;
} else {
return -1;
}
}
public static int delete(Catalogue catalogue) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
if (catalogue.getSysId() == null || catalogue.getSysId().isEmpty()) {
return db.delete(TABLE_CATALOGUE, CATALOGUE_ID + "=" + catalogue.getId(), null);
} else {
return update(catalogue, SYNC_FLAG_DELETE);
}
}
return -1;
}
public static int update(Catalogue catalogue, int syncDirty) {
return update(catalogue, null, syncDirty);
}
public static int update(Catalogue catalogue, List<String> column, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
catalogue.setSyncDirty(syncDirty);
if (column == null || column.size() == 0) {
return db.update(TABLE_CATALOGUE, getContentValues(catalogue), CATALOGUE_ID + "=" + catalogue.getId(), null);
} else {
ContentValues contentValues = new ContentValues(column.size());
contentValues.put(CATALOGUE_SYNC_DIRTY, catalogue.getSyncDirty());
for (int i = 0; i < column.size(); i++) {
String columnName = column.get(i);
if (CATALOGUE_TITLE.equals(columnName)) {
contentValues.put(CATALOGUE_TITLE, catalogue.getTitle());
} else if (CATALOGUE_DESCRIPTION.equals(columnName)) {
contentValues.put(CATALOGUE_DESCRIPTION, catalogue.getDescription());
} else if (CATALOGUE_SYS_ID.equals(columnName)) {
contentValues.put(CATALOGUE_SYS_ID, catalogue.getSysId());
}
}
return db.update(TABLE_CATALOGUE, contentValues, CATALOGUE_ID + "=" + catalogue.getId(), null);
}
} else {
return -1;
}
}
public static void handleGetCatalogue(List<Catalogue> serverCatalogueList) {
if(serverCatalogueList != null && !serverCatalogueList.isEmpty()) {
/*catalogueSysIdMap contain all server response catalogues Sys Id*/
HashMap<String, Integer> catalogueSysIdMap = new HashMap<>(0);
Integer intObj = Integer.valueOf(1);
for (int i = 0; i < serverCatalogueList.size(); i++) {
String sysId = serverCatalogueList.get(i).getSysId();
catalogueSysIdMap.put(sysId, intObj);
}
/*localCatalogueList is contain all local Catalogues */
List<Catalogue> localCatalogueList = getAllCatalogues();
if (localCatalogueList != null && !localCatalogueList.isEmpty()) {
for (int i = 0; i < localCatalogueList.size(); i++) {
Catalogue localCatalogue = localCatalogueList.get(i);
String localCatalogueSysId = localCatalogue.getSysId();
if (localCatalogueSysId != null
&& !localCatalogueSysId.isEmpty()
&& !catalogueSysIdMap.containsKey(localCatalogueSysId)) {
//Update sys_id with empty string because required to delete locally
localCatalogue.setSysId("");
delete(localCatalogue);
}
}
}
/*Check this catalogue is exist in local DB or not
* If doesn't exist in local, save it
* If exist in local, update the local item with data from server item.
* */
for (int i = 0; i < serverCatalogueList.size(); i++) {
Catalogue catalogue = serverCatalogueList.get(i);
Catalogue localCatalogue = getCatalogueFromSysId(catalogue.getSysId());
if (localCatalogue == null) {
save(catalogue, DBConstants.SYNC_FLAG_NONE);
} else {
/*Update complete local Catalogue object with response Catalogue object*/
catalogue.setId(localCatalogue.getId());
update(catalogue, DBConstants.SYNC_FLAG_NONE);
}
}
} else {
/*That means there is no Catalogue category in server response, then all local items should be deleted those are contain sys_id*/
/*localCatalogueList is contain all local Catalogues */
List<Catalogue> localCatalogueList = getAllCatalogues();
if (localCatalogueList != null && !localCatalogueList.isEmpty()) {
for (int i = 0; i < localCatalogueList.size(); i++) {
Catalogue localCatalogue = localCatalogueList.get(i);
String localCatalogueSysId = localCatalogue.getSysId();
if (localCatalogueSysId != null
&& !localCatalogueSysId.isEmpty()) {
//Update sys_id with empty string because required to delete locally
localCatalogue.setSysId("");
delete(localCatalogue);
}
}
}
}
}
public static List<Catalogue> getAllCatalogues() {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_CATALOGUE
+ " where " + CATALOGUE_SYNC_DIRTY
+ "!=" + DBConstants.SYNC_FLAG_DELETE, null);
ArrayList<Catalogue> catalogueList;
if (c.getCount() > 0) {
catalogueList = new ArrayList<>(c.getCount());
while (c.moveToNext()) {
Catalogue.CatalogueBuilder builder = Catalogue.CatalogueBuilder.aCatalogue();
fillAllCatalogueDetails(c, builder);
catalogueList.add(builder.build());
}
} else {
catalogueList = new ArrayList<>(0);
}
c.close();
return catalogueList;
} else {
return new ArrayList<>(0);
}
}
public static Catalogue get(long catalogueId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
Catalogue catalogue = null;
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_CATALOGUE + " where " + CATALOGUE_ID + "=" + catalogueId, null);
if (c.moveToFirst()) {
Catalogue.CatalogueBuilder builder = Catalogue.CatalogueBuilder.aCatalogue();
fillAllCatalogueDetails(c, builder);
catalogue = builder.build();
}
c.close();
}
return catalogue;
}
public static Catalogue getCatalogueFromSysId(String sysId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
Catalogue catalogue = null;
if(db!=null) {
Cursor c = db.rawQuery("select * from " + TABLE_CATALOGUE + " where " + CATALOGUE_SYS_ID + "='" + sysId + "'", null);
if (c.moveToFirst()) {
Catalogue.CatalogueBuilder builder = Catalogue.CatalogueBuilder.aCatalogue();
fillAllCatalogueDetails(c, builder);
catalogue = builder.build();
}
c.close();
}
return catalogue;
}
private static void fillAllCatalogueDetails(Cursor c, Catalogue.CatalogueBuilder builder) {
builder.setId(c.getLong(INDEX_CATALOGUE_ID));
builder.setTitle(c.getString(INDEX_CATALOGUE_TITLE));
builder.setDescription(c.getString(INDEX_CATALOGUE_DESCRIPTION));
builder.setSysId(c.getString(INDEX_CATALOGUE_SYS_ID));
builder.setSyncDirty(c.getInt(INDEX_CATALOGUE_SYNC_DIRTY));
}
private static ContentValues getContentValues(Catalogue catalogue) {
ContentValues cv = new ContentValues(CATALOGUE_COLUMN_COUNT - 1);
cv.put(CATALOGUE_TITLE, catalogue.getTitle());
cv.put(CATALOGUE_DESCRIPTION, catalogue.getDescription());
cv.put(CATALOGUE_SYS_ID, catalogue.getSysId());
cv.put(CATALOGUE_SYNC_DIRTY, catalogue.getSyncDirty());
return cv;
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.db.managers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.db.models.CatalogueVariable;
import com.vsoft.uofl_catalogue.enums.ViewType;
import com.vsoft.uofl_catalogue.utils.DBConstants;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Kunj on 11-08-2016.
*/
public class CatalogueVariableValueManager implements DBConstants {
public static long save(String tableName, List<String> columnNameList, List<String> valueList, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
ContentValues contentValues = new ContentValues(columnNameList.size());
contentValues.put(CATALOGUE_VARIABLE_SYNC_DIRTY, syncDirty);
for (int i = 0; i < columnNameList.size(); i++) {
String columnName = columnNameList.get(i);
String value = valueList.get(i);
if(columnName!=null && value!=null)
contentValues.put(columnName, value);
}
long id = db.insert(tableName, null, contentValues);
return id;
} else {
return -1;
}
}
public static int delete(CatalogueVariable catalogueVariable) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
if (catalogueVariable.getSysId() == null || catalogueVariable.getSysId().isEmpty()) {
return db.delete(TABLE_CATALOGUE_VARIABLES, CATALOGUE_VARIABLE_ID + "=" + catalogueVariable.getId(), null);
} else {
return update(catalogueVariable, SYNC_FLAG_DELETE);
}
}
return -1;
}
public static int update(CatalogueVariable catalogueVariable, int syncDirty) {
return update(catalogueVariable, null, syncDirty);
}
public static int update(CatalogueVariable catalogueVariable, List<String> column, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
catalogueVariable.setSyncDirty(syncDirty);
if (column == null || column.size() == 0) {
return db.update(TABLE_CATALOGUE_VARIABLES, getContentValues(catalogueVariable), CATALOGUE_VARIABLE_ID + "=" + catalogueVariable.getId(), null);
} else {
ContentValues contentValues = new ContentValues(column.size());
contentValues.put(CATALOGUE_VARIABLE_SYNC_DIRTY, catalogueVariable.getSyncDirty());
for (int i = 0; i < column.size(); i++) {
String columnName = column.get(i);
if (CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID.equals(columnName)) {
contentValues.put(CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID, catalogueVariable.getCatalogueItemId());
} else if (CATALOGUE_VARIABLE_NAME.equals(columnName)) {
contentValues.put(CATALOGUE_VARIABLE_NAME, catalogueVariable.getName());
} else if (CATALOGUE_VARIABLE_QUESTION_TEXT.equals(columnName)) {
contentValues.put(CATALOGUE_VARIABLE_QUESTION_TEXT, catalogueVariable.getQuestionText());
} else if (CATALOGUE_VARIABLE_TYPE.equals(columnName)) {
contentValues.put(CATALOGUE_VARIABLE_TYPE, ViewType.getId(catalogueVariable.getType()));
} else if (CATALOGUE_VARIABLE_SYS_ID.equals(columnName)) {
contentValues.put(CATALOGUE_VARIABLE_SYS_ID, catalogueVariable.getSysId());
} else if (CATALOGUE_VARIABLE_SYNC_DIRTY.equals(columnName)) {
contentValues.put(CATALOGUE_VARIABLE_SYNC_DIRTY, catalogueVariable.getSyncDirty());
}
}
return db.update(TABLE_CATALOGUE_VARIABLES, contentValues, CATALOGUE_VARIABLE_ID + "=" + catalogueVariable.getId(), null);
}
} else {
return -1;
}
}
public static List<CatalogueVariable> getAllVariable(long catalogueItemId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_CATALOGUE_VARIABLES
+ " where " + CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID + "=" + catalogueItemId
+ " and " + CATALOGUE_VARIABLE_SYNC_DIRTY + "!=" + DBConstants.SYNC_FLAG_DELETE, null);
ArrayList<CatalogueVariable> variableList;
if (c.getCount() > 0) {
variableList = new ArrayList<>(c.getCount());
while (c.moveToNext()) {
CatalogueVariable.CatalogueVariableBuilder builder = CatalogueVariable.CatalogueVariableBuilder.aCatalogueVariable();
fillAllVariableDetails(c, builder);
variableList.add(builder.build());
}
} else {
variableList = new ArrayList<>(0);
}
c.close();
return variableList;
} else {
return new ArrayList<>(0);
}
}
public static CatalogueVariable get(long catalogueId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
CatalogueVariable catalogueVariable = null;
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_CATALOGUE_VARIABLES + " where " + CATALOGUE_VARIABLE_ID + "=" + catalogueId, null);
if (c.moveToFirst()) {
CatalogueVariable.CatalogueVariableBuilder builder = CatalogueVariable.CatalogueVariableBuilder.aCatalogueVariable();
fillAllVariableDetails(c, builder);
catalogueVariable = builder.build();
}
c.close();
}
return catalogueVariable;
}
public static CatalogueVariable getVariableFromSysId(String sysId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
CatalogueVariable catalogueVariable = null;
if(db!=null) {
Cursor c = db.rawQuery("select * from " + TABLE_CATALOGUE_VARIABLES + " where " + CATALOGUE_VARIABLE_SYS_ID + "='" + sysId + "'", null);
if (c.moveToFirst()) {
CatalogueVariable.CatalogueVariableBuilder builder = CatalogueVariable.CatalogueVariableBuilder.aCatalogueVariable();
fillAllVariableDetails(c, builder);
catalogueVariable = builder.build();
}
c.close();
}
return catalogueVariable;
}
private static void fillAllVariableDetails(Cursor c, CatalogueVariable.CatalogueVariableBuilder builder) {
builder.setId(c.getLong(INDEX_CATALOGUE_VARIABLE_ID));
builder.setCatalogueItemId(c.getLong(INDEX_CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID));
builder.setName(c.getString(INDEX_CATALOGUE_VARIABLE_NAME));
builder.setQuestionText(c.getString(INDEX_CATALOGUE_VARIABLE_QUESTION_TEXT));
builder.setType(ViewType.from(c.getInt(INDEX_CATALOGUE_VARIABLE_TYPE)));
builder.setSysId(c.getString(INDEX_CATALOGUE_VARIABLE_SYS_ID));
builder.setSyncDirty(c.getInt(INDEX_CATALOGUE_VARIABLE_SYNC_DIRTY));
}
private static ContentValues getContentValues(CatalogueVariable catalogueVariable) {
ContentValues cv = new ContentValues(CATALOGUE_VARIABLE_COLUMN_COUNT - 1);
cv.put(CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID, catalogueVariable.getCatalogueItemId());
cv.put(CATALOGUE_VARIABLE_NAME, catalogueVariable.getName());
cv.put(CATALOGUE_VARIABLE_QUESTION_TEXT, catalogueVariable.getQuestionText());
cv.put(CATALOGUE_VARIABLE_TYPE, catalogueVariable.getType().getId());
cv.put(CATALOGUE_VARIABLE_SYS_ID, catalogueVariable.getSysId());
cv.put(CATALOGUE_VARIABLE_SYNC_DIRTY, catalogueVariable.getSyncDirty());
return cv;
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.db.managers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.vsoft.uofl_catalogue.CatalogueApplication;
import com.vsoft.uofl_catalogue.db.models.VariableChoice;
import com.vsoft.uofl_catalogue.utils.DBConstants;
import java.util.ArrayList;
import java.util.List;
/**
* @author Kunj on 11-08-2016.
*/
public class VariableChoiceManager implements DBConstants {
public static long save(VariableChoice variableChoice) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
long id = db.insert(TABLE_VARIABLE_CHOICES, null, getContentValues(variableChoice));
variableChoice.setId(id);
return id;
} else {
return -1;
}
}
public static int delete(VariableChoice variableChoice) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
return db.delete(TABLE_VARIABLE_CHOICES, VARIABLE_CHOICE_ID + "=" + variableChoice.getId(), null);
}
return -1;
}
public static void deleteAll(long variableId) {
List<VariableChoice> localVariableChoiceList = getAllVariableChoices(variableId);
if(!localVariableChoiceList.isEmpty()) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
for (int i = 0; i < localVariableChoiceList.size(); i++) {
delete(localVariableChoiceList.get(i));
}
}
}
}
public static void handleGetVariableChoice(long variableId, List<VariableChoice> serverVariableChoiceList) {
if(serverVariableChoiceList != null && !serverVariableChoiceList.isEmpty()) {
/*First delete all existing variable choice for particular variable then we will save*/
deleteAll(variableId);
for (int i = 0; i < serverVariableChoiceList.size(); i++) {
VariableChoice variableChoice = serverVariableChoiceList.get(i);
variableChoice.setVariableId(variableId);
save(variableChoice);
}
} else {
/*That means there is no VariableChoice in server response,
*then all local items should be deleted those are contain that variable id*/
/*localVariableChoiceList is contain all local Catalogues */
deleteAll(variableId);
}
}
public static List<VariableChoice> getAllVariableChoices(long variableId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_VARIABLE_CHOICES
+ " where " + VARIABLE_CHOICE_VARIABLE_ID + "=" + variableId
+ " ORDER BY " + VARIABLE_CHOICE_ORDER + " ASC", null);
ArrayList<VariableChoice> variableChoiceList;
if (c.getCount() > 0) {
variableChoiceList = new ArrayList<>(c.getCount());
while (c.moveToNext()) {
VariableChoice.VariableChoiceBuilder builder = VariableChoice.VariableChoiceBuilder.aVariableChoice();
fillAllVariableChoiceDetails(c, builder);
variableChoiceList.add(builder.build());
}
} else {
variableChoiceList = new ArrayList<>(0);
}
c.close();
return variableChoiceList;
} else {
return new ArrayList<>(0);
}
}
public static VariableChoice get(long variableChoiceId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
VariableChoice variableChoice = null;
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_VARIABLE_CHOICES + " where " + VARIABLE_CHOICE_ID + "=" + variableChoiceId, null);
if (c.moveToFirst()) {
VariableChoice.VariableChoiceBuilder builder = VariableChoice.VariableChoiceBuilder.aVariableChoice();
fillAllVariableChoiceDetails(c, builder);
variableChoice = builder.build();
}
c.close();
}
return variableChoice;
}
private static void fillAllVariableChoiceDetails(Cursor c, VariableChoice.VariableChoiceBuilder builder) {
builder.setId(c.getLong(INDEX_VARIABLE_CHOICE_ID));
builder.setVariableId((c.getLong(INDEX_VARIABLE_CHOICE_VARIABLE_ID)));
builder.setText(c.getString(INDEX_VARIABLE_CHOICE_TEXT));
builder.setValue(c.getString(INDEX_VARIABLE_CHOICE_VALUE));
builder.setOrder(c.getInt(INDEX_VARIABLE_CHOICE_ORDER));
builder.setMisc(c.getFloat(INDEX_VARIABLE_CHOICE_MISC));
}
private static ContentValues getContentValues(VariableChoice variableChoice) {
ContentValues cv = new ContentValues(VARIABLE_CHOICE_COLUMN_COUNT - 1);
cv.put(VARIABLE_CHOICE_VARIABLE_ID, variableChoice.getVariableId());
cv.put(VARIABLE_CHOICE_TEXT, variableChoice.getText());
cv.put(VARIABLE_CHOICE_VALUE, variableChoice.getValue());
cv.put(VARIABLE_CHOICE_ORDER, variableChoice.getOrder());
cv.put(VARIABLE_CHOICE_MISC, variableChoice.getMisc());
return cv;
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by Kunj on 11/8/16.
*/
public class Catalogue {
private long id = -1;
@SerializedName("title")
@Expose
private String title;
@SerializedName("description")
@Expose
private String description;
@SerializedName("sys_id")
@Expose
private String sysId;
private int syncDirty;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
/**
*
* @return
* The title
*/
public String getTitle() {
return title;
}
/**
*
* @param title
* The title
*/
public void setTitle(String title) {
this.title = title;
}
/**
*
* @return
* The description
*/
public String getDescription() {
return description;
}
/**
*
* @param description
* The description
*/
public void setDescription(String description) {
this.description = description;
}
/**
*
* @return
* The sysId
*/
public String getSysId() {
return sysId;
}
/**
*
* @param sysId
* The sys_id
*/
public void setSysId(String sysId) {
this.sysId = sysId;
}
public int getSyncDirty() {
return syncDirty;
}
public void setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
}
public static final class CatalogueBuilder {
private long id = -1;
private String title;
private String description;
private String sysId;
private int syncDirty;
private CatalogueBuilder() {
}
public static CatalogueBuilder aCatalogue() {
return new CatalogueBuilder();
}
public CatalogueBuilder setId(long id) {
this.id = id;
return this;
}
public CatalogueBuilder setTitle(String title) {
this.title = title;
return this;
}
public CatalogueBuilder setDescription(String description) {
this.description = description;
return this;
}
public CatalogueBuilder setSysId(String sysId) {
this.sysId = sysId;
return this;
}
public CatalogueBuilder setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
return this;
}
public CatalogueBuilder but() {
return aCatalogue().setId(id).setTitle(title).setDescription(description).setSysId(sysId).setSyncDirty(syncDirty);
}
public Catalogue build() {
Catalogue catalogue = new Catalogue();
catalogue.setId(id);
catalogue.setTitle(title);
catalogue.setDescription(description);
catalogue.setSysId(sysId);
catalogue.setSyncDirty(syncDirty);
return catalogue;
}
}
public static class Json {
public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "sc_catalog";
}
@Override
public String toString() {
return "Catalogue{" +
"id=" + id +
", title='" + title + '\'' +
", description='" + description + '\'' +
", sysId='" + sysId + '\'' +
", syncDirty=" + syncDirty +
'}';
}
}
package com.vsoft.uofl_catalogue.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by Kunj on 11/8/16.
*/
public class CatalogueItem {
private long id = -1;
private long catalogue_id = -1;
@SerializedName("short_description")
@Expose
private String shortDescription;
@SerializedName("description")
@Expose
private String description;
@SerializedName("name")
@Expose
private String name;
@SerializedName("sys_id")
@Expose
private String sysId;
private int syncDirty;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getCatalogueId() {
return catalogue_id;
}
public void setCatalogueId(long catalogueId) {
this.catalogue_id = catalogueId;
}
/**
*
* @return
* The shortDescription
*/
public String getShortDescription() {
return shortDescription;
}
/**
*
* @param shortDescription
* The short_description
*/
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
/**
*
* @return
* The description
*/
public String getDescription() {
return description;
}
/**
*
* @param description
* The description
*/
public void setDescription(String description) {
this.description = description;
}
/**
*
* @return
* The name
*/
public String getName() {
return name;
}
/**
*
* @param name
* The name
*/
public void setName(String name) {
this.name = name;
}
/**
*
* @return
* The sysId
*/
public String getSysId() {
return sysId;
}
/**
*
* @param sysId
* The sys_id
*/
public void setSysId(String sysId) {
this.sysId = sysId;
}
public int getSyncDirty() {
return syncDirty;
}
public void setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
}
public static final class CatalogueItemBuilder {
private long id = -1;
private long catalogue_id = -1;
private String shortDescription;
private String description;
private String name;
private String sysId;
private int syncDirty;
private CatalogueItemBuilder() {
}
public static CatalogueItemBuilder aCatalogueItem() {
return new CatalogueItemBuilder();
}
public CatalogueItemBuilder setId(long id) {
this.id = id;
return this;
}
public CatalogueItemBuilder setCatalogueId(long catalogueId) {
this.catalogue_id = catalogueId;
return this;
}
public CatalogueItemBuilder setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
return this;
}
public CatalogueItemBuilder setDescription(String description) {
this.description = description;
return this;
}
public CatalogueItemBuilder setName(String name) {
this.name = name;
return this;
}
public CatalogueItemBuilder setSysId(String sysId) {
this.sysId = sysId;
return this;
}
public CatalogueItemBuilder setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
return this;
}
public CatalogueItemBuilder but() {
return aCatalogueItem().setId(id).setCatalogueId(catalogue_id).setShortDescription(shortDescription).setDescription(description).setName(name).setSysId(sysId).setSyncDirty(syncDirty);
}
public CatalogueItem build() {
CatalogueItem catalogueItem = new CatalogueItem();
catalogueItem.setId(id);
catalogueItem.setCatalogueId(catalogue_id);
catalogueItem.setShortDescription(shortDescription);
catalogueItem.setDescription(description);
catalogueItem.setName(name);
catalogueItem.setSysId(sysId);
catalogueItem.setSyncDirty(syncDirty);
return catalogueItem;
}
}
public static class Json {
public static final String URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE = "category";
public static final String SYS_ID = "sys_id";
}
@Override
public String toString() {
return "CatalogueItem{" +
"id=" + id +
", catalogue_id=" + catalogue_id +
", shortDescription='" + shortDescription + '\'' +
", description='" + description + '\'' +
", name='" + name + '\'' +
", sysId='" + sysId + '\'' +
", syncDirty=" + syncDirty +
'}';
}
}
package com.vsoft.uofl_catalogue.db.models;
import android.content.Context;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.enums.ViewType;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
/**
* Created by Kunj on 12/8/16.
*/
public class CatalogueVariable {
private long id = -1;
private long catalogue_item_id = -1;
@SerializedName("name")
@Expose
private String name;
@SerializedName("question_text")
@Expose
private String questionText;
@SerializedName("sys_id")
@Expose
private String sysId;
@SerializedName("mandatory")
@Expose
private boolean mandatory;
@SerializedName("none_required")
@Expose
private boolean isNoneRequired;
@SerializedName("reference_table")
@Expose
private String referenceTable;
// @SerializedName("type")
// @Expose
private ViewType type;
private int syncDirty;
private List<VariableChoice> mVariableChoiceList;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getCatalogueItemId() {
return catalogue_item_id;
}
public void setCatalogueItemId(long catalogue_item_id) {
this.catalogue_item_id = catalogue_item_id;
}
/**
*
* @return
* The name
*/
public String getName() {
return name;
}
/**
*
* @param name
* The name
*/
public void setName(String name) {
this.name = name;
}
/**
*
* @return
* The questionText
*/
public String getQuestionText() {
return questionText;
}
/**
*
* @param questionText
* The question_text
*/
public void setQuestionText(String questionText) {
this.questionText = questionText;
}
/**
*
* @return
* The sysId
*/
public String getSysId() {
return sysId;
}
/**
*
* @param sysId
* The sys_id
*/
public void setSysId(String sysId) {
this.sysId = sysId;
}
/**
*
* @return
* The type
*/
public ViewType getType() {
return type;
}
/**
*
* @param type
* The type
*/
public void setType(ViewType type) {
this.type = type;
}
public boolean isMandatory() {
return mandatory;
}
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
public boolean isNoneRequired() {
return isNoneRequired;
}
public void setNoneRequired(boolean noneRequired) {
isNoneRequired = noneRequired;
}
public String getReferenceTable() {
return referenceTable;
}
public void setReferenceTable(String referenceTable) {
this.referenceTable = referenceTable;
}
public int getSyncDirty() {
return syncDirty;
}
public void setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
}
public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList;
}
public void setVariableChoiceList(List<VariableChoice> mVariableChoiceList) {
this.mVariableChoiceList = mVariableChoiceList;
}
public String[] getDisplayChoiceText(Context context, boolean isNoneRequired) {
String[] choiceText;
if(isNoneRequired) {
choiceText = new String[mVariableChoiceList.size() + 1];
choiceText[0] = context.getString(R.string.none_string);
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
/*(i+1) for add None text as a first Element*/
if(variableChoice.getMisc() > 0) {
choiceText[i + 1] = String.format(context.getString(R.string.variable_form_misc_info_string),
variableChoice.getText(),
variableChoice.getMisc());
} else {
choiceText[i + 1] = variableChoice.getText();
}
}
} else {
choiceText = new String[mVariableChoiceList.size()];
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
if(variableChoice.getMisc() > 0) {
choiceText[i] = String.format(context.getString(R.string.variable_form_misc_info_string),
variableChoice.getText(),
variableChoice.getMisc());
} else {
choiceText[i] = variableChoice.getText();
}
}
}
return choiceText;
}
public void parseJson(JSONObject jsonObject) {
String viewType = null;
try {
viewType = jsonObject.getString(Json.TYPE);
} catch (JSONException e) {
e.printStackTrace();
}
this.setType(ViewType.from(viewType));
}
public static final class CatalogueVariableBuilder {
private long id = -1;
private long catalogue_item_id = -1;
private String name;
private String questionText;
private String sysId;
private boolean mandatory;
private boolean isNoneRequired;
private String referenceTable;
private ViewType type;
private int syncDirty;
private CatalogueVariableBuilder() {
}
public static CatalogueVariableBuilder aCatalogueVariable() {
return new CatalogueVariableBuilder();
}
public CatalogueVariableBuilder setId(long id) {
this.id = id;
return this;
}
public CatalogueVariableBuilder setCatalogueItemId(long catalogue_item_id) {
this.catalogue_item_id = catalogue_item_id;
return this;
}
public CatalogueVariableBuilder setName(String name) {
this.name = name;
return this;
}
public CatalogueVariableBuilder setQuestionText(String questionText) {
this.questionText = questionText;
return this;
}
public CatalogueVariableBuilder setSysId(String sysId) {
this.sysId = sysId;
return this;
}
public CatalogueVariableBuilder setMandatory(boolean mandatory) {
this.mandatory = mandatory;
return this;
}
public CatalogueVariableBuilder setNoneRequired(boolean isNoneRequired) {
this.isNoneRequired = isNoneRequired;
return this;
}
public CatalogueVariableBuilder setReferenceTable(String referenceTable) {
this.referenceTable = referenceTable;
return this;
}
public CatalogueVariableBuilder setType(ViewType type) {
this.type = type;
return this;
}
public CatalogueVariableBuilder setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
return this;
}
public CatalogueVariableBuilder but() {
return aCatalogueVariable().setId(id).setCatalogueItemId(catalogue_item_id).setName(name).setQuestionText(questionText).setSysId(sysId).setMandatory(mandatory).setNoneRequired(isNoneRequired).setReferenceTable(referenceTable).setType(type).setSyncDirty(syncDirty);
}
public CatalogueVariable build() {
CatalogueVariable catalogueVariable = new CatalogueVariable();
catalogueVariable.setId(id);
catalogueVariable.setCatalogueItemId(catalogue_item_id);
catalogueVariable.setName(name);
catalogueVariable.setQuestionText(questionText);
catalogueVariable.setSysId(sysId);
catalogueVariable.setMandatory(mandatory);
catalogueVariable.setNoneRequired(isNoneRequired);
catalogueVariable.setReferenceTable(referenceTable);
catalogueVariable.setType(type);
catalogueVariable.setSyncDirty(syncDirty);
return catalogueVariable;
}
}
public static class Json {
public static final String SYS_ID = "sys_id";
public static final String TYPE = "type";
}
@Override
public String toString() {
return "CatalogueVariable{" +
"id=" + id +
", catalogue_item_id=" + catalogue_item_id +
", name='" + name + '\'' +
", questionText='" + questionText + '\'' +
", sysId='" + sysId + '\'' +
", mandatory=" + mandatory +
", isNoneRequired=" + isNoneRequired +
", referenceTable='" + referenceTable + '\'' +
", type=" + type +
", syncDirty=" + syncDirty +
", mVariableChoiceList=" + mVariableChoiceList +
'}';
}
}
package com.vsoft.uofl_catalogue.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by Kunj on 9/8/16.
*/
public class Reference {
@SerializedName("name")
@Expose
private String name;
@SerializedName("sys_id")
@Expose
private String sysId;
/**
*
* @return
* The name
*/
public String getName() {
return name;
}
/**
*
* @param name
* The name
*/
public void setName(String name) {
this.name = name;
}
/**
*
* @return
* The sysId
*/
public String getSysId() {
return sysId;
}
/**
*
* @param sysId
* The name
*/
public void setSysID(String sysId) {
this.sysId = sysId;
}
public static class Json {
public static final String FIRST_NAME = "first_name";
}
}
package com.vsoft.uofl_catalogue.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class VariableChoice {
private long id;
private long variable_id;
@SerializedName("text")
@Expose
private String text;
@SerializedName("value")
@Expose
private String value;
@SerializedName("order")
@Expose
private int order;
@SerializedName("misc")
@Expose
private float misc;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getVariableId() {
return variable_id;
}
public void setVariableId(long variable_id) {
this.variable_id = variable_id;
}
/**
*
* @return
* The text
*/
public String getText() {
return text;
}
/**
*
* @param text
* The text
*/
public void setText(String text) {
this.text = text;
}
/**
*
* @return
* The value
*/
public String getValue() {
return value;
}
/**
*
* @param value
* The value
*/
public void setValue(String value) {
this.value = value;
}
/**
*
* @return
* The order
*/
public int getOrder() {
return order;
}
/**
*
* @param order
* The order
*/
public void setOrder(int order) {
this.order = order;
}
public float getMisc() {
return misc;
}
public void setMisc(float misc) {
this.misc = misc;
}
public static class Json {
public static final String URL_PARAM_VARIABLE_CHOICE_SYSPRM_QUERY_VALUE = "question";
}
public static final class VariableChoiceBuilder {
private long id;
private long variable_id;
private String text;
private String value;
private int order;
private float misc;
private VariableChoiceBuilder() {
}
public static VariableChoiceBuilder aVariableChoice() {
return new VariableChoiceBuilder();
}
public VariableChoiceBuilder setId(long id) {
this.id = id;
return this;
}
public VariableChoiceBuilder setVariableId(long variable_id) {
this.variable_id = variable_id;
return this;
}
public VariableChoiceBuilder setText(String text) {
this.text = text;
return this;
}
public VariableChoiceBuilder setValue(String value) {
this.value = value;
return this;
}
public VariableChoiceBuilder setOrder(int order) {
this.order = order;
return this;
}
public VariableChoiceBuilder setMisc(float misc) {
this.misc = misc;
return this;
}
public VariableChoiceBuilder but() {
return aVariableChoice().setId(id).setVariableId(variable_id).setText(text).setValue(value).setOrder(order).setMisc(misc);
}
public VariableChoice build() {
VariableChoice variableChoice = new VariableChoice();
variableChoice.setId(id);
variableChoice.setVariableId(variable_id);
variableChoice.setText(text);
variableChoice.setValue(value);
variableChoice.setOrder(order);
variableChoice.setMisc(misc);
return variableChoice;
}
}
@Override
public String toString() {
return "VariableChoice{" +
"id=" + id +
", variable_id=" + variable_id +
", text='" + text + '\'' +
", value='" + value + '\'' +
", order=" + order +
", misc=" + misc +
'}';
}
}
package com.vsoft.uofl_catalogue.dialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.api.listeners.get.GetReferenceApiListener;
import com.vsoft.uofl_catalogue.api.managers.VariableChoiceApiManager;
import com.vsoft.uofl_catalogue.db.models.Reference;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.listeners.ReferenceListener;
import com.vsoft.uofl_catalogue.utils.Constants;
import com.vsoft.uofl_catalogue.utils.Util;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnEditorAction;
import butterknife.OnItemClick;
import butterknife.OnTouch;
import butterknife.Unbinder;
/**
* Created by Kunj on 25/2/16.
*/
public class SelectReferenceDialog extends DialogFragment {
@BindView(R.id.dialog_list_view) ListView mListView;
@BindView(R.id.dialog_title) TextView mTitleTextView;
@BindView(R.id.dialog_edit_text) EditText mEditText;
private ArrayAdapter<String> mAdapter;
private ReferenceListener mListener;
private Unbinder mUnbinder;
private List<Reference> mReferenceList;
private String mReferenceTableName;
public SelectReferenceDialog() {
}
public void setListener(ReferenceListener listener) {
mListener = listener;
}
public static SelectReferenceDialog newInstance(String tableName) {
SelectReferenceDialog selectReferenceDialog = new SelectReferenceDialog();
Bundle bundle = new Bundle();
bundle.putString(Constants.DATA_KEY_REFERENCE_TABLE_NAME, tableName);
selectReferenceDialog.setArguments(bundle);
return selectReferenceDialog;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE, R.style.CustomDialog);
mReferenceTableName = getArguments().getString(Constants.DATA_KEY_REFERENCE_TABLE_NAME);
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null) {
int width = 4 * (getResources().getDisplayMetrics().widthPixels/5);
int height = 3 * (getResources().getDisplayMetrics().heightPixels/4);
dialog.getWindow().setLayout(width, height);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.custom_dialog, container, false);
mUnbinder = ButterKnife.bind(this, rootView);
return rootView;
}
@OnTouch(R.id.dialog_edit_text)
boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_RIGHT = 2;
Drawable drawable = mEditText.getCompoundDrawables()[DRAWABLE_RIGHT];
Rect bounds = drawable.getBounds();
if(event.getAction() == MotionEvent.ACTION_UP) {
if(event.getRawX() >= (mEditText.getRight() + mEditText.getLeft() - (bounds.width() / getResources().getDisplayMetrics().density))) {
mEditText.setText("");
return true;
} else {
return mEditText.onTouchEvent(event);
}
}
return true;
}
@OnClick(R.id.dialog_cancel_layout)
void cancelLayout() {
getDialog().dismiss();
}
@OnItemClick(R.id.dialog_list_view)
void listViewItemClick(int position) {
Reference reference = mReferenceList.get(position);
if(reference != null)
mListener.positiveButtonClick(reference);
else
mListener.negativeButtonClick();
getDialog().dismiss();
}
@OnEditorAction(R.id.dialog_edit_text) boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId == EditorInfo.IME_ACTION_SEARCH) {
Util.hideSoftKeyboard(getActivity(), v);
if(!mEditText.getText().toString().isEmpty()) {
new FetchReference().execute(mEditText.getText().toString());
}
return false;
}
return true;
}
class FetchReference extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
return VariableChoiceApiManager.getReference(mReferenceTableName, params[0], new GetReferenceApiListener() {
@Override
public void onDoneApiCall(List<Reference> referenceList) {
mReferenceList = referenceList;
}
});
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if(progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
mAdapter = new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
getReferenceForDisplay());
mListView.setAdapter(mAdapter);
}
}
private List<String> getReferenceForDisplay() {
List<String> stringList = new ArrayList<>(mReferenceList.size());
for (int i = 0; i < mReferenceList.size(); i++) {
stringList.add(mReferenceList.get(i).getName());
}
return stringList;
}
@Override
public void onDestroyView() {
super.onDestroyView();
mUnbinder.unbind();
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.enums;
/**
* @since 1.0
* @author Kunj on 11/8/16.
*
*/
public enum SyncStatus {
SUCCESS (1),
FAIL (2);
int id;
SyncStatus(int id) {
this.id = id;
}
public static int getSyncStatus(SyncStatus status) {
return status.id;
}
public int getId() {
return this.id;
}
}
package com.vsoft.uofl_catalogue.enums;
public enum ViewType {
UNKNOWN (-1, "unknown"),
YES_NO (0, "Yes / No"),
MULTI_LINE_TEXT (1, "Multi Line Text"),
MULTIPLE_CHOICE (2, "Multiple Choice"),
NUMERIC_SCALE (3, "Numeric Scale"),
SELECT_BOX (4, "Select Box"),
SINGLE_LINE_TEXT (5, "Single Line Text"),
CHECK_BOX(6, "CheckBox"),
REFERENCE(7, "Reference"),
DATE(8, "Date"),
DATE_AND_TIME(9, "Date/Time"),
LABEL (10, "Label"),
BREAK (11, "Break"),
MACRO (12, "Macro"),
UI_PAGE (13, "UI Page"),
WIDE_SINGLE_LINE_TEXT (14, "Wide Single Line Text"),
MACRO_WITH_LABEL (15, "Macro with Label"),
LOOKUP_SELECT_BOX (16, "Lookup Select Box"),
CONTAINER_START (17, "Container Start"),
CONTAINER_END(18, "Container End"),
LIST_COLLECTOR (19, "List Collector"),
LOOKUP_MULTIPLE_CHOICE (20, "Lookup Multiple Choice"),
HTML (21, "HTML"),
CONTAINER_SPLIT (22, "Container Split"),
MASKED (23, "Masked");
private int id;
private String displayString;
/* construct */
ViewType(int id, String displayString) {
this.id = id;
this.displayString = displayString;
}
/* getters */
public static int getId(ViewType expenseType) {
return expenseType.id;
}
public int getId() {
return this.id;
}
public static String getDisplayString(ViewType expenseType) {
return expenseType.displayString;
}
public String getDisplayString() {
return this.displayString;
}
public static ViewType from(int id) {
for(int i = 0; i< ViewType.values().length; i++) {
ViewType expenseType = ViewType.values()[i];
if(expenseType.id == id)
return ViewType.values()[i];
}
return UNKNOWN;
}
public static ViewType from(String string) {
for(int i = 0; i< ViewType.values().length; i++) {
ViewType expenseType = ViewType.values()[i];
if(expenseType.displayString.equals(string))
return ViewType.values()[i];
}
return UNKNOWN;
}
}
package com.vsoft.uofl_catalogue.listeners;
import com.vsoft.uofl_catalogue.db.models.Reference;
/**
* Created by Kunj on 10/8/16.
*/
public interface ReferenceListener {
void positiveButtonClick(Reference reference);
void negativeButtonClick();
}
package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.CatalogueCategoryItemAdapter;
import com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueItemApiListener;
import com.vsoft.uofl_catalogue.api.managers.CatalogueItemApiManager;
import com.vsoft.uofl_catalogue.db.managers.CatalogueItemManager;
import com.vsoft.uofl_catalogue.db.managers.CatalogueManager;
import com.vsoft.uofl_catalogue.db.models.Catalogue;
import com.vsoft.uofl_catalogue.db.models.CatalogueItem;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import java.util.List;
/**
* Created by Kunj on 11/8/16.
*/
public class CatalogueItemScreen extends Activity {
private Catalogue mCatalogue;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
String catalogueSysId = null;
if (extras != null) {
catalogueSysId = extras.getString(Constants.DATA_KEY_SYS_ID);
//The key argument here must match that used in the other activity
}
mCatalogue = CatalogueManager.getCatalogueFromSysId(catalogueSysId);
if(mCatalogue == null) {
CatalogueLog.e("CatalogueItemScreen: onCreate: mCatalogue is null");
return;
}
List<CatalogueItem> catalogueItemList = CatalogueItemManager.getAllCatalogueItems(mCatalogue.getId());
if(catalogueItemList.isEmpty()) {
new FetchCatalogueItem().execute();
} else {
createView(catalogueItemList);
}
}
class FetchCatalogueItem extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(CatalogueItemScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
SyncStatus syncStatus = CatalogueItemApiManager.getCatalogueItems(mCatalogue.getSysId(), new GetCatalogueItemApiListener() {
@Override
public void onDoneApiCall(List<CatalogueItem> catalogueItemList) {
CatalogueLog.e("Data: catalogueItemList: "+catalogueItemList);
CatalogueItemManager.handleGetCatalogueItem(mCatalogue.getId(), catalogueItemList);
}
});
return syncStatus;
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if(progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
createView(CatalogueItemManager.getAllCatalogueItems(mCatalogue.getId()));
}
}
private void createView(final List<CatalogueItem> catalogueItemList) {
if(!catalogueItemList.isEmpty()) {
ListView listView = new ListView(CatalogueItemScreen.this);
CatalogueCategoryItemAdapter adapter = new CatalogueCategoryItemAdapter(CatalogueItemScreen.this);
adapter.setCatalogueList(catalogueItemList);
listView.setAdapter(adapter);
setContentView(listView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
CatalogueLog.e("OnItemClickListener: position: " + position + ", Catalogue: " + catalogueItemList.get(position));
Intent intent = new Intent(CatalogueItemScreen.this, CatalogueVariableScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, catalogueItemList.get(position).getSysId());
startActivity(intent);
}
});
} else {
/*There is no catalogue items*/
TextView textView = new TextView(CatalogueItemScreen.this);
textView.setGravity(Gravity.CENTER);
textView.setText(R.string.no_catalogue_item_string);
setContentView(textView);
}
}
}
package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.CatalogueCategoryAdapter;
import com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueApiListener;
import com.vsoft.uofl_catalogue.api.managers.CatalogueApiManager;
import com.vsoft.uofl_catalogue.db.managers.CatalogueManager;
import com.vsoft.uofl_catalogue.db.models.Catalogue;
import com.vsoft.uofl_catalogue.enums.SyncStatus;
import com.vsoft.uofl_catalogue.utils.CatalogueLog;
import com.vsoft.uofl_catalogue.utils.Constants;
import java.util.List;
/**
* Created by Kunj on 11/8/16.
*/
public class CatalogueScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
List<Catalogue> catalogueList = CatalogueManager.getAllCatalogues();
if(catalogueList.isEmpty()) {
new FetchCatalogue().execute();
} else {
createView(catalogueList);
}
}
class FetchCatalogue extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(CatalogueScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected SyncStatus doInBackground(String... params) {
SyncStatus syncStatus = CatalogueApiManager.getCatalogues(new GetCatalogueApiListener() {
@Override
public void onDoneApiCall(List<Catalogue> catalogueList) {
CatalogueLog.e("Data: catalogueList: "+catalogueList);
CatalogueManager.handleGetCatalogue(catalogueList);
}
});
return syncStatus;
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if(progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
createView(CatalogueManager.getAllCatalogues());
}
}
private void createView(final List<Catalogue> catalogueList) {
ListView listView = new ListView(CatalogueScreen.this);
CatalogueCategoryAdapter adapter = new CatalogueCategoryAdapter(CatalogueScreen.this);
adapter.setCatalogueList(catalogueList);
listView.setAdapter(adapter);
setContentView(listView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
CatalogueLog.e("OnItemClickListener: position: "+position + ", Catalogue: "+catalogueList.get(position));
Intent intent = new Intent(CatalogueScreen.this, CatalogueItemScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, catalogueList.get(position).getSysId());
startActivity(intent);
}
});
}
}
package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.GridView;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.adapters.HomeScreenAdapter;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;
/**
* Created by Kunj on 11/8/16.
*/
public class HomeScreen extends Activity {
@BindView(R.id.home_screen_grid_view) GridView mGridView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.home_screen);
ButterKnife.bind(this);
mGridView.setAdapter(new HomeScreenAdapter(this, getResources().getStringArray(R.array.home_screen_array)));
}
@OnItemClick(R.id.home_screen_grid_view)
void gridViewItemClicked(int position) {
if(position == 1) {
startActivity(new Intent(HomeScreen.this, CatalogueScreen.class));
}
}
}
package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.vsoft.uofl_catalogue.R;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by Kunj on 11/8/16.
*/
public class LoginScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login_screen);
ButterKnife.bind(this);
}
@OnClick(R.id.login_screen_login_text_view)
void onLoginClicked() {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
}
}
package com.vsoft.uofl_catalogue.ui.supportviews;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
import com.vsoft.uofl_catalogue.R;
import com.vsoft.uofl_catalogue.utils.Constants;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
public class DateAndTimePickerFragment extends DialogFragment {
private DatePickerDialog.OnDateSetListener mOnDateSetListener;
private TimePickerDialog.OnTimeSetListener mOnTimeSetListener;
@BindView(R.id.date_picker) DatePicker mDatePicker;
@BindView(R.id.time_picker) TimePicker mTimePicker;
@BindView(R.id.date_and_time_title_text_view) TextView mTitle;
private Unbinder unbinder;
public DateAndTimePickerFragment(){
}
public void setDateListener(DatePickerDialog.OnDateSetListener listener) {
mOnDateSetListener = listener;
}
public void setmTimeListener(TimePickerDialog.OnTimeSetListener listener) {
mOnTimeSetListener = listener;
}
public static DateAndTimePickerFragment newInstance(String title) {
DateAndTimePickerFragment fragment = new DateAndTimePickerFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.DATA_DATE_AND_TIME_PICKER_TITLE, title);
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE, R.style.DatePickerCustomDialog);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.custom_dialog_date_picker, container, false);
unbinder = ButterKnife.bind(this, rootView);
String title = getArguments().getString(Constants.DATA_DATE_AND_TIME_PICKER_TITLE);
if(title.equals(getString(R.string.select_date_string))) {
mTimePicker.setVisibility(View.GONE);
} else if(title.equals(getString(R.string.select_date_and_time_string))) {
mTimePicker.setVisibility(View.VISIBLE);
}
mTitle.setText(title);
getDialog().setCanceledOnTouchOutside(true);
return rootView;
}
@OnClick(R.id.date_picker_cancel_text_view)
void cancelLayoutClick() {
getDialog().dismiss();
}
@OnClick(R.id.date_picker_set_text_view)
void setLayoutClick() {
mOnDateSetListener.onDateSet(mDatePicker, mDatePicker.getYear(), mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
if(mOnTimeSetListener!=null) {
int currentApiVersion = android.os.Build.VERSION.SDK_INT;
if (currentApiVersion > android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
mOnTimeSetListener.onTimeSet(mTimePicker, mTimePicker.getHour(), mTimePicker.getMinute());
} else {
mOnTimeSetListener.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
}
}
getDialog().dismiss();
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.utils;
/**
* @since 1.0
* @author prathap bezawada
*
* Boolean Flag to set Build Target and DDMS Log enable/disable
*/
public final class CatalogueBuildConfig {
public final static boolean DEBUG = true;
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.utils;
import android.util.Log;
/**
* @since 1.0
* @author prathap bezawada
*
*/
public class CatalogueLog {
public static void d(String msg) {
if (CatalogueBuildConfig.DEBUG) {
Log.d(Constants.TAG, msg);
}
}
public static void e(String msg) {
if(CatalogueBuildConfig.DEBUG) {
Log.e(Constants.TAG, msg);
}
}
public static void e(String msg, Exception e) {
if(CatalogueBuildConfig.DEBUG) {
Log.e(Constants.TAG, msg, e);
}
}
}
package com.vsoft.uofl_catalogue.utils;
import com.vsoft.uofl_catalogue.BuildConfig;
/**
* @author Kunj on 11/8/16.
* @since 1.0
*/
public class Constants {
public static final String TAG = "UofLCatalogue";
public static final String[] month = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
/**
* Preference
*/
public static final String PREFS_OLD_VERSION_NUMBER = "oldVersionNumber";
public static final String PREFS_NEW_VERSION_NUMBER = "newVersionNumber";
/**
* Intent String
*/
public static final String DATA_DATE_AND_TIME_PICKER_TITLE = "title";
public static final String DATA_KEY_SYS_ID = "sys_id";
public static final String DATA_KEY_REFERENCE_TABLE_NAME = "table_name";
/**
* Catalogue services post parameters
*/
public static final String URL_PARAM_SYSPRM_QUERY = "sysparm_query";
public static final String URL_PARAM_SYSPRM_FIELDS = "sysparm_fields";
/**
* Debug logs
*/
public static final boolean DEBUG = true;
/**
* Decides the URLS used
*/
private static final String DOMAIN_PRODUCTION = "https://ven01199.service-now.com/";
private static final String DOMAIN_TEST = "https://uofltest.service-now.com/";
private static final String API_PATH_PRODUCTION = "/api/now/table/";
private static final String API_PATH_TEST = "/api/now/table/";
public static final int BUILD_TYPE_DEBUG = 1;
public static final int BUILD_TYPE_RELEASE = 2;
private static final String API_PATH = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? API_PATH_PRODUCTION
: API_PATH_TEST);
private static final String DOMAIN_FROM_BUILD = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? DOMAIN_PRODUCTION
: DOMAIN_TEST);
/**
* Decides the Client data used
*/
private static final String LOGIN_CLIENT_ID_PRODUCTION = "a40b3f05ae582600433c09623de6cbe4";
private static final String LOGIN_CLIENT_SECRET_PRODUCTION = "t8SdV}crm&";
private static final String LOGIN_CLIENT_ID_TEST = "8689966b6f8426001fbf10d078fc4cc5";
private static final String LOGIN_CLIENT_SECRET_TEST = "tGm41IOL6i";
public static final String LOGIN_CLIENT_ID = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? LOGIN_CLIENT_ID_PRODUCTION
: LOGIN_CLIENT_ID_TEST);
public static final String LOGIN_CLIENT_SECRET = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? LOGIN_CLIENT_SECRET_PRODUCTION
: LOGIN_CLIENT_SECRET_TEST);
/**
* Decides the Api auth data used
*/
private static final String API_AUTH_PARAM_USER_NAME_PRODUCTION = "vsoft.admin";
private static final String API_AUTH_PARAM_PASSWORD_PRODUCTION = "v50ft@123456";
private static final String API_AUTH_PARAM_USER_NAME_TEST = "a0kuma18";
private static final String API_AUTH_PARAM_PASSWORD_TEST = "v$0ftA$win";
public static final String API_AUTH_PARAM_USER_NAME = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? API_AUTH_PARAM_USER_NAME_PRODUCTION
: API_AUTH_PARAM_USER_NAME_TEST);
public static final String API_AUTH_PARAM_PASSWORD = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? API_AUTH_PARAM_PASSWORD_PRODUCTION
: API_AUTH_PARAM_PASSWORD_TEST);
/**
* Domain to use
*/
public static final String DOMAIN = DOMAIN_FROM_BUILD;
/**
* 17d0392d4f00e2005e1a3d728110c739
* Catalogue web services Header parameters
*/
public static final String API_HEADER_PARAM_AUTHORIZATION = "Authorization";
/**
* Catalogue web service post response object name
**/
public static final String RESPONSE_RESULT_OBJECT_NAME = "result";
public static final String RESPONSE_ERROR_OBJECT_NAME = "error";
/**
* Catalogue web services urls
*/
public static final String URL_GET_CATALOGUE = API_PATH + "sc_category";
public static final String URL_GET_CATALOGUE_ITEM = API_PATH + "sc_cat_item";
public static final String URL_GET_VARIABLE = "/api/uno33/uofl_mobile/variables";
public static final String URL_GET_VARIABLE_CHOICE = API_PATH + "question_choice";
public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile";
public static final String URL_GET_REFERENCE = API_PATH;
}
package com.vsoft.uofl_catalogue.utils;
public interface DBConstants {
//Tables
String TABLE_CATALOGUE = "catalogue_category";
String TABLE_CATALOGUE_ITEM = "catalogue_category_item";
String TABLE_CATALOGUE_VARIABLES = "catalogue_variable";
String TABLE_VARIABLE_CHOICES = "variable_choices";
String ID = "_id";
String SYS_ID = "sys_id";
String SYNC_DIRTY = "sync_dirty";
int SYNC_FLAG_NONE = 0;
int SYNC_FLAG_CREATE = 1;
int SYNC_FLAG_UPDATE = 2;
int SYNC_FLAG_DELETE = 3;
/**
* Catalogue table
*/
String CATALOGUE_ID = ID;
String CATALOGUE_TITLE = "title";
String CATALOGUE_DESCRIPTION = "description";
String CATALOGUE_SYS_ID = SYS_ID;
String CATALOGUE_SYNC_DIRTY = SYNC_DIRTY;
/*
* Indices for Catalogue table. *Use these only if you fetch all columns*
*/
int INDEX_CATALOGUE_ID = 0;
int INDEX_CATALOGUE_TITLE = 1;
int INDEX_CATALOGUE_DESCRIPTION = 2;
int INDEX_CATALOGUE_SYS_ID = 3;
int INDEX_CATALOGUE_SYNC_DIRTY = 4;
int CATALOGUE_COLUMN_COUNT = 5;
/**
* Catalogue_item table
*/
String CATALOGUE_ITEM_ID = ID;
String CATALOGUE_ITEM_CATALOGUE_ID = "catalogue_id";
String CATALOGUE_ITEM_NAME = "name";
String CATALOGUE_ITEM_SHORT_DESCRIPTION = "short_description";
String CATALOGUE_ITEM_DESCRIPTION = "item_description";
String CATALOGUE_ITEM_SYS_ID = SYS_ID;
String CATALOGUE_ITEM_SYNC_DIRTY = SYNC_DIRTY;
/**
* Indices for Catalogue_item table. *Use these only if you fetch all columns*
*/
int INDEX_CATALOGUE_ITEM_ID = 0;
int INDEX_CATALOGUE_ITEM_CATALOGUE_ID = 1;
int INDEX_CATALOGUE_ITEM_NAME = 2;
int INDEX_CATALOGUE_ITEM_SHORT_DESCRIPTION = 3;
int INDEX_CATALOGUE_ITEM_DESCRIPTION = 4;
int INDEX_CATALOGUE_ITEM_SYS_ID = 5;
int INDEX_CATALOGUE_ITEM_SYNC_DIRTY = 6;
int CATALOGUE_ITEM_COLUMN_COUNT = 7;
/**
* Catalogue variables table
*/
String CATALOGUE_VARIABLE_ID = ID;
String CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID = "catalogue_item_id";
String CATALOGUE_VARIABLE_NAME = "name";
String CATALOGUE_VARIABLE_QUESTION_TEXT = "question_text";
String CATALOGUE_VARIABLE_TYPE = "type";
String CATALOGUE_VARIABLE_MANDATORY = "mandatory";
String CATALOGUE_VARIABLE_NONE_REQUIRED = "isNoneRequired";
String CATALOGUE_VARIABLE_REFERENCE_TABLE = "reference_table";
String CATALOGUE_VARIABLE_SYS_ID = SYS_ID;
String CATALOGUE_VARIABLE_SYNC_DIRTY = SYNC_DIRTY;
/**
* Indices for Catalogue variables table. *Use these only if you fetch all columns*
*/
int INDEX_CATALOGUE_VARIABLE_ID = 0;
int INDEX_CATALOGUE_VARIABLE_CATALOGUE_ITEM_ID = 1;
int INDEX_CATALOGUE_VARIABLE_NAME = 2;
int INDEX_CATALOGUE_VARIABLE_QUESTION_TEXT = 3;
int INDEX_CATALOGUE_VARIABLE_TYPE = 4;
int INDEX_CATALOGUE_VARIABLE_MANDATORY = 5;
int INDEX_CATALOGUE_VARIABLE_NONE_REQUIRED = 6;
int INDEX_CATALOGUE_VARIABLE_REFERENCE = 7;
int INDEX_CATALOGUE_VARIABLE_SYS_ID = 8;
int INDEX_CATALOGUE_VARIABLE_SYNC_DIRTY = 9;
int CATALOGUE_VARIABLE_COLUMN_COUNT = 10;
/**
* Variables Choice table
*/
String VARIABLE_CHOICE_ID = ID;
String VARIABLE_CHOICE_VARIABLE_ID = "variable_id";
String VARIABLE_CHOICE_TEXT = "text";
String VARIABLE_CHOICE_VALUE = "value";
String VARIABLE_CHOICE_ORDER = "choice_order";
String VARIABLE_CHOICE_MISC = "misc";
/**
* Indices for Variables Choice table. *Use these only if you fetch all columns*
*/
int INDEX_VARIABLE_CHOICE_ID = 0;
int INDEX_VARIABLE_CHOICE_VARIABLE_ID = 1;
int INDEX_VARIABLE_CHOICE_TEXT = 2;
int INDEX_VARIABLE_CHOICE_VALUE = 3;
int INDEX_VARIABLE_CHOICE_ORDER = 4;
int INDEX_VARIABLE_CHOICE_MISC = 5;
int VARIABLE_CHOICE_COLUMN_COUNT = 6;
}
\ No newline at end of file
package com.vsoft.uofl_catalogue.utils;
/**
* Created by Kunj on 18/8/16.
*/
public class TagObject {
private int index;
private Object tagObject;
public TagObject(int index, Object tagObject) {
this.index = index;
this.tagObject = tagObject;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public Object getTagObject() {
return tagObject;
}
public void setTagObject(Object tagObject) {
this.tagObject = tagObject;
}
@Override
public boolean equals(Object o) {
return (o instanceof TagObject && this.index==((TagObject) o).index);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:layout_gravity="center"
android:src="@android:drawable/ic_dialog_dialer"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7.5"
android:orientation="vertical"
android:padding="@dimen/small_margin">
<TextView
android:id="@+id/catalogue_category_adapter_title_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textSize="@dimen/normal_text_size"
android:lines="1" />
<TextView
android:id="@+id/catalogue_category_adapter_des_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="2"
android:textSize="@dimen/small_text_size"
android:paddingTop="@dimen/small_margin" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/catalogue_item_content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2.5"
android:src="@android:drawable/ic_dialog_dialer" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7.5"
android:orientation="vertical"
android:padding="@dimen/small_margin">
<TextView
android:id="@+id/catalogue_category_item_adapter_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textSize="@dimen/normal_text_size" />
<TextView
android:id="@+id/catalogue_category_item_adapter_des_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="2"
android:paddingTop="@dimen/small_margin"
android:textSize="@dimen/small_text_size" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/WhiteBackgroundStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="10">
<TextView
android:id="@+id/dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="@string/search_for_reference_string"
android:textSize="@dimen/large_text_size"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/black" />
<EditText
android:id="@+id/dialog_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_margin"
android:layout_marginRight="@dimen/large_margin"
android:layout_weight="0"
android:drawableEnd="@android:drawable/ic_menu_close_clear_cancel"
android:drawableRight="@android:drawable/ic_menu_close_clear_cancel"
android:hint="@string/search_for_reference_string"
android:imeOptions="actionSearch"
android:singleLine="true"
android:textColor="@android:color/black"/>
<ListView
android:id="@+id/dialog_list_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:divider="@android:color/black"
android:dividerHeight="0.5dp"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/black" />
<TextView
android:id="@+id/dialog_cancel_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="@android:string/cancel"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/date_and_time_title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:textColor="@android:color/black"
android:textSize="@dimen/large_text_size" />
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/black" />
<DatePicker
android:id="@+id/date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<TimePicker
android:id="@+id/time_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin">
<TextView
android:id="@+id/date_picker_cancel_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginStart="@dimen/small_margin"
android:layout_weight="1"
android:gravity="center"
android:text="@android:string/cancel"
android:textColor="@android:color/black"
android:textSize="@dimen/normal_text_size" />
<View
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:background="@android:color/black" />
<TextView
android:id="@+id/date_picker_set_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginStart="@dimen/small_margin"
android:layout_weight="1"
android:gravity="center"
android:text="@string/set_string"
android:textColor="@android:color/black"
android:textSize="@dimen/normal_text_size" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/home_screen_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="@dimen/large_margin"
android:horizontalSpacing="@dimen/large_margin"
android:stretchMode="columnWidth"
android:padding="@dimen/large_margin"
android:background="@color/home_screen_bg_color"
android:numColumns="2"/>
</merge>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_screen_adapter_text_view"
android:layout_width="match_parent"
android:layout_height="@dimen/home_screen_item_height"
android:gravity="center"
android:padding="@dimen/normal_margin"
android:background="@android:color/black"
android:textColor="@android:color/white"
android:textSize="@dimen/large_text_size"/>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/large_margin"
android:layout_marginRight="@dimen/large_margin">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/login_screen_logo"/>
<EditText
android:id="@+id/login_screen_username_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:layout_marginTop="@dimen/normal_margin"
android:hint="@string/login_screen_user_name_string"/>
<EditText
android:id="@+id/login_screen_password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:lines="1"
android:singleLine="true"
android:layout_marginTop="@dimen/normal_margin"
android:hint="@string/login_screen_password_string"/>
<TextView
android:id="@+id/login_screen_login_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="@dimen/normal_margin"
android:background="@color/login_screen_login_button_bg_color"
android:textColor="@android:color/white"
android:textSize="@dimen/extra_normal_text_size"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingLeft="@dimen/extra_large_margin"
android:paddingRight="@dimen/extra_large_margin"
android:text="@string/login_screen_login_string"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="home_screen_array">
<item>Report Incident</item>
<item>Order Services</item>
<item>My Incidents</item>
<item>My Requests</item>
<item>My Dashboard</item>
</string-array>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#F44336</color>
<color name="colorPrimaryDark">#D32F2F</color>
<color name="colorAccent">#FF5252</color>
<color name="error_color">#FF0000</color>
<color name="dark_gray_color">#A9A9A9</color>
<color name="name_null_view_color">#88FFA500</color>
<color name="view_not_implemented_color">#88ff0000</color>
<color name="login_screen_login_button_bg_color">@color/colorPrimary</color>
<color name="home_screen_bg_color">@color/colorPrimary</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--Margins-->
<dimen name="small_margin">5dp</dimen>
<dimen name="normal_margin">10dp</dimen>
<dimen name="large_margin">15dp</dimen>
<dimen name="extra_large_margin">20dp</dimen>
<!--Text size-->
<dimen name="small_text_size">12sp</dimen>
<dimen name="normal_text_size">16sp</dimen>
<dimen name="extra_normal_text_size">18sp</dimen>
<dimen name="large_text_size">20sp</dimen>
<dimen name="separator_value">1dp</dimen>
<!--Home Screen-->
<dimen name="home_screen_item_height">120dp</dimen>
<!--Spinner Item height-->
<dimen name="spinner_item_height">40dp</dimen>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="create_form_save_text_view" type="id"/>
<item name="create_form_cancel_text_view" type="id"/>
</resources>
\ No newline at end of file
<resources>
<string name="app_name">UofL Catalogue</string>
<string name="set_string">Set</string>
<string name="save_string">Save</string>
<string name="error_string">* Required</string>
<string name="none_string">-None-</string>
<string name="search_for_reference_string">Reference</string>
<string name="loading_string">Loading&#8230;</string>
<string name="select_date_string">Select Date</string>
<string name="select_date_and_time_string">Select Date &#038; Time</string>
<string name="name_null_view_string">Not rendering (name not available)</string>
<string name="view_not_implemented_string">Not Implemented: %s</string>
<string name="no_variables_string">No Variables&#8230;</string>
<string name="date_string">%1$s %2$s, %3$s</string>
<string name="date_and_time_string"> %1$s:%2$s</string>
<!--Login Screen-->
<string name="login_screen_user_name_string">Username</string>
<string name="login_screen_password_string">Password</string>
<string name="login_screen_login_string">Login</string>
<string name="variable_form_misc_info_string">%1$s [add %2$s]</string>
<!--Catalogue Item Screen-->
<string name="no_catalogue_item_string">No Catalogue Items&#8230;</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="WhiteBackgroundStyle" parent="@style/Theme.AppCompat">
<item name="android:background">@android:color/white</item>
</style>
<style name="DatePickerCustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="editTextStyle">@android:style/Widget.EditText</item>
</style>
<style name="CustomDialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
\ No newline at end of file
No preview for this file type
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
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