This commit is contained in:
Fuchimoto1234 2024-01-17 12:35:30 +09:00
parent a5efab5838
commit 20d30e338e
14 changed files with 115 additions and 48 deletions

View File

@ -39,4 +39,4 @@ public class MainActivity extends AppCompatActivity {
} }
} }

View File

@ -43,4 +43,8 @@ public interface Document {
DocumentDetail getDocumentDetailByMeta(DocumentMeta meta); // 簡単に使えるように DocumentDetail getDocumentDetailByMeta(DocumentMeta meta); // 簡単に使えるように
DocumentDetail createDocumentByMeta(DocumentMeta meta); DocumentDetail createDocumentByMeta(DocumentMeta meta);
Object getDocumentDetail();
ArrayList<DocumentDetail> getAllDocumentDetail(int i);
} }

View File

@ -138,4 +138,14 @@ public class DocumentImpl implements Document{
return documentDetail; return documentDetail;
} }
@Override
public Object getDocumentDetail() {
return null;
}
@Override
public ArrayList<DocumentDetail> getAllDocumentDetail(int i) {
return null;
}
} }

View File

@ -23,4 +23,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" /> app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -30,6 +30,8 @@ dependencies {
implementation libs.androidx.appcompat implementation libs.androidx.appcompat
implementation libs.com.google.android.material implementation libs.com.google.android.material
implementation project(path: ':feature:debug')
implementation project(path: ':utils')
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core androidTestImplementation libs.androidx.test.espresso.core

View File

@ -1,26 +1,25 @@
package one.nem.lacerta.feature.home; package one.nem.lacerta.feature.home;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log; 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 androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document; import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag;
import dagger.hilt.android.AndroidEntryPoint;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -33,6 +32,11 @@ public class HomeTopFragment extends Fragment {
@Inject @Inject
Document document; 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";
@ -64,12 +68,15 @@ public class HomeTopFragment extends Fragment {
return fragment; return fragment;
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getArguments() != null) { if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1); mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2); mParam2 = getArguments().getString(ARG_PARAM2);
} }
} }
@ -79,12 +86,38 @@ public class HomeTopFragment extends Fragment {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home_top, container, false); View view = inflater.inflate(R.layout.fragment_home_top, container, false);
ArrayList<DocumentMeta> metas = document.getAllDocumentMetas(100); List<DocumentMeta> metas = document.getAllDocumentMetas(100);
Log.d("docs", Integer.toString(metas.size())); Log.d("docs", Integer.toString(metas.size()));
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
MyAdapter myAdapter = new MyAdapter(metas);
recyclerView.setAdapter(myAdapter);
return view; return view;
}
} }
String pageTitle;
String pageId;
ArrayList listItems;
String title;
String description;
String itemId;
}

View File

@ -1,7 +1,9 @@
package one.nem.lacerta.feature.home; package one.nem.lacerta.feature.home;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView;
import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentMeta;
@ -11,28 +13,56 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List; import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyAdapterViewHolder> { public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyAdapterViewHolder> {
List<DocumentMeta> documentMetas;
public MyAdapter(List<DocumentMeta> documentMeta) { public MyAdapter(List<DocumentMeta> documentMeta) {
this.documentMetas = documentMeta;
} }
@NonNull @NonNull
@Override @Override
public MyAdapterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public MyAdapterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null; View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_home_document, parent, false);
return new MyAdapterViewHolder(view);
} }
@Override @Override
public void onBindViewHolder(@NonNull MyAdapterViewHolder holder, int position) { public void onBindViewHolder(@NonNull MyAdapterViewHolder holder, int position) {
holder.title.setText(documentMetas.get(position).getTitle());
holder.description.setText(documentMetas.get(position).getId());
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return 100; return documentMetas.size();
} }
public class MyAdapterViewHolder extends RecyclerView.ViewHolder { public class MyAdapterViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView description;
public MyAdapterViewHolder(@NonNull View itemView) { public MyAdapterViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
title = itemView.findViewById(R.id.debug_menu_item_title);
description = itemView.findViewById(R.id.debug_menu_item_description);
} }
} }
} }

View File

@ -1,33 +0,0 @@
package one.nem.lacerta.feature.home;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class myfragment extends Fragment {
private RecyclerView recyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager layoutManager;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
Object myDataset = 100;
mAdapter = new MyAdapter(myDataset);
recyclerView.setAdapter(mAdapter);
return view;
}
}

View File

@ -13,7 +13,9 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</FrameLayout> </FrameLayout>

View File

@ -23,4 +23,14 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" /> app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
<TextView
android:id="@+id/debug_menu_item_updated_at_home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="Updated at: aaaaaaaaaa"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<item name="my_recycler_view" type="id" /> <item name="my_recycler_view" type="id" />
<item name="TITLE" type="id" />
<item name="textView" type="id" />
</resources> </resources>

View File

@ -1,4 +1,5 @@
<resources> <resources>
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
<string name="textview">TextView</string>
</resources> </resources>

View File

@ -8,6 +8,8 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
/** /**
* 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

View File

@ -125,4 +125,6 @@ public class DocumentDetail {
this.repository = repository; this.repository = repository;
} }
}
}