Search in sources :

Example 1 with AppHolder

use of com.amaze.filemanager.adapters.holders.AppHolder in project AmazeFileManager by TeamAmaze.

the class AppsAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final AppDataParcelable rowItem = getItem(position);
    View view;
    if (convertView == null) {
        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        view = mInflater.inflate(R.layout.rowlayout, null);
        final AppHolder vholder = new AppHolder(view);
        view.findViewById(R.id.generic_icon).setVisibility(View.GONE);
        view.findViewById(R.id.picture_icon).setVisibility(View.GONE);
        view.setTag(vholder);
        sizeProvider.setView(view.findViewById(R.id.apk_icon));
    } else {
        view = convertView;
    }
    final AppHolder holder = (AppHolder) view.getTag();
    modelProvider.loadApkImage(rowItem.path, holder.apkIcon);
    if (holder.about != null) {
        if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT))
            holder.about.setColorFilter(Color.parseColor("#ff666666"));
        showPopup(holder.about, rowItem);
    }
    holder.txtTitle.setText(rowItem.label);
    // File f = new File(rowItem.getDesc());
    holder.txtDesc.setText(rowItem.fileSize);
    holder.rl.setClickable(true);
    holder.rl.setOnClickListener(p1 -> {
        Intent i1 = app.getActivity().getPackageManager().getLaunchIntentForPackage(rowItem.packageName);
        if (i1 != null)
            app.startActivity(i1);
        else
            Toast.makeText(app.getActivity(), app.getResources().getString(R.string.not_allowed), Toast.LENGTH_LONG).show();
    // TODO: Implement this method
    });
    if (myChecked.get(position)) {
        holder.rl.setBackgroundColor(Utils.getColor(context, R.color.appsadapter_background));
    } else {
        if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT)) {
            holder.rl.setBackgroundResource(R.drawable.safr_ripple_white);
        } else {
            holder.rl.setBackgroundResource(R.drawable.safr_ripple_black);
        }
    }
    return view;
}
Also used : AppDataParcelable(com.amaze.filemanager.adapters.data.AppDataParcelable) AppHolder(com.amaze.filemanager.adapters.holders.AppHolder) LayoutInflater(android.view.LayoutInflater) Intent(android.content.Intent) View(android.view.View)

Aggregations

Intent (android.content.Intent)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AppDataParcelable (com.amaze.filemanager.adapters.data.AppDataParcelable)1 AppHolder (com.amaze.filemanager.adapters.holders.AppHolder)1