OSDN Git Service

記録表示用のダミー表示を行ってみた。
authorMRSa <mrsa@myad.jp>
Thu, 8 Mar 2018 15:40:24 +0000 (00:40 +0900)
committerMRSa <mrsa@myad.jp>
Thu, 8 Mar 2018 15:40:24 +0000 (00:40 +0900)
wear/src/main/AndroidManifest.xml
wear/src/main/java/net/osdn/gokigen/joggingtimer/MainActivity.java
wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/DataRecord.java [new file with mode: 0644]
wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/ListActivity.java [moved from wear/src/main/java/net/osdn/gokigen/joggingtimer/ListActivity.java with 76% similarity]
wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/RecordHolder.java [new file with mode: 0644]
wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/RecordSummaryAdapter.java [new file with mode: 0644]
wear/src/main/res/layout-notround/column_list.xml [new file with mode: 0644]
wear/src/main/res/layout-round/column_list.xml [new file with mode: 0644]

index 5c3094e..2e2f576 100644 (file)
@@ -49,7 +49,7 @@
             </intent-filter>
         </activity>
         <activity
-            android:name=".ListActivity"
+            android:name=".recordlist.ListActivity"
             android:label="@string/result_list">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
index a81361a..ea6ffa5 100644 (file)
@@ -11,6 +11,8 @@ import android.widget.ImageButton;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import net.osdn.gokigen.joggingtimer.recordlist.ListActivity;
+
 import java.util.List;
 
 /**
diff --git a/wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/DataRecord.java b/wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/DataRecord.java
new file mode 100644 (file)
index 0000000..f6ea5f7
--- /dev/null
@@ -0,0 +1,42 @@
+package net.osdn.gokigen.joggingtimer.recordlist;
+
+/**
+ *
+ *
+ */
+public class DataRecord
+{
+    private int iconId = 0;
+    private String title = "";
+    private String detail = "";
+
+    /**
+     *
+     */
+    public DataRecord(int iconId, String title, String detail)
+    {
+        this.iconId = iconId;
+        this.title = title;
+        this.detail = detail;
+    }
+
+    public void setIconId(int iconId)
+    {
+        this.iconId = iconId;
+    }
+
+    public int getIconId()
+    {
+        return (iconId);
+    }
+
+    public String getTitle()
+    {
+        return (title);
+    }
+
+    public String getDetail()
+    {
+        return (detail);
+    }
+}
@@ -1,10 +1,13 @@
-package net.osdn.gokigen.joggingtimer;
+package net.osdn.gokigen.joggingtimer.recordlist;
 
 import android.os.Bundle;
+import android.support.wear.widget.WearableLinearLayoutManager;
 import android.support.wearable.activity.WearableActivity;
 import android.support.wear.widget.WearableRecyclerView;
 import android.util.Log;
 
