Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Add back navigation from the ActionBar
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Mar 13, 2016
1 parent 7b5f6a1 commit d52d4f4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
21 changes: 15 additions & 6 deletions kolumbus/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<manifest
package="io.kolumbus"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.kolumbus">

<application>
<activity
android:name=".activity.TableActivity"
android:theme="@style/kolumbus_Theme"/>
android:parentActivityName=".activity.TablesActivity"
android:theme="@style/kolumbus_Theme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.TablesActivity" />
</activity>

<activity
android:name=".activity.TableInfoActivity"
android:theme="@style/kolumbus_Theme"/>
android:parentActivityName=".activity.TableActivity"
android:theme="@style/kolumbus_Theme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.TableActivity" />
</activity>

<activity
android:name=".activity.TablesActivity"
android:label="@string/kolumbus_tables_list"
android:theme="@style/kolumbus_Theme"/>
android:theme="@style/kolumbus_Theme" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class TableActivity : AppCompatActivity() {

this.setContentView(R.layout.kolumbus_activity_table)

this.supportActionBar?.setDisplayHomeAsUpEnabled(true)

this.empty = this.findViewById(android.R.id.empty) as TextView?
this.scroll = this.findViewById(R.id.scroll) as ScrollView?
this.table = this.findViewById(R.id.table) as TableLayout?
Expand All @@ -99,6 +101,12 @@ class TableActivity : AppCompatActivity() {
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
if (item?.itemId == android.R.id.home) {
this.onBackPressed()

return true
}

if (item?.itemId == R.id.menu_clear_table) {
AlertDialog.Builder(this)
.setMessage(this.getString(R.string.kolumbus_clear_table_confirm, this.tableClass?.simpleName))
Expand Down
13 changes: 13 additions & 0 deletions kolumbus/src/main/kotlin/io/kolumbus/activity/TableInfoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.MenuItem
import io.kolumbus.BuildConfig
import io.kolumbus.R
import io.kolumbus.adapter.TableInfoAdapter
Expand Down Expand Up @@ -49,6 +50,8 @@ class TableInfoActivity : AppCompatActivity() {

this.setContentView(R.layout.kolumbus_activity_table_info)

this.supportActionBar?.setDisplayHomeAsUpEnabled(true)

val recyclerView = this.findViewById(android.R.id.list) as RecyclerView?
val tableClass = this.intent.getSerializableExtra(EXTRA_TABLE_CLASS) as Class<out RealmObject>

Expand All @@ -71,4 +74,14 @@ class TableInfoActivity : AppCompatActivity() {
recyclerView.layoutManager = LinearLayoutManager(this)
}
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
if (item?.itemId == android.R.id.home) {
this.onBackPressed()

return true
}

return super.onOptionsItemSelected(item)
}
}

0 comments on commit d52d4f4

Please sign in to comment.