-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ca3db8b
Showing
44 changed files
with
1,327 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,43 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android-extensions' | ||
id 'kotlin-android' | ||
id 'kotlin-kapt' | ||
} | ||
|
||
android { | ||
compileSdk 32 | ||
|
||
defaultConfig { | ||
applicationId "com.azhar.sortnfilter" | ||
minSdk 21 | ||
targetSdk 32 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.10" | ||
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'androidx.appcompat:appcompat:1.4.1' | ||
implementation 'com.google.android.material:material:1.5.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
22 changes: 22 additions & 0 deletions
22
app/src/androidTest/java/com/azhar/sortnfilter/ExampleInstrumentedTest.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,22 @@ | ||
package com.azhar.sortnfilter | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see [Testing documentation](http://d.android.com/tools/testing) | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
Assert.assertEquals("com.azhar.sortnfilter", appContext.packageName) | ||
} | ||
} |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.azhar.sortnfilter"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.SortFilterRecyclerView" | ||
android:usesCleartextTraffic="true" | ||
tools:targetApi="s"> | ||
<activity | ||
android:name=".main.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/azhar/sortnfilter/adapter/MainAdapter.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,46 @@ | ||
package com.azhar.sortnfilter.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.azhar.sortnfilter.R | ||
import com.azhar.sortnfilter.model.ModelMain | ||
import kotlinx.android.synthetic.main.list_item_main.view.* | ||
|
||
/** | ||
* Created by Azhar Rivaldi on 04-02-2022 | ||
* Youtube Channel : https://bit.ly/2PJMowZ | ||
* Github : https://github.com/AzharRivaldi | ||
* Twitter : https://twitter.com/azharrvldi_ | ||
* Instagram : https://www.instagram.com/azhardvls_ | ||
* LinkedIn : https://www.linkedin.com/in/azhar-rivaldi | ||
*/ | ||
|
||
class MainAdapter(var modelPenugasanList: List<ModelMain>) : RecyclerView.Adapter<MainAdapter.ViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_main, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val data = modelPenugasanList[position] | ||
|
||
holder.tvRadius.text = data.strRadius | ||
holder.tvNama.text = data.strNama | ||
holder.tvDetail.text = data.strDetail | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return modelPenugasanList.size | ||
} | ||
|
||
internal class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
var tvRadius: TextView = itemView.tvRadius | ||
var tvNama: TextView = itemView.tvNama | ||
var tvDetail: TextView = itemView.tvDetail | ||
} | ||
|
||
} |
106 changes: 106 additions & 0 deletions
106
app/src/main/java/com/azhar/sortnfilter/main/MainActivity.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,106 @@ | ||
package com.azhar.sortnfilter.main | ||
|
||
import android.os.Bundle | ||
import android.widget.CompoundButton | ||
import android.widget.RadioButton | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.azhar.sortnfilter.R | ||
import com.azhar.sortnfilter.adapter.MainAdapter | ||
import com.azhar.sortnfilter.model.ModelMain | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
import java.util.* | ||
|
||
class MainActivity : AppCompatActivity() { | ||
var modelMainList: MutableList<ModelMain> = ArrayList() | ||
lateinit var modelMain: ModelMain | ||
lateinit var mainAdapter: MainAdapter | ||
lateinit var bottomSheetDialog: BottomSheetDialog | ||
lateinit var cbAZ: RadioButton | ||
lateinit var cbZA: RadioButton | ||
lateinit var cbTerdekat: RadioButton | ||
lateinit var cbTerjauh: RadioButton | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
rvListData.setHasFixedSize(true) | ||
rvListData.setLayoutManager(LinearLayoutManager(this)) | ||
|
||
getListData() | ||
setFilterData() | ||
} | ||
|
||
private fun getListData() { | ||
modelMain = ModelMain("7", "Ariel Tatum", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("1", "Cinta Laura", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("5", "Anya Geraldine", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("9", "Maudy Ayunda", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("4", "Nabilah JKT48", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("8", "Jessica Jane", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("10", "Vivi Novika", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("2", "N Lidyawati", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("3", "Cindy Yuvia", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
modelMain = ModelMain("6", "Babyla", "Testing data buat penugasan") | ||
modelMainList.add(modelMain) | ||
|
||
mainAdapter = MainAdapter(modelMainList) | ||
rvListData.adapter = mainAdapter | ||
} | ||
|
||
private fun setFilterData() { | ||
fabFilter.setOnClickListener { | ||
val dialogView = layoutInflater.inflate(R.layout.bottom_sheet_filter, null) | ||
|
||
cbAZ = dialogView.findViewById(R.id.cbAZ) | ||
cbZA = dialogView.findViewById(R.id.cbZA) | ||
cbTerdekat = dialogView.findViewById(R.id.cbTerdekat) | ||
cbTerjauh = dialogView.findViewById(R.id.cbTerjauh) | ||
|
||
bottomSheetDialog = BottomSheetDialog(this@MainActivity) | ||
bottomSheetDialog.setContentView(dialogView) | ||
bottomSheetDialog.show() | ||
|
||
cbAZ.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> | ||
if (isChecked) { | ||
Collections.sort(modelMainList, ModelMain.sortByNameAZ) | ||
mainAdapter.notifyDataSetChanged() | ||
} | ||
} | ||
|
||
cbZA.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> | ||
if (isChecked) { | ||
Collections.sort(modelMainList, ModelMain.sortByNameZA) | ||
mainAdapter.notifyDataSetChanged() | ||
} | ||
} | ||
|
||
cbTerdekat.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> | ||
if (isChecked) { | ||
Collections.sort(modelMainList, ModelMain.sortByAscRadius) | ||
mainAdapter.notifyDataSetChanged() | ||
} | ||
} | ||
|
||
cbTerjauh.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> | ||
if (isChecked) { | ||
Collections.sort(modelMainList, ModelMain.sortByDescRadius) | ||
mainAdapter.notifyDataSetChanged() | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/azhar/sortnfilter/model/ModelMain.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,25 @@ | ||
package com.azhar.sortnfilter.model | ||
|
||
/** | ||
* Created by Azhar Rivaldi on 04-02-2022 | ||
* Youtube Channel : https://bit.ly/2PJMowZ | ||
* Github : https://github.com/AzharRivaldi | ||
* Twitter : https://twitter.com/azharrvldi_ | ||
* Instagram : https://www.instagram.com/azhardvls_ | ||
* LinkedIn : https://www.linkedin.com/in/azhar-rivaldi | ||
*/ | ||
|
||
class ModelMain(var strRadius: String, var strNama: String, var strDetail: String) { | ||
|
||
companion object { | ||
|
||
var sortByAscRadius = Comparator<ModelMain> { o1, o2 -> o1.strRadius.toInt() - o2.strRadius.toInt() } | ||
|
||
var sortByDescRadius = Comparator<ModelMain> { o1, o2 -> o2.strRadius.toInt() - o1.strRadius.toInt() } | ||
|
||
var sortByNameAZ = Comparator<ModelMain> { o1, o2 -> o1.strNama.compareTo(o2.strNama) } | ||
|
||
var sortByNameZA = Comparator<ModelMain> { o1, o2 -> o2.strNama.compareTo(o1.strNama) } | ||
} | ||
|
||
} |
Oops, something went wrong.