• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.android.dialer.callcomposer;
18 
19 import android.support.v4.app.Fragment;
20 import android.support.v4.app.FragmentManager;
21 import android.support.v4.app.FragmentPagerAdapter;
22 import com.android.dialer.common.Assert;
23 
24 /** ViewPager adapter for call compose UI. */
25 public class CallComposerPagerAdapter extends FragmentPagerAdapter {
26 
27   public static final int INDEX_CAMERA = 0;
28   public static final int INDEX_GALLERY = 1;
29   public static final int INDEX_MESSAGE = 2;
30 
31   private final int messageComposerCharLimit;
32 
CallComposerPagerAdapter(FragmentManager fragmentManager, int messageComposerCharLimit)33   public CallComposerPagerAdapter(FragmentManager fragmentManager, int messageComposerCharLimit) {
34     super(fragmentManager);
35     this.messageComposerCharLimit = messageComposerCharLimit;
36   }
37 
38   @Override
getItem(int position)39   public Fragment getItem(int position) {
40     switch (position) {
41       case INDEX_MESSAGE:
42         return MessageComposerFragment.newInstance(messageComposerCharLimit);
43       case INDEX_GALLERY:
44         return GalleryComposerFragment.newInstance();
45       case INDEX_CAMERA:
46         return new CameraComposerFragment();
47       default:
48         Assert.fail();
49         return null;
50     }
51   }
52 
53   @Override
getCount()54   public int getCount() {
55     return 3;
56   }
57 }
58