mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-03 20:47:37 +01:00
Bugfix
Code Cleanup
This commit is contained in:
parent
c694abc5d3
commit
5e6c724dd8
@ -210,7 +210,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
String rtStr = Integer.toString(rt);
|
||||
txtFav.setText(favStr);
|
||||
txtRet.setText(rtStr);
|
||||
txtAns.setText("0");
|
||||
|
||||
setIcons();
|
||||
if(repliedUsername != null) {
|
||||
|
@ -10,6 +10,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import twitter4j.IDs;
|
||||
import twitter4j.PagableResponseList;
|
||||
import twitter4j.Paging;
|
||||
import twitter4j.Query;
|
||||
@ -386,8 +387,7 @@ public class TwitterEngine {
|
||||
public void retweet(long id, boolean active) throws TwitterException {
|
||||
if(!active) {
|
||||
twitter.retweetStatus(id);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
deleteTweet(id);
|
||||
}
|
||||
}
|
||||
@ -401,14 +401,28 @@ public class TwitterEngine {
|
||||
public void favorite(long id, boolean active) throws TwitterException {
|
||||
if(!active){
|
||||
twitter.createFavorite(id);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
twitter.destroyFavorite(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User who retweeted a Tweet
|
||||
* @param tweetID Tweet ID
|
||||
* @param cursor List Cursor
|
||||
* @throws TwitterException if Access is unavailable
|
||||
*/
|
||||
public List<User> getRetweeter(long tweetID, long cursor) throws TwitterException {
|
||||
Status embeddedStat = getStatus(tweetID).getRetweetedStatus();
|
||||
if(embeddedStat != null)
|
||||
tweetID = embeddedStat.getId();
|
||||
IDs test = twitter.getRetweeterIds(tweetID,load,cursor);
|
||||
return twitter.lookupUsers(test.getIDs());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id Tweet ID
|
||||
* @throws TwitterException if Access is unavailable
|
||||
*/
|
||||
public void deleteTweet(long id) throws TwitterException {
|
||||
twitter.destroyStatus(id);
|
||||
|
@ -40,9 +40,6 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
uProgress = (ProgressBar)((UserDetail)context).findViewById(R.id.user_progress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data [0] mode UserLists/UserDetail , [1] UserID
|
||||
*/
|
||||
@Override
|
||||
protected Void doInBackground(Long... data) {
|
||||
long id = data[0];
|
||||
@ -69,7 +66,8 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
}
|
||||
}
|
||||
else if(mode == RETWEETER) {
|
||||
// GET RETWEET USER TODO
|
||||
UserDatabase udb = new UserDatabase(context,mTwitter.getRetweeter(id,cursor));
|
||||
usrAdp = new UserAdapter(context,udb);
|
||||
}
|
||||
else if(mode == FAVORISER) {
|
||||
// GET FAV USERS TODO
|
||||
@ -85,9 +83,9 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
protected void onPostExecute(Void v) {
|
||||
if(errmsg == null) {
|
||||
userList.setAdapter(usrAdp);
|
||||
uProgress.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
Toast.makeText(context,errmsg,Toast.LENGTH_LONG).show();
|
||||
}
|
||||
uProgress.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
@ -110,7 +110,6 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
break;
|
||||
case R.id.no_rt_detail:
|
||||
intent = new Intent(getApplicationContext(), UserDetail.class);
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("mode",2L);
|
||||
intent.putExtras(bundle);
|
||||
@ -118,7 +117,6 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
break;
|
||||
case R.id.no_fav_detail:
|
||||
intent = new Intent(getApplicationContext(), UserDetail.class);
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("mode",3L);
|
||||
intent.putExtras(bundle);
|
||||
|
@ -2,6 +2,7 @@ package org.nuclearfog.twidda.window;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
@ -21,9 +22,10 @@ import org.nuclearfog.twidda.viewadapter.UserAdapter;
|
||||
*/
|
||||
public class UserDetail extends AppCompatActivity implements AdapterView.OnItemClickListener {
|
||||
|
||||
private long userID;
|
||||
private long userID, tweetID;
|
||||
private long mode;
|
||||
private ListView userListview;
|
||||
private UserLists uList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle b) {
|
||||
@ -38,6 +40,12 @@ public class UserDetail extends AppCompatActivity implements AdapterView.OnItemC
|
||||
getUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
uList.cancel(true);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Home Button
|
||||
*/
|
||||
@ -78,7 +86,7 @@ public class UserDetail extends AppCompatActivity implements AdapterView.OnItemC
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void getUsers() {
|
||||
UserLists uList = new UserLists(UserDetail.this);
|
||||
uList = new UserLists(UserDetail.this);
|
||||
if(mode == 0L){
|
||||
getSupportActionBar().setTitle(R.string.following);
|
||||
uList.execute(userID, UserLists.FOLLOWING, -1L);
|
||||
@ -87,16 +95,17 @@ public class UserDetail extends AppCompatActivity implements AdapterView.OnItemC
|
||||
uList.execute(userID, UserLists.FOLLOWERS, -1L);
|
||||
} else if(mode == 2L){
|
||||
getSupportActionBar().setTitle(R.string.retweet);
|
||||
uList.execute(userID, UserLists.RETWEETER, -1L);
|
||||
uList.execute(tweetID, UserLists.RETWEETER, -1L);
|
||||
} else if(mode == 3L){
|
||||
getSupportActionBar().setTitle(R.string.favorite);
|
||||
uList.execute(userID, UserLists.FAVORISER, -1L);
|
||||
uList.execute(tweetID, UserLists.FAVORISER, -1L);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantCondidions")
|
||||
private void getExtras(Bundle b) {
|
||||
userID = b.getLong("userID");
|
||||
userID = b.getLong("userID");
|
||||
tweetID = b.getLong("tweetID");
|
||||
mode = b.getLong("mode");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user