+import net.osdn.gokigen.joggingtimer.R;
+
 public class ListActivity extends WearableActivity
 {
     private final String TAG = toString();
@@ -22,6 +25,20 @@ public class ListActivity extends WearableActivity
 
         // Enables Always-on
         setAmbientEnabled();
+
+        try
+        {
+            WearableRecyclerView view = findViewById(R.id.recycler_list_view);
+            RecordSummaryAdapter adapter = new RecordSummaryAdapter();
+            WearableLinearLayoutManager layoutManager = new WearableLinearLayoutManager(this);
+
+            view.setLayoutManager(layoutManager);
+            view.setAdapter(adapter);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
     }
 
     /**
diff --git a/wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/RecordHolder.java b/wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/RecordHolder.java
new file mode 100644 (file)
index 0000000..b0cabd3
--- /dev/null
@@ -0,0 +1,41 @@
+package net.osdn.gokigen.joggingtimer.recordlist;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osdn.gokigen.joggingtimer.R;
+
+class RecordHolder extends RecyclerView.ViewHolder
+{
+    private ImageView iconView = null;
+    private TextView mainText = null;
+    private TextView subText = null;
+
+    RecordHolder(View itemView)
+    {
+        super(itemView);
+        iconView = itemView.findViewById(R.id.gokigen_icon);
+        mainText = itemView.findViewById(R.id.main_text);
+        subText = itemView.findViewById(R.id.sub_text);
+    }
+
+    void setIconId(int iconId)
+    {
+        if (iconId != 0)
+        {
+            iconView.setImageResource(iconId);
+        }
+    }
+
+    void setMainText(String message)
+    {
+        mainText.setText(message);
+    }
+
+    void setSubText(String message)
+    {
+        subText.setText(message);
+    }
+}
diff --git a/wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/RecordSummaryAdapter.java b/wear/src/main/java/net/osdn/gokigen/joggingtimer/recordlist/RecordSummaryAdapter.java
new file mode 100644 (file)
index 0000000..fae38dc
--- /dev/null
@@ -0,0 +1,113 @@
+package net.osdn.gokigen.joggingtimer.recordlist;
+
+import android.provider.ContactsContract;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import net.osdn.gokigen.joggingtimer.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ *
+ */
+public class RecordSummaryAdapter extends RecyclerView.Adapter<RecordHolder>
+{
+    private List<DataRecord> list = null;
+
+    /**
+     *
+     *
+     */
+    public RecordSummaryAdapter()
+    {
+        list = new ArrayList<>();
+        list.clear();
+
+        addRecord(new DataRecord(0, "XXXXX", "00000000"));
+        addRecord(new DataRecord(R.drawable.ic_sentiment_very_dissatisfied_black_24dp, "XXXXX", "11111111"));
+        addRecord(new DataRecord(R.drawable.ic_mood_bad_black_24dp, "XXXXX", "2222222"));
+        addRecord(new DataRecord(R.drawable.ic_sentiment_dissatisfied_black_24dp, "XXXXX", "3333333"));
+        addRecord(new DataRecord(R.drawable.ic_sentiment_neutral_black_24dp, "XXXXX", "44444444"));
+        addRecord(new DataRecord(R.drawable.ic_sentiment_satisfied_black_24dp, "XXXXX", "55555555"));
+        addRecord(new DataRecord(R.drawable.ic_mood_black_24dp, "XXXXX", "66666666"));
+        addRecord(new DataRecord(R.drawable.ic_sentiment_very_satisfied_black_24dp, "XXXXX", "77777777"));
+    }
+
+    /**
+     *
+     *
+     */
+    public void addRecord(DataRecord record)
+    {
+        try
+        {
+            list.add(record);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     *
+     *
+     */
+    public void clearRecord()
+    {
+        try
+        {
+            list.clear();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public RecordHolder onCreateViewHolder(ViewGroup parent, int viewType)
+    {
+        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.column_list, parent,false);
+        return (new RecordHolder(inflate));
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void onBindViewHolder(RecordHolder holder, int position)
+    {
+        try
+        {
+            holder.setIconId(list.get(position).getIconId());
+            holder.setMainText(list.get(position).getTitle());
+            holder.setSubText(list.get(position).getDetail());
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public int getItemCount()
+    {
+        return (list.size());
+    }
+}
diff --git a/wear/src/main/res/layout-notround/column_list.xml b/wear/src/main/res/layout-notround/column_list.xml
new file mode 100644 (file)
index 0000000..52565b6
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    >
+    <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/gokigen_icon"
+        android:layout_width="18dp"
+        android:layout_height="18dp"
+        android:scaleType="fitCenter"
+        android:src="@drawable/ic_info_outline_black_24dp"
+        android:layout_gravity="center_vertical"
+        android:maxHeight="18dp"
+        android:minWidth="18dp"
+        android:layout_margin="4dp"
+        android:contentDescription="@string/blank"
+        android:tint="@color/white"
+        android:tag="icon"
+        />
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:id="@+id/data_list"
+        >
+        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textStyle="normal"
+            android:textSize="10pt"
+            android:clickable="false"
+            android:focusable="false"
+            android:tag="main"
+            android:id="@+id/main_text"
+            />
+        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="8pt"
+            android:clickable="false"
+            android:focusable="false"
+            android:tag="sub"
+            android:id="@+id/sub_text"
+            />
+    </LinearLayout>
+</LinearLayout>
diff --git a/wear/src/main/res/layout-round/column_list.xml b/wear/src/main/res/layout-round/column_list.xml
new file mode 100644 (file)
index 0000000..ea40b09
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    >
+    <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/gokigen_icon"
+        android:layout_width="18dp"
+        android:layout_height="18dp"
+        android:scaleType="fitCenter"
+        android:src="@drawable/ic_info_outline_black_24dp"
+        android:layout_gravity="center_vertical"
+        android:maxHeight="18dp"
+        android:minWidth="18dp"
+        android:contentDescription="@string/blank"
+        android:tag="icon"
+        />
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:id="@+id/data_list"
+        >
+        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textStyle="normal"
+            android:textSize="10pt"
+            android:clickable="false"
+            android:focusable="false"
+            android:tag="main"
+            android:id="@+id/main_text"
+            />
+        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="8pt"
+            android:clickable="false"
+            android:focusable="false"
+            android:tag="sub"
+            android:id="@+id/sub_text"
+            />
+    </LinearLayout>
+</LinearLayout>