mirror of
https://github.com/bspeice/itcs4180
synced 2024-11-13 19:08:20 -05:00
DetailedTweetActivity is now working correctly
Still needs some alignment, etc.
This commit is contained in:
parent
ba85390eb7
commit
dddab46731
@ -28,6 +28,10 @@
|
||||
android:name="edu.uncc.itcs4180.hw5.TweetsListActivity"
|
||||
android:label="@string/title_activity_tweets_list" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name="edu.uncc.itcs4180.hw5.DetailedTweetActivity"
|
||||
android:label="@string/title_activity_detailed_tweet" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
60
HW5/res/layout/activity_detailed_tweet.xml
Normal file
60
HW5/res/layout/activity_detailed_tweet.xml
Normal file
@ -0,0 +1,60 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".DetailedTweetActivity" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtDetailUsername"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="TextView" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgDetailBackground"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/txtDetailUsername"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtDetailTweet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/txtDetailUsername"
|
||||
android:layout_below="@+id/imgDetailBackground"
|
||||
android:text="TextView" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDetailBack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="onClickBack"
|
||||
android:text="Button" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtFavoritesCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignRight="@+id/txtDetailTweet"
|
||||
android:layout_below="@+id/txtDetailTweet"
|
||||
android:text="TextView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtRetweetCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/txtFavoritesCount"
|
||||
android:layout_below="@+id/txtFavoritesCount"
|
||||
android:text="TextView" />
|
||||
|
||||
</RelativeLayout>
|
@ -3,6 +3,7 @@
|
||||
android:id="@+id/RelativeLayout1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:padding="2dp" >
|
||||
|
||||
<ImageView
|
||||
|
9
HW5/res/menu/detailed_tweet.xml
Normal file
9
HW5/res/menu/detailed_tweet.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
@ -5,5 +5,6 @@
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="title_activity_tweets_list">TweetsListActivity</string>
|
||||
<string name="title_activity_detailed_tweet">DetailedTweetActivity</string>
|
||||
|
||||
</resources>
|
||||
|
47
HW5/src/edu/uncc/itcs4180/hw5/DetailedTweetActivity.java
Normal file
47
HW5/src/edu/uncc/itcs4180/hw5/DetailedTweetActivity.java
Normal file
@ -0,0 +1,47 @@
|
||||
package edu.uncc.itcs4180.hw5;
|
||||
|
||||
import edu.uncc.itcs4180.hw5.twitter.Tweet;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class DetailedTweetActivity extends Activity {
|
||||
|
||||
private Tweet tweet;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_detailed_tweet);
|
||||
|
||||
tweet = (Tweet)getIntent().getExtras().getSerializable("tweet");
|
||||
|
||||
TextView userName = (TextView)findViewById(R.id.txtDetailUsername);
|
||||
TextView tweetText = (TextView)findViewById(R.id.txtDetailTweet);
|
||||
TextView favoritesCount = (TextView)findViewById(R.id.txtFavoritesCount);
|
||||
TextView retweetCount = (TextView)findViewById(R.id.txtRetweetCount);
|
||||
ImageView profileBackground = (ImageView)findViewById(R.id.imgDetailBackground);
|
||||
|
||||
userName.setText(tweet.getUser().getName());
|
||||
tweetText.setText(tweet.getText());
|
||||
favoritesCount.setText("Favorites Count: " + tweet.getFavoriteCount());
|
||||
retweetCount.setText("ReTweets Count: " + tweet.getRetweetCount());
|
||||
|
||||
new BitmapDownloader(profileBackground).execute(tweet.getUser().getProfileBackgroundImageUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.detailed_tweet, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onClickBack(View v) {
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
@ -7,14 +7,19 @@ import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class TweetsListActivity extends Activity {
|
||||
|
||||
ProgressDialog dialog;
|
||||
private ProgressDialog dialog;
|
||||
private TweetList list;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -49,10 +54,27 @@ public class TweetsListActivity extends Activity {
|
||||
return true;
|
||||
}
|
||||
|
||||
public TweetList getTweetList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
private void displayTweets(TweetList list) {
|
||||
this.list = list;
|
||||
ListView lv = (ListView)findViewById(R.id.listTweetList);
|
||||
ListAdapter la = new TweetListAdapter(this, list.toArray(new Tweet[list.size()]));
|
||||
lv.setAdapter(la);
|
||||
Log.d("ClickListener", "Setting click listener!");
|
||||
lv.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int pos,
|
||||
long l) {
|
||||
Log.d("ClickListener", "You clicked me!");
|
||||
Intent i = new Intent(TweetsListActivity.this, DetailedTweetActivity.class);
|
||||
i.putExtra("tweet", getTweetList().get(pos));
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,11 @@ package edu.uncc.itcs4180.hw5.twitter;
|
||||
//
|
||||
// We changed the field names to conform to Java standards
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Tweet {
|
||||
public class Tweet implements Serializable {
|
||||
|
||||
@SerializedName("created_at")
|
||||
private String dateCreated;
|
||||
@ -32,6 +34,28 @@ public class Tweet {
|
||||
|
||||
@SerializedName("retweeted")
|
||||
private boolean retweeted;
|
||||
|
||||
@SerializedName("favorite_count")
|
||||
private int favoriteCount;
|
||||
|
||||
@SerializedName("retweet_count")
|
||||
private int retweetCount;
|
||||
|
||||
public int getFavoriteCount() {
|
||||
return favoriteCount;
|
||||
}
|
||||
|
||||
public void setFavoriteCount(int favoriteCount) {
|
||||
this.favoriteCount = favoriteCount;
|
||||
}
|
||||
|
||||
public int getRetweetCount() {
|
||||
return retweetCount;
|
||||
}
|
||||
|
||||
public void setRetweetCount(int retweetCount) {
|
||||
this.retweetCount = retweetCount;
|
||||
}
|
||||
|
||||
public String getDateCreated() {
|
||||
return dateCreated;
|
||||
|
@ -3,9 +3,11 @@ package edu.uncc.itcs4180.hw5.twitter;
|
||||
// Code copied from:
|
||||
// https://github.com/Rockncoder/TwitterTutorial/blob/master/src/com/example/TwitterTutorial/TwitterUser.java
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class TwitterUser {
|
||||
public class TwitterUser implements Serializable {
|
||||
|
||||
@SerializedName("screen_name")
|
||||
private String screenName;
|
||||
|
Loading…
Reference in New Issue
Block a user