mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Created base files for UI Designer
This commit is contained in:
Regular → Executable
+5
@@ -31,5 +31,10 @@
|
|||||||
<option name="name" value="Google" />
|
<option name="name" value="Google" />
|
||||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenLocal" />
|
||||||
|
<option name="name" value="MavenLocal" />
|
||||||
|
<option name="url" value="file:/C:/Users/Akash%20Yadav/.m2/repository/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
+18
-1
@@ -3,9 +3,26 @@
|
|||||||
<component name="DesignSurface">
|
<component name="DesignSurface">
|
||||||
<option name="filePathToZoomLevelMap">
|
<option name="filePathToZoomLevelMap">
|
||||||
<map>
|
<map>
|
||||||
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_main.xml" value="0.264" />
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/drawable/bg_ripple.xml" value="0.3105485232067511" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/drawable/bg_ripple_pressed.xml" value="0.3105485232067511" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/drawable/bg_widget_group_selected.xml" value="0.33" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/drawable/ic_replace.xml" value="0.3105485232067511" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/drawable/ic_widget_edittext.xml" value="0.3105485232067511" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/drawable/ic_widget_seekbar.xml" value="0.3105485232067511" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_designer.xml" value="0.33" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_download.xml" value="0.30128205128205127" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_editor.xml" value="0.30128205128205127" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_simple_icon_text.xml" value="0.30128205128205127" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_widget_group_item.xml" value="0.33" />
|
||||||
|
<entry key="..\:/Projects/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_widget_item.xml" value="0.33" />
|
||||||
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/drawable/ic_website.xml" value="0.2189873417721519" />
|
||||||
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/drawable/ic_widget_button.xml" value="0.22179487179487178" />
|
||||||
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_designer.xml" value="0.264" />
|
||||||
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_main.xml" value="0.33" />
|
||||||
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_create_project.xml" value="0.20854700854700856" />
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_create_project.xml" value="0.20854700854700856" />
|
||||||
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_create_project_content.xml" value="0.33" />
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_create_project_content.xml" value="0.33" />
|
||||||
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_widget_item.xml" value="0.264" />
|
||||||
|
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/menu/menu_designer_widgets.xml" value="0.20854700854700856" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+3
-1
@@ -31,7 +31,9 @@ android {
|
|||||||
"SmallSp"
|
"SmallSp"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures.viewBinding true
|
buildFeatures {
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Regular → Executable
Regular → Executable
+82
-12
@@ -17,18 +17,43 @@
|
|||||||
**************************************************************************************/
|
**************************************************************************************/
|
||||||
package com.itsaky.androidide;
|
package com.itsaky.androidide;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.blankj.utilcode.util.ThrowableUtils;
|
import com.blankj.utilcode.util.ThrowableUtils;
|
||||||
|
import com.itsaky.androidide.adapters.WidgetGroupItemAdapter;
|
||||||
|
import com.itsaky.androidide.adapters.WidgetItemAdapter;
|
||||||
import com.itsaky.androidide.app.StudioActivity;
|
import com.itsaky.androidide.app.StudioActivity;
|
||||||
import com.itsaky.androidide.databinding.ActivityDesignerBinding;
|
import com.itsaky.androidide.databinding.ActivityDesignerBinding;
|
||||||
|
import com.itsaky.androidide.models.UIWidget;
|
||||||
|
import com.itsaky.androidide.models.UIWidgetGroup;
|
||||||
import com.itsaky.androidide.utils.Logger;
|
import com.itsaky.androidide.utils.Logger;
|
||||||
import com.itsaky.layoutinflater.ILayoutInflater;
|
import com.itsaky.layoutinflater.ILayoutInflater;
|
||||||
import com.itsaky.layoutinflater.IView;
|
import com.itsaky.layoutinflater.IView;
|
||||||
|
import com.itsaky.toaster.Toaster;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DesignerActivity extends StudioActivity {
|
public class DesignerActivity extends StudioActivity {
|
||||||
|
|
||||||
@@ -37,6 +62,13 @@ public class DesignerActivity extends StudioActivity {
|
|||||||
public static final String KEY_LAYOUT_PATH = "designer_layoutPath";
|
public static final String KEY_LAYOUT_PATH = "designer_layoutPath";
|
||||||
private static final Logger LOG = Logger.instance("DesignerActivity");
|
private static final Logger LOG = Logger.instance("DesignerActivity");
|
||||||
|
|
||||||
|
private final List<UIWidgetGroup> widgetGroups = new ArrayList<>();
|
||||||
|
|
||||||
|
private final WidgetItemAdapter.OnWidgetDragListener dragListener = (widget, v, event) -> {
|
||||||
|
getApp().toast("Dragging: " + widget.getName(), Toaster.Type.INFO);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected View bindLayout() {
|
protected View bindLayout() {
|
||||||
mBinding = ActivityDesignerBinding.inflate(getLayoutInflater());
|
mBinding = ActivityDesignerBinding.inflate(getLayoutInflater());
|
||||||
@@ -47,9 +79,12 @@ public class DesignerActivity extends StudioActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final var toggle = new ActionBarDrawerToggle(this, mBinding.getRoot(), mBinding.toolbar, R.string.app_name, R.string.app_name);
|
||||||
|
mBinding.getRoot().addDrawerListener(toggle);
|
||||||
|
toggle.syncState();
|
||||||
|
|
||||||
setSupportActionBar(mBinding.toolbar);
|
setSupportActionBar(mBinding.toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
mBinding.toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
|
||||||
|
|
||||||
final Bundle extras = getIntent().getExtras();
|
final Bundle extras = getIntent().getExtras();
|
||||||
final String path = extras.getString(KEY_LAYOUT_PATH, null);
|
final String path = extras.getString(KEY_LAYOUT_PATH, null);
|
||||||
@@ -57,25 +92,60 @@ public class DesignerActivity extends StudioActivity {
|
|||||||
try {
|
try {
|
||||||
final ILayoutInflater inflater = getApp().getLayoutInflater();
|
final ILayoutInflater inflater = getApp().getLayoutInflater();
|
||||||
inflater.resetContextProvider(newContextProvider());
|
inflater.resetContextProvider(newContextProvider());
|
||||||
final IView view = inflater.inflatePath(path, mBinding.realContainer);
|
final IView view = inflater.inflatePath(path, mBinding.layoutContainer);
|
||||||
mBinding.realContainer.addView(view.asView());
|
mBinding.layoutContainer.addView(view.asView());
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
mBinding.realContainer.removeAllViews();
|
mBinding.layoutContainer.removeAllViews();
|
||||||
mBinding.realContainer.addView(createErrorText(th));
|
mBinding.layoutContainer.addView(createErrorText(th));
|
||||||
|
|
||||||
LOG.error (getString(R.string.err_cannot_inflate_layout));
|
LOG.error (getString(R.string.err_cannot_inflate_layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupWidgets() {
|
||||||
|
final var common = new UIWidgetGroup(getString(R.string.widget_group_android));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_button), R.drawable.ic_widget_button, Button.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_checkbox), R.drawable.ic_widget_checkbox, CheckBox.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_checked_textview), R.drawable.ic_widget_checked_textview, CheckedTextView.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_edittext), R.drawable.ic_widget_edittext, EditText.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_image_button), R.drawable.ic_widget_image, ImageButton.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_image_view), R.drawable.ic_widget_image, ImageView.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_progressbar), R.drawable.ic_widget_progress, ProgressBar.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_radio_button), R.drawable.ic_widget_radio_button, RadioButton.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_seekbar), R.drawable.ic_widget_seekbar, SeekBar.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_spinner), R.drawable.ic_widget_spinner, Spinner.class));
|
||||||
|
common.addChild(new UIWidget(getString(R.string.widget_textview), R.drawable.ic_widget_textview, TextView.class));
|
||||||
|
|
||||||
|
// IMPORTANT: Do not select any other groups here
|
||||||
|
common.setSelected(true);
|
||||||
|
widgetGroups.add(common);
|
||||||
|
|
||||||
|
final var layouts = new UIWidgetGroup("Layouts");
|
||||||
|
layouts.addChild(new UIWidget("LinearLayout", R.drawable.ic_widget_linear, LinearLayout.class));
|
||||||
|
layouts.addChild(new UIWidget("RelativeLayout", R.drawable.ic_widget_relative, RelativeLayout.class));
|
||||||
|
|
||||||
|
widgetGroups.add(layouts);
|
||||||
|
|
||||||
|
final var adapter = new WidgetGroupItemAdapter(widgetGroups, this::showWidgetGroup);
|
||||||
|
mBinding.groupItems.setAdapter(adapter);
|
||||||
|
|
||||||
|
showWidgetGroup(common);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showWidgetGroup (@NonNull UIWidgetGroup group) {
|
||||||
|
final var children = group.getChildren();
|
||||||
|
mBinding.widgetItems.setAdapter(new WidgetItemAdapter(children, dragListener));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Contract(pure = true)
|
||||||
private ILayoutInflater.ContextProvider newContextProvider() {
|
private ILayoutInflater.ContextProvider newContextProvider() {
|
||||||
return new ILayoutInflater.ContextProvider() {
|
return () -> DesignerActivity.this;
|
||||||
@Override
|
|
||||||
public Context getContext() {
|
|
||||||
return DesignerActivity.this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private TextView createErrorText (Throwable th) {
|
private TextView createErrorText (Throwable th) {
|
||||||
final TextView error = new TextView (this);
|
final TextView error = new TextView (this);
|
||||||
error.setText(ThrowableUtils.getFullStackTrace(th));
|
error.setText(ThrowableUtils.getFullStackTrace(th));
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+105
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of AndroidIDE.
|
||||||
|
*
|
||||||
|
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* AndroidIDE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.itsaky.androidide.adapters;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.itsaky.androidide.databinding.LayoutSimpleIconTextBinding;
|
||||||
|
import com.itsaky.androidide.models.IconTextListItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A RecyclerView.Adapter which can be used to show a list with an icon and a text.
|
||||||
|
*
|
||||||
|
* @author Akash Yadav
|
||||||
|
*/
|
||||||
|
public class SimpleIconTextAdapter extends RecyclerView.Adapter<SimpleIconTextAdapter.VH> {
|
||||||
|
|
||||||
|
private final List<? extends IconTextListItem> items;
|
||||||
|
private OnBindListener bindListener;
|
||||||
|
|
||||||
|
public SimpleIconTextAdapter(@NonNull List<? extends IconTextListItem> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleIconTextAdapter setOnBindListener (OnBindListener listener) {
|
||||||
|
this.bindListener = listener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new VH (LayoutSimpleIconTextBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull VH holder, int position) {
|
||||||
|
final var binding = holder.binding;
|
||||||
|
final var item = items.get(position);
|
||||||
|
|
||||||
|
if (this.bindListener != null && this.bindListener.onBind(item, holder, position)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final var icon = item.getIconResource();
|
||||||
|
|
||||||
|
if (icon == -1) {
|
||||||
|
binding.icon.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
binding.icon.setImageResource(icon);
|
||||||
|
}
|
||||||
|
binding.text.setText(item.getText());
|
||||||
|
|
||||||
|
if (this.bindListener != null) {
|
||||||
|
this.bindListener.postBind(item, holder, position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IconTextListItem getItemAt (int index) {
|
||||||
|
return this.items.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VH extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
public final LayoutSimpleIconTextBinding binding;
|
||||||
|
|
||||||
|
public VH(@NonNull LayoutSimpleIconTextBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface OnBindListener {
|
||||||
|
boolean onBind (IconTextListItem item, VH holder, int position);
|
||||||
|
|
||||||
|
default void postBind (IconTextListItem item, VH holder, int position) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Regular → Executable
+60
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of AndroidIDE.
|
||||||
|
*
|
||||||
|
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* AndroidIDE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.itsaky.androidide.adapters;
|
||||||
|
|
||||||
|
import com.itsaky.androidide.models.IconTextListItem;
|
||||||
|
import com.itsaky.androidide.models.UIWidgetGroup;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WidgetGroupItemAdapter extends SimpleIconTextAdapter implements SimpleIconTextAdapter.OnBindListener {
|
||||||
|
|
||||||
|
private final OnGroupClickListener clickListener;
|
||||||
|
|
||||||
|
public WidgetGroupItemAdapter(List<UIWidgetGroup> groups, OnGroupClickListener clickListener) {
|
||||||
|
super(groups);
|
||||||
|
this.clickListener = clickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBind(IconTextListItem item, VH holder, int position) {
|
||||||
|
final var binding = holder.binding;
|
||||||
|
final var group = (UIWidgetGroup) getItemAt(position);
|
||||||
|
|
||||||
|
if (this.clickListener != null) {
|
||||||
|
binding.getRoot().setOnClickListener(v -> this.clickListener.onGroupClick(group));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postBind(IconTextListItem item, VH holder, int position) {
|
||||||
|
final var binding = holder.binding;
|
||||||
|
final var group = (UIWidgetGroup) item;
|
||||||
|
|
||||||
|
if (group.isSelected()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnGroupClickListener {
|
||||||
|
void onGroupClick(UIWidgetGroup group);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of AndroidIDE.
|
||||||
|
*
|
||||||
|
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* AndroidIDE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.itsaky.androidide.adapters;
|
||||||
|
|
||||||
|
import android.view.DragEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.itsaky.androidide.models.IconTextListItem;
|
||||||
|
import com.itsaky.androidide.models.UIWidget;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WidgetItemAdapter extends SimpleIconTextAdapter implements SimpleIconTextAdapter.OnBindListener {
|
||||||
|
|
||||||
|
private final OnWidgetDragListener dragListener;
|
||||||
|
|
||||||
|
public WidgetItemAdapter(List<UIWidget> widgets, OnWidgetDragListener dragListener) {
|
||||||
|
super(widgets);
|
||||||
|
this.dragListener = dragListener;
|
||||||
|
|
||||||
|
setOnBindListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBind(IconTextListItem item, @NonNull VH holder, int position) {
|
||||||
|
final var binding = holder.binding;
|
||||||
|
final var widget = (UIWidget) getItemAt(position);
|
||||||
|
|
||||||
|
if (this.dragListener != null) {
|
||||||
|
binding.getRoot().setOnDragListener((v, event) -> {
|
||||||
|
return this.dragListener.onDrag(widget, v, event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // Returning true will not set the text and icon
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface OnWidgetDragListener {
|
||||||
|
boolean onDrag(UIWidget widget, View v, DragEvent event);
|
||||||
|
}
|
||||||
|
}
|
||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user