Merge pull request 'feature/showtotalreword' (#106) from feature/showtotalreword into main
Reviewed-on: #106
This commit is contained in:
commit
44c11c4f4f
|
@ -36,6 +36,10 @@ dependencies {
|
|||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
|
||||
implementation project(':utils')
|
||||
implementation project(':model')
|
||||
implementation project(':data')
|
||||
|
||||
// Hilt (DI)
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
|
|
@ -7,13 +7,32 @@ import androidx.fragment.app.Fragment;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.kidshift.data.RewardData;
|
||||
import one.nem.kidshift.utils.KSLogger;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ChildMainFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class ChildMainFragment extends Fragment {
|
||||
@Inject
|
||||
KSLogger ksLogger;
|
||||
|
||||
@Inject
|
||||
RewardData rewardData;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
|
@ -61,4 +80,29 @@ public class ChildMainFragment extends Fragment {
|
|||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_child_main, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
|
||||
ksLogger.addTag("ChildMainFragment");
|
||||
|
||||
Integer reward = rewardData.getTotalReward().join();
|
||||
|
||||
ksLogger.debug("取得したデータ: " + reward);
|
||||
|
||||
Calendar cl = Calendar.getInstance();
|
||||
TextView tr = view.findViewById(R.id.totalReward);
|
||||
TextView dv = view.findViewById(R.id.dateView);
|
||||
Date date = new Date();
|
||||
|
||||
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
sdf.applyPattern("yyyy年MM月");
|
||||
|
||||
dv.setText(sdf.format(cl.getTime()) + " お小遣い総額");
|
||||
tr.setText("¥" + nf.format(reward).toString());
|
||||
}
|
||||
}
|
|
@ -8,13 +8,25 @@
|
|||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:id="@+id/totalReward"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="🧒CHILD"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Display3"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="お小遣い総額"
|
||||
app:layout_constraintBottom_toTopOf="@+id/totalReward"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.10"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.85" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user