Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/small code cleanup #594

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</activity>

<activity android:name="com.jiangdg.demo.MainActivity"
android:exported="true"
android:theme="@style/Theme.ClinkCameraDemo.NoActionBar" />
</application>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jiangdg/demo/DemoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ class DemoFragment : CameraFragment(), View.OnClickListener, CaptureMediaView.On
}
} catch (e: Exception) {
activity?.runOnUiThread {
ToastUtils.show("${e.localizedMessage}")
ToastUtils.show(e.localizedMessage)
}
Logger.e(TAG, "showRecentMedia failed", e)
}
Expand Down
4 changes: 2 additions & 2 deletions libausbc/src/main/java/com/jiangdg/ausbc/utils/CrashUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ object CrashUtils : Thread.UncaughtExceptionHandler {

fun init(application: Application) {
this.mApplication = application
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler(this)
}

override fun uncaughtException(t: Thread, e: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
package com.jiangdg.ausbc.utils

import java.util.concurrent.*
import java.util.concurrent.CancellationException
import java.util.concurrent.ExecutionException
import java.util.concurrent.Future
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
import java.util.concurrent.locks.AbstractQueuedSynchronizer

/** Sync read tool
Expand Down Expand Up @@ -99,10 +103,12 @@ open class SettableFuture<V> : Future<V> {
} else {
value
}

CANCELLED, INTERRUPTED -> throw cancellationExceptionWithCause(
"Task was cancelled.",
exception
)

else -> throw IllegalStateException("Error, synchronizer in invalid state: $state")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import androidx.recyclerview.widget.RecyclerView
*
* @author Created by jiangdg on 2022/7/24
*/
class SpaceItemDecoration(private val space: Int): RecyclerView.ItemDecoration() {
class SpaceItemDecoration(private val space: Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
) {
outRect.left = space;
outRect.bottom = space;
if (parent.getChildLayoutPosition(view) %3==0) {
outRect.left = space
outRect.bottom = space
if (parent.getChildLayoutPosition(view) % 3 == 0) {
outRect.left = 0
}
}
Expand Down
5 changes: 2 additions & 3 deletions libausbc/src/main/java/com/jiangdg/ausbc/utils/ToastUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.annotation.MainThread
*/
object ToastUtils {

private var applicationCtx: Context ?= null
private var applicationCtx: Context? = null

@MainThread
fun init(ctx: Context) {
Expand All @@ -36,7 +36,7 @@ object ToastUtils {
}

@JvmStatic
fun show(msg: String) {
fun show(msg: String?) {
applicationCtx?.let { ctx ->
Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show()
}
Expand All @@ -48,5 +48,4 @@ object ToastUtils {
Toast.makeText(ctx, ctx.getString(resId), Toast.LENGTH_LONG).show()
}
}

}