Skip to content

Commit

Permalink
Adding checkbox to items in Confirm Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
votaguz authored and gubatron committed Mar 23, 2016
1 parent f0e9a20 commit 39997cd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.frostwire.android.R;
Expand Down Expand Up @@ -86,6 +89,36 @@ public ConfirmListDialogDefaultAdapter(Context context, List<T> list, SelectionM
this.selectionMode = selectionMode;
}

@Override
public View getView(int position, View view, ViewGroup parent) {
SearchResult item = (SearchResult) getItem(position);
Context ctx = getContext();

if (view == null && ctx != null) {
int layoutId = selectionModeToLayoutId.get(selectionMode).intValue();
// every list view item is wrapped in a generic container which has a hidden checkbox on the left hand side.
view = View.inflate(ctx, layoutId, null);
//LinearLayout container = findView(view, R.id.view_selectable_list_item_container);
//View.inflate(ctx, viewItemId, container);
}

try {

initTouchFeedback(view, item);
setCheckboxesVisibility(selectionMode == SelectionMode.MULTIPLE_SELECTION);
initCheckBox(view, item);
//TODO: setRadioButtonsVisibility(selectionMode == SelectionMode.SINGLE_SELECTION);
//TODO: initRadioButton(view, item);
populateView(view, item);

} catch (Throwable e) {
LOGGER.error("Fatal error getting view: " + e.getMessage(), e);
}

return view;

}

@Override
protected void populateView(View view, Object data) {
if (data instanceof SearchResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ protected Dialog trackDialog(Dialog dialog) {
*
* @see #getChecked()
*/
private void initCheckBox(View view, T item) {
protected void initCheckBox(View view, T item) {

CheckBox checkbox = findView(view, R.id.view_selectable_list_item_checkbox);

Expand All @@ -419,7 +419,7 @@ private void initCheckBox(View view, T item) {
}
}

private void initTouchFeedback(View v, T item) {
protected void initTouchFeedback(View v, T item) {
if (v == null || v instanceof CheckBox) {
return;
}
Expand Down

0 comments on commit 39997cd

Please sign in to comment.