Skip to content

Commit

Permalink
CloudActivity TextViews to ListViews
Browse files Browse the repository at this point in the history
  • Loading branch information
adithya321 committed May 20, 2016
1 parent c0cd623 commit 8f10aae
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 54 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
applicationId "com.pimp.companionforband"
minSdkVersion 17
targetSdkVersion 23
versionCode 28
versionName "2.7.0"
versionCode 29
versionName "2.8.0"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
Expand All @@ -28,14 +31,18 @@
import org.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class ActivitiesFragment extends Fragment {

TextView activitiesTV, statusTV;
TextView statusTV;
ListView activitiesLV;
ArrayAdapter<String> stringArrayAdapter;
ArrayList<String> stringArrayList;

@Nullable
@Override
Expand All @@ -47,8 +54,12 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

activitiesTV = (TextView) view.findViewById(R.id.activities_textview);
activitiesLV = (ListView) view.findViewById(R.id.activities_listview);
statusTV = (TextView) view.findViewById(R.id.status_textview);
stringArrayList = new ArrayList<>();
stringArrayAdapter = new ArrayAdapter<>(getContext(), R.layout.activities_list_item,
R.id.list_item_textView, stringArrayList);
activitiesLV.setAdapter(stringArrayAdapter);

RequestQueue queue = Volley.newRequestQueue(getContext());

Expand Down Expand Up @@ -83,22 +94,23 @@ public void onResponse(JSONObject response) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject activity = jsonArray.getJSONObject(i);
Iterator<String> iterator = activity.keys();
String str = "";
while (iterator.hasNext()) {
key = iterator.next();
activitiesTV.append(UIUtils.splitCamelCase(key) + " : ");
activitiesTV.append(activity.get(key).toString() + "\n");
str = str + UIUtils.splitCamelCase(key) + " : "
+ activity.get(key).toString() + "\n";
}
activitiesTV.append("\n\n");
stringArrayAdapter.add(str);
}
} catch (Exception e) {
activitiesTV.append(e.toString());
Log.e("Activities", e.toString());
}
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
activitiesTV.setText(error.getMessage());
Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_LONG).show();
}
}) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
Expand All @@ -28,14 +31,18 @@
import org.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class SummariesFragment extends Fragment {

TextView summariesTV, statusTV;
TextView statusTV;
ListView summariesLV;
ArrayAdapter<String> stringArrayAdapter;
ArrayList<String> stringArrayList;

@Nullable
@Override
Expand All @@ -47,8 +54,12 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

summariesTV = (TextView) view.findViewById(R.id.summaries_textview);
summariesLV = (ListView) view.findViewById(R.id.summaries_listview);
statusTV = (TextView) view.findViewById(R.id.status_textview);
stringArrayList = new ArrayList<>();
stringArrayAdapter = new ArrayAdapter<>(getContext(), R.layout.activities_list_item,
R.id.list_item_textView, stringArrayList);
summariesLV.setAdapter(stringArrayAdapter);

RequestQueue queue = Volley.newRequestQueue(getContext());

Expand Down Expand Up @@ -84,22 +95,23 @@ public void onResponse(JSONObject response) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject activity = jsonArray.getJSONObject(i);
Iterator<String> iterator = activity.keys();
String str = "";
while (iterator.hasNext()) {
key = iterator.next();
summariesTV.append(UIUtils.splitCamelCase(key) + " : ");
summariesTV.append(activity.get(key).toString() + "\n");
str = str + UIUtils.splitCamelCase(key) + " : "
+ activity.get(key).toString() + "\n";
}
summariesTV.append("\n\n");
stringArrayAdapter.add(str);
}
} catch (Exception e) {
summariesTV.append(e.toString());
Log.e("Summaries", e.toString());
}
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
summariesTV.setText(error.getMessage());
Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_LONG).show();
}
}) {
@Override
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res-screen/layout/activities_list_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="8dp"
android:textAppearance="?android:attr/textAppearanceListItem" />
</android.support.v7.widget.CardView>
35 changes: 16 additions & 19 deletions app/src/main/res-screen/layout/fragment_activities.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">

<LinearLayout
<TextView
android:id="@+id/status_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
android:text="Loading...\n"
android:textAppearance="?android:textAppearanceLarge" />

<TextView
android:id="@+id/status_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Loading...\n"
android:textAppearance="?android:textAppearanceLarge" />

<TextView
android:id="@+id/activities_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium" />
</LinearLayout>
</ScrollView>
<ListView
android:id="@+id/activities_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:fastScrollAlwaysVisible="true" />
</LinearLayout>
35 changes: 16 additions & 19 deletions app/src/main/res-screen/layout/fragment_summaries.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">

<LinearLayout
<TextView
android:id="@+id/status_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
android:text="Loading...\n"
android:textAppearance="?android:textAppearanceLarge" />

<TextView
android:id="@+id/status_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Loading...\n"
android:textAppearance="?android:textAppearanceLarge" />

<TextView
android:id="@+id/summaries_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium" />
</LinearLayout>
</ScrollView>
<ListView
android:id="@+id/summaries_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:fastScrollAlwaysVisible="true" />
</LinearLayout>
4 changes: 4 additions & 0 deletions app/src/main/res-screen/raw/changelog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog bulletedList="true">
<changelogversion changeDate="MAY 20, 2016" versionName="2.8.0">
<changelogimprovement>Log MS Health activities and summaries</changelogimprovement>
</changelogversion>

<changelogversion changeDate="MAY 16, 2016" versionName="2.7.0">
<changelogimprovement>Improved Sensors UI</changelogimprovement>
<changelogbug>Fix 'Pick Me Tile' bug</changelogbug>
Expand Down

0 comments on commit 8f10aae

Please sign in to comment.