ファイル書き込みテスト

This commit is contained in:
ろむねこ 2023-12-12 12:24:14 +09:00
parent 20575e115c
commit 7e262b6b57
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
2 changed files with 36 additions and 4 deletions

View File

@ -4,14 +4,15 @@ import android.os.Bundle;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;
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.Button;
import android.widget.Toast; import android.widget.Toast;
import java.io.File;
import java.io.IOException;
import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.AndroidEntryPoint;
import javax.inject.Inject; import javax.inject.Inject;
@ -82,7 +83,18 @@ public class DebugMenuFragment extends Fragment {
Toast.makeText(getContext(), getContext().getExternalFilesDir(null).toPath().toString(), Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), getContext().getExternalFilesDir(null).toPath().toString(), Toast.LENGTH_SHORT).show();
}); });
view.findViewById(R.id.btn_debug_menu_go_to_repository_debugger).setOnClickListener( v -> { view.findViewById(R.id.btn_debug_menu_file_write_test).setOnClickListener( v -> {
File file = getContext().getExternalFilesDir(null);
// ファイル書き込みテスト
try {
File testFile = new File(file, "test.txt");
testFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
});
view.findViewById(R.id.btn_debug_menu_go_to_repository_debug).setOnClickListener(v -> {
Navigation.findNavController(view).navigate(R.id.action_debugMenuFragment_to_debugRepositoryDebuggerFragment); Navigation.findNavController(view).navigate(R.id.action_debugMenuFragment_to_debugRepositoryDebuggerFragment);
}); });

View File

@ -119,6 +119,26 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="16dp" /> android:layout_height="16dp" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="File Debug"
android:textSize="24sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_debug_menu_file_write_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:text="Repository Debugger" />
<View
android:layout_width="match_parent"
android:layout_height="16dp" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -127,7 +147,7 @@
android:textSize="24sp" /> android:textSize="24sp" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/btn_debug_menu_go_to_repository_debugger" android:id="@+id/btn_debug_menu_go_to_repository_debug"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"