Skip to content

Commit

Permalink
Merge pull request #1 from MEY-Mental-Education-Yes/Revisi_Add_API_Li…
Browse files Browse the repository at this point in the history
…st_Music

Revisi add api list music
  • Loading branch information
candrajulius authored Jun 9, 2022
2 parents b2e8834 + a0458cf commit 2733c69
Show file tree
Hide file tree
Showing 103 changed files with 1,850 additions and 862 deletions.
32 changes: 30 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ android {
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

aaptOptions {
noCompress "tflite"
}
}

buildTypes {
Expand All @@ -42,12 +46,13 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-support:0.3.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.3.0'
implementation 'org.tensorflow:tensorflow-lite:2.8.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down Expand Up @@ -101,7 +106,11 @@ dependencies {
def viewPager2 = "1.0.0"
implementation "androidx.viewpager2:viewpager2:$viewPager2"

implementation 'com.ismaeldivita.chipnavigation:chip-navigation-bar:1.3.4'
// Required Library Dexter
implementation 'com.karumi:dexter:6.2.3'

// Shimmer
implementation 'com.facebook.shimmer:shimmer:0.5.0'


}
29 changes: 19 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/>


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".di.MeyApp"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ProjectCapstone">
Expand All @@ -36,17 +34,28 @@
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />

<activity android:name=".activity.tempt.TemplateLoginAndRegister"
<activity android:name=".activity.home.ListDetailScan"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />

<activity android:name=".activity.login.LoginActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.candra.projectcapstone"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_path"/>
</provider>

<activity android:name=".activity.register.RegisterActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
</application>

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
</queries>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@ package com.candra.projectcapstone.activity.home

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.candra.projectcapstone.R
import com.candra.projectcapstone.databinding.ActivityMainBinding
import com.candra.projectcapstone.fragment.HomeFragment
import com.candra.projectcapstone.fragment.MusicFragment
import com.candra.projectcapstone.helper.Helper
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
Helper.loadFragment(HomeFragment(),supportFragmentManager)
setBottomNavigation()
}

private fun setBottomNavigation(){
binding.bottomNavigation.setOnItemSelectedListener {
when(it.itemId){
R.id.home -> Helper.loadFragment(HomeFragment(),supportFragmentManager)
R.id.music -> Helper.loadFragment(MusicFragment(),supportFragmentManager)
}
return@setOnItemSelectedListener true
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.candra.projectcapstone.activity.onboarding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.candra.projectcapstone.activity.onboarding.screen.FragmentOne
import com.candra.projectcapstone.activity.onboarding.screen.FragmentThree
import com.candra.projectcapstone.activity.onboarding.screen.FragmentTwo
import com.candra.projectcapstone.databinding.FragmentViewPagerBinding

Expand All @@ -21,10 +19,9 @@ class ViewPagerActivity: AppCompatActivity()
}

private fun setFragment(){
val fragmentList = arrayListOf<Fragment>(
val fragmentList = arrayListOf(
FragmentOne(),
FragmentTwo(),
FragmentThree()
)

val adapterListFragment = ViewPagerAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.candra.projectcapstone.R
import com.candra.projectcapstone.databinding.FragmentScreenOneBinding
import com.candra.projectcapstone.helper.Helper
import com.candra.projectcapstone.helper.Helper.IMAGE_SCREEN_ONE
import com.candra.projectcapstone.helper.Helper.imageScreen
import com.candra.projectcapstone.helper.Helper.setCheckedData

class FragmentOne: Fragment()
{
Expand All @@ -37,11 +39,11 @@ class FragmentOne: Fragment()
}

btnSkipScreenOne.setOnClickListener {
Helper.toScreenHome(requireActivity())
Helper.setCheckedData(lifecycleScope,requireActivity())
Helper.toHomeScreen(requireActivity())
setCheckedData(lifecycleScope,requireActivity())
}

Helper.imageScreen(ivScreenOne,IMAGE_SCREEN_ONE)
imageScreen(ivScreenOne,IMAGE_SCREEN_ONE)
}
}

Expand Down
Loading

0 comments on commit 2733c69

Please sign in to comment.