Skip to content

Commit

Permalink
improve generation of new activities and items to not have duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Jan 11, 2024
1 parent 8f38e59 commit a924889
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,9 @@ class CameraFragment : BaseFragment<FragmentCameraBinding>(R.layout.fragment_cam
}
}

var intent = Intent(NEW_MEDIA_EVENT)
intent.data = newMediaFile
activity?.applicationContext?.let { LocalBroadcastManager.getInstance(it).sendBroadcast(intent) }
// var intent = Intent(NEW_MEDIA_EVENT)
// intent.data = newMediaFile
// activity?.applicationContext?.let { LocalBroadcastManager.getInstance(it).sendBroadcast(intent) }

}

Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/org/witness/proofmode/Activities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,16 @@ object Activities: ViewModel()
val lastActivity = this.activities.lastOrNull()
if (activity.type is ActivityType.MediaCaptured && lastActivity != null && lastActivity.type is ActivityType.MediaCaptured && (lastActivity.startTime.time + timeBatchWindow) >= activity.startTime.time) {
// If within the same minute, add it to the same "batch" as the previous one.
lastActivity.type.items += activity.type.items

for (pItem in activity.type.items)
{
if (!lastActivity.type.items.any{ it.uri == pItem.uri})
{
lastActivity.type.items.add(pItem)
}
}

// lastActivity.type.items += activity.type.items
viewModelScope.launch {
if (db.activitiesDao().activityFromProofableItemId(activity.id) == null)
db.activitiesDao().update(lastActivity)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/witness/proofmode/ProofEventReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import java.util.UUID
class ProofEventReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {

/**
//got event
Toast.makeText(
context,
R.string.progress_generating_proof,
Toast.LENGTH_SHORT
).show()
**/

var uriMedia = intent?.getStringExtra(ProofMode.EVENT_PROOF_EXTRA_URI)?.let {

Expand Down

0 comments on commit a924889

Please sign in to comment.