mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
Merge pull request #11 from lacerta-doc/feature/library/add_document_list
Feature/library/add document list
This commit is contained in:
commit
3e24896bd1
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetDropDown">
|
|
||||||
<runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="RUNNING_DEVICE_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="SERIAL_NUMBER" />
|
|
||||||
<value value="ZY227DCBHN" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-12-21T04:53:14.729902700Z" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,5 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.library'
|
id 'com.android.library'
|
||||||
|
id 'com.google.dagger.hilt.android'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
@ -46,5 +47,9 @@ dependencies {
|
||||||
|
|
||||||
implementation project(':shared:ui')
|
implementation project(':shared:ui')
|
||||||
|
|
||||||
|
implementation project(':model')
|
||||||
|
|
||||||
|
implementation project(':data')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,12 +10,18 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
|
|
||||||
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
|
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
|
||||||
|
|
||||||
private List<String> documentList;
|
private List<DocumentMeta> documentMetas;
|
||||||
|
|
||||||
public DocumentAdapter(List<String> documentList) {
|
public DocumentAdapter(List<DocumentMeta> documentMetas) {
|
||||||
this.documentList = documentList;
|
// nullの場合に例外を発生させる
|
||||||
|
if (documentMetas == null) {
|
||||||
|
throw new IllegalArgumentException("DocumentMetas list cannot be null or empty");
|
||||||
|
}
|
||||||
|
this.documentMetas = documentMetas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -27,12 +33,15 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
||||||
holder.title.setText(documentList.get(position));
|
DocumentMeta documentMeta = documentMetas.get(position);
|
||||||
|
if (documentMeta != null) {
|
||||||
|
holder.title.setText(documentMeta.getTitle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return documentList.size();
|
return documentMetas.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
class DocumentViewHolder extends RecyclerView.ViewHolder {
|
class DocumentViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@ -40,7 +49,7 @@ public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.Docume
|
||||||
|
|
||||||
DocumentViewHolder(View itemView) {
|
DocumentViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
title = itemView.findViewById(R.id.debug_menu_item_title);
|
title = itemView.findViewById(R.id.debug_menu_item_title); // 適切な id に変更する
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
// LibraryArchiveFragment.java
|
// LibraryArchiveFragment.java
|
||||||
|
|
||||||
|
//画面変移用のコード
|
||||||
|
//Fragmentへのデータの受け渡し機能
|
||||||
public class LibraryArchiveFragment extends AppCompatActivity {
|
public class LibraryArchiveFragment extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
//Fragmentにデータを受け渡す機能
|
||||||
public class LibraryDocFragment extends Fragment {
|
public class LibraryDocFragment extends Fragment {
|
||||||
|
|
||||||
private TextView textView; // フィールドとして TextView を定義
|
private TextView textView; // フィールドとして TextView を定義
|
||||||
|
|
|
@ -13,17 +13,29 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.data.Document;
|
||||||
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
|
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
* Use the {@link LibraryTopFragment#newInstance} factory method to
|
* Use the {@link LibraryTopFragment#newInstance} factory method to
|
||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
|
@AndroidEntryPoint
|
||||||
public class LibraryTopFragment extends Fragment {
|
public class LibraryTopFragment extends Fragment {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Document document;
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
// TODO: Rename parameter arguments, choose names that match
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||||
private static final String ARG_PARAM1 = "param1";
|
private static final String ARG_PARAM1 = "param1";
|
||||||
|
@ -76,13 +88,14 @@ public class LibraryTopFragment extends Fragment {
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
||||||
documentRecyclerView.setLayoutManager(layoutManager);
|
documentRecyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
List<String> documentList = new ArrayList<>();
|
//データを取得
|
||||||
documentList.add("Document A");
|
|
||||||
documentList.add("Document B");
|
List<DocumentMeta> metas = document.getAllDocumentMetas(100);
|
||||||
documentList.add("Document C");
|
|
||||||
|
Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
// Create and set the adapter
|
// Create and set the adapter
|
||||||
DocumentAdapter adapter = new DocumentAdapter(documentList);
|
DocumentAdapter adapter = new DocumentAdapter(metas);
|
||||||
documentRecyclerView.setAdapter(adapter);
|
documentRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
// Use a LinearLayoutManager to specify the layout
|
// Use a LinearLayoutManager to specify the layout
|
||||||
|
|
Loading…
Reference in New Issue
Block a user