From f5cfe5ab252763cac40798dded794820b9aad692 Mon Sep 17 00:00:00 2001 From: tokugawa Date: Mon, 14 Apr 2014 21:38:50 -0400 Subject: [PATCH] Added isRetweet status to database and saved tweets now display properly. Added comments to the head of all files. --- HW5/res/layout/saved_tweets_list.xml | 13 ++----------- .../uncc/itcs4180/hw5/BitmapDownloader.java | 7 +++++++ .../itcs4180/hw5/DetailedTweetActivity.java | 7 +++++++ .../edu/uncc/itcs4180/hw5/MainActivity.java | 7 +++++++ .../uncc/itcs4180/hw5/SavedNewsActivity.java | 7 +++++++ .../uncc/itcs4180/hw5/SavedNewsAdapter.java | 15 +++++++++++---- .../uncc/itcs4180/hw5/TweetListAdapter.java | 8 ++++++++ .../uncc/itcs4180/hw5/TweetsListActivity.java | 7 +++++++ .../itcs4180/hw5/database/DataManager.java | 7 +++++++ .../itcs4180/hw5/database/DatabaseHelper.java | 9 ++++++++- .../itcs4180/hw5/database/SavedTweet.java | 19 ++++++++++++++++++- .../itcs4180/hw5/database/SavedTweetDAO.java | 14 ++++++++++++-- .../hw5/database/SavedTweetTable.java | 11 ++++++++++- .../edu/uncc/itcs4180/hw5/twitter/Tweet.java | 7 +++++++ .../uncc/itcs4180/hw5/twitter/TweetList.java | 7 +++++++ .../hw5/twitter/TwitterAuthentication.java | 7 +++++++ .../itcs4180/hw5/twitter/TwitterClient.java | 7 +++++++ .../itcs4180/hw5/twitter/TwitterUser.java | 7 +++++++ 18 files changed, 146 insertions(+), 20 deletions(-) diff --git a/HW5/res/layout/saved_tweets_list.xml b/HW5/res/layout/saved_tweets_list.xml index 47f1295..05c9bb7 100644 --- a/HW5/res/layout/saved_tweets_list.xml +++ b/HW5/res/layout/saved_tweets_list.xml @@ -34,22 +34,13 @@ android:padding="5dp" android:text="TextView" /> - - - \ No newline at end of file diff --git a/HW5/src/edu/uncc/itcs4180/hw5/BitmapDownloader.java b/HW5/src/edu/uncc/itcs4180/hw5/BitmapDownloader.java index 2702ac4..f659b9b 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/BitmapDownloader.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/BitmapDownloader.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * BitmapDownloader.java + */ + import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/DetailedTweetActivity.java b/HW5/src/edu/uncc/itcs4180/hw5/DetailedTweetActivity.java index 8139bee..67a8508 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/DetailedTweetActivity.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/DetailedTweetActivity.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * DetailedTweetActivity.java + */ + import edu.uncc.itcs4180.hw5.twitter.Tweet; import android.os.Bundle; import android.app.Activity; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/MainActivity.java b/HW5/src/edu/uncc/itcs4180/hw5/MainActivity.java index e6cc6f5..b2a9140 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/MainActivity.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/MainActivity.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * MainActivity.java + */ + import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsActivity.java b/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsActivity.java index d28396e..a2e4694 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsActivity.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsActivity.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * SavedNewsActivity.java + */ + import java.util.List; import edu.uncc.itcs4180.hw5.database.DataManager; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsAdapter.java b/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsAdapter.java index 46ef2dd..44e0571 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsAdapter.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/SavedNewsAdapter.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * SavedNewsAdapter.java + */ + import edu.uncc.itcs4180.hw5.database.SavedTweet; import android.app.Activity; import android.view.View; @@ -29,7 +36,7 @@ public class SavedNewsAdapter extends ArrayAdapter if (rowView == null) { // Inflate a new row - rowView = activity.getLayoutInflater().inflate(R.layout.tweet_list, null); + rowView = activity.getLayoutInflater().inflate(R.layout.saved_tweets_list, null); tv = new TweetView(); tv.imgProfileImage = (ImageView) rowView.findViewById(R.id.imgProfileImage); @@ -48,10 +55,10 @@ public class SavedNewsAdapter extends ArrayAdapter new BitmapDownloader(tv.imgProfileImage).execute(tweet.getProfileImageUrl()); tv.txtTweetText.setText(tweet.getText()); tv.txtTweetInfo.setText(tweet.getTime()); - // Set the retweet image - //if (tweet.isRetweet()) { + //Set the retweet image + if (tweet.getIsRetweet()==1) { tv.imgIsRetweet.setImageDrawable(activity.getResources().getDrawable(R.drawable.retweeted)); - //} + } return rowView; } diff --git a/HW5/src/edu/uncc/itcs4180/hw5/TweetListAdapter.java b/HW5/src/edu/uncc/itcs4180/hw5/TweetListAdapter.java index 8adab55..d583214 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/TweetListAdapter.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/TweetListAdapter.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * TweetListAdapter.java + */ + import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -93,6 +100,7 @@ public class TweetListAdapter extends ArrayAdapter { save.setText(t.getText()); save.setTime(t.getDateCreated()); save.setProfileImageUrl(t.getUser().getProfileImageUrl()); + save.setIsRetweet((t.isRetweet()) ? 1 : 0); dm.saveTweet(save); Toast.makeText(activity, "Saved in DB!", Toast.LENGTH_SHORT).show(); } diff --git a/HW5/src/edu/uncc/itcs4180/hw5/TweetsListActivity.java b/HW5/src/edu/uncc/itcs4180/hw5/TweetsListActivity.java index 3eadb42..3460292 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/TweetsListActivity.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/TweetsListActivity.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * TweetsListActvity.java + */ + import edu.uncc.itcs4180.hw5.twitter.Tweet; import edu.uncc.itcs4180.hw5.twitter.TweetList; import edu.uncc.itcs4180.hw5.twitter.TwitterClient; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/database/DataManager.java b/HW5/src/edu/uncc/itcs4180/hw5/database/DataManager.java index c17df53..791376d 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/database/DataManager.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/database/DataManager.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.database; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * DataManager.java + */ + import java.util.List; import android.content.Context; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/database/DatabaseHelper.java b/HW5/src/edu/uncc/itcs4180/hw5/database/DatabaseHelper.java index 5c9771b..fa9def7 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/database/DatabaseHelper.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/database/DatabaseHelper.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.database; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * DatabaseHelper.java + */ + import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; @@ -8,7 +15,7 @@ import android.util.Log; public class DatabaseHelper extends SQLiteOpenHelper { final static String DATABASE_NAME = "savedtweets.db"; - final static int DATABASE_VERSION = 1; + final static int DATABASE_VERSION = 2; final static String TAG = "STdb1"; DatabaseHelper(Context mContext) diff --git a/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweet.java b/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweet.java index 80bf940..97fb130 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweet.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweet.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.database; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * SavedTweet.java + */ + public class SavedTweet { private long id; @@ -7,6 +14,7 @@ public class SavedTweet private String text; private String time; private String profileImageUrl; + private int isRetweet; public SavedTweet() { @@ -15,15 +23,17 @@ public class SavedTweet this.text = ""; this.time = ""; this.profileImageUrl = ""; + this.isRetweet = 0; } - public SavedTweet(long id, String username, String text, String time, String profileImageUrl) + public SavedTweet(long id, String username, String text, String time, String profileImageUrl, int isRetweet) { this.id= id; this.username = username; this.text = text; this.time = time; this.profileImageUrl = profileImageUrl; + this.isRetweet = isRetweet; } public long getId() { @@ -41,7 +51,14 @@ public class SavedTweet public void setUsername(String username) { this.username = username; } + + public int getIsRetweet(){ + return isRetweet; + } + public void setIsRetweet(int isRetweet){ + this.isRetweet = isRetweet; + } public String getText() { return text; } diff --git a/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetDAO.java b/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetDAO.java index ae6fa91..cb32b55 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetDAO.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetDAO.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.database; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * SavedTweetDAO.java + */ + import java.util.ArrayList; import java.util.List; @@ -24,6 +31,7 @@ public class SavedTweetDAO values.put(SavedTweetTable.TEXT, tweet.getText()); values.put(SavedTweetTable.TIME, tweet.getTime()); values.put(SavedTweetTable.PROFILE_IMAGE_URL, tweet.getProfileImageUrl()); + values.put(SavedTweetTable.IS_RETWEET, tweet.getIsRetweet()); return db.insert(SavedTweetTable.TABLE_NAME, null, values); } @@ -34,6 +42,7 @@ public class SavedTweetDAO values.put(SavedTweetTable.TEXT, tweet.getText()); values.put(SavedTweetTable.TIME, tweet.getTime()); values.put(SavedTweetTable.PROFILE_IMAGE_URL, tweet.getProfileImageUrl()); + values.put(SavedTweetTable.IS_RETWEET, tweet.getIsRetweet()); return db.update(SavedTweetTable.TABLE_NAME, values, SavedTweetTable.ID+"="+tweet.getId(), null)<0; } @@ -46,7 +55,7 @@ public class SavedTweetDAO { SavedTweet tweet = null; Cursor c = db.query(true, SavedTweetTable.TABLE_NAME, - new String[]{SavedTweetTable.ID, SavedTweetTable.USER_NAME, SavedTweetTable.TEXT, SavedTweetTable.TIME, SavedTweetTable.PROFILE_IMAGE_URL}, + new String[]{SavedTweetTable.ID, SavedTweetTable.USER_NAME, SavedTweetTable.TEXT, SavedTweetTable.TIME, SavedTweetTable.PROFILE_IMAGE_URL, SavedTweetTable.IS_RETWEET}, SavedTweetTable.ID+"="+id, null, null, null, null, null); if(c!=null) { @@ -64,7 +73,7 @@ public class SavedTweetDAO { List list = new ArrayList(); Cursor c = db.query(SavedTweetTable.TABLE_NAME, - new String[]{SavedTweetTable.ID, SavedTweetTable.USER_NAME, SavedTweetTable.TEXT, SavedTweetTable.TIME, SavedTweetTable.PROFILE_IMAGE_URL}, + new String[]{SavedTweetTable.ID, SavedTweetTable.USER_NAME, SavedTweetTable.TEXT, SavedTweetTable.TIME, SavedTweetTable.PROFILE_IMAGE_URL, SavedTweetTable.IS_RETWEET}, null, null, null, null, null); if(c!=null) { @@ -98,6 +107,7 @@ public class SavedTweetDAO tweet.setText(c.getString(2)); tweet.setTime(c.getString(3)); tweet.setProfileImageUrl(c.getString(4)); + tweet.setIsRetweet(c.getInt(5)); } catch(Exception e) { diff --git a/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetTable.java b/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetTable.java index e521b26..295632d 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetTable.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/database/SavedTweetTable.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.database; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * SavedTweetTable.java + */ + import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; @@ -11,6 +18,7 @@ public class SavedTweetTable final static String TEXT = "text"; final static String TIME = "time"; final static String PROFILE_IMAGE_URL = "profileimageurl"; + final static String IS_RETWEET = "isretweet"; public static void onCreate(SQLiteDatabase db) { @@ -19,7 +27,8 @@ public class SavedTweetTable SavedTweetTable.USER_NAME+ " text not null, "+ SavedTweetTable.TEXT+ " text not null, "+ SavedTweetTable.TIME+ " text not null, "+ - SavedTweetTable.PROFILE_IMAGE_URL+ " text not null);"; + SavedTweetTable.PROFILE_IMAGE_URL+ " text not null, "+ + SavedTweetTable.IS_RETWEET+" integer not null);"; try { diff --git a/HW5/src/edu/uncc/itcs4180/hw5/twitter/Tweet.java b/HW5/src/edu/uncc/itcs4180/hw5/twitter/Tweet.java index df06d1d..a51ccb5 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/twitter/Tweet.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/twitter/Tweet.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.twitter; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * Tweet.java + */ + // Code adapted from: // https://github.com/Rockncoder/TwitterTutorial/blob/master/src/com/example/TwitterTutorial/Tweet.java // diff --git a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TweetList.java b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TweetList.java index 8ecd101..7e3aeeb 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TweetList.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TweetList.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.twitter; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * TweetList.java + */ + import java.util.ArrayList; public class TweetList extends ArrayList { diff --git a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterAuthentication.java b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterAuthentication.java index 5dcbf0b..5bb185c 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterAuthentication.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterAuthentication.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.twitter; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * TwitterAuthentication.java + */ + import com.google.gson.annotations.SerializedName; public class TwitterAuthentication { diff --git a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterClient.java b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterClient.java index 3dbab5e..c5d081a 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterClient.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterClient.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.twitter; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * TwitterClient.java + */ + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; diff --git a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterUser.java b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterUser.java index 665e9bb..cd15b00 100644 --- a/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterUser.java +++ b/HW5/src/edu/uncc/itcs4180/hw5/twitter/TwitterUser.java @@ -1,5 +1,12 @@ package edu.uncc.itcs4180.hw5.twitter; +/* + * Bradlee Speice, Brandon Rodenmayer + * ITIS 4180 + * Homework 5 + * TwitterUser.java + */ + // Code copied from: // https://github.com/Rockncoder/TwitterTutorial/blob/master/src/com/example/TwitterTutorial/TwitterUser.java