1*90c8c64dSAndroid Build Coastguard Worker /* 2*90c8c64dSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 3*90c8c64dSAndroid Build Coastguard Worker * 4*90c8c64dSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*90c8c64dSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*90c8c64dSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*90c8c64dSAndroid Build Coastguard Worker * 8*90c8c64dSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*90c8c64dSAndroid Build Coastguard Worker * 10*90c8c64dSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*90c8c64dSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*90c8c64dSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*90c8c64dSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*90c8c64dSAndroid Build Coastguard Worker * limitations under the License. 15*90c8c64dSAndroid Build Coastguard Worker */ 16*90c8c64dSAndroid Build Coastguard Worker 17*90c8c64dSAndroid Build Coastguard Worker package com.example.android.lnotifications; 18*90c8c64dSAndroid Build Coastguard Worker 19*90c8c64dSAndroid Build Coastguard Worker import android.os.Bundle; 20*90c8c64dSAndroid Build Coastguard Worker import android.support.design.widget.TabLayout; 21*90c8c64dSAndroid Build Coastguard Worker import android.support.v4.app.Fragment; 22*90c8c64dSAndroid Build Coastguard Worker import android.support.v4.app.FragmentActivity; 23*90c8c64dSAndroid Build Coastguard Worker import android.support.v4.app.FragmentManager; 24*90c8c64dSAndroid Build Coastguard Worker import android.support.v4.app.FragmentPagerAdapter; 25*90c8c64dSAndroid Build Coastguard Worker import android.support.v4.view.ViewPager; 26*90c8c64dSAndroid Build Coastguard Worker 27*90c8c64dSAndroid Build Coastguard Worker import static com.example.android.lnotifications.R.id.pager; 28*90c8c64dSAndroid Build Coastguard Worker 29*90c8c64dSAndroid Build Coastguard Worker /** 30*90c8c64dSAndroid Build Coastguard Worker * Launcher Activity for the L Notification samples application. 31*90c8c64dSAndroid Build Coastguard Worker */ 32*90c8c64dSAndroid Build Coastguard Worker public class LNotificationActivity extends FragmentActivity { 33*90c8c64dSAndroid Build Coastguard Worker 34*90c8c64dSAndroid Build Coastguard Worker @Override onCreate(Bundle savedInstanceState)35*90c8c64dSAndroid Build Coastguard Worker protected void onCreate(Bundle savedInstanceState) { 36*90c8c64dSAndroid Build Coastguard Worker super.onCreate(savedInstanceState); 37*90c8c64dSAndroid Build Coastguard Worker setContentView(R.layout.activity_notification); 38*90c8c64dSAndroid Build Coastguard Worker 39*90c8c64dSAndroid Build Coastguard Worker // Show 3 tabs with the different notification options. 40*90c8c64dSAndroid Build Coastguard Worker ViewPager viewPager = (ViewPager) findViewById(pager); 41*90c8c64dSAndroid Build Coastguard Worker TabLayout tabs = (TabLayout) findViewById(R.id.tabs); 42*90c8c64dSAndroid Build Coastguard Worker 43*90c8c64dSAndroid Build Coastguard Worker NotificationsPagerAdapter pagerAdapter = 44*90c8c64dSAndroid Build Coastguard Worker new NotificationsPagerAdapter(getSupportFragmentManager()); 45*90c8c64dSAndroid Build Coastguard Worker viewPager.setAdapter(pagerAdapter); 46*90c8c64dSAndroid Build Coastguard Worker tabs.setupWithViewPager(viewPager); 47*90c8c64dSAndroid Build Coastguard Worker } 48*90c8c64dSAndroid Build Coastguard Worker 49*90c8c64dSAndroid Build Coastguard Worker private static class NotificationsPagerAdapter extends FragmentPagerAdapter { 50*90c8c64dSAndroid Build Coastguard Worker NotificationsPagerAdapter(FragmentManager fm)51*90c8c64dSAndroid Build Coastguard Worker NotificationsPagerAdapter(FragmentManager fm) { 52*90c8c64dSAndroid Build Coastguard Worker super(fm); 53*90c8c64dSAndroid Build Coastguard Worker } 54*90c8c64dSAndroid Build Coastguard Worker 55*90c8c64dSAndroid Build Coastguard Worker @Override getItem(int position)56*90c8c64dSAndroid Build Coastguard Worker public Fragment getItem(int position) { 57*90c8c64dSAndroid Build Coastguard Worker switch (position) { 58*90c8c64dSAndroid Build Coastguard Worker case 0: 59*90c8c64dSAndroid Build Coastguard Worker return HeadsUpNotificationFragment.newInstance(); 60*90c8c64dSAndroid Build Coastguard Worker case 1: 61*90c8c64dSAndroid Build Coastguard Worker return VisibilityMetadataFragment.newInstance(); 62*90c8c64dSAndroid Build Coastguard Worker case 2: 63*90c8c64dSAndroid Build Coastguard Worker return OtherMetadataFragment.newInstance(); 64*90c8c64dSAndroid Build Coastguard Worker default: 65*90c8c64dSAndroid Build Coastguard Worker break; 66*90c8c64dSAndroid Build Coastguard Worker } 67*90c8c64dSAndroid Build Coastguard Worker return null; 68*90c8c64dSAndroid Build Coastguard Worker } 69*90c8c64dSAndroid Build Coastguard Worker 70*90c8c64dSAndroid Build Coastguard Worker @Override getCount()71*90c8c64dSAndroid Build Coastguard Worker public int getCount() { 72*90c8c64dSAndroid Build Coastguard Worker return 3; 73*90c8c64dSAndroid Build Coastguard Worker } 74*90c8c64dSAndroid Build Coastguard Worker 75*90c8c64dSAndroid Build Coastguard Worker @Override getPageTitle(int position)76*90c8c64dSAndroid Build Coastguard Worker public CharSequence getPageTitle(int position) { 77*90c8c64dSAndroid Build Coastguard Worker switch (position) { 78*90c8c64dSAndroid Build Coastguard Worker case 0: 79*90c8c64dSAndroid Build Coastguard Worker return "Heads Up"; 80*90c8c64dSAndroid Build Coastguard Worker case 1: 81*90c8c64dSAndroid Build Coastguard Worker return "Visibility"; 82*90c8c64dSAndroid Build Coastguard Worker case 2: 83*90c8c64dSAndroid Build Coastguard Worker return "Others"; 84*90c8c64dSAndroid Build Coastguard Worker default: 85*90c8c64dSAndroid Build Coastguard Worker return super.getPageTitle(position); 86*90c8c64dSAndroid Build Coastguard Worker } 87*90c8c64dSAndroid Build Coastguard Worker } 88*90c8c64dSAndroid Build Coastguard Worker } 89*90c8c64dSAndroid Build Coastguard Worker } 90