Android Open Source - HomeSwipeManager Apps Array Adapter






From Project

Back to project page HomeSwipeManager.

License

The source code is released under:

Apache License

If you think the Android project HomeSwipeManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* Copyright 2013 Andrea De Cesare
*//  w  w w .  jav a2  s .com
* 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.andreadec.homeswipemanager;

import java.util.*;
import android.content.*;
import android.view.*;
import android.widget.*;

public class AppsArrayAdapter extends ArrayAdapter<App> {
  private final Context context;
  private final ArrayList<App> apps;

  public AppsArrayAdapter(Context context, ArrayList<App> apps) {
    super(context, R.layout.app_list_item, apps);
    this.context = context;
    this.apps = apps;
  }

  @Override
  public View getView(int position, View view, ViewGroup parent) {
    return generateView(position, view, parent);
  }
  
  @Override
  public View getDropDownView(int position, View view, ViewGroup parent) {
    return generateView(position, view, parent);
  }
  
  private View generateView(int position, View view, ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(context);
    view = inflater.inflate(R.layout.app_list_item, parent, false);
    TextView textViewLabel = (TextView)view.findViewById(R.id.textViewLabel);
    ImageView imageViewIcon = (ImageView)view.findViewById(R.id.imageViewIcon);
    App app = apps.get(position);
    textViewLabel.setText(app.label);
    imageViewIcon.setImageDrawable(app.icon);
    return view;
  }
  
  public ArrayList<App> getItems() {
    return apps;
  }
}




Java Source Code List

com.andreadec.homeswipemanager.Action.java
com.andreadec.homeswipemanager.App.java
com.andreadec.homeswipemanager.AppsArrayAdapter.java
com.andreadec.homeswipemanager.HomeSwipeManagerApp.java
com.andreadec.homeswipemanager.MainActivity.java
com.andreadec.homeswipemanager.SettingsActivity.java