1 /* ownCloud Android client application 
   2  *   Copyright (C) 2011  Bartek Przybylski 
   3  *   Copyright (C) 2012-2013 ownCloud Inc. 
   5  *   This program is free software: you can redistribute it and/or modify 
   6  *   it under the terms of the GNU General Public License version 2, 
   7  *   as published by the Free Software Foundation. 
   9  *   This program is distributed in the hope that it will be useful, 
  10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
  11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  12  *   GNU General Public License for more details. 
  14  *   You should have received a copy of the GNU General Public License 
  15  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
  18 package de
.mobilcom
.debitel
.cloud
.android
.ui
.adapter
; 
  21 import android
.content
.Context
; 
  22 import android
.content
.Intent
; 
  23 import android
.view
.LayoutInflater
; 
  24 import android
.view
.View
; 
  25 import android
.view
.ViewGroup
; 
  26 import android
.widget
.BaseAdapter
; 
  27 import android
.widget
.ImageView
; 
  28 import android
.widget
.TextView
; 
  29 import de
.mobilcom
.debitel
.cloud
.android
.R
; 
  30 import de
.mobilcom
.debitel
.cloud
.android
.authentication
.AccountUtils
; 
  31 import de
.mobilcom
.debitel
.cloud
.android
.ui
.activity
.FileDisplayActivity
; 
  32 import de
.mobilcom
.debitel
.cloud
.android
.ui
.activity
.Preferences
; 
  35  * Populates the landing screen icons. 
  37  * @author Lennart Rosam 
  40 public class LandingScreenAdapter 
extends BaseAdapter 
{ 
  42     private Context mContext
; 
  44     private final Integer
[] mLandingScreenIcons 
= { R
.drawable
.home
, 
  45             R
.drawable
.music
, R
.drawable
.contacts
, R
.drawable
.calendar
, 
  46             android
.R
.drawable
.ic_menu_agenda
, R
.drawable
.settings 
}; 
  48     private final Integer
[] mLandingScreenTexts 
= { R
.string
.main_files
, 
  49             R
.string
.main_music
, R
.string
.main_contacts
, 
  50             R
.string
.main_calendar
, R
.string
.main_bookmarks
, 
  51             R
.string
.main_settings 
}; 
  53     public LandingScreenAdapter(Context context
) { 
  58     public int getCount() { 
  59         return mLandingScreenIcons
.length
; 
  64      * Returns the Intent associated with this object 
  65      * or null if the functionality is not yet implemented 
  67     public Object 
getItem(int position
) { 
  68         Intent intent 
= new Intent(); 
  73              * The FileDisplayActivity requires the ownCloud account as an 
  74              * parcableExtra. We will put in the one that is selected in the 
  77             intent
.setClass(mContext
, FileDisplayActivity
.class); 
  78             intent
.putExtra("ACCOUNT", 
  79                     AccountUtils
.getCurrentOwnCloudAccount(mContext
)); 
  80             intent
.addFlags(Intent
.FLAG_ACTIVITY_NEW_TASK
); 
  83             intent
.setClass(mContext
, Preferences
.class); 
  92     public long getItemId(int position
) { 
  97     public View 
getView(int position
, View convertView
, ViewGroup parent
) { 
  98         if (convertView 
== null
) { 
  99             LayoutInflater inflator 
= LayoutInflater
.from(mContext
); 
 100             convertView 
= inflator
.inflate(R
.layout
.landing_page_item
, null
); 
 102             ImageView icon 
= (ImageView
) convertView
 
 103                     .findViewById(R
.id
.gridImage
); 
 104             TextView iconText 
= (TextView
) convertView
 
 105                     .findViewById(R
.id
.gridText
); 
 107             icon
.setImageResource(mLandingScreenIcons
[position
]); 
 108             iconText
.setText(mLandingScreenTexts
[position
]);