-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
darkengine
committed
Sep 8, 2024
1 parent
5865941
commit cdb0327
Showing
87 changed files
with
2,283 additions
and
2,174 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/dark/androidbox/adapter/MethodSelectAdapter.java
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,68 @@ | ||
package com.dark.androidbox.adapter; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
|
||
import com.dark.androidbox.databinding.MethodsListBinding; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
|
||
import java.util.List; | ||
|
||
public class MethodSelectAdapter extends BaseAdapter { | ||
|
||
private List<MethodDeclaration> data; | ||
private Context context; | ||
private LayoutInflater inflater; | ||
|
||
public MethodSelectAdapter(Context context, List<MethodDeclaration> data) { | ||
this.context = context; | ||
this.data = data; | ||
this.inflater = LayoutInflater.from(context); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return data.size(); | ||
} | ||
|
||
@Override | ||
public Object getItem(int i) { | ||
return data.get(i); | ||
} | ||
|
||
@Override | ||
public long getItemId(int i) { | ||
return i; | ||
} | ||
|
||
@SuppressLint("ViewHolder") | ||
@Override | ||
public View getView(int i, View convertView, ViewGroup viewGroup) { | ||
ViewHolder holder; | ||
if (convertView == null) { | ||
MethodsListBinding binding = MethodsListBinding.inflate(inflater, viewGroup, false); | ||
holder = new ViewHolder(binding); | ||
convertView = binding.getRoot(); | ||
convertView.setTag(holder); | ||
} else { | ||
holder = (ViewHolder) convertView.getTag(); | ||
} | ||
|
||
MethodDeclaration method = data.get(i); | ||
holder.binding.title.setText(method.getNameAsString()); | ||
|
||
return convertView; | ||
} | ||
|
||
static class ViewHolder { | ||
MethodsListBinding binding; | ||
|
||
ViewHolder(MethodsListBinding binding) { | ||
this.binding = binding; | ||
} | ||
} | ||
} |
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
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
84 changes: 84 additions & 0 deletions
84
app/src/main/java/com/dark/androidbox/nodes/MethodNode.java
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,84 @@ | ||
package com.dark.androidbox.nodes; | ||
|
||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.util.AttributeSet; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.ArrayAdapter; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.widget.AppCompatSpinner; | ||
|
||
import com.dark.androidbox.MainActivity; | ||
import com.dark.androidbox.adapter.MethodSelectAdapter; | ||
import com.dark.androidbox.databinding.MethodNodeBinding; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MethodNode extends BaseNode { | ||
|
||
private MethodNodeBinding binding; | ||
|
||
public MethodNode(Context context) { | ||
super(context); | ||
} | ||
|
||
public MethodNode(Context context, @Nullable AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public MethodNode(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
public MethodNode(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
super.init(); | ||
binding = MethodNodeBinding.inflate(LayoutInflater.from(getContext()), this, true); | ||
setBackgroundColor(Color.GREEN); | ||
} | ||
|
||
@Override | ||
public void postInit() { | ||
super.postInit(); | ||
binding.title.setVisibility(GONE); | ||
|
||
setup(binding.choose); | ||
|
||
} | ||
|
||
|
||
void setup(AppCompatSpinner spinner) { | ||
|
||
MethodSelectAdapter adapter = new MethodSelectAdapter(getContext(), (List<MethodDeclaration>) data.getParentNode().value.data); | ||
|
||
|
||
|
||
// Bind the adapter to the Spinner | ||
spinner.setAdapter(adapter); | ||
|
||
// Set a listener to handle item selection | ||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
String selectedItem = parent.getItemAtPosition(position).toString(); | ||
binding.title.setText(selectedItem); | ||
MainActivity.treeViewStatic.getEditor().setWantEdit(false); | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
// Handle the case where no item is 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/white"/> | ||
<corners android:radius="12dp"/> | ||
</shape> |
Oops, something went wrong.