Skip to content

Commit

Permalink
re-wrote nested comments as a view (instead of a listview). Fixed spe…
Browse files Browse the repository at this point in the history
…cial character display issue(s)
  • Loading branch information
glebpopoff committed Nov 9, 2011
1 parent 88a9d12 commit 985885b
Show file tree
Hide file tree
Showing 62 changed files with 1,537 additions and 115 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.glebpopov.hackernews"
android:versionCode="11"
android:versionName="2.1">
android:versionCode="12"
android:versionName="2.2">
<uses-sdk android:minSdkVersion="7" />

<application
Expand Down
Binary file modified bin/HackerNewsDroid.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/AskActivity.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/BestActivity.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/CommentsActivity.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/NewestActivity.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$dimen.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$drawable.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$id.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$layout.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$menu.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$raw.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$string.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$style.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$styleable.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/R$xml.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/domain/CommentItem.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/CommentsFragment$1.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/CommentsFragment$2.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/CommentsFragment.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/NewsFragment$2.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/NewsFragment$5$1.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/NewsFragment.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/PreviewFragment.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/fragments/SavedNewsFragment$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/net/DataParser.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/service/HackerNewsService.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/ui/BaseActivity.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/ui/BaseSinglePaneActivity.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/util/ActivityHelper$1.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/util/ActivityHelper$2.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/util/ActivityHelper.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/util/SimpleMenu.class
Binary file not shown.
Binary file modified bin/com/glebpopov/hackernews/util/SimpleMenuItem.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
126 changes: 65 additions & 61 deletions gen/com/glebpopov/hackernews/R.java
Expand Up @@ -171,33 +171,34 @@ public static final class color {
public static final int hyperlink=0x7f070009;
}
public static final class dimen {
public static final int actionbar_compat_height=0x7f080001;
public static final int body_padding_large=0x7f08000f;
public static final int actionbar_compat_height=0x7f080002;
public static final int body_padding_large=0x7f080010;
/** body content
*/
public static final int body_padding_medium=0x7f08000e;
public static final int body_padding_medium=0x7f08000f;
public static final int colorstrip_height=0x7f080001;
/** UI elements
*/
public static final int colorstrip_height=0x7f080000;
public static final int schedule_header_padding=0x7f080005;
public static final int schedule_hour_height=0x7f080006;
public static final int schedule_label_header_width=0x7f080007;
public static final int schedule_label_padding=0x7f080008;
public static final int speaker_image_padding=0x7f080015;
public static final int speaker_image_size=0x7f080014;
public static final int star_button_padding=0x7f080009;
public static final int tab_height=0x7f08000a;
public static final int tab_side_padding=0x7f08000b;
public static final int text_size_large=0x7f080012;
public static final int text_size_medium=0x7f080011;
public static final int text_size_small=0x7f080010;
public static final int text_size_xlarge=0x7f080013;
public static final int track_icon_padding=0x7f08000d;
public static final int track_icon_width=0x7f08000c;
public static final int vendor_image_size=0x7f080016;
public static final int whats_on_button_right_padding=0x7f080004;
public static final int whats_on_height=0x7f080002;
public static final int whats_on_item_padding=0x7f080003;
public static final int line_break_height=0x7f080000;
public static final int schedule_header_padding=0x7f080006;
public static final int schedule_hour_height=0x7f080007;
public static final int schedule_label_header_width=0x7f080008;
public static final int schedule_label_padding=0x7f080009;
public static final int speaker_image_padding=0x7f080016;
public static final int speaker_image_size=0x7f080015;
public static final int star_button_padding=0x7f08000a;
public static final int tab_height=0x7f08000b;
public static final int tab_side_padding=0x7f08000c;
public static final int text_size_large=0x7f080013;
public static final int text_size_medium=0x7f080012;
public static final int text_size_small=0x7f080011;
public static final int text_size_xlarge=0x7f080014;
public static final int track_icon_padding=0x7f08000e;
public static final int track_icon_width=0x7f08000d;
public static final int vendor_image_size=0x7f080017;
public static final int whats_on_button_right_padding=0x7f080005;
public static final int whats_on_height=0x7f080003;
public static final int whats_on_item_padding=0x7f080004;
}
public static final class drawable {
public static final int actionbar_compat_background=0x7f020000;
Expand Down Expand Up @@ -237,56 +238,59 @@ public static final class id {
public static final int actionbar_compat_text=0x7f090003;
public static final int blocks_now=0x7f09000c;
public static final int blocks_ruler=0x7f09000b;
public static final int buttonLogin=0x7f09002d;
public static final int checkBoxRemember=0x7f09002b;
public static final int buttonLogin=0x7f090030;
public static final int checkBoxRemember=0x7f09002e;
public static final int colorstrip=0x7f090012;
public static final int comment_author=0x7f090018;
public static final int comment_comment=0x7f09001a;
public static final int comment_whenposted=0x7f090019;
public static final int comments_inner_layout=0x7f090017;
public static final int comments_layout=0x7f090016;
public static final int comment_author=0x7f09001b;
public static final int comment_comment=0x7f09001d;
public static final int comment_whenposted=0x7f09001c;
public static final int comments_header_layout=0x7f090014;
public static final int comments_inner_layout=0x7f09001a;
public static final int comments_layout=0x7f090019;
public static final int dialog_discard_confirm=0x7f090009;
public static final int dialog_moderator=0x7f09000a;
public static final int editPassword=0x7f090029;
public static final int editUsername=0x7f090026;
public static final int editPassword=0x7f09002c;
public static final int editUsername=0x7f090029;
public static final int fragment_session_detail=0x7f090005;
public static final int fragment_sessions=0x7f090004;
public static final int fragment_vendor_detail=0x7f090007;
public static final int fragment_vendors=0x7f090006;
public static final int get_more_button=0x7f09002f;
public static final int header_news=0x7f09001b;
public static final int get_more_button=0x7f090032;
public static final int header_news=0x7f09001e;
public static final int layout_root=0x7f09000d;
public static final int layout_root_more_footer=0x7f09002e;
public static final int loading_spinner=0x7f090030;
public static final int menu_more=0x7f090038;
public static final int menu_refresh=0x7f090037;
public static final int layout_root_more_footer=0x7f090031;
public static final int loading_spinner=0x7f090033;
public static final int menu_more=0x7f09003b;
public static final int menu_refresh=0x7f09003a;
public static final int menu_refresh_progress=0x7f090008;
public static final int news_author=0x7f090022;
public static final int news_comments=0x7f090021;
public static final int news_domain=0x7f09001f;
public static final int news_hour=0x7f09001e;
public static final int news_image=0x7f09001c;
public static final int news_points=0x7f090020;
public static final int news_title=0x7f09001d;
public static final int news_author=0x7f090025;
public static final int news_comments=0x7f090024;
public static final int news_domain=0x7f090022;
public static final int news_hour=0x7f090021;
public static final int news_image=0x7f09001f;
public static final int news_points=0x7f090023;
public static final int news_title=0x7f090020;
public static final int no_data_retrieved=0x7f090018;
public static final int preview_nodata=0x7f090010;
public static final int root_container=0x7f09000f;
public static final int scrllvwNo1=0x7f090013;
public static final int story_break=0x7f090011;
public static final int story_domain=0x7f090015;
public static final int story_hour=0x7f090014;
public static final int story_title=0x7f090013;
public static final int tableLayout1=0x7f090023;
public static final int tableRow1=0x7f090024;
public static final int tableRow2=0x7f090027;
public static final int tableRow3=0x7f09002c;
public static final int tableRow4=0x7f09002a;
public static final int textView1=0x7f090025;
public static final int textView2=0x7f090028;
public static final int webview=0x7f090031;
public static final int widget_author_comments=0x7f090036;
public static final int widget_hour=0x7f090034;
public static final int widget_points=0x7f090035;
public static final int widget_refresh=0x7f090032;
public static final int widget_title=0x7f090033;
public static final int story_domain=0x7f090017;
public static final int story_hour=0x7f090016;
public static final int story_title=0x7f090015;
public static final int tableLayout1=0x7f090026;
public static final int tableRow1=0x7f090027;
public static final int tableRow2=0x7f09002a;
public static final int tableRow3=0x7f09002f;
public static final int tableRow4=0x7f09002d;
public static final int textView1=0x7f090028;
public static final int textView2=0x7f09002b;
public static final int webview=0x7f090034;
public static final int widget_author_comments=0x7f090039;
public static final int widget_hour=0x7f090037;
public static final int widget_points=0x7f090038;
public static final int widget_refresh=0x7f090035;
public static final int widget_title=0x7f090036;
}
public static final class layout {
public static final int about_dialog=0x7f030000;
Expand Down
30 changes: 25 additions & 5 deletions res/layout/comments_header_view.xml
@@ -1,8 +1,21 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:id="@+id/scrllvwNo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/comments_header_layout"
android:scrollbars="vertical"
>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -34,9 +47,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextHeaderSubTimeWhen" />





</RelativeLayout>
<TextView android:id="@+id/no_data_retrieved"
android:text="Unable to retrieve data. Please try again."
android:visibility="gone"
android:indeterminate="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="@style/TextHeaderSub" />
</LinearLayout>
</ScrollView>
</LinearLayout>
7 changes: 7 additions & 0 deletions res/layout/fragment_comments.xml
Expand Up @@ -4,6 +4,13 @@
android:layout_height="fill_parent"
android:id="@+id/comments_layout"
>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="@dimen/line_break_height"
android:foreground="#DEDEDE"
android:background="#000" />

<RelativeLayout
android:id="@+id/comments_inner_layout"
android:layout_width="fill_parent"
Expand Down
16 changes: 0 additions & 16 deletions res/menu/refresh_menu_items.xml
@@ -1,20 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_refresh"
android:icon="@drawable/ic_title_refresh"
Expand Down
1 change: 1 addition & 0 deletions res/values/dimens.xml
@@ -1,6 +1,7 @@
<resources>

<!-- UI elements -->
<dimen name="line_break_height">1dp</dimen>
<dimen name="colorstrip_height">6dp</dimen>
<dimen name="actionbar_compat_height">45dp</dimen>
<dimen name="whats_on_height">70dp</dimen>
Expand Down
2 changes: 1 addition & 1 deletion res/values/strings.xml
Expand Up @@ -17,7 +17,7 @@
<string name="hn_url_newest">http://hndroidapi.appspot.com/newest</string>
<string name="hn_url_best">http://hndroidapi.appspot.com/best</string>
<string name="hn_comments_url">http://hndroidapi.appspot.com/nestedcomments/format/json/id/</string>
<string name="about_app">Build:\r\n2.1 Beta (10/25/11)\r\n\r\nAuthor:\r\nGleb Popov (gpopov@gmail.com)\r\n\r\nNotes:\r\n*Not affiliated with Y Combinator\r\n*Uses 3rd party API (http://hndroidapi.appspot.com)\r\n*Integrates with ViewText.org, Instapaper, getFavicon(g.etfv.co)\r\n\r\nThanks:\r\nSuan Aik Yeo (nested comments), Eric Kigathi (API data fetcher)</string>
<string name="about_app">Build:\r\n2.2 Beta (11/08/11)\r\n\r\nAuthor:\r\nGleb Popov (gpopov@gmail.com)\r\n\r\nNotes:\r\n*Not affiliated with Y Combinator\r\n*Uses 3rd party API (http://hndroidapi.appspot.com)\r\n*Integrates with ViewText.org, Instapaper, getFavicon(g.etfv.co)\r\n\r\nThanks:\r\nSuan Aik Yeo (nested comments), Eric Kigathi (API data fetcher)</string>
<string name="warranty_info">The software is provided AS IS and the author makes NO WARRANTY or representation either express or implied as to its quality, accuracy, or fitness for a particular purpose.</string>

<string-array name="saved_menu">
Expand Down
16 changes: 15 additions & 1 deletion src/com/glebpopov/hackernews/AskActivity.java
Expand Up @@ -24,7 +24,21 @@ public void refreshData()
{
Log.d(TAG, "Refreshing Data...");
String startUpUrl = getResources().getString(R.string.hn_url_ask);
newsFragment.refreshData(startUpUrl);
if (newsFragment != null)
{
newsFragment.refreshData(startUpUrl);
} else
{
try
{
newsFragment = new NewsFragment(this, R.string.hn_url_ask);
newsFragment.refreshData(startUpUrl);

} catch (Exception ex)
{
Log.e(TAG, "Unable to instantiate NewsFragment or refresh data");
}
}
}

public void displayPreview(String url) {
Expand Down
16 changes: 15 additions & 1 deletion src/com/glebpopov/hackernews/BestActivity.java
Expand Up @@ -23,7 +23,21 @@ public void refreshData()
{
Log.d(TAG, "Refreshing Data...");
String startUpUrl = getResources().getString(R.string.hn_url_best);
newsFragment.refreshData(startUpUrl);
if (newsFragment != null)
{
newsFragment.refreshData(startUpUrl);
} else
{
try
{
newsFragment = new NewsFragment(this, R.string.hn_url_best);
newsFragment.refreshData(startUpUrl);

} catch (Exception ex)
{
Log.e(TAG, "Unable to instantiate NewsFragment or refresh data");
}
}
}

public void displayPreview(String url) {
Expand Down
9 changes: 4 additions & 5 deletions src/com/glebpopov/hackernews/CommentsActivity.java
@@ -1,7 +1,6 @@
package com.glebpopov.hackernews;

import com.glebpopov.hackernews.fragments.CommentsFragment;
import com.glebpopov.hackernews.fragments.NewsFragment;
import com.glebpopov.hackernews.fragments.CommentsFragmentView;
import com.glebpopov.hackernews.ui.BaseSinglePaneActivity;

import android.content.Intent;
Expand All @@ -11,12 +10,12 @@

public class CommentsActivity extends BaseSinglePaneActivity {

private CommentsFragment fragment = null;
private CommentsFragmentView fragment = null;
private static final String TAG = "CommentsActivity";

@Override
protected Fragment onCreatePane() {
fragment = new CommentsFragment(this);
fragment = new CommentsFragmentView(this);
return fragment;

}
Expand All @@ -31,7 +30,7 @@ public void refreshData()
{
try
{
fragment = new CommentsFragment(this);
fragment = new CommentsFragmentView(this);
fragment.refreshData();

} catch (Exception ex)
Expand Down
16 changes: 15 additions & 1 deletion src/com/glebpopov/hackernews/NewestActivity.java
Expand Up @@ -23,7 +23,21 @@ public void refreshData()
{
Log.d(TAG, "Refreshing Data...");
String startUpUrl = getResources().getString(R.string.hn_url_newest);
newsFragment.refreshData(startUpUrl);
if (newsFragment != null)
{
newsFragment.refreshData(startUpUrl);
} else
{
try
{
newsFragment = new NewsFragment(this, R.string.hn_url_newest);
newsFragment.refreshData(startUpUrl);

} catch (Exception ex)
{
Log.e(TAG, "Unable to instantiate NewsFragment or refresh data");
}
}
}

public void displayPreview(String url) {
Expand Down
9 changes: 6 additions & 3 deletions src/com/glebpopov/hackernews/domain/CommentItem.java
Expand Up @@ -3,6 +3,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import com.glebpopov.hackernews.util.StringEscapeUtils;

import android.text.Html;
import android.util.Log;
Expand All @@ -16,12 +17,12 @@ public class CommentItem
private int color;
private ArrayList<CommentItem> childrenContainer;

public int getParentID()
public int getParentId()
{
return parentID;
}

public void setParentID(int i)
public void setParentId(int i)
{
parentID = i;
}
Expand Down Expand Up @@ -96,7 +97,9 @@ public String getComment() {
}
try {
comment = comment.replace("\\", "");
comment = comment.replace("&amp;#62;", ">");
comment = StringEscapeUtils.unescapeHtml(comment);
comment = comment.replace("&#62;", ">");
comment = comment.replace("&#60;", "<");
} catch (Exception e)
{
Log.w(TAG, "Exception(s) replacing char in comment: " + e);
Expand Down

0 comments on commit 985885b

Please sign in to comment.