Optimizations
This commit is contained in:
NudeDude 2018-03-05 14:55:58 +01:00
parent fc4c3d9d64
commit ec4bf33323
5 changed files with 18 additions and 23 deletions

View File

@ -12,10 +12,7 @@ import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import org.nuclearfog.twidda.R;
import java.io.File;
import java.io.InputStream;
import java.net.URL;

View File

@ -411,14 +411,19 @@ public class TwitterEngine {
* Get User who retweeted a Tweet
* @param tweetID Tweet ID
* @param cursor List Cursor
* @return List of users or empty list if no match
* @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());
long[] userIds = twitter.getRetweeterIds(tweetID,load,cursor).getIDs();
if(userIds.length == 0) {
return new ArrayList<>();
} else {
return twitter.lookupUsers(userIds);
}
}
/**

View File

@ -159,23 +159,22 @@ public class TweetDatabase {
if(mode==HOME_TL) {
SQL_GET_HOME = "SELECT * FROM timeline " +
"INNER JOIN tweet ON timeline.tweetID = tweet.tweetID " +
"INNER JOIN user ON tweet.userID=user.userID ORDER BY time DESC";
"INNER JOIN user ON tweet.userID=user.userID ORDER BY tweetID DESC";
} else if(mode==FAV_TL) {
SQL_GET_HOME = "SELECT * FROM favorit " +
"INNER JOIN tweet ON favorit.tweetID = tweet.tweetID " +
"INNER JOIN user ON tweet.userID=user.userID " +
"WHERE favorit.ownerID = "+CurrentId+" ORDER BY tweet.time DESC";
"WHERE favorit.ownerID = "+CurrentId+" ORDER BY tweetID DESC";
} else if(mode==USER_TL) {
SQL_GET_HOME = "SELECT * FROM user INNER JOIN tweet ON user.userID = tweet.userID " +
"WHERE user.userID = "+CurrentId+" ORDER BY tweet.time DESC";
"WHERE user.userID = "+CurrentId+" ORDER BY tweetID DESC";
} else if(mode==GET_TWEET) {
SQL_GET_HOME = "SELECT * FROM user INNER JOIN tweet ON user.userID = tweet.userID " +
"WHERE tweet.tweetID = "+CurrentId+" ORDER BY tweet.time DESC";
} else if(mode==GET_MENT){
"WHERE tweetID = "+CurrentId+" ORDER BY tweetID DESC";
} else if(mode==GET_MENT) {
SQL_GET_HOME = "SELECT * FROM timeline " +
"INNER JOIN tweet ON timeline.mTweetID = tweet.tweetID " +
"INNER JOIN user ON tweet.userID=user.userID ORDER BY time DESC";
limit = 5; //TODO 5 Mentions only!
"INNER JOIN user ON tweet.userID=user.userID ORDER BY tweetID ASC";
}
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
@ -205,7 +204,7 @@ public class TweetDatabase {
index = cursor.getColumnIndex("retweeter");
retweeter.add(cursor.getString(index));
size++;
} while(cursor.moveToNext() && size < limit);
} while(cursor.moveToNext());
}
cursor.close();
db.close();

View File

@ -1,17 +1,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
android:orientation="vertical">
<Button
android:id="@+id/linkButton"
android:layout_width="match_parent"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:background="@android:color/darker_gray"
@ -43,7 +39,7 @@
<Button
android:id="@+id/get"
android:layout_width="match_parent"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:background="@android:color/darker_gray"

View File

@ -7,7 +7,6 @@
<item name="android:navigationBarColor">@android:color/background_dark</item>
<item name="android:colorBackground">@color/DarkBlue</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<style name="Transparency" parent="AppTheme">
@ -18,7 +17,6 @@
<style name="TransactionPending" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
</resources>