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