Android Open Source - app_list_widget App Item






From Project

Back to project page app_list_widget.

License

The source code is released under:

Apache License

If you think the Android project app_list_widget 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 acbelter// w w  w . ja va  2 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.acbelter.applistwidget.ui;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

public class AppItem implements Parcelable, Comparable<AppItem> {
    private ApplicationInfo mAppInfo;
    private Drawable mIcon;
    private String mAppName;
    private String mPackageName;

    public AppItem(ApplicationInfo info, PackageManager pm) {
        mAppInfo = info;
        mIcon = mAppInfo.loadIcon(pm);
        mAppName = mAppInfo.loadLabel(pm).toString();
        mPackageName = mAppInfo.packageName;
    }

    private AppItem(Parcel in) {
        mAppInfo = in.readParcelable((((Object) this).getClass()).getClassLoader());
        Bitmap bitmap = in.readParcelable((((Object) this).getClass()).getClassLoader());
        mIcon = new BitmapDrawable(null, bitmap);
        mAppName = in.readString();
        mPackageName = in.readString();
    }

    public Drawable getIcon() {
        return mIcon;
    }

    public String getAppName() {
        return mAppName;
    }

    public String getPackageName() {
        return mPackageName;
    }

    public static final Parcelable.Creator<AppItem> CREATOR = new Parcelable.Creator<AppItem>() {
        @Override
        public AppItem createFromParcel(Parcel in) {
            return new AppItem(in);
        }

        @Override
        public AppItem[] newArray(int size) {
            return new AppItem[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeParcelable(mAppInfo, flags);
        Bitmap bitmap = ((BitmapDrawable) mIcon).getBitmap();
        out.writeParcelable(bitmap, flags);
        out.writeString(mAppName);
        out.writeString(mPackageName);
    }

    @Override
    public int compareTo(AppItem another) {
        return mAppName.compareTo(another.mAppName);
    }
}




Java Source Code List

com.acbelter.applistwidget.ui.AppItem.java
com.acbelter.applistwidget.ui.AppListOrderAdapter.java
com.acbelter.applistwidget.ui.AppListSelectAdapter.java
com.acbelter.applistwidget.ui.AppOrderFragment.java
com.acbelter.applistwidget.ui.AppSelectFragment.java
com.acbelter.applistwidget.ui.ConfigActivity.java
com.acbelter.applistwidget.ui.SeekBarPreference.java
com.acbelter.applistwidget.ui.SettingsActivity.java
com.acbelter.applistwidget.ui.SettingsFragment.java
com.acbelter.applistwidget.widget.AppListLargeWidgetProvider.java
com.acbelter.applistwidget.widget.AppListWidgetFactory.java
com.acbelter.applistwidget.widget.AppListWidgetProvider.java
com.acbelter.applistwidget.widget.AppListWidgetService.java
com.acbelter.applistwidget.widget.Pref.java