Home | History | Annotate | Download | only in calllog
      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.calllog;
     18 
     19 import android.database.ContentObserver;
     20 import android.os.Bundle;
     21 import android.provider.CallLog;
     22 import android.provider.VoicemailContract;
     23 import android.support.v7.widget.LinearLayoutManager;
     24 import android.support.v7.widget.RecyclerView;
     25 import android.view.LayoutInflater;
     26 import android.view.View;
     27 import android.view.ViewGroup;
     28 
     29 import com.android.dialer.R;
     30 import com.android.dialer.list.ListsFragment;
     31 import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
     32 
     33 public class VisualVoicemailCallLogFragment extends CallLogFragment {
     34 
     35     private VoicemailPlaybackPresenter mVoicemailPlaybackPresenter;
     36     private final ContentObserver mVoicemailStatusObserver = new CustomContentObserver();
     37 
     38     public VisualVoicemailCallLogFragment() {
     39         super(CallLog.Calls.VOICEMAIL_TYPE);
     40     }
     41 
     42     @Override
     43     public void onCreate(Bundle state) {
     44         super.onCreate(state);
     45         mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter.getInstance(getActivity(), state);
     46         getActivity().getContentResolver().registerContentObserver(
     47                 VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver);
     48     }
     49 
     50     @Override
     51     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
     52         View view = inflater.inflate(R.layout.call_log_fragment, container, false);
     53         setupView(view, mVoicemailPlaybackPresenter);
     54         return view;
     55     }
     56 
     57     @Override
     58     public void onResume() {
     59         super.onResume();
     60         mVoicemailPlaybackPresenter.onResume();
     61     }
     62 
     63     @Override
     64     public void onPause() {
     65         mVoicemailPlaybackPresenter.onPause();
     66         super.onPause();
     67     }
     68 
     69     @Override
     70     public void onDestroy() {
     71         mVoicemailPlaybackPresenter.onDestroy();
     72         getActivity().getContentResolver().unregisterContentObserver(mVoicemailStatusObserver);
     73         super.onDestroy();
     74     }
     75 
     76     @Override
     77     public void onSaveInstanceState(Bundle outState) {
     78         super.onSaveInstanceState(outState);
     79         mVoicemailPlaybackPresenter.onSaveInstanceState(outState);
     80     }
     81 
     82     @Override
     83     public void fetchCalls() {
     84         super.fetchCalls();
     85         ((ListsFragment) getParentFragment()).updateTabUnreadCounts();
     86     }
     87 }
     88