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;
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations