-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement module feature abstraction
- Loading branch information
0 parents
commit 3096f22
Showing
125 changed files
with
1,791 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,14 @@ | ||
*.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 |
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.
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,37 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
apply from: "$rootDir/build-system/dependencies-feature-generator.gradle" | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.wisnu.ordertiket" | ||
minSdkVersion 19 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
project.config.each { module -> | ||
project.dependencies.add("implementation", project(":${module}")) | ||
} | ||
|
||
implementation project(':launcher:main') | ||
|
||
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.0.2' | ||
implementation "androidx.cardview:cardview:1.0.0" | ||
implementation 'androidx.core:core-ktx:1.0.2' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation "androidx.recyclerview:recyclerview:1.1.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 |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.wisnu.ordertiket"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
android:name=".MainApplication"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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,29 @@ | ||
package com.wisnu.ordertiket | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.recyclerview.widget.GridLayoutManager | ||
import com.wisnu.launcher.main.Launcher | ||
import com.wisnu.ordertiket.recyclerview.FeatureAdapter | ||
import com.wisnu.ordertiket.recyclerview.FeatureUiModel | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val features = (applicationContext as? Launcher.Provider)?.launcher?.features | ||
val featureUiModels = features?.map { FeatureUiModel(it.type, getString(it.title()), it.icon(), it.intent()) } ?: listOf() | ||
val adapter = FeatureAdapter(featureUiModels) { | ||
startActivity(it) | ||
} | ||
val layoutManager = GridLayoutManager(this, 3) | ||
rv_feature.layoutManager = layoutManager | ||
rv_feature.adapter = adapter | ||
rv_feature.setHasFixedSize(true) | ||
} | ||
} |
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,14 @@ | ||
package com.wisnu.ordertiket | ||
|
||
import android.app.Application | ||
import com.wisnu.launcher.main.Launcher | ||
|
||
class MainApplication : Application(), Launcher.Provider { | ||
override lateinit var launcher: Launcher | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
launcher = MainLauncher(this) | ||
launcher.onCreate() | ||
} | ||
} |
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,19 @@ | ||
package com.wisnu.ordertiket | ||
|
||
import android.app.Application | ||
import com.wisnu.feature.order.flight.OrderFlightFeatureApplication | ||
import com.wisnu.feature.order.hotel.OrderHotelFeatureApplication | ||
import com.wisnu.feature.order.train.OrderTrainFeatureApplication | ||
import com.wisnu.feature.setting.SettingFeatureApplication | ||
import com.wisnu.feature.transaction.TransactionFeatureApplication | ||
import com.wisnu.launcher.main.BaseLauncher | ||
|
||
class MainLauncher(application: Application) : BaseLauncher(application) { | ||
init { | ||
registerFeatureApplication(OrderFlightFeatureApplication()) | ||
registerFeatureApplication(OrderHotelFeatureApplication()) | ||
registerFeatureApplication(OrderTrainFeatureApplication()) | ||
registerFeatureApplication(TransactionFeatureApplication()) | ||
registerFeatureApplication(SettingFeatureApplication()) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/wisnu/ordertiket/recyclerview/FeatureAdapter.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.wisnu.ordertiket.recyclerview | ||
|
||
import android.content.Intent | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.wisnu.ordertiket.R | ||
|
||
class FeatureAdapter( | ||
private val items: List<FeatureUiModel>, | ||
private val onClick: (Intent) -> Unit | ||
) : RecyclerView.Adapter<FeatureViewHolder>() { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FeatureViewHolder { | ||
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.view_feature_item, parent, false) | ||
return FeatureViewHolder(itemView, onClick) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return items.size | ||
} | ||
|
||
override fun onBindViewHolder(holder: FeatureViewHolder, position: Int) { | ||
holder.bindData(items[position]) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/wisnu/ordertiket/recyclerview/FeatureUiModel.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,10 @@ | ||
package com.wisnu.ordertiket.recyclerview | ||
|
||
import android.content.Intent | ||
|
||
data class FeatureUiModel( | ||
val type: Int, | ||
val title: String, | ||
val icon: Int, | ||
val intent: Intent? | ||
) |
Oops, something went wrong.