-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from MEY-Mental-Education-Yes/Revisi_Add_API_Li…
…st_Music Revisi add api list music
- Loading branch information
Showing
103 changed files
with
1,850 additions
and
862 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions
139
app/src/main/java/com/candra/projectcapstone/activity/home/ListDetailScan.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package com.candra.projectcapstone.activity.home | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Intent | ||
import android.graphics.BitmapFactory | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.widget.ImageView | ||
import androidx.activity.viewModels | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.ContextCompat | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import coil.load | ||
import coil.transform.CircleCropTransformation | ||
import com.candra.projectcapstone.R | ||
import com.candra.projectcapstone.adapter.AdapterForFear | ||
import com.candra.projectcapstone.databinding.ResultActivityBinding | ||
import com.candra.projectcapstone.helper.Constant | ||
import com.candra.projectcapstone.helper.Constant.PICTURE | ||
import com.candra.projectcapstone.helper.Constant.RESULT_SCAN_FACE | ||
import com.candra.projectcapstone.viewmodel.ListMusicViewModel | ||
import com.google.android.material.textview.MaterialTextView | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import java.io.File | ||
|
||
@AndroidEntryPoint | ||
class ListDetailScan: AppCompatActivity() | ||
{ | ||
|
||
private lateinit var binding: ResultActivityBinding | ||
private var getFile: File? = null | ||
private var getIsBackCamera:Boolean = false | ||
private val listMusicViewModel by viewModels<ListMusicViewModel>() | ||
private val adapterMusic by lazy { AdapterForFear() } | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ResultActivityBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
setBackgroundCardView() | ||
setActionComponentClick() | ||
readObserverData() | ||
setAdapterToListDetailScan() | ||
} | ||
|
||
private fun setBackgroundCardView(){ | ||
binding.apply { | ||
containerImageview.background = ContextCompat.getDrawable(this@ListDetailScan, R.drawable.turn_back) | ||
} | ||
} | ||
|
||
private fun setActionComponentClick(){ | ||
binding.apply { | ||
containerImageview.setOnClickListener { | ||
toBackHomeFragment() | ||
} | ||
getResultFromCamera(imageScanUser,resultTextScanUser,textDescriptionName) | ||
} | ||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
private fun getResultFromCamera(imageView: ImageView, textResultScan: MaterialTextView, textDescriptionResultScan: MaterialTextView){ | ||
val resultImage = intent.getSerializableExtra(PICTURE) as File | ||
val resultScanFace = intent.getStringExtra(RESULT_SCAN_FACE) | ||
val convertFileToBitmap = BitmapFactory.decodeFile(resultImage.path) | ||
|
||
|
||
imageView.load(convertFileToBitmap){ | ||
transformations(CircleCropTransformation()) | ||
} | ||
textResultScan.text = resultScanFace | ||
textDescriptionResultScan.text = "Lagu untuk hasil ${resultScanFace}, Selamat menikmati lagu ${resultScanFace}" | ||
|
||
resultScanFace?.let { setListMusicBasedResultFace(it) } | ||
} | ||
|
||
private fun setListMusicBasedResultFace(resultFace: String){ | ||
when(resultFace){ | ||
Constant.ANGRY -> { | ||
listMusicViewModel.getAllMusicList(Constant.ANGRY) | ||
} | ||
Constant.SAD -> { | ||
listMusicViewModel.getAllMusicList(Constant.SAD) | ||
} | ||
Constant.DISGUST -> { | ||
listMusicViewModel.getAllMusicList(Constant.DISGUST) | ||
} | ||
Constant.FEAR -> { | ||
listMusicViewModel.getAllMusicList(Constant.FEAR) | ||
} | ||
Constant.HAPPY -> { | ||
listMusicViewModel.getAllMusicList(Constant.HAPPY) | ||
} | ||
Constant.NEUTRAL -> { | ||
listMusicViewModel.getAllMusicList(Constant.NEUTRAL) | ||
} | ||
Constant.SURPRISE -> { | ||
listMusicViewModel.getAllMusicList(Constant.SURPRISE) | ||
} | ||
} | ||
} | ||
|
||
private fun setAdapterToListDetailScan(){ | ||
binding.listMusicItem.apply { | ||
layoutManager = LinearLayoutManager(this@ListDetailScan) | ||
adapter = adapterMusic | ||
} | ||
} | ||
|
||
private fun readObserverData(){ | ||
listMusicViewModel.listMusicData.observe(this){ | ||
if (it != null){ | ||
adapterMusic.addAllDataMusic(it) | ||
} | ||
} | ||
listMusicViewModel.loading.observe(this){ | ||
showShimmerEffect(it) | ||
} | ||
} | ||
|
||
private fun showShimmerEffect(show: Boolean){ | ||
binding.apply { | ||
if (show){ | ||
shimmerEffect.startShimmer() | ||
shimmerEffect.visibility = View.VISIBLE | ||
listMusicItem.visibility = View.GONE | ||
}else{ | ||
shimmerEffect.hideShimmer() | ||
shimmerEffect.visibility = View.GONE | ||
listMusicItem.visibility = View.VISIBLE | ||
} | ||
} | ||
} | ||
|
||
private fun toBackHomeFragment(){ | ||
startActivity(Intent(this@ListDetailScan,MainActivity::class.java)) | ||
finish() | ||
} | ||
} |
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
23 changes: 0 additions & 23 deletions
23
app/src/main/java/com/candra/projectcapstone/activity/login/LoginActivity.kt
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.