This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view.setOnTouchListener { _, event -> | |
val x = event.x.toInt() + 200 | |
val y = event.y.toInt() | |
if (pickMode != 5 && event.action == ACTION_DOWN) { | |
viewModel.products.observeOnce(viewLifecycleOwner) { products -> | |
products.forEach { | |
if (it.rectName?.contains(x, y) == true && it.isVisible) { | |
findNavController().navigate( | |
R.id.action_pickFragment_to_productFragment, | |
bundleOf(PRODUCT_ID to it.id.toString()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BarcodeGraphic internal constructor( | |
overlay: GraphicOverlay<*>?, | |
private val viewModel: PickCompleteViewModel?, | |
private val lifecycleOwner: LifecycleOwner | |
) : Graphic(overlay!!) { | |
var id = 0 | |
private val rectPaint = Paint().apply { | |
color = GREEN | |
style = Paint.Style.FILL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PickCompleteViewModel( | |
private val repository: ApiRepository, | |
private val preferences: SharedPreferences | |
) : ViewModel() { | |
val response = MutableLiveData<ResponseMessage>() | |
val error = MutableLiveData<String>() | |
val products = MutableLiveData<MutableSet<Product>>() | |
val currentProduct = MutableLiveData<PickProduct>() | |
val sentSuccess = MutableLiveData<Boolean>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout | |
android:id="@+id/top_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:keepScreenOn="true" | |
android:orientation="vertical"> | |
<team.marker.util.camera.CameraSourcePreview | |
android:id="@+id/preview" | |
android:layout_width="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CameraSourcePreview( | |
private val mContext: Context, | |
attrs: AttributeSet? | |
) : ViewGroup(mContext, attrs) { | |
private val mSurfaceView: SurfaceView = SurfaceView(mContext) | |
private var mStartRequested = false | |
private var mSurfaceAvailable = false | |
private var mCameraSource: CameraSource? = null | |
private var mOverlay: GraphicOverlay<*>? = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GraphicOverlay<T : Graphic?>(context: Context?, attrs: AttributeSet?) : View(context, attrs) { | |
private val mLock = Any() | |
private var mPreviewWidth = 0 | |
/** | |
* Returns the horizontal scale factor. | |
*/ | |
var widthScaleFactor = 1.0f | |
private set | |
private var mPreviewHeight = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun validMountainArray(arr: IntArray): Boolean { | |
if (arr.size < 3 || arr[0] > arr[1]) return false | |
var ascend = true | |
for (i in 1 until arr.size) { | |
if (arr[i - 1] == arr[i]) return false | |
if (ascend) { | |
if (arr[i - 1] > arr[i]) ascend = false | |
} else { | |
if (arr[i - 1] < arr[i]) return false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean validMountainArray(int[] arr) { | |
if (arr.length < 3 || arr[0] > arr[1]) return false; | |
boolean ascend = true; | |
for (int i = 1; i < arr.length; i++) { | |
if (arr[i - 1] == arr[i]) return false; | |
if (ascend) { | |
if (arr[i - 1] > arr[i]) ascend = false; | |
} else { | |
if (arr[i - 1] < arr[i]) return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun countSubstrings(s: String): Int { | |
var c = 0 | |
for (i in s.indices) { | |
val sb = StringBuilder() | |
for (j in i until s.length) if (isPal(sb.append(s[j]).toString())) c++ | |
} | |
return c | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun countSubstrings(s: String): Int { | |
var c = 0 | |
for (i in s.indices) { | |
val sb = StringBuilder() | |
for (j in i until s.length) if (sb.append(s[j]).toString() == sb.toString().reversed()) c++ | |
} | |
return c | |
} |
NewerOlder