From 5abd9ec086d5f89e50f54711943bf7e7d76af2e9 Mon Sep 17 00:00:00 2001 From: it232115 Date: Mon, 22 Jan 2024 22:30:07 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E7=A8=AE=E3=83=90=E3=82=B0=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E9=80=9A=E7=9F=A5=E3=81=AE=E3=83=AA?= =?UTF-8?q?=E3=82=B9=E3=83=88=E5=8C=96=E6=98=A8=E6=97=A5=E3=81=AE=E6=96=AD?= =?UTF-8?q?=E5=BF=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/MainActivity.java | 8 +-- .../com/example/childguard/TestService.java | 67 +------------------ app/src/main/res/menu/bottom_menu.xml | 5 +- 3 files changed, 4 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index 846a4e2..8ea8856 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -98,12 +98,7 @@ public class MainActivity extends AppCompatActivity { .commit(); firebaselink(); - } else if (v.getItemId() == findViewById(R.id.navigation_notification).getId()) { - findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.VISIBLE); - getSupportFragmentManager().beginTransaction() - .replace(findViewById(R.id.fragmentContainerView).getId(), NotificationFragment.newInstance("test", "test")) - .addToBackStack(null) - .commit(); + } else if (v.getItemId() == findViewById(R.id.navigation_settings).getId()) { findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.GONE); getSupportFragmentManager().beginTransaction() @@ -111,6 +106,7 @@ public class MainActivity extends AppCompatActivity { .addToBackStack(null) .commit(); } + firebaselink(); return true; }); diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index 64a8ca4..46ffcde 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -50,76 +50,11 @@ public class TestService extends Service { public PeriodicTaskManager periodicTaskManager; - //時間を取得するやつ↓ - public static String getNowDate() { - @SuppressLint("SimpleDateFormat") final DateFormat df = new SimpleDateFormat("yyy/MM/dd HH:mm:ss"); - final Date date = new Date(System.currentTimeMillis()); - return df.format(date); - } - - @SuppressLint("NotifyDataSetChanged") - public void NotifityRecycle(){ - - RecyclerView recyclerView = recyclerView().findViewById(R.id.recyclerView1); - - //RecyclerViewのサイズを固定 - recyclerView.setHasFixedSize(true); - - //RecyclerViewに区切り線を入れる - RecyclerView.ItemDecoration itemDecoration = - new DividerItemDecoration(this, DividerItemDecoration.VERTICAL); - recyclerView.addItemDecoration(itemDecoration); - - //レイアウトマネージャを設定 - RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); - recyclerView.setLayoutManager(layoutManager); - - //①リスト構造(String型の可変長の配列)を宣言 - ArrayList arrayList = new ArrayList<>(); - - //③Adapterとリスト構造を結び付け - //RecyclerAdapterクラスを呼び出す - RecyclerAdapter2 adapter = new RecyclerAdapter2(arrayList, null); - - //④RecyclerViewとAdapterの結び付け - recyclerView.setAdapter(adapter); - - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); - - arrayList.add(0,"通知を検知しました: " + getNowDate()); - - //一番下に値が追加されたことをAdapterが画面に通知 - adapter.notifyItemInserted(arrayList.size()); - - //共有プリファレンス 書き込みの準備 - SharedPreferences.Editor e = pref.edit(); - - //リストを,区切りで結合する - String str = String.join(",", arrayList); - - //変数名currentに、値の代入 - e.putString("current", str.toString()); - - //確定処理 - e.apply(); - - String strTo = pref.getString("current", null); - if (strTo == null) return; - - String[] list = strTo.split(","); - arrayList.clear(); - arrayList.addAll(Arrays.asList(list)); - adapter.notifyDataSetChanged(); - } - - private Activity recyclerView() { - return null; - } @Override public int onStartCommand(Intent intent, int flags, int startId) { - NotifityRecycle(); + //共有プリファレンス全体の準備 SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE); String IdPref = sharedPreferences.getString("ID", null);//アプリに記録されているIDの取得 diff --git a/app/src/main/res/menu/bottom_menu.xml b/app/src/main/res/menu/bottom_menu.xml index c3e8d9a..0d0305f 100644 --- a/app/src/main/res/menu/bottom_menu.xml +++ b/app/src/main/res/menu/bottom_menu.xml @@ -4,10 +4,7 @@ android:id="@+id/navigation_home" android:icon="@drawable/ic_home_black_24dp" android:title="home"/> - +