mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
とりあえずタグを表示できるようにした
This commit is contained in:
parent
ab92c6ce93
commit
9045cec67d
|
@ -121,6 +121,19 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
||||||
listItem.setDescription(simpleDateFormat.format(documentEntity.updatedAt));
|
listItem.setDescription(simpleDateFormat.format(documentEntity.updatedAt));
|
||||||
listItem.setItemId(documentEntity.id);
|
listItem.setItemId(documentEntity.id);
|
||||||
listItem.setHasCombined(documentEntity.isCombineParent);
|
listItem.setHasCombined(documentEntity.isCombineParent);
|
||||||
|
// タグを取得して関連付ける処理 TODO-rca: わかりにくい + 責任がめちゃくちゃ + めちゃくちゃ重いのでなんとかする
|
||||||
|
List<ToxiDocumentTagEntity> documentTagEntities = database.toxiDocumentTagDao().findByDocumentId(documentEntity.id);
|
||||||
|
ArrayList<DocumentTag> documentTags = new ArrayList<>();
|
||||||
|
for (ToxiDocumentTagEntity toxiDocumentTagEntity : documentTagEntities) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "toxiDocumentTagEntity.tagId: " + toxiDocumentTagEntity.tagId);
|
||||||
|
TagEntity tagEntity = database.tagDao().findById(toxiDocumentTagEntity.tagId);
|
||||||
|
if (tagEntity != null) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "tagEntity.tagName: " + tagEntity.tagName);
|
||||||
|
documentTags.add(convertTagEntityToDocumentTag(tagEntity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listItem.setTagList(documentTags);
|
||||||
|
logger.debug("LacertaLibraryImpl", "documentTags.size(): " + documentTags.size());
|
||||||
listItems.add(listItem);
|
listItems.add(listItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,11 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
||||||
|
import one.nem.lacerta.data.Document;
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.LibraryItemPage;
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
import one.nem.lacerta.model.ListItemType;
|
||||||
|
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||||
import one.nem.lacerta.utils.FeatureSwitch;
|
import one.nem.lacerta.utils.FeatureSwitch;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
|
@ -53,6 +55,9 @@ public class LibraryPageFragment extends Fragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLogger logger;
|
LacertaLogger logger;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Document document;
|
||||||
|
|
||||||
ListItemAdapter listItemAdapter;
|
ListItemAdapter listItemAdapter;
|
||||||
|
|
||||||
public LibraryPageFragment() {
|
public LibraryPageFragment() {
|
||||||
|
@ -233,6 +238,9 @@ public class LibraryPageFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getTag(String documentId) { //debug
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toolbarのサブタイトルを更新
|
* Toolbarのサブタイトルを更新
|
||||||
* @param subtitle サブタイトル
|
* @param subtitle サブタイトル
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package one.nem.lacerta.feature.library;
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.chip.Chip;
|
||||||
|
import com.google.android.material.chip.ChipGroup;
|
||||||
|
|
||||||
import one.nem.lacerta.model.LibraryItemPage;
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
import one.nem.lacerta.model.ListItemType;
|
||||||
|
@ -31,7 +36,7 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
|
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item_with_tag, parent, false);
|
||||||
return new ListItemViewHolder(view);
|
return new ListItemViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +48,20 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
||||||
holder.title.setText(listItem.getTitle());
|
holder.title.setText(listItem.getTitle());
|
||||||
holder.description.setText(listItem.getDescription());
|
holder.description.setText(listItem.getDescription());
|
||||||
|
|
||||||
|
if (listItem.getTagList() != null) {
|
||||||
|
for (int i = 0; i < listItem.getTagList().size(); i++) {
|
||||||
|
Toast.makeText(holder.tagGroup.getContext(), listItem.getTagList().get(i).getName(), Toast.LENGTH_SHORT).show();
|
||||||
|
ChipGroup chipGroup = holder.tagGroup;
|
||||||
|
Chip chip = new Chip(chipGroup.getContext());
|
||||||
|
chip.setText(listItem.getTagList().get(i).getName());
|
||||||
|
chipGroup.addView(chip);
|
||||||
|
}
|
||||||
|
holder.tagGroup.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
Log.d("tagList", "tagList is null");
|
||||||
|
holder.tagGroup.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
holder.itemView.setOnClickListener( v -> {
|
holder.itemView.setOnClickListener( v -> {
|
||||||
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
|
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||||
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined());
|
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined());
|
||||||
|
@ -64,12 +83,14 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
||||||
ImageView icon;
|
ImageView icon;
|
||||||
TextView title;
|
TextView title;
|
||||||
TextView description;
|
TextView description;
|
||||||
|
ChipGroup tagGroup;
|
||||||
public ListItemViewHolder(@NonNull View itemView) {
|
public ListItemViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
|
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
|
||||||
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
|
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
|
||||||
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
|
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
|
||||||
|
tagGroup = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user