Search in sources :

Example 16 with Context

use of android.content.Context in project detective-droid by michaelcarrano.

the class DetectorAsyncTask method detect.

/**
     * Detects all libraries by trying to load the pattern classpath in a given Application
     */
private static AppSource detect(PackageInfo pkg) {
    ArrayList<Library> libraries = new ArrayList<Library>();
    // Loop through known libraries
    for (Library library : Libraries.getInstance().getLibraries()) {
        try {
            Context ctx = mContext.createPackageContext(pkg.packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
            Class<?> clazz = Class.forName(library.getPath(), false, ctx.getClassLoader());
            // Detected a library!!!
            if (clazz != null) {
                libraries.add(library);
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    // Only return AppSource if app has a library
    return libraries.size() > 0 ? new AppSource(pkg, libraries) : null;
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) Library(com.michaelcarrano.detectivedroid.model.Library) AppSource(com.michaelcarrano.detectivedroid.model.AppSource)

Example 17 with Context

use of android.content.Context in project FastAdapter by mikepenz.

the class HeaderSelectionItem method bindView.

@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
    super.bindView(viewHolder, payloads);
    //get the context
    Context ctx = viewHolder.itemView.getContext();
    //set the background for the item
    UIUtils.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true));
    //set the text for the name
    StringHolder.applyTo(name, viewHolder.name);
    //set the text for the description or hide
    int selectedSubItems = 0;
    if (mSubSelectionProvider != null)
        selectedSubItems = mSubSelectionProvider.getSelectedSubItems();
    StringHolder descr = new StringHolder(description.getText());
    if (selectedSubItems > 0)
        descr.setText("Selected children: " + selectedSubItems + "/" + getSubItems().size());
    StringHolder.applyToOrHide(descr, viewHolder.description);
    viewHolder.description.setTextColor(selectedSubItems == 0 ? Color.BLACK : Color.RED);
}
Also used : Context(android.content.Context) StringHolder(com.mikepenz.materialdrawer.holder.StringHolder)

Example 18 with Context

use of android.content.Context in project FastAdapter by mikepenz.

the class ImageItem method bindView.

/**
     * binds the data of this item onto the viewHolder
     *
     * @param viewHolder the viewHolder of this item
     */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
    super.bindView(viewHolder, payloads);
    //get the context
    Context ctx = viewHolder.itemView.getContext();
    //define our data for the view
    viewHolder.imageName.setText(mName);
    viewHolder.imageDescription.setText(mDescription);
    viewHolder.imageView.setImageBitmap(null);
    //we pre-style our heart :D
    style(viewHolder.imageLovedOn, mStarred ? 1 : 0);
    style(viewHolder.imageLovedOff, mStarred ? 0 : 1);
    //load glide
    Glide.with(ctx).load(mImageUrl).animate(R.anim.alpha_on).into(viewHolder.imageView);
}
Also used : Context(android.content.Context)

Example 19 with Context

use of android.content.Context in project FastAdapter by mikepenz.

the class SimpleItem method bindView.

/**
     * binds the data of this item onto the viewHolder
     *
     * @param viewHolder the viewHolder of this item
     */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
    super.bindView(viewHolder, payloads);
    //get the context
    Context ctx = viewHolder.itemView.getContext();
    //set the background for the item
    UIUtils.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true));
    //set the text for the name
    StringHolder.applyTo(name, viewHolder.name);
    //set the text for the description or hide
    StringHolder.applyToOrHide(description, viewHolder.description);
}
Also used : Context(android.content.Context)

Example 20 with Context

use of android.content.Context in project FastAdapter by mikepenz.

the class SimpleSubExpandableItem method bindView.

/**
     * binds the data of this item onto the viewHolder
     *
     * @param viewHolder the viewHolder of this item
     */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
    super.bindView(viewHolder, payloads);
    //get the context
    Context ctx = viewHolder.itemView.getContext();
    //set the background for the item
    UIUtils.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true));
    //set the text for the name
    StringHolder.applyTo(name, viewHolder.name);
    //set the text for the description or hide
    StringHolder.applyToOrHide(description, viewHolder.description);
    if (isExpanded()) {
        ViewCompat.setRotation(viewHolder.icon, 0);
    } else {
        ViewCompat.setRotation(viewHolder.icon, 180);
    }
}
Also used : Context(android.content.Context)

Aggregations

Context (android.content.Context)7516 Test (org.junit.Test)1645 Intent (android.content.Intent)1356 View (android.view.View)797 TextView (android.widget.TextView)549 BroadcastReceiver (android.content.BroadcastReceiver)497 IntentFilter (android.content.IntentFilter)485 PackageManager (android.content.pm.PackageManager)383 Resources (android.content.res.Resources)369 ArrayList (java.util.ArrayList)358 Bundle (android.os.Bundle)292 PendingIntent (android.app.PendingIntent)281 File (java.io.File)280 LayoutInflater (android.view.LayoutInflater)279 ImageView (android.widget.ImageView)263 Drawable (android.graphics.drawable.Drawable)256 IOException (java.io.IOException)248 Uri (android.net.Uri)247 RecyclerView (android.support.v7.widget.RecyclerView)200 Activity (android.app.Activity)198