Commit 04b8e06f by Kunj Gupta

Added Screens and local DB for HR case category and category items.

parent 06194faa
Showing with 2173 additions and 14 deletions
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>
<activity <activity
android:name="com.vsoft.servicenow.ui.CreateHRCaseScreen" android:name="com.vsoft.servicenow.ui.HRCaseScreen"
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>
<activity <activity
android:name="com.vsoft.servicenow.ui.ViewHRCaseScreen" android:name="com.vsoft.servicenow.ui.ViewHRCaseScreen"
......
package com.vsoft.servicenow.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.squareup.picasso.Picasso;
import com.vsoft.servicenow.R;
import com.vsoft.servicenow.db.models.HRCase;
import com.vsoft.servicenow.utils.Constants;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Kunj on 11/04/18.
*/
public class HRCaseCategoryAdapter extends BaseAdapter {
private final List<HRCase> mHRCaseList = new ArrayList<>(0);
private LayoutInflater mInflater;
private Context mContext;
public HRCaseCategoryAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setHRCaseList(List<HRCase> hrCaseList) {
mHRCaseList.clear();
if(hrCaseList!=null)
mHRCaseList.addAll(hrCaseList);
notifyDataSetChanged();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mHRCaseList.size();
}
@Override
public HRCase getItem(int position) {
// TODO Auto-generated method stub
return mHRCaseList.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.hr_case_category_adapter, parent, false);
holder = new ViewHolder();
holder.titleTextView = (TextView) convertView.findViewById(R.id.hr_case_category_adapter_title_tv);
holder.desTextView = (TextView) convertView.findViewById(R.id.hr_case_category_adapter_des_tv);
holder.image = (ImageView) convertView.findViewById(R.id.hr_case_category_adapter_image);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
HRCase hrCase = mHRCaseList.get(position);
holder.titleTextView.setText(hrCase.getTitle());
if(hrCase.getDescription() != null && !hrCase.getDescription().isEmpty()) {
holder.desTextView.setVisibility(View.VISIBLE);
holder.desTextView.setText(hrCase.getDescription());
} else {
holder.desTextView.setVisibility(View.GONE);
holder.desTextView.setText(hrCase.getDescription());
}
if(hrCase.getIcon() != null && !hrCase.getIcon().isEmpty()) {
holder.image.setVisibility(View.VISIBLE);
StringBuilder builder = new StringBuilder();
builder.append(Constants.DOMAIN);
builder.append(hrCase.getIcon());
Picasso.with(mContext).load(builder.toString()).into(holder.image);
} else {
holder.image.setVisibility(View.INVISIBLE);
}
return convertView;
}
static class ViewHolder {
private TextView titleTextView;
private TextView desTextView;
private ImageView image;
}
}
\ No newline at end of file
package com.vsoft.servicenow.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.squareup.picasso.Picasso;
import com.vsoft.servicenow.R;
import com.vsoft.servicenow.db.models.HRCaseItem;
import com.vsoft.servicenow.utils.Constants;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Kunj on 11/04/18.
*/
public class HRCaseCategoryItemAdapter extends BaseAdapter {
private final List<HRCaseItem> mHRCaseItemList = new ArrayList<>(0);
private LayoutInflater mInflater;
private Context mContext;
public HRCaseCategoryItemAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setHRCaseItemList(List<HRCaseItem> hrCaseItemList) {
mHRCaseItemList.clear();
if(hrCaseItemList!=null)
mHRCaseItemList.addAll(hrCaseItemList);
notifyDataSetChanged();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mHRCaseItemList.size();
}
@Override
public HRCaseItem getItem(int position) {
// TODO Auto-generated method stub
return mHRCaseItemList.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.hr_case_category_item_adapter, parent, false);
holder = new ViewHolder();
holder.nameTextView = (TextView) convertView.findViewById(R.id.hr_case_category_item_adapter_name_tv);
holder.desTextView = (TextView) convertView.findViewById(R.id.hr_case_category_item_adapter_des_tv);
holder.image = (ImageView) convertView.findViewById(R.id.hr_case_category_item_adapter_image);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
HRCaseItem hrCaseItem = mHRCaseItemList.get(position);
holder.nameTextView.setText(hrCaseItem.getName());
if(hrCaseItem.getShortDescription()!=null && !hrCaseItem.getShortDescription().isEmpty()) {
holder.desTextView.setVisibility(View.VISIBLE);
holder.desTextView.setText(hrCaseItem.getShortDescription());
} else {
holder.desTextView.setVisibility(View.GONE);
holder.desTextView.setText(hrCaseItem.getShortDescription());
}
if(hrCaseItem.getIcon() != null && !hrCaseItem.getIcon().isEmpty()) {
holder.image.setVisibility(View.VISIBLE);
StringBuilder builder = new StringBuilder();
builder.append(Constants.DOMAIN);
builder.append(hrCaseItem.getIcon());
Picasso.with(mContext).load(builder.toString()).into(holder.image);
} else {
holder.image.setVisibility(View.INVISIBLE);
}
return convertView;
}
static class ViewHolder {
private TextView nameTextView;
private TextView desTextView;
private ImageView image;
}
}
\ No newline at end of file
package com.vsoft.servicenow.api.interfaces;
import com.vsoft.servicenow.utils.Constants;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
/**
* @since 1.0
* @author Kunj on 11/04/18.
*
*/
public interface HRCaseCategoryApi {
// Get HRCase API
@GET(Constants.URL_GET_HR_CASE)
Call<ResponseBody> getHRCase(@Query(Constants.URL_PARAM_SYS_ID) String sysId);
}
package com.vsoft.servicenow.api.interfaces;
import com.vsoft.servicenow.utils.Constants;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
/**
* @since 1.0
* @author Kunj on 11/04/18.
*
*/
public interface HRCaseCategoryItemApi {
// Get HRCase Item API
@GET(Constants.URL_GET_HR_CASE_ITEM)
Call<ResponseBody> getHRCaseItem(@Query(Constants.URL_PARAM_SYS_ID) String sysId);
}
package com.vsoft.servicenow.api.listeners.get;
import com.vsoft.servicenow.db.models.HRCase;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/04/18.
*
*/
public interface GetHRCaseApiListener {
void onDoneApiCall(List<HRCase> hrCaseList);
void onFailApiCall();
}
package com.vsoft.servicenow.api.listeners.get;
import com.vsoft.servicenow.db.models.HRCaseItem;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/04/18.
*
*/
public interface GetHRCaseItemApiListener {
void onDoneApiCall(List<HRCaseItem> hrCaseItemList);
void onFailApiCall();
}
package com.vsoft.servicenow.api.managers;
import android.content.Context;
import android.util.Log;
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.servicenow.api.RestClient;
import com.vsoft.servicenow.api.interfaces.HRCaseCategoryApi;
import com.vsoft.servicenow.api.listeners.get.GetHRCaseApiListener;
import com.vsoft.servicenow.db.models.HRCase;
import com.vsoft.servicenow.enums.SyncStatus;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager;
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.Collections;
import java.util.Comparator;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* @author Kunj on 11/04/18.
*/
public class HRCaseApiManager {
public static void getHRCases(Context context, final GetHRCaseApiListener listener) {
CatalogueLog.d("HRCaseApiManager: getHRCases: ");
String accessToken = PrefManager.getSharedPref(context, PrefManager.PREFERENCE_ACCESS_TOKEN);
if (accessToken.isEmpty()) {
listener.onFailApiCall();
return;
}
final Retrofit retrofit = RestClient.getInitializedRestAdapter(accessToken);
Call<ResponseBody> call = retrofit.create(HRCaseCategoryApi.class).getHRCase("9a6a1d924f8286005e1a3d728110c75b");
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 hrCaseJsonArray = jsonObject.getJSONArray(Constants.RESPONSE_RESULT_OBJECT_NAME);
if (hrCaseJsonArray.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("HRCaseApiManager: getHRCases: 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("HRCaseApiManager: getHRCases: 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("HRCaseApiManager: getHRCases: deserialize: float.class: NumberFormatException: ", e);
}
return value;
}
})
.create();
final List<HRCase> hrCaseList = new ArrayList<>(hrCaseJsonArray.length());
for (int i = 0; i < hrCaseJsonArray.length(); i++) {
JSONObject hrCaseJsonObject = hrCaseJsonArray.getJSONObject(i);
HRCase hrCase = gson.fromJson(hrCaseJsonObject.toString(), HRCase.class);
hrCaseList.add(hrCase);
}
if (!hrCaseList.isEmpty()) {
Collections.sort(hrCaseList, new Comparator<HRCase>() {
@Override
public int compare(HRCase lhs, HRCase rhs) {
return (int) (lhs.getOrder() - rhs.getOrder());
}
});
listener.onDoneApiCall(hrCaseList);
} else {
listener.onDoneApiCall(new ArrayList<HRCase>(0));
}
} else {
listener.onDoneApiCall(new ArrayList<HRCase>(0));
}
} else
listener.onFailApiCall();
} catch (JSONException e) {
CatalogueLog.e("HRCaseApiManager: getHRCases: onResponse: ", e);
listener.onFailApiCall();
} catch (IOException e) {
CatalogueLog.e("HRCaseApiManager: getHRCases: onResponse: ", e);
listener.onFailApiCall();
}
} else {
CatalogueLog.d("HRCaseApiManager: getHRCases: response is not success");
if (response.code() == 401) {
Log.d(Constants.TAG, "-- is 401, try refresh token...");
Log.d(Constants.TAG, "refresh token: " + PrefManager.getSharedPref(context, PrefManager.PREFERENCE_REFRESH_TOKEN));
SyncStatus status = LoginApiManager.refreshLogin(context, PrefManager.getSharedPref(context, PrefManager.PREFERENCE_REFRESH_TOKEN));
if (status == SyncStatus.SUCCESS) {
CatalogueLog.d("refresh token success, retry same...");
getHRCases(context, listener);
} else {
CatalogueLog.d("refresh token failed, return FAIL");
}
} else {
listener.onFailApiCall();
}
}
} catch (IOException e) {
CatalogueLog.e("HRCaseApiManager: getHRCases: IOException: ", e);
listener.onFailApiCall();
} catch (NullPointerException e) {
CatalogueLog.e("HRCaseApiManager: getHRCases: NullPointerException: ", e);
listener.onFailApiCall();
}
}
}
package com.vsoft.servicenow.api.managers;
import android.content.Context;
import android.util.Log;
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.servicenow.api.RestClient;
import com.vsoft.servicenow.api.interfaces.HRCaseCategoryItemApi;
import com.vsoft.servicenow.api.listeners.get.GetHRCaseItemApiListener;
import com.vsoft.servicenow.db.models.HRCaseItem;
import com.vsoft.servicenow.enums.SyncStatus;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager;
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/04/18.
*
*/
public class HRCaseItemApiManager {
public static void getHRCaseItems(Context context, String hrCaseSysId, GetHRCaseItemApiListener listener) {
CatalogueLog.d("HRCaseItemApiManager: getHRCaseItems: ");
String accessToken = PrefManager.getSharedPref(context, PrefManager.PREFERENCE_ACCESS_TOKEN);
if(accessToken.isEmpty()) {
listener.onFailApiCall();
return;
}
final Retrofit retrofit = RestClient.getInitializedRestAdapter(accessToken);
Call<ResponseBody> call = retrofit.create(HRCaseCategoryItemApi.class).getHRCaseItem(hrCaseSysId);
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 hrCaseItemJsonArray = jsonObject.getJSONArray(Constants.RESPONSE_RESULT_OBJECT_NAME);
if(hrCaseItemJsonArray.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("HRCaseItemApiManager: getHRCaseItems: 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("HRCaseItemApiManager: getHRCaseItems: 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("HRCaseItemApiManager: getHRCaseItems: deserialize: float.class: NumberFormatException: ", e);
}
return value;
}
})
.create();
List<HRCaseItem> hrCaseItems = new ArrayList<>(hrCaseItemJsonArray.length());
for (int i = 0; i < hrCaseItemJsonArray.length(); i++) {
JSONObject hrCaseItemJsonObject = hrCaseItemJsonArray.getJSONObject(i);
HRCaseItem hrCaseItem = gson.fromJson(hrCaseItemJsonObject.toString(), HRCaseItem.class);
hrCaseItems.add(hrCaseItem);
}
listener.onDoneApiCall(hrCaseItems);
} else {
listener.onDoneApiCall(new ArrayList<HRCaseItem>(0));
}
} else
listener.onFailApiCall();
} catch (JSONException e) {
CatalogueLog.e("HRCaseItemApiManager: getHRCaseItems: onResponse: ", e);
listener.onFailApiCall();
} catch (IOException e) {
CatalogueLog.e("HRCaseItemApiManager: getHRCaseItems: onResponse: ", e);
listener.onFailApiCall();
}
} else {
CatalogueLog.d("HRCaseItemApiManager: getHRCaseItems: response is not success");
if (response.code() == 401) {
Log.d(Constants.TAG, "-- is 401, try refresh token...");
Log.d(Constants.TAG, "refresh token: " + PrefManager.getSharedPref(context, PrefManager.PREFERENCE_REFRESH_TOKEN));
SyncStatus status = LoginApiManager.refreshLogin(context, PrefManager.getSharedPref(context, PrefManager.PREFERENCE_REFRESH_TOKEN));
if (status == SyncStatus.SUCCESS) {
CatalogueLog.d("refresh token success, retry same...");
getHRCaseItems(context, hrCaseSysId, listener);
} else {
CatalogueLog.d("refresh token failed, return FAIL");
}
} else {
listener.onFailApiCall();
}
}
} catch (IOException e) {
CatalogueLog.e("HRCaseItemApiManager: getHRCaseItems: IOException: ", e);
listener.onFailApiCall();
} catch (NullPointerException e) {
CatalogueLog.e("HRCaseItemApiManager: getHRCaseItems: NullPointerException: ", e);
listener.onFailApiCall();
}
}
}
...@@ -19,6 +19,8 @@ public interface DBConstants { ...@@ -19,6 +19,8 @@ public interface DBConstants {
String TABLE_NOTIFICATIONS = "notifications"; String TABLE_NOTIFICATIONS = "notifications";
String TABLE_CHAT_BOT_HISTORY = "chat_bot_history"; String TABLE_CHAT_BOT_HISTORY = "chat_bot_history";
String TABLE_CHAT_BOT_USER = "chat_bot_user"; String TABLE_CHAT_BOT_USER = "chat_bot_user";
String TABLE_HR_CASE = "hr_case_category";
String TABLE_HR_CASE_ITEM = "hr_case__category_item";
String ID = "_id"; String ID = "_id";
String SYS_ID = "sys_id"; String SYS_ID = "sys_id";
...@@ -77,6 +79,8 @@ public interface DBConstants { ...@@ -77,6 +79,8 @@ public interface DBConstants {
int CATALOGUE_ITEM_COLUMN_COUNT = 8; int CATALOGUE_ITEM_COLUMN_COUNT = 8;
/** /**
* Catalogue variables table * Catalogue variables table
*/ */
...@@ -406,4 +410,52 @@ public interface DBConstants { ...@@ -406,4 +410,52 @@ public interface DBConstants {
* CHAT_BOT_USER_COLUMN_COUNT: Total column count for chatbot user table. * CHAT_BOT_USER_COLUMN_COUNT: Total column count for chatbot user table.
*/ */
int CHAT_BOT_USER_COLUMN_COUNT = 3; int CHAT_BOT_USER_COLUMN_COUNT = 3;
/**
* HR case table
*/
String HR_CASE_ID = ID;
String HR_CASE_SYS_ID = SYS_ID;
String HR_CASE_TITLE = "title";
String HR_CASE_DESCRIPTION = "description";
String HR_CASE_ICON= "icon";
String HR_CASE_SYNC_DIRTY = SYNC_DIRTY;
/*
* Indices for HR_CASE table. *Use these only if you fetch all columns*
*/
int INDEX_HR_CASE_ID = 0;
int INDEX_HR_CASE_SYS_ID = 1;
int INDEX_HR_CASE_TITLE = 2;
int INDEX_HR_CASE_DESCRIPTION = 3;
int INDEX_HR_CASE_ICON = 4;
int INDEX_HR_CASE_SYNC_DIRTY = 5;
int HR_CASE_COLUMN_COUNT = 6;
/**
* HR_CASE_item table
*/
String HR_CASE_ITEM_ID = ID;
String HR_CASE_ITEM_HR_CASE_ID = "hr_case_id";
String HR_CASE_ITEM_SYS_ID = SYS_ID;
String HR_CASE_ITEM_NAME = "name";
String HR_CASE_ITEM_SHORT_DESCRIPTION = "short_description";
String HR_CASE_ITEM_DESCRIPTION = "item_description";
String HR_CASE_ITEM_ICON = "icon";
String HR_CASE_ITEM_SYNC_DIRTY = SYNC_DIRTY;
/**
* Indices for HR_CASE_item table. *Use these only if you fetch all columns*
*/
int INDEX_HR_CASE_ITEM_ID = 0;
int INDEX_HR_CASE_ITEM_HR_CASE_ID = 1;
int INDEX_HR_CASE_ITEM_SYS_ID = 2;
int INDEX_HR_CASE_ITEM_NAME = 3;
int INDEX_HR_CASE_ITEM_SHORT_DESCRIPTION = 4;
int INDEX_HR_CASE_ITEM_DESCRIPTION = 5;
int INDEX_HR_CASE_ITEM_ICON = 6;
int INDEX_HR_CASE_ITEM_SYNC_DIRTY = 7;
int HR_CASE_ITEM_COLUMN_COUNT = 8;
} }
\ No newline at end of file
...@@ -49,6 +49,11 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants { ...@@ -49,6 +49,11 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
createChatBotTable(db); createChatBotTable(db);
createChatBotUserTable(db); createChatBotUserTable(db);
} }
if(Util.isHrCaseEnabled()) {
createHRCaseTable(db);
createHRCaseItemsTable(db);
}
} }
@Override @Override
...@@ -235,4 +240,28 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants { ...@@ -235,4 +240,28 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
+ CHAT_BOT_USER_NAME + " text" + CHAT_BOT_USER_NAME + " text"
+ ");"); + ");");
} }
private void createHRCaseTable(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_HR_CASE + "("
+ HR_CASE_ID + " integer primary key autoincrement, "
+ HR_CASE_SYS_ID + " text, "
+ HR_CASE_TITLE + " text, "
+ HR_CASE_DESCRIPTION + " text, "
+ HR_CASE_ICON + " text, "
+ HR_CASE_SYNC_DIRTY + " integer default " + SYNC_FLAG_NONE
+ ");");
}
private void createHRCaseItemsTable(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_HR_CASE_ITEM + "("
+ HR_CASE_ITEM_ID + " integer primary key autoincrement, "
+ HR_CASE_ITEM_HR_CASE_ID + " integer default -1, "
+ HR_CASE_ITEM_SYS_ID + " text, "
+ HR_CASE_ITEM_NAME + " integer, "
+ HR_CASE_ITEM_SHORT_DESCRIPTION + " text, "
+ HR_CASE_ITEM_DESCRIPTION + " text, "
+ HR_CASE_ITEM_ICON + " text, "
+ HR_CASE_ITEM_SYNC_DIRTY + " integer default " + SYNC_FLAG_NONE
+ ");");
}
} }
package com.vsoft.servicenow.db.managers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.db.DBConstants;
import com.vsoft.servicenow.db.models.HRCaseItem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author Kunj on 11/04/18.
*/
public class HRCaseItemManager implements DBConstants {
public static long save(HRCaseItem hrCaseItem, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
hrCaseItem.setSyncDirty(syncDirty);
long id = db.insert(TABLE_HR_CASE_ITEM, null, getContentValues(hrCaseItem));
hrCaseItem.setId(id);
return id;
} else {
return -1;
}
}
public static int delete(HRCaseItem hrCaseItem) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
if (hrCaseItem.getSysId() == null || hrCaseItem.getSysId().isEmpty()) {
return db.delete(TABLE_HR_CASE_ITEM, HR_CASE_ITEM_ID + "=" + hrCaseItem.getId(), null);
} else {
return update(hrCaseItem, SYNC_FLAG_DELETE);
}
}
return -1;
}
public static int update(HRCaseItem hrCaseItem, int syncDirty) {
return update(hrCaseItem, null, syncDirty);
}
public static int update(HRCaseItem hrCaseItem, List<String> column, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
hrCaseItem.setSyncDirty(syncDirty);
if (column == null || column.size() == 0) {
return db.update(TABLE_HR_CASE_ITEM, getContentValues(hrCaseItem), HR_CASE_ITEM_ID + "=" + hrCaseItem.getId(), null);
} else {
ContentValues contentValues = new ContentValues(column.size());
contentValues.put(HR_CASE_SYNC_DIRTY, hrCaseItem.getSyncDirty());
for (int i = 0; i < column.size(); i++) {
String columnName = column.get(i);
if (HR_CASE_ITEM_SYS_ID.equals(columnName)) {
contentValues.put(HR_CASE_ITEM_SYS_ID, hrCaseItem.getSysId());
} else if (HR_CASE_ITEM_NAME.equals(columnName)) {
contentValues.put(HR_CASE_ITEM_NAME, hrCaseItem.getName());
} else if (HR_CASE_ITEM_HR_CASE_ID.equals(columnName)) {
contentValues.put(HR_CASE_ITEM_HR_CASE_ID, hrCaseItem.getHRCaseId());
} else if (HR_CASE_ITEM_SHORT_DESCRIPTION.equals(columnName)) {
contentValues.put(HR_CASE_ITEM_SHORT_DESCRIPTION, hrCaseItem.getShortDescription());
} else if (HR_CASE_ITEM_DESCRIPTION.equals(columnName)) {
contentValues.put(HR_CASE_ITEM_DESCRIPTION, hrCaseItem.getDescription());
} else if (HR_CASE_ITEM_ICON.equals(columnName)) {
contentValues.put(HR_CASE_ITEM_ICON, hrCaseItem.getIcon());
}
}
return db.update(TABLE_HR_CASE_ITEM, contentValues, HR_CASE_ITEM_ID + "=" + hrCaseItem.getId(), null);
}
} else {
return -1;
}
}
public static void handleGetHRCaseItem(long hrCaseId, List<HRCaseItem> serverHRCaseItemList) {
if(serverHRCaseItemList != null && !serverHRCaseItemList.isEmpty()) {
/*hrCaseItemSysIdMap contain all server response HRCaseItem Sys Id*/
HashMap<String, Integer> hrCaseItemSysIdMap = new HashMap<>(0);
Integer intObj = Integer.valueOf(1);
for (int i = 0; i < serverHRCaseItemList.size(); i++) {
String sysId = serverHRCaseItemList.get(i).getSysId();
hrCaseItemSysIdMap.put(sysId, intObj);
}
/*localHRCaseItemList is contain all local HRCaseItem */
List<HRCaseItem> localHRCaseItemList = getAllHRCaseItems(hrCaseId);
if (localHRCaseItemList != null && !localHRCaseItemList.isEmpty()) {
for (int i = 0; i < localHRCaseItemList.size(); i++) {
HRCaseItem localHRCaseItem = localHRCaseItemList.get(i);
String localHRCaseItemSysId = localHRCaseItem.getSysId();
if (localHRCaseItemSysId != null
&& !localHRCaseItemSysId.isEmpty()
&& !hrCaseItemSysIdMap.containsKey(localHRCaseItemSysId)) {
//Update sys_id with empty string because required to delete locally
localHRCaseItem.setSysId("");
delete(localHRCaseItem);
}
}
}
/*Check this HRCaseItem 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 < serverHRCaseItemList.size(); i++) {
HRCaseItem hrCaseItem = serverHRCaseItemList.get(i);
HRCaseItem localHRCaseItem = getHRCaseItemFromSysId(hrCaseItem.getSysId());
if (localHRCaseItem == null) {
hrCaseItem.setHRCaseId(hrCaseId);
save(hrCaseItem, DBConstants.SYNC_FLAG_NONE);
} else {
/*Update complete local HRCaseItem object with response HRCaseItem object*/
hrCaseItem.setHRCaseId(hrCaseId);
hrCaseItem.setId(localHRCaseItem.getId());
update(hrCaseItem, DBConstants.SYNC_FLAG_NONE);
}
}
} else {
/*That means there is no HRCaseItem category in server response, then all local items should be deleted those are contain sys_id*/
/*localHRCaseItemList is contain all local HRCaseItems */
List<HRCaseItem> localHRCaseItemList = getAllHRCaseItems(hrCaseId);
if (localHRCaseItemList != null && !localHRCaseItemList.isEmpty()) {
for (int i = 0; i < localHRCaseItemList.size(); i++) {
HRCaseItem localHRCaseItem = localHRCaseItemList.get(i);
String localLocalHRCaseItemSysId = localHRCaseItem.getSysId();
if (localLocalHRCaseItemSysId != null
&& !localLocalHRCaseItemSysId.isEmpty()) {
//Update sys_id with empty string because required to delete locally
localHRCaseItem.setSysId("");
delete(localHRCaseItem);
}
}
}
}
}
public static List<HRCaseItem> getAllHRCaseItems(long hrCaseId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_HR_CASE_ITEM
+ " where " + HR_CASE_ITEM_HR_CASE_ID + "=" + hrCaseId
+ " and " + HR_CASE_ITEM_SYNC_DIRTY + "!=" + DBConstants.SYNC_FLAG_DELETE, null);
ArrayList<HRCaseItem> hrCaseItemList;
if (c.getCount() > 0) {
hrCaseItemList = new ArrayList<>(c.getCount());
while (c.moveToNext()) {
HRCaseItem.HRCaseItemBuilder builder = HRCaseItem.HRCaseItemBuilder.aHRCaseItem();
fillAllHRCaseItemDetails(c, builder);
hrCaseItemList.add(builder.build());
}
} else {
hrCaseItemList = new ArrayList<>(0);
}
c.close();
return hrCaseItemList;
} else {
return new ArrayList<>(0);
}
}
public static HRCaseItem get(long hrCaseItemId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
HRCaseItem hrCaseItem = null;
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_HR_CASE_ITEM + " where " + HR_CASE_ITEM_ID + "=" + hrCaseItemId, null);
if (c.moveToFirst()) {
HRCaseItem.HRCaseItemBuilder builder = HRCaseItem.HRCaseItemBuilder.aHRCaseItem();
fillAllHRCaseItemDetails(c, builder);
hrCaseItem = builder.build();
}
c.close();
}
return hrCaseItem;
}
public static HRCaseItem getHRCaseItemFromSysId(String sysId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
HRCaseItem hrCaseItem = null;
if(db!=null) {
Cursor c = db.rawQuery("select * from " + TABLE_HR_CASE_ITEM + " where " + HR_CASE_SYS_ID + "='" + sysId + "'", null);
if (c.moveToFirst()) {
HRCaseItem.HRCaseItemBuilder builder = HRCaseItem.HRCaseItemBuilder.aHRCaseItem();
fillAllHRCaseItemDetails(c, builder);
hrCaseItem = builder.build();
}
c.close();
}
return hrCaseItem;
}
private static void fillAllHRCaseItemDetails(Cursor c, HRCaseItem.HRCaseItemBuilder builder) {
builder.setId(c.getLong(INDEX_HR_CASE_ITEM_ID));
builder.setHRCaseeId(c.getLong(INDEX_HR_CASE_ITEM_HR_CASE_ID));
builder.setSysId(c.getString(INDEX_HR_CASE_ITEM_SYS_ID));
builder.setName(c.getString(INDEX_HR_CASE_ITEM_NAME));
builder.setShortDescription(c.getString(INDEX_HR_CASE_ITEM_SHORT_DESCRIPTION));
builder.setDescription(c.getString(INDEX_HR_CASE_ITEM_DESCRIPTION));
builder.setIcon(c.getString(INDEX_HR_CASE_ITEM_ICON));
builder.setSyncDirty(c.getInt(INDEX_HR_CASE_ITEM_SYNC_DIRTY));
}
private static ContentValues getContentValues(HRCaseItem hrCaseItem) {
ContentValues cv = new ContentValues(HR_CASE_ITEM_COLUMN_COUNT - 1);
cv.put(HR_CASE_ITEM_HR_CASE_ID, hrCaseItem.getHRCaseId());
cv.put(HR_CASE_ITEM_SYS_ID, hrCaseItem.getSysId());
cv.put(HR_CASE_ITEM_NAME, hrCaseItem.getName());
cv.put(HR_CASE_ITEM_SHORT_DESCRIPTION, hrCaseItem.getShortDescription());
cv.put(HR_CASE_ITEM_DESCRIPTION, hrCaseItem.getDescription());
cv.put(HR_CASE_ITEM_ICON, hrCaseItem.getIcon());
cv.put(HR_CASE_ITEM_SYNC_DIRTY, hrCaseItem.getSyncDirty());
return cv;
}
}
\ No newline at end of file
package com.vsoft.servicenow.db.managers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.db.DBConstants;
import com.vsoft.servicenow.db.models.HRCase;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
*
* @author Kunj on 11/04/18.
*/
public class HRCaseManager implements DBConstants {
public static long save(HRCase hrCase, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
hrCase.setSyncDirty(syncDirty);
long id = db.insert(TABLE_HR_CASE, null, getContentValues(hrCase));
hrCase.setId(id);
return id;
} else {
return -1;
}
}
public static int delete(HRCase hrCase) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
if (hrCase.getSysId() == null || hrCase.getSysId().isEmpty()) {
return db.delete(TABLE_HR_CASE, HR_CASE_ID + "=" + hrCase.getId(), null);
} else {
return update(hrCase, SYNC_FLAG_DELETE);
}
}
return -1;
}
public static int update(HRCase hrCase, int syncDirty) {
return update(hrCase, null, syncDirty);
}
public static int update(HRCase hrCase, List<String> column, int syncDirty) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
hrCase.setSyncDirty(syncDirty);
if (column == null || column.size() == 0) {
return db.update(TABLE_HR_CASE, getContentValues(hrCase), HR_CASE_ID + "=" + hrCase.getId(), null);
} else {
ContentValues contentValues = new ContentValues(column.size());
contentValues.put(HR_CASE_SYNC_DIRTY, hrCase.getSyncDirty());
for (int i = 0; i < column.size(); i++) {
String columnName = column.get(i);
if (HR_CASE_SYS_ID.equals(columnName)) {
contentValues.put(HR_CASE_SYS_ID, hrCase.getSysId());
} else if (HR_CASE_TITLE.equals(columnName)) {
contentValues.put(HR_CASE_TITLE, hrCase.getTitle());
} else if (HR_CASE_DESCRIPTION.equals(columnName)) {
contentValues.put(HR_CASE_DESCRIPTION, hrCase.getDescription());
} else if (HR_CASE_ICON.equals(columnName)) {
contentValues.put(HR_CASE_ICON, hrCase.getIcon());
}
}
return db.update(TABLE_HR_CASE, contentValues, HR_CASE_ID + "=" + hrCase.getId(), null);
}
} else {
return -1;
}
}
public static void handleGetHRCase(List<HRCase> serverHRCaseList) {
if(serverHRCaseList != null && !serverHRCaseList.isEmpty()) {
/*hrCaseSysIdMap contain all server response HRCase Sys Id*/
HashMap<String, Integer> hrCaseSysIdMap = new HashMap<>(0);
Integer intObj = Integer.valueOf(1);
for (int i = 0; i < serverHRCaseList.size(); i++) {
String sysId = serverHRCaseList.get(i).getSysId();
hrCaseSysIdMap.put(sysId, intObj);
}
/*localHRCaseList is contain all local HRCases */
List<HRCase> localHRCaseList = getAllHRCases();
if (localHRCaseList != null && !localHRCaseList.isEmpty()) {
for (int i = 0; i < localHRCaseList.size(); i++) {
HRCase localHRCase = localHRCaseList.get(i);
String localHRCaseSysId = localHRCase.getSysId();
if (localHRCaseSysId != null
&& !localHRCaseSysId.isEmpty()
&& !hrCaseSysIdMap.containsKey(localHRCaseSysId)) {
//Update sys_id with empty string because required to delete locally
localHRCase.setSysId("");
delete(localHRCase);
}
}
}
/*Check this HRCase 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 < serverHRCaseList.size(); i++) {
HRCase hrCase = serverHRCaseList.get(i);
HRCase localHRCase = getHRCaseFromSysId(hrCase.getSysId());
if (localHRCase == null) {
save(hrCase, DBConstants.SYNC_FLAG_NONE);
} else {
/*Update complete local HRCase object with response HRCase object*/
hrCase.setId(localHRCase.getId());
update(hrCase, DBConstants.SYNC_FLAG_NONE);
}
}
} else {
/*That means there is no HRCase category in server response, then all local items should be deleted those are contain sys_id*/
/*localHRCaseList is contain all local HRCases */
List<HRCase> localHRCaseList = getAllHRCases();
if (localHRCaseList != null && !localHRCaseList.isEmpty()) {
for (int i = 0; i < localHRCaseList.size(); i++) {
HRCase localHRCase = localHRCaseList.get(i);
String localHRCaseSysId = localHRCase.getSysId();
if (localHRCaseSysId != null
&& !localHRCaseSysId.isEmpty()) {
//Update sys_id with empty string because required to delete locally
localHRCase.setSysId("");
delete(localHRCase);
}
}
}
}
}
public static List<HRCase> getAllHRCases() {
SQLiteDatabase db = CatalogueApplication.getDatabase();
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_HR_CASE
+ " where " + HR_CASE_SYNC_DIRTY
+ "!=" + DBConstants.SYNC_FLAG_DELETE, null);
ArrayList<HRCase> hrCaseList;
if (c.getCount() > 0) {
hrCaseList = new ArrayList<>(c.getCount());
while (c.moveToNext()) {
HRCase.HRCaseBuilder builder = HRCase.HRCaseBuilder.aHRCase();
fillAllHRCaseDetails(c, builder);
hrCaseList.add(builder.build());
}
} else {
hrCaseList = new ArrayList<>(0);
}
c.close();
return hrCaseList;
} else {
return new ArrayList<>(0);
}
}
public static HRCase get(long hrCaseId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
HRCase hrCase = null;
if (db != null) {
Cursor c = db.rawQuery("select * from " + TABLE_HR_CASE + " where " + HR_CASE_ID + "=" + hrCaseId, null);
if (c.moveToFirst()) {
HRCase.HRCaseBuilder builder = HRCase.HRCaseBuilder.aHRCase();
fillAllHRCaseDetails(c, builder);
hrCase = builder.build();
}
c.close();
}
return hrCase;
}
public static HRCase getHRCaseFromSysId(String sysId) {
SQLiteDatabase db = CatalogueApplication.getDatabase();
HRCase hrCase = null;
if(db!=null) {
Cursor c = db.rawQuery("select * from " + TABLE_HR_CASE + " where " + HR_CASE_SYS_ID + "='" + sysId + "'", null);
if (c.moveToFirst()) {
HRCase.HRCaseBuilder builder = HRCase.HRCaseBuilder.aHRCase();
fillAllHRCaseDetails(c, builder);
hrCase = builder.build();
}
c.close();
}
return hrCase;
}
private static void fillAllHRCaseDetails(Cursor c, HRCase.HRCaseBuilder builder) {
builder.setId(c.getLong(INDEX_HR_CASE_ID));
builder.setSysId(c.getString(INDEX_HR_CASE_SYS_ID));
builder.setTitle(c.getString(INDEX_HR_CASE_TITLE));
builder.setDescription(c.getString(INDEX_HR_CASE_DESCRIPTION));
builder.setIcon(c.getString(INDEX_HR_CASE_ICON));
builder.setSyncDirty(c.getInt(INDEX_HR_CASE_SYNC_DIRTY));
}
private static ContentValues getContentValues(HRCase hrCase) {
ContentValues cv = new ContentValues(HR_CASE_COLUMN_COUNT - 1);
cv.put(HR_CASE_SYS_ID, hrCase.getSysId());
cv.put(HR_CASE_TITLE, hrCase.getTitle());
cv.put(HR_CASE_DESCRIPTION, hrCase.getDescription());
cv.put(HR_CASE_ICON, hrCase.getIcon());
cv.put(HR_CASE_SYNC_DIRTY, hrCase.getSyncDirty());
return cv;
}
}
\ No newline at end of file
package com.vsoft.servicenow.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by Kunj on 11/04/18.
*/
public class HRCase {
private long id = -1;
@SerializedName("title")
@Expose
private String title;
@SerializedName("description")
@Expose
private String description;
@SerializedName("sys_id")
@Expose
private String sysId;
@SerializedName("homepage_image")
@Expose
private String icon;
@SerializedName("order")
@Expose
private long order;
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;
}
/**
*
* @return
* The icon
*/
public String getIcon() {
return icon;
}
/**
*
* @param icon
* The icon
*/
public void setIcon(String icon) {
this.icon = icon;
}
/**
*
* @param order
* The order
*/
public void setOrder(long order) {
this.order = order;
}
/**
*
* @return
* The order
*/
public long getOrder() {
return order;
}
public int getSyncDirty() {
return syncDirty;
}
public void setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
}
public static final class HRCaseBuilder {
private long id = -1;
private String title;
private String description;
private String sysId;
private String icon;
private int syncDirty;
private HRCaseBuilder() {
}
public static HRCaseBuilder aHRCase() {
return new HRCaseBuilder();
}
public HRCaseBuilder setId(long id) {
this.id = id;
return this;
}
public HRCaseBuilder setTitle(String title) {
this.title = title;
return this;
}
public HRCaseBuilder setDescription(String description) {
this.description = description;
return this;
}
public HRCaseBuilder setSysId(String sysId) {
this.sysId = sysId;
return this;
}
public HRCaseBuilder setIcon(String icon) {
this.icon = icon;
return this;
}
public HRCaseBuilder setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
return this;
}
public HRCaseBuilder but() {
return aHRCase().setId(id).setTitle(title).setDescription(description).setSysId(sysId).setIcon(icon).setSyncDirty(syncDirty);
}
public HRCase build() {
HRCase hrCase = new HRCase();
hrCase.setId(id);
hrCase.setTitle(title);
hrCase.setDescription(description);
hrCase.setSysId(sysId);
hrCase.setIcon(icon);
hrCase.setSyncDirty(syncDirty);
return hrCase;
}
}
@Override
public String toString() {
return "HRCase{" +
"id=" + id +
", title='" + title + '\'' +
", description='" + description + '\'' +
", sysId='" + sysId + '\'' +
", icon='" + icon + '\'' +
", order=" + order +
", syncDirty=" + syncDirty +
'}';
}
}
package com.vsoft.servicenow.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by Kunj on 11/04/18.
*/
public class HRCaseItem {
private long id = -1;
private long hrCase_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;
@SerializedName("icon")
@Expose
private String icon;
private int syncDirty;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getHRCaseId() {
return hrCase_id;
}
public void setHRCaseId(long hrCaseId) {
this.hrCase_id = hrCaseId;
}
/**
*
* @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;
}
/**
*
* @return
* The icon
*/
public String getIcon() {
return icon;
}
/**
*
* @param icon
* The icon
*/
public void setIcon(String icon) {
this.icon = icon;
}
public int getSyncDirty() {
return syncDirty;
}
public void setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
}
public static final class HRCaseItemBuilder {
private long id = -1;
private long hrCase_id = -1;
private String shortDescription;
private String description;
private String name;
private String sysId;
private String icon;
private int syncDirty;
private HRCaseItemBuilder() {
}
public static HRCaseItemBuilder aHRCaseItem() {
return new HRCaseItemBuilder();
}
public HRCaseItemBuilder setId(long id) {
this.id = id;
return this;
}
public HRCaseItemBuilder setHRCaseeId(long HRCaseId) {
this.hrCase_id = HRCaseId;
return this;
}
public HRCaseItemBuilder setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
return this;
}
public HRCaseItemBuilder setDescription(String description) {
this.description = description;
return this;
}
public HRCaseItemBuilder setName(String name) {
this.name = name;
return this;
}
public HRCaseItemBuilder setSysId(String sysId) {
this.sysId = sysId;
return this;
}
public HRCaseItemBuilder setIcon(String icon) {
this.icon = icon;
return this;
}
public HRCaseItemBuilder setSyncDirty(int syncDirty) {
this.syncDirty = syncDirty;
return this;
}
public HRCaseItemBuilder but() {
return aHRCaseItem().setId(id).setHRCaseeId(hrCase_id).setShortDescription(shortDescription).setDescription(description).setName(name).setSysId(sysId).setIcon(icon).setSyncDirty(syncDirty);
}
public HRCaseItem build() {
HRCaseItem hrCaseItem = new HRCaseItem();
hrCaseItem.setId(id);
hrCaseItem.setHRCaseId(hrCase_id);
hrCaseItem.setShortDescription(shortDescription);
hrCaseItem.setDescription(description);
hrCaseItem.setName(name);
hrCaseItem.setSysId(sysId);
hrCaseItem.setIcon(icon);
hrCaseItem.setSyncDirty(syncDirty);
return hrCaseItem;
}
}
@Override
public String toString() {
return "HRCaseItem{" +
"id=" + id +
", hrCase_id=" + hrCase_id +
", shortDescription='" + shortDescription + '\'' +
", description='" + description + '\'' +
", name='" + name + '\'' +
", sysId='" + sysId + '\'' +
", icon='" + icon + '\'' +
", syncDirty=" + syncDirty +
'}';
}
}
...@@ -3,8 +3,8 @@ package com.vsoft.servicenow.menu; ...@@ -3,8 +3,8 @@ package com.vsoft.servicenow.menu;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import com.vsoft.servicenow.ui.CreateHRCaseScreen; import com.vsoft.servicenow.ui.CatalogueScreen;
import com.vsoft.servicenow.ui.ReportIncidentScreen; import com.vsoft.servicenow.ui.HRCaseScreen;
/** /**
* Created by Kunj on 23/03/18. * Created by Kunj on 23/03/18.
...@@ -46,7 +46,7 @@ public class CreateHRCaseMenuItemData extends HomeScreenMenuItemData implements ...@@ -46,7 +46,7 @@ public class CreateHRCaseMenuItemData extends HomeScreenMenuItemData implements
public Builder() { public Builder() {
item = new CreateHRCaseMenuItemData(); item = new CreateHRCaseMenuItemData();
setActivity(CreateHRCaseScreen.class); setActivity(HRCaseScreen.class);
} }
} }
} }
package com.vsoft.servicenow.ui;
import android.support.v7.app.AppCompatActivity;
/**
* Created by chaukadev on 4/9/18.
*/
public class CreateHRCaseScreen extends AppCompatActivity {
}
package com.vsoft.servicenow.ui;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.R;
import com.vsoft.servicenow.adapters.HRCaseCategoryItemAdapter;
import com.vsoft.servicenow.api.listeners.get.GetHRCaseItemApiListener;
import com.vsoft.servicenow.api.managers.HRCaseItemApiManager;
import com.vsoft.servicenow.db.managers.HRCaseItemManager;
import com.vsoft.servicenow.db.managers.HRCaseManager;
import com.vsoft.servicenow.db.models.HRCase;
import com.vsoft.servicenow.db.models.HRCaseItem;
import com.vsoft.servicenow.enums.SyncStatus;
import com.vsoft.servicenow.utils.CatalogueLog;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.DialogUtils;
import com.vsoft.servicenow.utils.Util;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by Kunj on 11/04/18.
*/
public class HRCaseItemScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.hr_case_item_screen_list_view) ListView mListView;
@BindView(R.id.hr_case_item_screen_empty_text_view) TextView mEmptyTextView;
@BindView(R.id.toolbar_refresh_icon) ImageView mRefreshIcon;
@BindView(R.id.toolbar_progress_icon) ProgressBar mProgressBar;
private HRCase mHRCase;
private boolean isProgressRequire;
private CatalogueApplication mApplication;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.hr_case_item_screen);
ButterKnife.bind(this);
mApplication = (CatalogueApplication) getApplication();
String hrCaseSysId = getIntent().getExtras().getString(Constants.DATA_KEY_SYS_ID);
String hrCaseTitle = getIntent().getExtras().getString(Constants.DATA_KEY_HR_CASE_TITLE);
if (hrCaseSysId == null) {
CatalogueLog.e("HRCaseItemScreen: hrCaseSysId is null");
}
mHRCase = HRCaseManager.getHRCaseFromSysId(hrCaseSysId);
if(mHRCase == null) {
CatalogueLog.e("HRCaseItemScreen: onCreate: mHRCase is null");
finish();
return;
}
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setElevation(0);
actionBar.setTitle(hrCaseTitle);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = mApplication.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
List<HRCaseItem> hrCaseItemList = HRCaseItemManager.getAllHRCaseItems(mHRCase.getId());
if(!hrCaseItemList.isEmpty()) {
setData(hrCaseItemList);
}
if(mApplication.isNetConnected()) {
isProgressRequire = hrCaseItemList.isEmpty();
new FetchHRCaseItem().execute();
}
}
@OnClick(R.id.toolbar_refresh_icon)
void onRefreshClicked() {
if(mApplication.isNetConnected()) {
new FetchHRCaseItem().execute();
} else {
DialogUtils.showNoConnectionDialogWithCloseActivity(HRCaseItemScreen.this);
}
}
class FetchHRCaseItem extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
private SyncStatus syncStatus;
@Override
protected void onPreExecute() {
super.onPreExecute();
if(isProgressRequire) {
progressDialog = new ProgressDialog(HRCaseItemScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
} else {
mRefreshIcon.setVisibility(View.GONE);
mProgressBar.setVisibility(View.VISIBLE);
}
}
@Override
protected SyncStatus doInBackground(String... params) {
HRCaseItemApiManager.getHRCaseItems(HRCaseItemScreen.this, mHRCase.getSysId(), new
GetHRCaseItemApiListener() {
@Override
public void onDoneApiCall(List<HRCaseItem> hrCaseItemList) {
syncStatus = SyncStatus.SUCCESS;
HRCaseItemManager.handleGetHRCaseItem(mHRCase.getId(), hrCaseItemList);
}
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
});
return syncStatus;
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if(progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
} else {
mRefreshIcon.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
if(syncStatus == SyncStatus.SUCCESS) {
List<HRCaseItem> hrCaseItemList = HRCaseItemManager.getAllHRCaseItems(mHRCase.getId());
isProgressRequire = hrCaseItemList.isEmpty();
setData(hrCaseItemList);
} else {
showErrorDialog(R.string.failed_to_fetch_hr_case_items_category_string);
}
}
}
private void setData(final List<HRCaseItem> hrCaseItemList) {
if (!hrCaseItemList.isEmpty()) {
/*Sort HRCase items list alphabetically*/
Collections.sort(hrCaseItemList, new Comparator<HRCaseItem>() {
@Override
public int compare(HRCaseItem lhs, HRCaseItem rhs) {
return lhs.getName().compareToIgnoreCase(rhs.getName());
}
});
}
if(!hrCaseItemList.isEmpty()) {
mListView.setVisibility(View.VISIBLE);
mEmptyTextView.setVisibility(View.GONE);
HRCaseCategoryItemAdapter adapter = new HRCaseCategoryItemAdapter(HRCaseItemScreen.this);
adapter.setHRCaseItemList(hrCaseItemList);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HRCaseItem hrCaseItem = hrCaseItemList.get(position);
Intent intent = new Intent(HRCaseItemScreen.this, CatalogueVariableScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, hrCaseItem.getSysId());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_DESCRIPTION, hrCaseItem.getDescription());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION, hrCaseItem.getShortDescription());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_TITLE, hrCaseItem.getName());
startActivity(intent);
}
});
} else {
/*There is no HRCase items*/
mEmptyTextView.setVisibility(View.VISIBLE);
mListView.setVisibility(View.GONE);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(menuItem);
}
private void showErrorDialog(int message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message)
.setCancelable(false)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
package com.vsoft.servicenow.ui;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.R;
import com.vsoft.servicenow.adapters.HRCaseCategoryAdapter;
import com.vsoft.servicenow.api.listeners.get.GetHRCaseApiListener;
import com.vsoft.servicenow.api.managers.HRCaseApiManager;
import com.vsoft.servicenow.db.managers.HRCaseManager;
import com.vsoft.servicenow.db.models.HRCase;
import com.vsoft.servicenow.enums.SyncStatus;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.DialogUtils;
import com.vsoft.servicenow.utils.Util;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by Kunj on 11/04/18.
*/
public class HRCaseScreen extends HandleNotificationActivity {
@BindView(R.id.tool_bar_view)
Toolbar mToolbar;
@BindView(R.id.hr_case_screen_list_view)
ListView mListView;
@BindView(R.id.toolbar_refresh_icon)
ImageView mRefreshIcon;
@BindView(R.id.toolbar_progress_icon)
ProgressBar mProgressBar;
/*isProgressRequire variable is use for showing progress bar in middle of screen during fetch data from server*/
private boolean isProgressRequire;
private CatalogueApplication mApplication;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.hr_case_screen);
ButterKnife.bind(this);
mApplication = (CatalogueApplication) getApplication();
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setElevation(0);
actionBar.setTitle(R.string.hr_case_category_string);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
}
Tracker tracker = mApplication.getDefaultTracker();
// Send initial screen view hit.
Util.sendScreenName(tracker, actionBar.getTitle().toString());
List<HRCase> hrCaseList = HRCaseManager.getAllHRCases();
if(!hrCaseList.isEmpty()) {
setData(hrCaseList);
}
if(mApplication.isNetConnected()) {
isProgressRequire = hrCaseList.isEmpty();
new FetchHRCase().execute();
}
}
@OnClick(R.id.toolbar_refresh_icon)
void onRefreshClicked() {
if(mApplication.isNetConnected()) {
new FetchHRCase().execute();
} else {
DialogUtils.showNoConnectionDialogWithCloseActivity(HRCaseScreen.this);
}
}
class FetchHRCase extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog;
private SyncStatus syncStatus = SyncStatus.FAIL;
@Override
protected void onPreExecute() {
super.onPreExecute();
if(isProgressRequire) {
progressDialog = new ProgressDialog(HRCaseScreen.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
} else {
mRefreshIcon.setVisibility(View.GONE);
mProgressBar.setVisibility(View.VISIBLE);
}
}
@Override
protected SyncStatus doInBackground(String... params) {
HRCaseApiManager.getHRCases(HRCaseScreen.this, new GetHRCaseApiListener() {
@Override
public void onDoneApiCall(List<HRCase> hrCaseList) {
syncStatus = SyncStatus.SUCCESS;
HRCaseManager.handleGetHRCase(hrCaseList);
}
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
});
return syncStatus;
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if(progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
} else {
mRefreshIcon.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
if(syncStatus == SyncStatus.SUCCESS) {
List<HRCase> hrCaseList = HRCaseManager.getAllHRCases();
isProgressRequire = hrCaseList.isEmpty();
setData(hrCaseList);
} else {
showErrorDialog(R.string.failed_to_fetch_hr_case_category_string);
}
}
}
private void setData(final List<HRCase> hrCases) {
/*Sort HRCase list alphabetically*/
Collections.sort(hrCases, new Comparator<HRCase>() {
@Override
public int compare(HRCase lhs, HRCase rhs) {
return lhs.getTitle().compareToIgnoreCase(rhs.getTitle());
}
});
HRCaseCategoryAdapter adapter = new HRCaseCategoryAdapter(HRCaseScreen.this);
adapter.setHRCaseList(hrCases);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent intent = new Intent(HRCaseScreen.this, HRCaseItemScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, hrCases.get(position).getSysId());
intent.putExtra(Constants.DATA_KEY_HR_CASE_TITLE, hrCases.get(position).getTitle());
startActivity(intent);
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(menuItem);
}
private void showErrorDialog(int message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message)
.setCancelable(false)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
...@@ -32,6 +32,8 @@ public class Constants { ...@@ -32,6 +32,8 @@ public class Constants {
public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title"; public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title";
public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message"; public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message";
public static final String DATA_KEY_LOGIN_REQUEST_CODE = "login_request_code"; public static final String DATA_KEY_LOGIN_REQUEST_CODE = "login_request_code";
public static final String DATA_KEY_CATEGORY_SYS_ID = "category_sys_id";
public static final String DATA_KEY_HR_CASE_TITLE = "hr_case_title";
/** /**
* Broadcast custom intent * Broadcast custom intent
...@@ -170,10 +172,27 @@ public class Constants { ...@@ -170,10 +172,27 @@ public class Constants {
/*Chat Activity*/ /*Chat Activity*/
public static final String CHAT_USER_API_URL = DOMAIN + URL_GET_USERDETAILS.substring(1); public static final String CHAT_USER_API_URL = DOMAIN + URL_GET_USERDETAILS.substring(1);
/*HRCase Category API */
public static final String URL_GET_HR_CASE = DOMAIN + AppConfig.URL_GET_HR_CASE;
/*HRCase Category Items API */
public static final String URL_GET_HR_CASE_ITEM = DOMAIN + AppConfig.URL_GET_HR_CASE_ITEM;
/** /**
* Chat Server URL * Chat Server URL
* */ * */
public static final String CHAT_SERVER_URL = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT public static final String CHAT_SERVER_URL = (BUILD_TYPE_RELEASE == BuildConfig.BUILD_TYPE_INT
? AppConfig.CHAT_SERVER_URL_RELEASE ? AppConfig.CHAT_SERVER_URL_RELEASE
: (BUILD_TYPE_DEBUG == BuildConfig.BUILD_TYPE_INT ? AppConfig.CHAT_SERVER_URL_DEBUG : AppConfig.CHAT_SERVER_URL_STAGING)); : (BUILD_TYPE_DEBUG == BuildConfig.BUILD_TYPE_INT ? AppConfig.CHAT_SERVER_URL_DEBUG : AppConfig.CHAT_SERVER_URL_STAGING));
/**
* Category API - Hardcode value.
* We are using category api for getting catalogue category and HR case category.
* For both, We're passing hardcode sysId.
*
* For both part, We're using same screens and same API calls also, But we need to make only one change.
* We need to pass different-2 sysid for getting different category.
**/
public static final String CATELOGUE_CATEGORY_SYS_ID = "e0d08b13c3330100c8b837659bba8fb4";
public static final String HR_CASE_CATEGORY_SYS_ID = "9a6a1d924f8286005e1a3d728110c75b";
} }
...@@ -39,6 +39,7 @@ import com.vsoft.servicenow.db.models.VariableChoice; ...@@ -39,6 +39,7 @@ import com.vsoft.servicenow.db.models.VariableChoice;
import com.vsoft.servicenow.db.models.VariableViewContainer; import com.vsoft.servicenow.db.models.VariableViewContainer;
import com.vsoft.servicenow.enums.ViewType; import com.vsoft.servicenow.enums.ViewType;
import com.vsoft.servicenow.menu.ChatMenuItemData; import com.vsoft.servicenow.menu.ChatMenuItemData;
import com.vsoft.servicenow.menu.CreateHRCaseMenuItemData;
import com.vsoft.servicenow.menu.NotificationMenuItemData; import com.vsoft.servicenow.menu.NotificationMenuItemData;
import java.io.IOException; import java.io.IOException;
...@@ -692,4 +693,12 @@ public class Util { ...@@ -692,4 +693,12 @@ public class Util {
} }
return false; return false;
} }
public static boolean isHrCaseEnabled() {
for(int i=0; i<MenuProvider.MENU_ITEMS.size(); i++) {
if(MenuProvider.MENU_ITEMS.get(i) instanceof CreateHRCaseMenuItemData)
return true;
}
return false;
}
} }
<?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="@dimen/list_item_height"
android:weightSum="10"
android:paddingLeft="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:background="@drawable/list_view_item_bg_with_border">
<ImageView
android:id="@+id/hr_case_category_adapter_image"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:layout_gravity="center"
android:padding="@dimen/normal_margin"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="vertical"
android:layout_gravity="center"
android:paddingLeft="@dimen/small_margin">
<TextView
android:id="@+id/hr_case_category_adapter_title_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textSize="@dimen/normal_text_size"
android:textStyle="bold"/>
<TextView
android:id="@+id/hr_case_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:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:weightSum="10"
android:paddingLeft="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:background="@drawable/list_view_item_bg_with_border">
<ImageView
android:id="@+id/hr_case_category_item_adapter_image"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:layout_gravity="center"
android:padding="@dimen/normal_margin"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="vertical"
android:layout_gravity="center"
android:paddingLeft="@dimen/small_margin">
<TextView
android:id="@+id/hr_case_category_item_adapter_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textSize="@dimen/normal_text_size"
android:textStyle="bold"/>
<TextView
android:id="@+id/hr_case_category_item_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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
style="@style/LightBackgroundStyle">
<include layout="@layout/toolbar_with_refresh_option"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/hr_case_item_screen_empty_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:visibility="gone"
android:text="@string/no_hr_case_item_string"
android:textSize="@dimen/extra_normal_text_size" />
<ListView
android:id="@+id/hr_case_item_screen_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/normal_margin"
android:background="@android:color/white"
android:divider="@android:color/white"
android:dividerHeight="@dimen/catalogue_category_and_item_list_view_divider_height"
android:padding="@dimen/normal_margin"
android:scrollbars="none"/>
</FrameLayout>
</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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/LightBackgroundStyle">
<include layout="@layout/toolbar_with_refresh_option"/>
<ListView
android:id="@+id/hr_case_screen_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:layout_margin="@dimen/normal_margin"
android:padding="@dimen/normal_margin"
android:divider="@android:color/white"
android:dividerHeight="@dimen/catalogue_category_and_item_list_view_divider_height"
android:scrollbars="none"/>
</LinearLayout>
\ No newline at end of file
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
<string name="failed_to_submit_form_string">Failed to submit form.</string> <string name="failed_to_submit_form_string">Failed to submit form.</string>
<string name="failed_to_fetch_incident_string">Failed to fetch incidents.</string> <string name="failed_to_fetch_incident_string">Failed to fetch incidents.</string>
<string name="failed_to_fetch_user_detail_string">Failed to fetch User Details.</string> <string name="failed_to_fetch_user_detail_string">Failed to fetch User Details.</string>
<string name="failed_to_fetch_hr_case_category_string">Failed to fetch HR Case Category.</string>
<string name="failed_to_fetch_hr_case_items_category_string">Failed to fetch HR Case Category Items.</string>
<!--Login Screen--> <!--Login Screen-->
<string name="prompt_relogin_login_expired">Login expired, please login again&#8230;</string> <string name="prompt_relogin_login_expired">Login expired, please login again&#8230;</string>
...@@ -164,4 +166,10 @@ ...@@ -164,4 +166,10 @@
<string name="home_screen_notification_title">Notifications</string> <string name="home_screen_notification_title">Notifications</string>
<string name="home_screen_notification_icon">notifications</string> <string name="home_screen_notification_icon">notifications</string>
<!--End--> <!--End-->
<!--HRCase Screen-->
<string name="hr_case_category_string">HR Case</string>
<!--HRCase Item Screen-->
<string name="no_hr_case_item_string">No HR Case Items&#8230;</string>
</resources> </resources>
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
android:name="com.vsoft.servicenow.ui.NotificationScreen" android:name="com.vsoft.servicenow.ui.NotificationScreen"
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>
<activity
android:name="com.vsoft.servicenow.ui.HRCaseScreen"
android:screenOrientation="portrait"/>
<activity
android:name="com.vsoft.servicenow.ui.HRCaseItemScreen"
android:screenOrientation="portrait"/>
<service android:name=".service.NotificationInstanceIdService" <service android:name=".service.NotificationInstanceIdService"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
......
...@@ -40,6 +40,12 @@ public class AppConfig { ...@@ -40,6 +40,12 @@ public class AppConfig {
public static final String URL_GET_VARIABLE_CHOICE = "/api/vsng2/uofl_mobile/question_choice"; public static final String URL_GET_VARIABLE_CHOICE = "/api/vsng2/uofl_mobile/question_choice";
public static final String URL_POST_CATALOGUE_ITEM = "api/vsng2/uofl_mobile"; public static final String URL_POST_CATALOGUE_ITEM = "api/vsng2/uofl_mobile";
/*HRCase Category API */
public static final String URL_GET_HR_CASE = "api/vsng2/uofl_mobile/catalogue_screen";
/*Catalogue Category Items API */
public static final String URL_GET_HR_CASE_ITEM = "api/vsng2/uofl_mobile/catalog_item";
/** /**
* Socket Chat server URLs - Urls given by Ravi * Socket Chat server URLs - Urls given by Ravi
* develop - http://111.93.6.218:12911/ * develop - http://111.93.6.218:12911/
......
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