Home | History | Annotate | Download | only in launcher2
      1 /*
      2  * Copyright (C) 2009 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.launcher2;
     18 
     19 import android.appwidget.AppWidgetHostView;
     20 import android.content.ContentValues;
     21 
     22 /**
     23  * Represents a widget, which just contains an identifier.
     24  */
     25 class LauncherAppWidgetInfo extends ItemInfo {
     26 
     27     /**
     28      * Identifier for this widget when talking with
     29      * {@link android.appwidget.AppWidgetManager} for updates.
     30      */
     31     int appWidgetId;
     32 
     33     /**
     34      * View that holds this widget after it's been created.  This view isn't created
     35      * until Launcher knows it's needed.
     36      */
     37     AppWidgetHostView hostView = null;
     38 
     39     LauncherAppWidgetInfo(int appWidgetId) {
     40         itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
     41         this.appWidgetId = appWidgetId;
     42     }
     43 
     44     @Override
     45     void onAddToDatabase(ContentValues values) {
     46         super.onAddToDatabase(values);
     47         values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
     48     }
     49 
     50     @Override
     51     public String toString() {
     52         return "AppWidget(id=" + Integer.toString(appWidgetId) + ")";
     53     }
     54 
     55 
     56     @Override
     57     void unbind() {
     58         super.unbind();
     59         hostView = null;
     60     }
     61 }
     62