Skip to content

Commit

Permalink
solve bug 0000338
Browse files Browse the repository at this point in the history
  • Loading branch information
domjos1994 committed Oct 24, 2019
1 parent 0ea3dd5 commit 43b5c7e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package de.domjos.unitrackermobile.activities;

import android.app.Activity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.view.Menu;
Expand Down Expand Up @@ -318,6 +319,33 @@ protected void initControls() {

this.lvMainIssues = this.findViewById(R.id.lvMainIssues);
this.lvMainIssues.setContextMenu(R.menu.context_main);
this.lvMainIssues.addButtonClick(R.drawable.ic_style_black_24dp, new SwipeRefreshDeleteList.ButtonClickListener() {
@Override
public void onClick(List<ListObject> objectList) {
try {
Activity act = MainActivity.this;
boolean show = settings.showNotifications();
Object pid = settings.getCurrentProjectId();

String tags = Helper.showTagDialog(act, bugService, show, pid);

for(ListObject listObject : objectList) {
IssueTask issueTask = new IssueTask(act, bugService, pid, false, true, show, R.drawable.ic_bug_report_black_24dp);
List<Issue> issues = issueTask.execute(listObject.getDescriptionObject().getId()).get();

if(issues!=null) {
if(!issues.isEmpty()) {
issues.get(0).setTags(tags);
issueTask = new IssueTask(act, bugService, pid, false, false, show, R.drawable.ic_bug_report_black_24dp);
issueTask.execute(issues.get(0)).get();
}
}
}
} catch (Exception ex) {
MessageHelper.printException(ex, MainActivity.this);
}
}
});

this.spMainFilters = this.findViewById(R.id.spMainFilters);
this.filterAdapter = new ArrayAdapter<>(this.getApplicationContext(), R.layout.spinner_item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import com.google.android.material.snackbar.Snackbar;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import de.domjos.unitrackerlibrary.model.ListObject;
import de.domjos.unitrackerlibrary.tasks.IssueTask;
import de.domjos.unitrackermobile.R;
Expand All @@ -52,6 +57,7 @@ public class SwipeRefreshDeleteList extends LinearLayout {
private Snackbar snackbar;
private SwipeRefreshLayout swipeRefreshLayout;
private LinearLayout linearLayout;
private Map<Integer, ButtonClickListener> menuItems;

public SwipeRefreshDeleteList(@NonNull Context context) {
super(context);
Expand All @@ -72,6 +78,7 @@ public RecyclerAdapter getAdapter() {
}

private void initDefault() {
this.menuItems = new LinkedHashMap<>();
this.setOrientation(VERTICAL);

this.swipeRefreshLayout = new SwipeRefreshLayout(this.context);
Expand Down Expand Up @@ -112,23 +119,6 @@ private void initDefault() {
});
this.linearLayout.addView(cmdDelete);

ImageButton cmdTags = new ImageButton(this.context);
cmdTags.setImageDrawable(VectorDrawableCompat.create(context.getResources(), R.drawable.ic_style_black_24dp, null));
cmdTags.setBackground(null);
cmdTags.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
cmdTags.setOnClickListener(event -> {
Settings settings = MainActivity.GLOBALS.getSettings(context);
String tags = Helper.showTagDialog(((Activity)context), Helper.getCurrentBugService(context), settings.showNotifications(), settings.getCurrentProjectId());

for(int i = 0; i<=this.adapter.getItemCount()-1; i++) {
ListObject obj = this.adapter.getItem(i);
if(obj.isSelected()) {

}
}
});
this.linearLayout.addView(cmdTags);

this.addView(this.linearLayout);

this.snackbar = Snackbar.make(((Activity)context).findViewById(android.R.id.content), R.string.sys_item_deleted, Snackbar.LENGTH_SHORT);
Expand Down Expand Up @@ -203,6 +193,26 @@ public void click(ClickListener clickListener) {
this.clickListener = clickListener;
}

public void addButtonClick(int drawableId, ButtonClickListener buttonClickListener) {
ImageButton cmdTags = new ImageButton(this.context);
cmdTags.setImageDrawable(VectorDrawableCompat.create(context.getResources(), drawableId, null));
cmdTags.setBackground(null);
cmdTags.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
cmdTags.setOnClickListener(event -> {
List<ListObject> listObjects = new LinkedList<>();
for(int i = 0; i<=this.adapter.getItemCount()-1; i++) {
ListObject obj = this.adapter.getItem(i);
if(obj.isSelected()) {
listObjects.add(obj);
}
}
if(buttonClickListener!=null) {
buttonClickListener.onClick(listObjects);
}
});
this.linearLayout.addView(cmdTags);
}

public void setContextMenu(int menuId) {
this.adapter.setContextMenu(menuId);
}
Expand All @@ -218,4 +228,8 @@ public abstract static class DeleteListener {
public abstract static class ClickListener {
public abstract void onClick(ListObject listObject);
}

public abstract static class ButtonClickListener {
public abstract void onClick(List<ListObject> objectList);
}
}

0 comments on commit 43b5c7e

Please sign in to comment.