mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-08 08:09:03 +01:00
tweet bug fix, added comments
This commit is contained in:
parent
a0c7b490e9
commit
4d68e09935
@ -200,7 +200,6 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu m) {
|
||||
getMenuInflater().inflate(R.menu.tweet, m);
|
||||
AppStyles.setMenuIconColor(m, settings.getIconColor());
|
||||
return super.onCreateOptionsMenu(m);
|
||||
}
|
||||
|
||||
@ -253,45 +252,37 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// answer to the tweet
|
||||
if (v.getId() == R.id.tweet_answer) {
|
||||
if (tweet != null) {
|
||||
if (tweet != null) {
|
||||
// answer to the tweet
|
||||
if (v.getId() == R.id.tweet_answer) {
|
||||
String tweetPrefix = tweet.getUser().getScreenname() + " ";
|
||||
Intent tweetPopup = new Intent(this, TweetPopup.class);
|
||||
tweetPopup.putExtra(KEY_TWEETPOPUP_REPLYID, tweetId);
|
||||
tweetPopup.putExtra(KEY_TWEETPOPUP_TEXT, tweetPrefix);
|
||||
startActivity(tweetPopup);
|
||||
}
|
||||
}
|
||||
// show user retweeting this tweet
|
||||
else if (v.getId() == R.id.tweet_retweet) {
|
||||
if (tweet != null) {
|
||||
// show user retweeting this tweet
|
||||
else if (v.getId() == R.id.tweet_retweet) {
|
||||
Intent userList = new Intent(this, UserDetail.class);
|
||||
userList.putExtra(KEY_USERDETAIL_ID, tweet.getId());
|
||||
userList.putExtra(KEY_USERDETAIL_MODE, USERLIST_RETWEETS);
|
||||
startActivity(userList);
|
||||
}
|
||||
}
|
||||
// open profile of the tweet author
|
||||
else if (v.getId() == R.id.profileimage_detail) {
|
||||
if (tweet != null) {
|
||||
// open profile of the tweet author
|
||||
else if (v.getId() == R.id.profileimage_detail) {
|
||||
Intent profile = new Intent(getApplicationContext(), UserProfile.class);
|
||||
profile.putExtra(UserProfile.KEY_PROFILE_DATA, tweet.getUser());
|
||||
startActivity(profile);
|
||||
}
|
||||
}
|
||||
// open replied tweet
|
||||
else if (v.getId() == R.id.answer_reference_detail) {
|
||||
if (tweet != null) {
|
||||
// open replied tweet
|
||||
else if (v.getId() == R.id.answer_reference_detail) {
|
||||
Intent answerIntent = new Intent(getApplicationContext(), TweetActivity.class);
|
||||
answerIntent.putExtra(KEY_TWEET_ID, tweet.getReplyId());
|
||||
answerIntent.putExtra(KEY_TWEET_NAME, tweet.getReplyName());
|
||||
startActivity(answerIntent);
|
||||
}
|
||||
}
|
||||
// open tweet location coordinates
|
||||
else if (v.getId() == R.id.tweet_location_coordinate) {
|
||||
if (tweet != null) {
|
||||
// open tweet location coordinates
|
||||
else if (v.getId() == R.id.tweet_location_coordinate) {
|
||||
Intent locationIntent = new Intent(Intent.ACTION_VIEW);
|
||||
locationIntent.setData(Uri.parse("geo:" + tweet.getLocationCoordinates()));
|
||||
try {
|
||||
@ -300,10 +291,8 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_card_app, LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
// open tweet media
|
||||
else if (v.getId() == R.id.tweet_media_attach) {
|
||||
if (tweet != null) {
|
||||
// open tweet media
|
||||
else if (v.getId() == R.id.tweet_media_attach) {
|
||||
Intent mediaIntent = new Intent(this, MediaViewer.class);
|
||||
mediaIntent.putExtra(KEY_MEDIA_LINK, tweet.getMediaLinks());
|
||||
switch (tweet.getMediaType()) {
|
||||
@ -331,21 +320,19 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
||||
statusAsync = new TweetAction(this, tweet);
|
||||
// retweet this tweet
|
||||
if (v.getId() == R.id.tweet_retweet) {
|
||||
if (tweet.retweeted()) {
|
||||
if (tweet.retweeted())
|
||||
statusAsync.execute(Action.UNRETWEET);
|
||||
} else {
|
||||
else
|
||||
statusAsync.execute(Action.RETWEET);
|
||||
}
|
||||
Toast.makeText(this, R.string.info_loading, LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
// favorite the tweet
|
||||
else if (v.getId() == R.id.tweet_favorit) {
|
||||
if (tweet.favored()) {
|
||||
if (tweet.favored())
|
||||
statusAsync.execute(Action.UNFAVORITE);
|
||||
} else {
|
||||
else
|
||||
statusAsync.execute(Action.FAVORITE);
|
||||
}
|
||||
Toast.makeText(this, R.string.info_loading, LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
@ -536,13 +523,16 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
||||
*/
|
||||
public void onError(@NonNull EngineException error, long tweetId) {
|
||||
ErrorHandler.handleFailure(this, error);
|
||||
if (error.resourceNotFound()) {
|
||||
if (tweet == null) {
|
||||
finish();
|
||||
} else if (error.resourceNotFound()) {
|
||||
Intent returnData = new Intent();
|
||||
// if tweet is an embedded tweet, get parent tweet ID
|
||||
if (tweet.getParentTweet() != null)
|
||||
tweetId = tweet.getParentTweet().getId();
|
||||
returnData.putExtra(INTENT_TWEET_REMOVED_ID, tweetId);
|
||||
setResult(RETURN_TWEET_CHANGED, returnData);
|
||||
finish();
|
||||
} else if (tweet == null) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
@ -154,7 +154,7 @@ public class FragmentAdapter extends FragmentStatePagerAdapter {
|
||||
* setup adapter for tweet page to show replies of a tweet
|
||||
*
|
||||
* @param tweetId ID of the tweet
|
||||
* @param replyName screen name of the author
|
||||
* @param replyName screen name of the author, needed to search for answers
|
||||
*/
|
||||
public void setupTweetPage(long tweetId, String replyName) {
|
||||
Bundle param = new Bundle();
|
||||
|
@ -38,7 +38,7 @@ public class Tweet implements Serializable {
|
||||
private String source;
|
||||
|
||||
private User user;
|
||||
private Tweet embedded;
|
||||
private Tweet embedded, parent;
|
||||
|
||||
private long replyID;
|
||||
private long replyUserId;
|
||||
@ -111,7 +111,7 @@ public class Tweet implements Serializable {
|
||||
else
|
||||
replyName = "";
|
||||
if (status.getRetweetedStatus() != null)
|
||||
embedded = new Tweet(status.getRetweetedStatus());
|
||||
embedded = new Tweet(status.getRetweetedStatus(), this);
|
||||
else
|
||||
embedded = null;
|
||||
|
||||
@ -147,6 +147,17 @@ public class Tweet implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create an embedded tweet with reference to its parent
|
||||
*
|
||||
* @param status embedded tweet
|
||||
* @param parent parent tweet retweeting this tweet
|
||||
*/
|
||||
private Tweet(Status status, Tweet parent) {
|
||||
this(status);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tweet constructor for database tweets
|
||||
*
|
||||
@ -242,13 +253,23 @@ public class Tweet implements Serializable {
|
||||
/**
|
||||
* get embedded Tweet
|
||||
*
|
||||
* @return tweet
|
||||
* @return tweet retweeted by this tweet
|
||||
*/
|
||||
@Nullable
|
||||
public Tweet getEmbeddedTweet() {
|
||||
return embedded;
|
||||
}
|
||||
|
||||
/**
|
||||
* get parent Tweet
|
||||
*
|
||||
* @return parent tweet, retweeting this tweet
|
||||
*/
|
||||
@Nullable
|
||||
public Tweet getParentTweet() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* name of replied user
|
||||
*
|
||||
|
@ -203,7 +203,14 @@ public final class AppStyles {
|
||||
tArray.recycle();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* create tab icons with TextView
|
||||
*
|
||||
* @param tabLayout TabLayout to set the icons
|
||||
* @param settings settings instance
|
||||
* @param array Array of drawable resources to set the icons
|
||||
* @return array of TextViews
|
||||
*/
|
||||
public static TextView[] createTabIcon(TabLayout tabLayout, GlobalSettings settings, @ArrayRes int array) {
|
||||
Context context = tabLayout.getContext();
|
||||
TypedArray tArray = context.getResources().obtainTypedArray(array);
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tab_icon"
|
||||
android:layout_width="@dimen/icon_profile_size"
|
||||
android:layout_height="@dimen/icon_profile_size"
|
||||
app:srcCompat="@drawable/add" />
|
||||
android:layout_height="@dimen/icon_profile_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tab_text"
|
||||
@ -19,4 +19,5 @@
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/icon_profile_textsize" />
|
||||
|
||||
</LinearLayout>
|
@ -131,7 +131,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user