diff options
author | Mick Lin <Mick.Lin@mediatek.com> | 2014-09-11 16:36:08 +0800 |
---|---|---|
committer | PauloftheWest <paulofthewest@google.com> | 2014-10-01 13:56:36 -0700 |
commit | 97850c066b3eccdabecdd5f424735883661c12ed (patch) | |
tree | a160093fbd5b73358f29908da0a66fad5b67b7a5 /core/java/com/android/internal/widget/AccountViewAdapter.java | |
parent | d480147f1853e452e7e8fc4820db0e7821488289 (diff) | |
download | frameworks_base-97850c066b3eccdabecdd5f424735883661c12ed.zip frameworks_base-97850c066b3eccdabecdd5f424735883661c12ed.tar.gz frameworks_base-97850c066b3eccdabecdd5f424735883661c12ed.tar.bz2 |
[DS] DSDS support for widget view
Change-Id: If8b8410eb3cc471933f0b109973ea1f43fe5e791
Diffstat (limited to 'core/java/com/android/internal/widget/AccountViewAdapter.java')
-rw-r--r-- | core/java/com/android/internal/widget/AccountViewAdapter.java | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/core/java/com/android/internal/widget/AccountViewAdapter.java b/core/java/com/android/internal/widget/AccountViewAdapter.java new file mode 100644 index 0000000..8a7a9a6 --- /dev/null +++ b/core/java/com/android/internal/widget/AccountViewAdapter.java @@ -0,0 +1,127 @@ +/* +* Copyright (C) 2011-2014 The Android Open Source Project. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.android.internal.widget; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; + +import java.util.List; + +public class AccountViewAdapter extends BaseAdapter { + + private List<AccountElements> mData; + private Context mContext; + + /** + * Constructor + * + * @param context The context where the View associated with this Adapter is running + * @param data A list with AccountElements data type. The list contains the data of each + * account and the each member of AccountElements will correspond to one item view. + */ + public AccountViewAdapter(Context context, final List<AccountElements> data) { + mContext = context; + mData = data; + } + + @Override + public int getCount() { + return mData.size(); + } + + @Override + public Object getItem(int position) { + return mData.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + public void updateData(final List<AccountElements> data) { + mData = data; + notifyDataSetChanged(); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + AccountItemView view; + if (convertView == null) { + view = new AccountItemView(mContext); + } else { + view = (AccountItemView) convertView; + } + AccountElements elements = (AccountElements) getItem(position); + view.setViewItem(elements); + return view; + } + + public static class AccountElements { + private int mIcon; + private Drawable mDrawable; + private String mName; + private String mNumber; + + /** + * Constructor + * A structure with basic element of an Account, icon, name and number + * + * @param icon Account icon id + * @param name Account name + * @param num Account number + */ + public AccountElements(int icon, String name, String number) { + this(icon, null, name, number); + } + + /** + * Constructor + * A structure with basic element of an Account, drawable, name and number + * + * @param drawable Account drawable + * @param name Account name + * @param num Account number + */ + public AccountElements(Drawable drawable, String name, String number) { + this(0, drawable, name, number); + } + + private AccountElements(int icon, Drawable drawable, String name, String number) { + mIcon = icon; + mDrawable = drawable; + mName = name; + mNumber = number; + } + + public int getIcon() { + return mIcon; + } + public String getName() { + return mName; + } + public String getNumber() { + return mNumber; + } + public Drawable getDrawable() { + return mDrawable; + } + } +} |