Skip to content

Commit

Permalink
add color from ui
Browse files Browse the repository at this point in the history
  • Loading branch information
appt2 committed Mar 31, 2024
1 parent a645993 commit 10f5afe
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 11 deletions.
50 changes: 50 additions & 0 deletions .androidide/editor/openedFiles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"allFiles": [
{
"file": "/storage/emulated/0/AndroidIDEProjects/ListSheet/library/src/main/java/adapter/ListAdapter.java",
"selection": {
"end": {
"column": 35,
"index": 2004,
"line": 67
},
"start": {
"column": 35,
"index": 2004,
"line": 67
}
}
},
{
"file": "/storage/emulated/0/AndroidIDEProjects/ListSheet/library/src/main/java/widget/ItemRuner.java",
"selection": {
"end": {
"column": 32,
"index": 3030,
"line": 115
},
"start": {
"column": 14,
"index": 3012,
"line": 115
}
}
},
{
"file": "/storage/emulated/0/AndroidIDEProjects/ListSheet/app/src/main/java/com/ninjacoder/listshset/MainActivity.java",
"selection": {
"end": {
"column": 42,
"index": 1087,
"line": 31
},
"start": {
"column": 42,
"index": 1087,
"line": 31
}
}
}
],
"selectedFile": "/storage/emulated/0/AndroidIDEProjects/ListSheet/app/src/main/java/com/ninjacoder/listshset/MainActivity.java"
}
8 changes: 7 additions & 1 deletion app/src/main/java/com/ninjacoder/listshset/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ninjacoder.listshset;

import android.graphics.Color;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -23,7 +24,12 @@ protected void onCreate(Bundle savedInstanceState) {
runer.setCallBack((pos) ->{
runer.setDismiss();
});

runer.setTextColors(Color.CYAN);
runer.setColorFilter(Color.CYAN);
runer.serDivarColor(Color.BLUE);
runer.setTitleColor(Color.CYAN);
runer.setTitle("Hello");
runer.setSheetBackground(Color.BLACK);
runer.show();


Expand Down
22 changes: 19 additions & 3 deletions library/src/main/java/adapter/ListAdapter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ninjacoder.listshset.library.adapter;

import android.graphics.Color;
import android.graphics.PorterDuff;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.View;
Expand All @@ -16,6 +18,11 @@

public class ListAdapter extends BaseAdapter implements Adapter {
protected List<SheetModel> model;
private int colorText = Color.WHITE;
private int colorFilter = Color.WHITE;
private LinearLayout root;
protected ImageView img;
protected TextView tv;
public ListAdapter(List<SheetModel> model) {
this.model = model;

Expand All @@ -40,16 +47,25 @@ public long getItemId(int arg0) {
public View getView(int pos, View views, ViewGroup par) {
views = LayoutInflater.from(par.getContext()).inflate(R.layout.layout_adapter, par, false);
var sheet = model.get(pos);
LinearLayout root = views.findViewById(R.id.root);
ImageView img = views.findViewById(R.id.icon);
TextView tv = views.findViewById(R.id.name);
root = views.findViewById(R.id.root);
img = views.findViewById(R.id.icon);
tv = views.findViewById(R.id.name);
if (sheet.getIcon() == 0) {
img.setVisibility(GONE);
}
img.setImageResource(sheet.getIcon());
tv.setText(sheet.getName());
root.setEnabled(!sheet.getIsItem());
root.setAlpha(!sheet.getIsItem() ? 0.4f : 1f);
tv.setTextColor(colorText);
img.setColorFilter(colorFilter ,PorterDuff.Mode.SRC_IN);
return views;
}
public void setTextColor(int color){
this.colorText = color;
}
public void setColorFilter(int colorFilter){
this.colorFilter = colorFilter;
}

}
33 changes: 32 additions & 1 deletion library/src/main/java/widget/ItemRuner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.widget.TextView;
import androidx.annotation.IdRes;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.divider.MaterialDivider;
import com.ninjacoder.listshset.library.R;
import com.ninjacoder.listshset.library.adapter.ListAdapter;
import com.ninjacoder.listshset.library.interfaces.OnItemClickEvent;
Expand All @@ -22,12 +23,15 @@ public class ItemRuner {
protected BottomSheetDialog dialog;
protected SheetModel model;
protected ListAdapter ad;
protected TextView title;
protected MaterialDivider divar;

public ItemRuner(Context context) {
this.context = context;
var view = LayoutInflater.from(context).inflate(R.layout.layout_sheet_main, null);
TextView title = view.findViewById(R.id.title);
title = view.findViewById(R.id.title);
listview = view.findViewById(R.id.listdata);
divar = view.findViewById(R.id.diver);
listview.setScrollBarSize(0);
listview.setDividerHeight(0);
ad = new ListAdapter(list);
Expand Down Expand Up @@ -85,4 +89,31 @@ public ListView getListview() {
public void setListview(ListView listview) {
this.listview = listview;
}

public void setTextColors(int colors) {
ad.setTextColor(colors);
}

public void setColorFilter(int colors) {
ad.setColorFilter(colors);
}

public void setTitle(String str) {
title.setText(str);
}

public void setTitleColor(int color) {
title.setTextColor(color);
}

public void serDivarColor(int color) {
divar.setDividerColor(color);
}

public void serDivarColorFromRes(@IdRes int color) {
divar.setDividerColorResource(color);
}
public void setSheetBackground(int color){
dialog.getWindow().getDecorView().setBackgroundColor(color);
}
}
7 changes: 3 additions & 4 deletions library/src/main/res/layout/layout_adapter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@
android:id="@+id/root">

<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_width="60dp"
android:scaleType="centerInside"
android:id="@+id/icon" />

<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="16sp"
android:layout_marginLeft="2dp"
android:layout_marginRight="1dp"
android:layout_marginRight="4dp"
android:textColor="#ffffffff"
android:id="@+id/name"
android:text="TextView" />
Expand Down
6 changes: 4 additions & 2 deletions library/src/main/res/layout/layout_sheet_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
android:paddingVertical="2dp"
android:orientation="vertical"
android:paddingHorizontal="2dp">

<LinearLayout
android:layout_height="wrap_content"
Expand All @@ -31,7 +33,7 @@
<com.google.android.material.divider.MaterialDivider
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:paddingVertical="2dp"
android:id="@+id/diver" />

</LinearLayout>
Expand Down

0 comments on commit 10f5afe

Please sign in to comment.