mirror of
https://github.com/bspeice/itcs4180
synced 2024-11-12 10:28:13 -05:00
Added isRetweet status to database and saved tweets now display
properly. Added comments to the head of all files.
This commit is contained in:
parent
3b567ff0d4
commit
f5cfe5ab25
@ -34,22 +34,13 @@
|
||||
android:padding="5dp"
|
||||
android:text="TextView" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibtnSaveTweet"
|
||||
<ImageView
|
||||
android:id="@+id/imgIsRetweet"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/txtTweetText"
|
||||
android:padding="5dp"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgIsRetweet"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignTop="@+id/ibtnSaveTweet"
|
||||
android:layout_toLeftOf="@+id/ibtnSaveTweet"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/not_retweeted" />
|
||||
|
||||
</RelativeLayout>
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<SavedTweet>
|
||||
|
||||
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<SavedTweet>
|
||||
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;
|
||||
}
|
||||
|
@ -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<Tweet> {
|
||||
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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<SavedTweet> list = new ArrayList<SavedTweet>();
|
||||
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)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
//
|
||||
|
@ -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<Tweet> {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user