mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,368 @@
|
|||
package com.adins.mss.base.commons
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.bluetooth.BluetoothDevice
|
||||
import android.content.*
|
||||
import android.os.BatteryManager
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.Keep
|
||||
import android.util.Base64
|
||||
import com.adins.mss.base.PrintActivity
|
||||
|
||||
import com.adins.mss.base.crashlytics.FireCrash
|
||||
import com.adins.mss.base.mainmenu.MainMenuActivity
|
||||
import com.adins.mss.base.util.UserSession
|
||||
import com.adins.mss.constant.Global
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper
|
||||
import com.adins.mss.foundation.formatter.Tool
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences
|
||||
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.channels.FileChannel
|
||||
import java.security.MessageDigest
|
||||
|
||||
import de.greenrobot.dao.database.Database
|
||||
import zj.com.cn.bluetooth.sdk.Main_Activity1
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Helper class to support development
|
||||
* @Author Kusnendi.Muhamad
|
||||
* 31/01/2018
|
||||
*/
|
||||
class SecondHelper {
|
||||
|
||||
fun salt(length: Int): String {
|
||||
val SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||
val salt = StringBuilder()
|
||||
val rnd = Random()
|
||||
while (salt.length < length) { // length of the random string.
|
||||
val index = (rnd.nextFloat() * SALTCHARS.length).toInt()
|
||||
salt.append(SALTCHARS[index])
|
||||
}
|
||||
return salt.toString()
|
||||
}
|
||||
|
||||
fun getNameFromUrl(url: String): String {
|
||||
return url.replaceFirst(".*/([^/?]+).*".toRegex(), "$1")
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun signature(file: File, algorithm: String): String {
|
||||
val digest = MessageDigest.getInstance(algorithm)
|
||||
val `is` = FileInputStream(file)
|
||||
|
||||
var n = 0
|
||||
val buffer = ByteArray(BUFFER)
|
||||
while (n != -1) {
|
||||
n = `is`.read(buffer)
|
||||
if (n > 0) {
|
||||
digest.update(buffer, 0, n)
|
||||
}
|
||||
}
|
||||
|
||||
`is`.close()
|
||||
val result = digest.digest()
|
||||
val hexString = bytesToHex(result)
|
||||
return hexString.toUpperCase()
|
||||
}
|
||||
|
||||
fun fromBase64(encoded: String): ByteArray {
|
||||
// return Base64.getDecoder().decode(encoded);
|
||||
return Base64.decode(encoded, Base64.DEFAULT)
|
||||
}
|
||||
|
||||
// @Throws(IOException::class)
|
||||
// fun toBase64(file: File): String {
|
||||
// var textB64: String? = null
|
||||
// val bytes = loadFile(file)
|
||||
// // byte[] encoded = Base64.getEncoder().encode(bytes);
|
||||
// val encoded = Base64.encode(bytes, Base64.DEFAULT)
|
||||
//
|
||||
// textB64 = String(encoded)
|
||||
// return textB64
|
||||
// }
|
||||
|
||||
fun toBase64(bytes: ByteArray): String {
|
||||
// byte[] encoded = Base64.getEncoder().encode(bytes);
|
||||
val encoded = Base64.encode(bytes, Base64.DEFAULT)
|
||||
return String(encoded)
|
||||
}
|
||||
|
||||
fun isFileExist(path: String): Boolean {
|
||||
val file = File(path)
|
||||
return file.exists()
|
||||
}
|
||||
|
||||
fun createFile(bytes: ByteArray, pathFile: String): File? {
|
||||
try {
|
||||
val file = File(pathFile)
|
||||
val fos = FileOutputStream(file)
|
||||
fos.write(bytes)
|
||||
fos.flush()
|
||||
fos.close()
|
||||
|
||||
return file
|
||||
} catch (io: IOException) {
|
||||
io.printStackTrace()
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
// @Throws(IOException::class)
|
||||
// fun loadFile(file: File): ByteArray {
|
||||
// val `is` = FileInputStream(file)
|
||||
//
|
||||
// val length = file.length()
|
||||
// if (length > Integer.MAX_VALUE) {
|
||||
// //
|
||||
// }
|
||||
//
|
||||
// val bytes = ByteArray(length.toInt())
|
||||
// var offset = 0
|
||||
// var read = 0
|
||||
//
|
||||
// while (offset < bytes.size && (read = `is`.read(bytes, offset, bytes.size - offset)) >= 0) {
|
||||
// offset += read
|
||||
// }
|
||||
//
|
||||
// if (offset < bytes.size) {
|
||||
// throw IOException("Could not completely read file " + file.name)
|
||||
// }
|
||||
//
|
||||
// `is`.close()
|
||||
// return bytes
|
||||
// }
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun copy(sourceFile: File, destFile: File): File {
|
||||
|
||||
if (!destFile.parentFile.exists())
|
||||
destFile.parentFile.mkdirs()
|
||||
|
||||
if (!destFile.exists()) {
|
||||
destFile.createNewFile()
|
||||
}
|
||||
|
||||
var source: FileChannel? = null
|
||||
var destination: FileChannel? = null
|
||||
|
||||
try {
|
||||
source = FileInputStream(sourceFile).channel
|
||||
destination = FileOutputStream(destFile).channel
|
||||
destination!!.transferFrom(source, 0, source!!.size())
|
||||
} finally {
|
||||
source?.close()
|
||||
destination?.close()
|
||||
}
|
||||
|
||||
return destFile
|
||||
}
|
||||
|
||||
fun bytesToHex(bytes: ByteArray): String {
|
||||
val buffer = StringBuffer()
|
||||
for (i in bytes.indices) {
|
||||
if (bytes[i].toInt() and 0xff < 0x10)
|
||||
buffer.append("0")
|
||||
buffer.append(java.lang.Long.toString((bytes[i].toInt() and 0xff).toLong(), 16))
|
||||
}
|
||||
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
|
||||
fun isServiceAvailable(context: Context, serviceClass: Class<*>): Boolean {
|
||||
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
|
||||
if (manager != null) {
|
||||
for (service in manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (serviceClass.name.equals(service.service.className, ignoreCase = true)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@Keep companion object {
|
||||
private val BUFFER = 2048
|
||||
var CHIPER_SHA1 = "SHA-1"
|
||||
var CHIPER_MD5 = "MD5"
|
||||
|
||||
val instance: SecondHelper
|
||||
get() = SecondHelper()
|
||||
|
||||
fun clearSession(context: Context) {
|
||||
try {
|
||||
UserSession.clear()
|
||||
val sharedPref = ObscuredSharedPreferences.getPrefs(context,
|
||||
"GlobalData", Context.MODE_PRIVATE)
|
||||
|
||||
val sharedPrefEditor = sharedPref.edit()
|
||||
sharedPrefEditor.remove("HAS_LOGGED")
|
||||
sharedPrefEditor.commit()
|
||||
} catch (e: Exception) {
|
||||
FireCrash.log(e)
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun broadcastRouteEvent(context: Context, action: String) {
|
||||
val intent = Intent(MainMenuActivity.ACTION_ROUTE_EVENT)
|
||||
intent.putExtra(Global.EXTRA_ACTION_MENU, action)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
|
||||
fun updateDatabase(context: Context, path: String) {
|
||||
val db = DaoOpenHelper.getDb(context)
|
||||
|
||||
try {
|
||||
db.execSQL("ATTACH '$path' AS EXTDB")
|
||||
db.execSQL("REPLACE INTO MS_LOOKUP SELECT * FROM EXTDB.MS_LOOKUP")
|
||||
db.execSQL("REPLACE INTO MS_MIGRATION SELECT * FROM EXTDB.MS_MIGRATION")
|
||||
db.execSQL("REPLACE INTO MS_BLACKLIST SELECT * FROM EXTDB.MS_BLACKLIST")
|
||||
db.execSQL("REPLACE INTO MS_PO SELECT * FROM EXTDB.MS_PO")
|
||||
db.execSQL("REPLACE INTO MS_RULES SELECT * FROM EXTDB.MS_RULES")
|
||||
db.execSQL("REPLACE INTO MS_PO_ASSET SELECT * FROM EXTDB.MS_PO_ASSET")
|
||||
db.execSQL("REPLACE INTO MS_PO_DEALER SELECT * FROM EXTDB.MS_PO_DEALER")
|
||||
db.execSQL("REPLACE INTO MS_TMP_RULE SELECT * FROM EXTDB.MS_TMP_RULE")
|
||||
db.execSQL("REPLACE INTO MS_SYNC SELECT * FROM EXTDB.MS_SYNC")
|
||||
db.execSQL("DETACH 'EXTDB'")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun resetSession(activity: Activity, tClass: Class<*>) {
|
||||
SecondHelper.clearSession(activity)
|
||||
val login = Intent(activity, tClass)
|
||||
login.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
|
||||
login.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
activity.startActivity(login)
|
||||
activity.finish()
|
||||
}
|
||||
|
||||
fun isAlwaysFinishActivities(context: Context): Boolean {
|
||||
var alwaysFinishActivitiesInt = 0
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
alwaysFinishActivitiesInt = Settings.System.getInt(context.contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0)
|
||||
} else {
|
||||
alwaysFinishActivitiesInt = Settings.System.getInt(context.contentResolver, Settings.System.ALWAYS_FINISH_ACTIVITIES, 0)
|
||||
}
|
||||
|
||||
return alwaysFinishActivitiesInt == 1
|
||||
|
||||
// return if (alwaysFinishActivitiesInt == 1) {
|
||||
// true
|
||||
// } else {
|
||||
// false
|
||||
// }
|
||||
}
|
||||
|
||||
fun alwaysFinishActivityState(context: Context, state: Boolean) {
|
||||
val mode = if (state) 1 else 0
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
Settings.System.putInt(context.contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, mode)
|
||||
} else {
|
||||
Settings.System.putInt(context.contentResolver, Settings.System.ALWAYS_FINISH_ACTIVITIES, mode)
|
||||
}
|
||||
}
|
||||
|
||||
//Method for read developer options state
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
fun isDevMode(context: Context): Boolean {
|
||||
var mode = 0
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
mode = Settings.Secure.getInt(context.contentResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0)
|
||||
} else {
|
||||
mode = Settings.Secure.getInt(context.contentResolver, Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0)
|
||||
}
|
||||
|
||||
return mode == 1
|
||||
}
|
||||
|
||||
fun isUUID(text : String) : Boolean {
|
||||
val pattern = "[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"
|
||||
return text.matches(Regex(pattern));
|
||||
}
|
||||
|
||||
fun doPrint(context: Context, taskId: String?, source: String?) {
|
||||
val printPrefs = context.getSharedPreferences("printPrefs", Context.MODE_PRIVATE)
|
||||
// val printManger = if (printPrefs.getInt("printerType", 1) == 1) Main_Activity1::class.java else PrintActivity::class.java
|
||||
val printIntent = Intent(context, Main_Activity1::class.java)
|
||||
printIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
printIntent.putExtra("taskId", taskId)
|
||||
printIntent.putExtra("source", source)
|
||||
|
||||
if (printPrefs.contains("printerAddress"))
|
||||
printIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, printPrefs.getString("printerAddress", ""))
|
||||
|
||||
//Start print activity
|
||||
context.startActivity(printIntent)
|
||||
}
|
||||
|
||||
fun doPrint(context: Context, params: PrintParams) {
|
||||
val printPrefs = context.getSharedPreferences("printPrefs", Context.MODE_PRIVATE)
|
||||
val printIntent = Intent(context, Main_Activity1::class.java)
|
||||
printIntent.putExtra("taskId", params.taskId)
|
||||
if (params.source != null) printIntent.putExtra("source", params.source)
|
||||
if (params.isPrintDeposit != null) printIntent.putExtra("isPrintDeposit", params.isPrintDeposit!!)
|
||||
if (params.isDummy != null) printIntent.putExtra("isDummy", params.isDummy!!)
|
||||
|
||||
if (printPrefs.contains("printerAddress"))
|
||||
printIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, printPrefs.getString("printerAddress", ""))
|
||||
|
||||
//Start print activity
|
||||
context.startActivity(printIntent)
|
||||
}
|
||||
|
||||
fun isCharging(context: Context) : Boolean {
|
||||
val intent= context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||
val plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)
|
||||
return plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS
|
||||
}
|
||||
|
||||
// Method for receive battery change level
|
||||
fun registerBatteryChangeReceiver(context: Context, broadcastReceiver: BroadcastReceiver) {
|
||||
context.registerReceiver(broadcastReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||
}
|
||||
|
||||
// Method for stop receiver battery change
|
||||
fun unregisterBatteryChangeReceiver(context: Context, broadcastReceiver: BroadcastReceiver) {
|
||||
context.unregisterReceiver(broadcastReceiver)
|
||||
}
|
||||
|
||||
// Method for receive power connection
|
||||
fun registerPowerConnectionReceiver(context: Context, broadcastReceiver: BroadcastReceiver) {
|
||||
val powerStateFilter = IntentFilter()
|
||||
powerStateFilter.addAction(Intent.ACTION_POWER_CONNECTED)
|
||||
powerStateFilter.addAction(Intent.ACTION_POWER_DISCONNECTED)
|
||||
context.registerReceiver(broadcastReceiver, powerStateFilter)
|
||||
}
|
||||
|
||||
fun unregisterPowerConnection(context: Context, broadcastReceiver: BroadcastReceiver) {
|
||||
context.unregisterReceiver(broadcastReceiver)
|
||||
}
|
||||
|
||||
fun recordCashOnHand(context: Context, amount: String) {
|
||||
val preference = context.getSharedPreferences("cohPrefs", Context.MODE_PRIVATE)
|
||||
preference.edit().putString("cashOnHand", amount)
|
||||
.putLong("timestamp", Tool.truncTime(Date()).time)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
@Keep
|
||||
open class PrintParams(var taskId: String?, var source: String?, var isPrintDeposit: Boolean?, var isDummy: Boolean?)
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate android:fromXDelta="100%"
|
||||
android:toXDelta="0%"
|
||||
android:duration="@android:integer/config_shortAnimTime" />
|
||||
|
||||
</set>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<scale
|
||||
android:fromXScale="0.3" android:toXScale="1.0"
|
||||
android:fromYScale="0.3" android:toYScale="1.0"
|
||||
android:pivotX="50%" android:pivotY="100%"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
<alpha
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
</set>
|
|
@ -0,0 +1,67 @@
|
|||
package com.adins.mss.base.dynamicform.form.resolver;
|
||||
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.gadberry.utility.CalendarUtils;
|
||||
import com.gadberry.utility.expression.Resolver;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 15/09/2016.
|
||||
*/
|
||||
public class TimeResolver implements Resolver {
|
||||
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat(Global.TIME_STR_FORMAT);
|
||||
|
||||
@Override
|
||||
public boolean canResolve(String path) {
|
||||
return resolve(path) != null || path.equals("NULL");
|
||||
}
|
||||
|
||||
private Date getDate(String path) {
|
||||
try {
|
||||
return sdf.parse(path);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CalendarUtils.Unit getDateUnit(String path) {
|
||||
if (path.equals("|YEAR|")) {
|
||||
return CalendarUtils.Unit.YEAR;
|
||||
} else if (path.equals("|MONTH|")) {
|
||||
return CalendarUtils.Unit.MONTH;
|
||||
} else if (path.equals("|DAY|")) {
|
||||
return CalendarUtils.Unit.DAY;
|
||||
} else if (path.equals("|HOUR|")) {
|
||||
return CalendarUtils.Unit.HOUR;
|
||||
} else if (path.equals("|MINUTE|")) {
|
||||
return CalendarUtils.Unit.MINUTE;
|
||||
} else if (path.equals("|SECOND|")) {
|
||||
return CalendarUtils.Unit.SECOND;
|
||||
} else if (path.equals("|MILLISECOND|")) {
|
||||
return CalendarUtils.Unit.MILLISECOND;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isDate(String path) {
|
||||
return getDate(path) != null;
|
||||
}
|
||||
|
||||
private boolean isDateUnit(String path) {
|
||||
return getDateUnit(path) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolve(String path) {
|
||||
if (isDate(path)) {
|
||||
return getDate(path);
|
||||
} else if (isDateUnit(path)) {
|
||||
return getDateUnit(path);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/bottomnav_background">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/txtName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Name"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_person_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtDepartment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Department"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_job_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtPhone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Phone"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_phone_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtEmail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Email"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_email"
|
||||
android:drawablePadding="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnCall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_gravity="center_horizontal|center_vertical"
|
||||
android:background="@drawable/transparent_bg"
|
||||
android:src="@drawable/icon_call"/>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/taskListLayout">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/taskHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="5dp"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
app:cardBackgroundColor="@color/fontColorWhite">
|
||||
<LinearLayout
|
||||
android:id="@+id/taskLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
android:id="@+id/txtNoOrder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Assignment"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/fontColor"
|
||||
android:drawableLeft="@drawable/ic_assignment"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/txtCustomerName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Name"
|
||||
android:textColor="@color/fontColor"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_person_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" >
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/timelineLine"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@android:color/transparent"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -0,0 +1,54 @@
|
|||
package com.adins.mss.odr.catalogue.imageslider;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.adins.mss.odr.R;
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 11/28/2017.
|
||||
*/
|
||||
|
||||
public class FragmentSlider extends Fragment {
|
||||
private static final String ARG_PARAM1 = "params";
|
||||
|
||||
private String imageUrls;
|
||||
|
||||
public FragmentSlider() {
|
||||
}
|
||||
|
||||
public static FragmentSlider newInstance(byte[] params) {
|
||||
FragmentSlider fragment = new FragmentSlider();
|
||||
Bundle args = new Bundle();
|
||||
args.putByteArray(ARG_PARAM1, params);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// imageUrls = getArguments().getString(ARG_PARAM1);
|
||||
View view = inflater.inflate(R.layout.fragment_slider_item, container, false);
|
||||
ImageView image = (ImageView) view.findViewById(R.id.img);
|
||||
|
||||
byte[] tempImage = getArguments().getByteArray(ARG_PARAM1);
|
||||
// Bitmap bm = null;
|
||||
// if(tempImage != null){
|
||||
// try {
|
||||
// bm = Utils.byteToBitmap(tempImage);
|
||||
// } catch (Exception e) { }
|
||||
// }
|
||||
if (tempImage != null)
|
||||
Glide.with(getActivity()).load(tempImage).into(image);
|
||||
|
||||
// image.setImageBitmap(bm);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 489 B |
|
@ -0,0 +1,277 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.QuestionSet;
|
||||
import com.adins.mss.dao.QuestionSetDao;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
import de.greenrobot.dao.query.WhereCondition;
|
||||
|
||||
public class QuestionSetDataAccess {
|
||||
|
||||
private QuestionSetDataAccess() {
|
||||
}
|
||||
|
||||
/**
|
||||
* use to generate dao session that you can access modelDao
|
||||
*
|
||||
* @param context --> context from activity
|
||||
* @return
|
||||
*/
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get printItem dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static QuestionSetDao getQuestionSetDao(Context context) {
|
||||
return getDaoSession(context).getQuestionSetDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add questionSet as entity
|
||||
*
|
||||
* @param context
|
||||
* @param questionSet
|
||||
*/
|
||||
public static void add(Context context, QuestionSet questionSet) {
|
||||
getQuestionSetDao(context).insertInTx(questionSet);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add questionSet as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param questionSetList
|
||||
*/
|
||||
public static void add(Context context, List<QuestionSet> questionSetList) {
|
||||
getQuestionSetDao(context).insertInTx(questionSetList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all content in table.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void clean(Context context) {
|
||||
getQuestionSetDao(context).deleteAll();
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param questionSet
|
||||
*/
|
||||
public static void delete(Context context, QuestionSet questionSet) {
|
||||
getQuestionSetDao(context).delete(questionSet);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by keyScheme
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void delete(Context context, String keyScheme) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme));
|
||||
qb.build();
|
||||
getQuestionSetDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by keyScheme and version
|
||||
*/
|
||||
public static void delete(Context context, String uuidScheme, String schemeVersion) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(uuidScheme), QuestionSetDao.Properties.Form_version.eq(schemeVersion));
|
||||
qb.build();
|
||||
getQuestionSetDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param questionSet
|
||||
*/
|
||||
public static void update(Context context, QuestionSet questionSet) {
|
||||
getQuestionSetDao(context).insertOrReplaceInTx(questionSet);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add or replace questionSet as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @param listQuestionSet
|
||||
*/
|
||||
public static void addOrReplace(Context context, String keyScheme, List<QuestionSet> listQuestionSet) {
|
||||
getQuestionSetDao(context).insertOrReplaceInTx(listQuestionSet);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add or replace questionSet as entity
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @param questionSet
|
||||
*/
|
||||
public static void addOrReplace(Context context, String keyScheme, QuestionSet questionSet) {
|
||||
getQuestionSetDao(context).insertOrReplaceInTx(questionSet);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_scheme = param
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @param uuidQuestionSet
|
||||
* @return
|
||||
*/
|
||||
public static QuestionSet getOne(Context context, String keyScheme, String uuidQuestionSet) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme),
|
||||
QuestionSetDao.Properties.Uuid_question_set.eq(uuidQuestionSet));
|
||||
qb.build();
|
||||
if (qb.list().isEmpty())
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
public static QuestionSet getOne(String keyScheme, Context context, String questionId) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme),
|
||||
QuestionSetDao.Properties.Question_id.eq(questionId));
|
||||
qb.build();
|
||||
if (qb.list().isEmpty())
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_scheme = param
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @param questionId
|
||||
* @param questionGroupId
|
||||
* @return
|
||||
*/
|
||||
public static QuestionSet getOne(Context context, String keyScheme, String questionId, String questionGroupId) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme),
|
||||
QuestionSetDao.Properties.Question_id.eq(questionId),
|
||||
QuestionSetDao.Properties.Question_group_id.eq(questionGroupId));
|
||||
qb.build();
|
||||
if (qb.list().isEmpty())
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_scheme = param
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @return
|
||||
*/
|
||||
public static List<QuestionSet> getAll(Context context, String keyScheme) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme));
|
||||
qb.orderAsc(QuestionSetDao.Properties.Question_group_order);
|
||||
qb.orderAsc(QuestionSetDao.Properties.Question_order);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_scheme = param and form_version = param
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @param formVersion
|
||||
* @return
|
||||
*/
|
||||
public static List<QuestionSet> getAllByFormVersion(Context context, String keyScheme, String formVersion) {
|
||||
List<QuestionSet> list = null;
|
||||
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme), // Nendi: 2019.09.26 | Tambah penjagaan yang double insert bisa taskD nya jd kosong di form
|
||||
QuestionSetDao.Properties.Form_version.eq(formVersion), new WhereCondition.StringCondition("1 GROUP BY QUESTION_ID"));
|
||||
qb.orderAsc(QuestionSetDao.Properties.Question_group_order);
|
||||
qb.orderAsc(QuestionSetDao.Properties.Question_order);
|
||||
qb.build();
|
||||
if (qb != null) {
|
||||
list = qb.list();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void deleteBySchemeVersion(Context context, String keyScheme, List<String> versionScheme) {
|
||||
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Uuid_scheme.eq(keyScheme));
|
||||
if(!versionScheme.isEmpty()) {
|
||||
qb.where(QuestionSetDao.Properties.Form_version.notIn(versionScheme));
|
||||
}
|
||||
qb.build();
|
||||
getQuestionSetDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where questionID = param1 and questionGroupID = param2
|
||||
*
|
||||
* @param context
|
||||
* @param questionID
|
||||
* @param questionGroupID
|
||||
* @return
|
||||
*/
|
||||
public static List<QuestionSet> getAllByQuestionIDAndQuestionGroupID(Context context, String questionID, String questionGroupID) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Question_id.eq(questionID)
|
||||
, QuestionSetDao.Properties.Question_group_id.eq(questionGroupID));
|
||||
qb.orderAsc(QuestionSetDao.Properties.Question_group_order);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
public static QuestionSet getOneQuestionByTag(Context context, String tag) {
|
||||
QueryBuilder<QuestionSet> qb = getQuestionSetDao(context).queryBuilder();
|
||||
qb.where(QuestionSetDao.Properties.Tag.eq(tag));
|
||||
qb.build();
|
||||
|
||||
if (qb.list().size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:weightSum="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/newsImage"
|
||||
android:background="@drawable/button_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="0.5"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/newsDesc"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dummy_text_3"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/no"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:gravity="center_horizontal"/>
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/timelineLine" />
|
||||
<TextView
|
||||
android:id="@+id/fieldName"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:gravity="center_horizontal"/>
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/timelineLine" />
|
||||
<TextView
|
||||
android:id="@+id/fieldValue"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:gravity="center_horizontal"/>
|
||||
</TableRow>
|
Loading…
Add table
Add a link
Reference in a new issue