• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.cts.verifier.widget;
18  
19  import android.content.Context;
20  import android.content.Intent;
21  import android.widget.RemoteViews;
22  import android.widget.RemoteViewsService;
23  
24  import com.android.cts.verifier.R;
25  
26  /**
27   * This is the service that provides the factory to be bound to the collection
28   * service.
29   */
30  public class WidgetCtsService extends RemoteViewsService {
31      public static final int NUM_ITEMS = 50;
32  
33      @Override
onGetViewFactory(Intent intent)34      public RemoteViewsFactory onGetViewFactory(Intent intent) {
35          return new CtsRemoteViewsFactory(this.getApplicationContext(), intent);
36      }
37  }
38  
39  /**
40   * This is the factory that will provide data to the collection widget.
41   */
42  class CtsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
43  
44      Context mContext;
45  
CtsRemoteViewsFactory(Context context, Intent intent)46      public CtsRemoteViewsFactory(Context context, Intent intent) {
47          mContext = context;
48      }
49  
onCreate()50      public void onCreate() {
51      }
52  
onDestroy()53      public void onDestroy() {
54      }
55  
getCount()56      public int getCount() {
57          return WidgetCtsService.NUM_ITEMS;
58      }
59  
getViewAt(int position)60      public RemoteViews getViewAt(int position) {
61          RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.list_item);
62          String text = "List Item " + (position + 1);
63          rv.setTextViewText(R.id.list_item_text, text);
64          return rv;
65      }
66  
getLoadingView()67      public RemoteViews getLoadingView() {
68          // We aren't going to return a default loading view in this sample
69          return null;
70      }
71  
getViewTypeCount()72      public int getViewTypeCount() {
73          // Technically, we have two types of views (the dark and light
74          // background views)
75          return 1;
76      }
77  
getItemId(int position)78      public long getItemId(int position) {
79          return position;
80      }
81  
hasStableIds()82      public boolean hasStableIds() {
83          return true;
84      }
85  
onDataSetChanged()86      public void onDataSetChanged() {
87      }
88  }
89