parent
e3d90d9a11
commit
6f107ba97a
|
@ -168,8 +168,6 @@ public class MainActivity extends AppCompatActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
MainPage homeView = new MainPage(MainActivity.this);
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.widget.Toast;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
|
||||
public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
|
||||
public static final int HOME = 0;
|
||||
|
|
|
@ -116,18 +116,18 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
|||
else if(MODE == GET_TWEETS)
|
||||
{
|
||||
homeTl = (TimelineRecycler) profileTweets.getAdapter();
|
||||
if(homeTl == null || homeTl.getItemCount() == 0) {
|
||||
TweetDatabase hTweets = new TweetDatabase(mTwitter.getUserTweets(userId,args[2],id),context,TweetDatabase.USER_TL,userId);
|
||||
homeTl = new TimelineRecycler(hTweets,(UserProfile)context);
|
||||
} else {
|
||||
if(homeTl != null && homeTl.getItemCount() > 0) {
|
||||
id = homeTl.getItemId(0);
|
||||
homeTl.getData().insert(mTwitter.getUserTweets(userId,args[2],id),true);
|
||||
} else {
|
||||
TweetDatabase hTweets = new TweetDatabase(mTwitter.getUserTweets(userId,args[2],id),context,TweetDatabase.USER_TL,userId);
|
||||
homeTl = new TimelineRecycler(hTweets,(UserProfile)context);
|
||||
}
|
||||
}
|
||||
else if(MODE == GET_FAVS)
|
||||
{
|
||||
homeFav = (TimelineRecycler) profileFavorits.getAdapter();
|
||||
if(homeFav != null) {
|
||||
if(homeFav != null && homeFav.getItemCount() > 0) {
|
||||
id = homeFav.getItemId(0);
|
||||
homeFav.getData().insert(mTwitter.getUserFavs(userId,args[2],id),true);
|
||||
} else {
|
||||
|
|
|
@ -171,7 +171,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
|||
else if(mode == LOAD_REPLY) {
|
||||
String replyname = user.getScreenName();
|
||||
tlAdp = (TimelineRecycler) replyList.getAdapter();
|
||||
if(tlAdp != null)
|
||||
if(tlAdp != null && tlAdp.getItemCount() > 0)
|
||||
tweetID = tlAdp.getItemId(0);
|
||||
answers = mTwitter.getAnswers(replyname, tweetID);
|
||||
}
|
||||
|
@ -183,6 +183,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
|||
int err = e.getErrorCode();
|
||||
if(err == 144) { // gelöscht
|
||||
TweetDatabase.delete(c,tweetID);
|
||||
errMSG = e.getMessage();
|
||||
}
|
||||
e.printStackTrace();
|
||||
return ERROR;
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import twitter4j.IDs;
|
||||
import twitter4j.PagableResponseList;
|
||||
import twitter4j.Paging;
|
||||
import twitter4j.Query;
|
||||
|
|
|
@ -14,7 +14,7 @@ public class AppDatabase extends SQLiteOpenHelper
|
|||
private static final String tQuery = "CREATE TABLE IF NOT EXISTS tweet (" +
|
||||
"tweetID INTEGER PRIMARY KEY, userID INTEGER, retweeter TEXT," +
|
||||
"time INTEGER, tweet TEXT, retweet INTEGER, favorite INTEGER," +
|
||||
"FOREIGN KEY (userID) REFERENCES user(userID));";
|
||||
"retweeterID INTEGER, FOREIGN KEY (userID) REFERENCES user(userID));";
|
||||
|
||||
private static final String trQuery = "CREATE TABLE IF NOT EXISTS trend (" +
|
||||
"trendpos INTEGER PRIMARY KEY, trendname TEXT, trendlink TEXT);";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package org.nuclearfog.twidda.database;
|
||||
import org.nuclearfog.twidda.window.ColorPreferences;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
|
@ -8,9 +9,6 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
|
||||
import org.nuclearfog.twidda.window.ColorPreferences;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -23,7 +21,6 @@ public class TweetDatabase {
|
|||
public static final int HOME_TL = 0;
|
||||
public static final int FAV_TL = 1;
|
||||
public static final int USER_TL = 2;
|
||||
public static final int GET_TWEET = 3;
|
||||
public static final int GET_MENT = 4;
|
||||
|
||||
private AppDatabase dataHelper;
|
||||
|
@ -55,7 +52,7 @@ public class TweetDatabase {
|
|||
/**
|
||||
* Read Data
|
||||
* @param context MainActivity Context
|
||||
* @param mode which type of data should be loaded
|
||||
* @param mode {@link #FAV_TL #GET_MENT}
|
||||
* @param CurrentId current ID (USER OR TWEET)
|
||||
*/
|
||||
public TweetDatabase(Context context, final int mode, long CurrentId) {
|
||||
|
@ -112,10 +109,12 @@ public class TweetDatabase {
|
|||
|
||||
if(rtStat != null) {
|
||||
tweet.put("retweeter",usr.getScreenName());
|
||||
tweet.put("retweeterID", usr.getId());
|
||||
stat = rtStat;
|
||||
usr = rtStat.getUser();
|
||||
} else {
|
||||
tweet.put("retweeter","\0");
|
||||
tweet.put("retweeterID", -1L);
|
||||
}
|
||||
|
||||
user.put("userID",usr.getId());
|
||||
|
@ -166,17 +165,6 @@ public class TweetDatabase {
|
|||
SQL_GET_HOME = "SELECT * FROM timeline " +
|
||||
"INNER JOIN tweet ON timeline.tweetID = tweet.tweetID " +
|
||||
"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 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 tweetID DESC";
|
||||
} else if(mode==GET_TWEET) {
|
||||
SQL_GET_HOME = "SELECT * FROM user INNER JOIN tweet ON user.userID = tweet.userID " +
|
||||
"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 " +
|
||||
|
@ -184,6 +172,17 @@ public class TweetDatabase {
|
|||
limit = 5;
|
||||
}
|
||||
|
||||
else if(mode==USER_TL) {
|
||||
SQL_GET_HOME = "SELECT * FROM user INNER JOIN tweet ON user.userID = tweet.userID " +
|
||||
"WHERE tweet.userID = "+CurrentId+" OR tweet.retweeterID = "+CurrentId +" " +
|
||||
"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 tweetID DESC";
|
||||
}
|
||||
|
||||
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
|
||||
|
||||
if(cursor.moveToFirst()) {
|
||||
|
@ -321,6 +320,7 @@ public class TweetDatabase {
|
|||
for(Status stat: stats) {
|
||||
Status rtStat = stat.getRetweetedStatus();
|
||||
User usr = stat.getUser();
|
||||
tweetId.add(stat.getId());
|
||||
if(rtStat != null) {
|
||||
retweeter.add(usr.getScreenName());
|
||||
stat = rtStat;
|
||||
|
@ -335,7 +335,6 @@ public class TweetDatabase {
|
|||
noFav.add(stat.getFavoriteCount());
|
||||
userId.add(usr.getId());
|
||||
pbLink.add(usr.getMiniProfileImageURL());
|
||||
tweetId.add(stat.getId());
|
||||
verify.add(usr.isVerified() ? 1 : 0);
|
||||
timeMillis.add(stat.getCreatedAt().getTime());
|
||||
size++;
|
||||
|
@ -343,10 +342,11 @@ public class TweetDatabase {
|
|||
}
|
||||
|
||||
private void addFirst(List<Status> stats) {
|
||||
for(int index = stats.size()-1 ; index >=0 ; index--) {
|
||||
for(int index = stats.size()-1 ; index >= 0 ; index--) {
|
||||
Status stat = stats.get(index);
|
||||
Status rtStat = stat.getRetweetedStatus();
|
||||
User usr = stat.getUser();
|
||||
tweetId.add(0,stat.getId());
|
||||
if(rtStat != null) {
|
||||
retweeter.add(usr.getScreenName());
|
||||
stat = rtStat;
|
||||
|
@ -361,7 +361,6 @@ public class TweetDatabase {
|
|||
noFav.add(0,stat.getFavoriteCount());
|
||||
userId.add(0,usr.getId());
|
||||
pbLink.add(0,usr.getMiniProfileImageURL());
|
||||
tweetId.add(0,stat.getId());
|
||||
verify.add(0,usr.isVerified() ? 1 : 0);
|
||||
timeMillis.add(0,stat.getCreatedAt().getTime());
|
||||
size++;
|
||||
|
|
Loading…
Reference in New Issue