• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 package com.android.car.dialer.ui.calllog;
17 
18 import android.os.Bundle;
19 import android.view.View;
20 
21 import androidx.annotation.NonNull;
22 import androidx.annotation.Nullable;
23 import androidx.fragment.app.Fragment;
24 import androidx.lifecycle.ViewModelProviders;
25 
26 import com.android.car.dialer.ui.common.DialerListBaseFragment;
27 import com.android.car.dialer.ui.contact.ContactDetailsFragment;
28 import com.android.car.telephony.common.Contact;
29 
30 /** Fragment for call history page. */
31 public class CallHistoryFragment extends DialerListBaseFragment implements
32         CallLogAdapter.OnShowContactDetailListener {
33     private static final String CONTACT_DETAIL_FRAGMENT_TAG = "CONTACT_DETAIL_FRAGMENT_TAG";
34 
newInstance()35     public static CallHistoryFragment newInstance() {
36         return new CallHistoryFragment();
37     }
38 
39     @Override
onViewCreated(@onNull View view, @Nullable Bundle savedInstanceState)40     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
41         CallLogAdapter callLogAdapter = new CallLogAdapter(
42                 getContext(), /* onShowContactDetailListener= */this);
43         getRecyclerView().setAdapter(callLogAdapter);
44 
45         CallHistoryViewModel viewModel = ViewModelProviders.of(this).get(
46                 CallHistoryViewModel.class);
47 
48         viewModel.getCallHistory().observe(this, callLogAdapter::setUiCallLogs);
49     }
50 
51     @Override
onShowContactDetail(Contact contact)52     public void onShowContactDetail(Contact contact) {
53         Fragment contactDetailsFragment = ContactDetailsFragment.newInstance(contact);
54         pushContentFragment(contactDetailsFragment, CONTACT_DETAIL_FRAGMENT_TAG);
55     }
56 }
57