Search in sources :

Example 1 with AppDataParcelable

use of com.amaze.filemanager.adapters.data.AppDataParcelable 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)

Example 2 with AppDataParcelable

use of com.amaze.filemanager.adapters.data.AppDataParcelable in project AmazeFileManager by TeamAmaze.

the class AppsListFragment method onLoadFinished.

@Override
public void onLoadFinished(@NonNull Loader<List<AppDataParcelable>> loader, List<AppDataParcelable> data) {
    getSpinner().setVisibility(View.GONE);
    if (data.isEmpty()) {
        getRecyclerView().setVisibility(View.GONE);
        rootView.findViewById(R.id.empty_text_view).setVisibility(View.VISIBLE);
    } else {
        appDataParcelableList = new ArrayList<>(data);
        List<AppDataParcelable> adapterList = new ArrayList<>();
        for (AppDataParcelable appDataParcelable : data) {
            if (!showSystemApps && appDataParcelable.isSystemApp()) {
                continue;
            }
            adapterList.add(appDataParcelable);
        }
        adapter = new AppsRecyclerAdapter(this, modelProvider, false, this, adapterList);
        getRecyclerView().setVisibility(View.VISIBLE);
        getRecyclerView().setAdapter(adapter);
    }
}
Also used : AppDataParcelable(com.amaze.filemanager.adapters.data.AppDataParcelable) ArrayList(java.util.ArrayList) AppsRecyclerAdapter(com.amaze.filemanager.adapters.AppsRecyclerAdapter)

Example 3 with AppDataParcelable

use of com.amaze.filemanager.adapters.data.AppDataParcelable in project AmazeFileManager by TeamAmaze.

the class AppListLoader method loadInBackground.

@Override
public List<AppDataParcelable> loadInBackground() {
    List<ApplicationInfo> apps = packageManager.getInstalledApplications(PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS);
    if (apps == null)
        return Collections.emptyList();
    mApps = new ArrayList<>(apps.size());
    PackageInfo androidInfo = null;
    try {
        androidInfo = packageManager.getPackageInfo("android", PackageManager.GET_SIGNATURES);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    for (ApplicationInfo object : apps) {
        if (object.sourceDir == null) {
            continue;
        }
        File sourceDir = new File(object.sourceDir);
        String label = object.loadLabel(packageManager).toString();
        PackageInfo info;
        try {
            info = packageManager.getPackageInfo(object.packageName, PackageManager.GET_SIGNATURES);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            info = null;
        }
        boolean isSystemApp = isAppInSystemPartition(object) || isSignedBySystem(info, androidInfo);
        AppDataParcelable elem = new AppDataParcelable(label == null ? object.packageName : label, object.sourceDir, object.packageName, object.flags + "_" + (info != null ? info.versionName : ""), Formatter.formatFileSize(getContext(), sourceDir.length()), sourceDir.length(), sourceDir.lastModified(), isSystemApp, null);
        mApps.add(elem);
    }
    Collections.sort(mApps, new AppDataSorter(sortBy, isAscending));
    return mApps;
}
Also used : AppDataParcelable(com.amaze.filemanager.adapters.data.AppDataParcelable) AppDataSorter(com.amaze.filemanager.adapters.data.AppDataSorter) PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) ApplicationInfo(android.content.pm.ApplicationInfo) File(java.io.File)

Aggregations

AppDataParcelable (com.amaze.filemanager.adapters.data.AppDataParcelable)3 Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AppsRecyclerAdapter (com.amaze.filemanager.adapters.AppsRecyclerAdapter)1 AppDataSorter (com.amaze.filemanager.adapters.data.AppDataSorter)1 AppHolder (com.amaze.filemanager.adapters.holders.AppHolder)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1