|
|
@ -1,13 +1,21 @@ |
|
|
|
package awais.instagrabber.adapters.viewholder.dialogs; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
import awais.instagrabber.R; |
|
|
|
import awais.instagrabber.adapters.KeywordsFilterAdapter; |
|
|
|
import awais.instagrabber.utils.Constants; |
|
|
|
import awais.instagrabber.utils.SettingsHelper; |
|
|
|
|
|
|
|
public class KeywordsFilterDialogViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
@ -20,6 +28,19 @@ public class KeywordsFilterDialogViewHolder extends RecyclerView.ViewHolder { |
|
|
|
item = itemView.findViewById(R.id.keyword_text); |
|
|
|
} |
|
|
|
|
|
|
|
public void bind(ArrayList<String> items, int position, Context context, KeywordsFilterAdapter adapter){ |
|
|
|
item.setText(items.get(position)); |
|
|
|
deleteButton.setOnClickListener(view -> { |
|
|
|
final String s = items.get(position); |
|
|
|
SettingsHelper settingsHelper = new SettingsHelper(context); |
|
|
|
items.remove(position); |
|
|
|
settingsHelper.putStringSet(Constants.KEYWORD_FILTERS, new HashSet<>(items)); |
|
|
|
adapter.notifyDataSetChanged(); |
|
|
|
final String message = context.getString(R.string.removed_keywords, s); |
|
|
|
Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public Button getDeleteButton(){ |
|
|
|
return deleteButton; |
|
|
|
} |
|
|
|