-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved UI Of Config Activity (#1977)
- Loading branch information
1 parent
22f627b
commit bee7485
Showing
6 changed files
with
208 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.pslab; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CheckBoxGetter implements Serializable { | ||
|
||
private String name; | ||
private boolean isSelected; | ||
|
||
public CheckBoxGetter(String name, boolean isSelected) { | ||
this.name = name; | ||
this.isSelected = isSelected; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public boolean isSelected() { | ||
return isSelected; | ||
} | ||
|
||
public void setSelected(boolean selected) { | ||
isSelected = selected; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package io.pslab.adapters; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.CheckBox; | ||
import android.widget.TextView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import io.pslab.CheckBoxGetter; | ||
import io.pslab.R; | ||
|
||
|
||
public class CheckBoxAdapter extends RecyclerView.Adapter<CheckBoxAdapter.CheckBoxHolder> { | ||
|
||
private Context boxcontext; | ||
private List<CheckBoxGetter> list = new ArrayList<>(); | ||
|
||
public CheckBoxAdapter(Context boxcontext, List<CheckBoxGetter> list) { | ||
this.boxcontext = boxcontext; | ||
this.list = list; | ||
} | ||
|
||
@Override | ||
public CheckBoxHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
|
||
View view = LayoutInflater.from(boxcontext).inflate(R.layout.item_checkbox, parent, false); | ||
return new CheckBoxHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(final CheckBoxHolder holder, final int position) { | ||
|
||
final CheckBoxGetter check = list.get(position); | ||
|
||
holder.tv_name.setText(check.getName()); | ||
|
||
holder.checkBox.setChecked(check.isSelected()); | ||
holder.checkBox.setTag(list.get(position)); | ||
|
||
holder.checkBox.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
CheckBoxGetter check1 = (CheckBoxGetter) holder.checkBox.getTag(); | ||
check1.setSelected(holder.checkBox.isChecked()); | ||
list.get(position).setSelected(holder.checkBox.isChecked()); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return list.size(); | ||
} | ||
|
||
public List<CheckBoxGetter> getCheckList() { | ||
return list; | ||
} | ||
|
||
public static class CheckBoxHolder extends RecyclerView.ViewHolder { | ||
|
||
private TextView tv_name; | ||
private CheckBox checkBox; | ||
|
||
public CheckBoxHolder(View itemView) { | ||
super(itemView); | ||
tv_name = itemView.findViewById(R.id.tv_checkbox); | ||
checkBox = itemView.findViewById(R.id.checkBox_select); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/check_box_magin" | ||
android:layout_marginBottom="@dimen/check_box_magin" | ||
app:cardCornerRadius="@dimen/check_box_corner"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<TextView | ||
android:id="@+id/tv_checkbox" | ||
android:layout_width="@dimen/check_box_width" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:padding="@dimen/create_config_margin2" /> | ||
|
||
<CheckBox | ||
android:id="@+id/checkBox_select" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> | ||
|
||
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters