small optimization for ocfile
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / adapter / LandingScreenAdapter.java
index d14ac0f..914ed43 100644 (file)
-package eu.alefzero.owncloud.ui.adapter;
-
-import android.content.Context;
-import android.content.Intent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-import eu.alefzero.owncloud.R;
-import eu.alefzero.owncloud.ui.FileDisplayActivity;
-import eu.alefzero.owncloud.ui.Preferences;
-
-/**
- * Populates the landing screen icons.
- * @author Benutzer
- *
- */
-public class LandingScreenAdapter extends BaseAdapter {
-       
-       private Context mContext;
-
-       private final Integer[] mLandingScreenIcons = { R.drawable.home,
-                       R.drawable.music, R.drawable.contacts,
-                       R.drawable.calendar,
-                       android.R.drawable.ic_menu_agenda,
-                       R.drawable.settings };
-
-       private final Integer[] mLandingScreenTexts = { R.string.main_files,
-                       R.string.main_music, R.string.main_contacts,
-                       R.string.main_calendar, R.string.main_bookmarks,
-                       R.string.main_settings };
-
-       public LandingScreenAdapter(Context context) {
-               mContext = context;
-       }
-
-       @Override
-       public int getCount() {
-               return mLandingScreenIcons.length;
-       }
-
-       @Override
-       /**
-        * Returns the Intent associated with this object
-        * or null if the functionality is not yet implemented
-        */
-       public Object getItem(int position) {
-               Intent intent = new Intent();
-               switch (position) {
-               case 0:
-                       intent.setClass(mContext, FileDisplayActivity.class);
-                       break;
-               case 5:
-                       intent.setClass(mContext, Preferences.class);
-                       break;
-               default:
-                       intent = null;
-               }
-               return intent;
-       }
-
-       @Override
-       public long getItemId(int position) {
-               return position;
-       }
-
-       @Override
-       public View getView(int position, View convertView, ViewGroup parent) {
-               if (convertView == null) {
-                       LayoutInflater inflator = LayoutInflater.from(mContext);
-                       convertView = inflator
-                                       .inflate(R.layout.landing_page_item, null);
-
-                       ImageView icon = (ImageView) convertView
-                                       .findViewById(R.id.gridImage);
-                       TextView iconText = (TextView) convertView
-                                       .findViewById(R.id.gridText);
-
-                       icon.setImageResource(mLandingScreenIcons[position]);
-                       iconText.setText(mLandingScreenTexts[position]);
-               }
-               return convertView;
-       }
-
-}
+/* ownCloud Android client application\r
+ *   Copyright (C) 2011  Bartek Przybylski\r
+ *\r
+ *   This program is free software: you can redistribute it and/or modify\r
+ *   it under the terms of the GNU General Public License as published by\r
+ *   the Free Software Foundation, either version 3 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU General Public License\r
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ */\r
+package eu.alefzero.owncloud.ui.adapter;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.ViewGroup;\r
+import android.widget.BaseAdapter;\r
+import android.widget.ImageView;\r
+import android.widget.TextView;\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AuthUtils;\r
+import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
+import eu.alefzero.owncloud.ui.activity.Preferences;\r
+\r
+/**\r
+ * Populates the landing screen icons.\r
+ * @author Lennart Rosam\r
+ *\r
+ */\r
+public class LandingScreenAdapter extends BaseAdapter {\r
+       \r
+       private Context mContext;\r
+\r
+       private final Integer[] mLandingScreenIcons = { R.drawable.home,\r
+                       R.drawable.music, R.drawable.contacts,\r
+                       R.drawable.calendar,\r
+                       android.R.drawable.ic_menu_agenda,\r
+                       R.drawable.settings };\r
+\r
+       private final Integer[] mLandingScreenTexts = { R.string.main_files,\r
+                       R.string.main_music, R.string.main_contacts,\r
+                       R.string.main_calendar, R.string.main_bookmarks,\r
+                       R.string.main_settings };\r
+\r
+       public LandingScreenAdapter(Context context) {\r
+               mContext = context;\r
+       }\r
+\r
+       @Override\r
+       public int getCount() {\r
+               return mLandingScreenIcons.length;\r
+       }\r
+\r
+       @Override\r
+       /**\r
+        * Returns the Intent associated with this object\r
+        * or null if the functionality is not yet implemented\r
+        */\r
+       public Object getItem(int position) {\r
+               Intent intent = new Intent();\r
+               \r
+               switch (position) {\r
+               case 0:\r
+                       /* \r
+                        * The FileDisplayActivity requires the ownCloud account as an parcableExtra.\r
+                        * We will put in the one that is selected in the preferences\r
+                        */\r
+                       intent.setClass(mContext, FileDisplayActivity.class);   \r
+                       intent.putExtra("ACCOUNT", AuthUtils.getCurrentOwnCloudAccount(mContext));\r
+                       break;\r
+               case 5:\r
+                       intent.setClass(mContext, Preferences.class);\r
+                       break;\r
+               default:\r
+                       intent = null;\r
+               }\r
+               return intent;\r
+       }\r
+\r
+       @Override\r
+       public long getItemId(int position) {\r
+               return position;\r
+       }\r
+\r
+       @Override\r
+       public View getView(int position, View convertView, ViewGroup parent) {\r
+               if (convertView == null) {\r
+                       LayoutInflater inflator = LayoutInflater.from(mContext);\r
+                       convertView = inflator\r
+                                       .inflate(R.layout.landing_page_item, null);\r
+\r
+                       ImageView icon = (ImageView) convertView\r
+                                       .findViewById(R.id.gridImage);\r
+                       TextView iconText = (TextView) convertView\r
+                                       .findViewById(R.id.gridText);\r
+\r
+                       icon.setImageResource(mLandingScreenIcons[position]);\r
+                       iconText.setText(mLandingScreenTexts[position]);\r
+               }\r
+               return convertView;\r
+       }\r
+}\r