So basically, this is my code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_disable_app_list_view, parent, false);
holder = new ViewHolder();
holder.nameH = convertView.findViewById(R.id.appName);
holder.packageH = convertView.findViewById(R.id.packName);
holder.switchH = convertView.findViewById(R.id.switchDisable);
holder.imageH = convertView.findViewById(R.id.appIcon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
AppInfo appInfo = applicationInfoList.get(position);
holder.nameH.setText(appInfo.appName);
holder.packageH.setText(appInfo.packageName);
holder.switchH.setChecked(!appInfo.disabled);
if (appInfo.system) {
convertView.findViewById(R.id.systemOrNot).setVisibility(View.VISIBLE);
if (appInfo.packageName.equals("com.samsung.android.bixby.es.globalaction") ||
appInfo.packageName.equals("com.samsung.android.app.spage") ||
appInfo.packageName.equals("com.samsung.android.bixby.plmsync") ||
appInfo.packageName.equals("com.samsung.android.visionintelligence") ||
appInfo.packageName.equals("com.samsung.android.bixby.agent") ||
appInfo.packageName.equals("com.samsung.android.bixby.agent.dummy") ||
appInfo.packageName.equals("com.samsung.android.bixby.voiceinput") ||
appInfo.packageName.equals("com.samsung.android.bixby.wakeup")) {
convertView.findViewById(R.id.switchDisable).setVisibility(View.GONE);
} else
{
convertView.findViewById(R.id.switchDisable).setVisibility(View.VISIBLE);
}
} else {
convertView.findViewById(R.id.systemOrNot).setVisibility(View.GONE);
}
try {
holder.imageH.setImageDrawable(packageManager.getApplicationIcon(appInfo.packageName));
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to get ImageDrawable", e);
}
return convertView;
}
As you can see in one place it checks whether appInfo.packageName.equals some package names (mainly samsung bixby apps) and then hides a switch for those apps. However switch also disappears next to SOME of the packages that are not bixby AND aren't even system apps.
When I added else case to set to visible, switch reappeared next to some of the falsely hidden packages. Every time I run a program, same packages are affected.
Now, I know that this isn't a case with false positives because if I make it show a toast message in addition to setting visibility to gone, toasts aren't showing up for them (only shows up for bixby apps).
I'm lost. This is my first ever android project. Not only android actually. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire