Home | History | Annotate | Download | only in pdfrendererbasic
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.example.android.pdfrendererbasic
     18 
     19 import android.app.AlertDialog
     20 import android.os.Bundle
     21 import android.support.v7.app.AppCompatActivity
     22 import android.view.Menu
     23 import android.view.MenuItem
     24 
     25 val FRAGMENT_PDF_RENDERER_BASIC = "pdf_renderer_basic"
     26 
     27 class MainActivity : AppCompatActivity() {
     28 
     29 
     30     override fun onCreate(savedInstanceState: Bundle?) {
     31         super.onCreate(savedInstanceState)
     32         setContentView(R.layout.activity_main_real)
     33         if (savedInstanceState == null) {
     34             supportFragmentManager.beginTransaction()
     35                     .add(R.id.container, PdfRendererBasicFragment(), FRAGMENT_PDF_RENDERER_BASIC)
     36                     .commit()
     37         }
     38     }
     39 
     40     override fun onCreateOptionsMenu(menu: Menu): Boolean {
     41         menuInflater.inflate(R.menu.main, menu)
     42         return true
     43     }
     44 
     45     override fun onOptionsItemSelected(item: MenuItem): Boolean {
     46         return when (item.itemId) {
     47             R.id.action_info -> {
     48                 AlertDialog.Builder(this)
     49                         .setMessage(R.string.intro_message)
     50                         .setPositiveButton(android.R.string.ok, null)
     51                         .show()
     52                 return true
     53             }
     54             else -> super.onOptionsItemSelected(item)
     55         }
     56     }
     57 
     58 }
     59