This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
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
1 parent
daed687
commit 8ab98af
Showing
58 changed files
with
1,407 additions
and
455 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
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
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 @@ | ||
# GOOGLE SAMPLE PACKAGING DATA | ||
# | ||
# This file is used by Google as part of our samples packaging process. | ||
# End users may safely ignore this file. It has no relevance to other systems. | ||
--- | ||
|
||
status: PUBLISHED | ||
technologies: [Android] | ||
categories: [UI] | ||
languages: [Kotlin] | ||
solutions: [Mobile] | ||
github: googlesamples/android-Navigation Drawer | ||
level: BEGINNER | ||
icon: Navigation DrawerSample/src/main/res/drawable-xxhdpi/ic_launcher.png | ||
license: apache2 |
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,35 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
defaultConfig { | ||
applicationId "com.example.android.navigationdrawer" | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
sourceSets { | ||
main { | ||
java.srcDirs "src/main/java" | ||
res.srcDirs "src/main/res" | ||
} | ||
androidTest.setRoot('tests') | ||
androidTest.java.srcDirs = ['tests/src'] | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibVersion" | ||
implementation "com.android.support:cardview-v7:$rootProject.ext.supportLibVersion" | ||
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibVersion" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion" | ||
} |
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,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright 2018 The Android Open Source Project | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.android.navigationdrawer"> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".NavigationDrawerActivity" | ||
android:label="@string/app_name" > | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
76 changes: 76 additions & 0 deletions
76
kotlinApp/Application/src/main/java/com/example/android/navigationdrawer/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,76 @@ | ||
/* | ||
* Copyright (C) 2018 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.android.navigationdrawer | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.AdapterView | ||
import android.widget.BaseAdapter | ||
import android.widget.GridView | ||
import android.widget.TextView | ||
|
||
/** | ||
* A simple launcher activity offering access to the individual samples in this project. | ||
*/ | ||
class MainActivity : Activity(), AdapterView.OnItemClickListener { | ||
|
||
private lateinit var samples: Array<Sample> | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
// Prepare list of samples in this dashboard. | ||
samples = arrayOf(Sample(R.string.navigationdraweractivity_title, | ||
R.string.navigationdraweractivity_description, | ||
Intent(this, NavigationDrawerActivity::class.java))) | ||
|
||
// Prepare the GridView. | ||
findViewById<GridView>(android.R.id.list).run { | ||
adapter = SampleAdapter() | ||
onItemClickListener = this@MainActivity | ||
} | ||
} | ||
|
||
override fun onItemClick(container: AdapterView<*>, view: View, position: Int, id: Long) { | ||
startActivity(samples[position].intent) | ||
} | ||
|
||
private inner class SampleAdapter : BaseAdapter() { | ||
|
||
override fun getCount() = samples.size | ||
|
||
override fun getItem(position: Int) = samples[position] | ||
|
||
override fun getItemId(position: Int) = samples[position].hashCode().toLong() | ||
|
||
override fun getView(position: Int, convertView: View?, container: ViewGroup): View { | ||
return (convertView ?: layoutInflater.inflate(R.layout.sample_dashboard_item, | ||
container, false)).apply { | ||
findViewById<TextView>(android.R.id.text1)?.setText( | ||
samples[position].titleResId) | ||
findViewById<TextView>(android.R.id.text2)?.setText( | ||
samples[position].descriptionResId) | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.