Home | History | Annotate | Download | only in data
      1 /*
      2  * Copyright (C) 2013 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.camera.data;
     18 
     19 import android.database.ContentObserver;
     20 
     21 /**
     22  * Listening to the changes to the local image and video data. onChange will
     23  * happen on the main thread.
     24  */
     25 public class LocalMediaObserver extends ContentObserver {
     26 
     27     private boolean mActivityPaused = false;
     28     private boolean mMediaDataChangedDuringPause = false;
     29 
     30     public LocalMediaObserver() {
     31         super(null);
     32     }
     33 
     34     /**
     35      * When the activity is paused and MediaObserver get onChange() call, then
     36      * we would like to set a dirty bit to reload the data at onResume().
     37      */
     38     @Override
     39     public void onChange(boolean selfChange) {
     40         if (mActivityPaused) {
     41             mMediaDataChangedDuringPause = true;
     42         }
     43     }
     44 
     45     public void setActivityPaused(boolean paused) {
     46         mActivityPaused = paused;
     47         if (!paused) {
     48             mMediaDataChangedDuringPause = false;
     49         }
     50     }
     51 
     52     public boolean isMediaDataChangedDuringPause() {
     53         return mMediaDataChangedDuringPause;
     54     }
     55 }
     56