mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-03 12:37:33 +01:00
initial commit
This commit is contained in:
parent
7ab825cfed
commit
ef7d1cc6b2
1
.idea/dictionaries/Sufian.xml
generated
1
.idea/dictionaries/Sufian.xml
generated
@ -1,6 +1,7 @@
|
|||||||
<component name="ProjectDictionaryState">
|
<component name="ProjectDictionaryState">
|
||||||
<dictionary name="Sufian">
|
<dictionary name="Sufian">
|
||||||
<words>
|
<words>
|
||||||
|
<w>retweet</w>
|
||||||
<w>sqlite</w>
|
<w>sqlite</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
@ -1,25 +1,19 @@
|
|||||||
package org.nuclearfog.twidda.engine;
|
package org.nuclearfog.twidda.engine;
|
||||||
|
|
||||||
|
import org.nuclearfog.twidda.DataBase.AppDatabase;
|
||||||
|
import org.nuclearfog.twidda.R;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.DataBase.AppDatabase;
|
|
||||||
import org.nuclearfog.twidda.R;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import twitter4j.Status;
|
import twitter4j.Status;
|
||||||
import twitter4j.User;
|
|
||||||
|
|
||||||
public class TweetDatabase
|
public class TweetDatabase {
|
||||||
{
|
|
||||||
private AppDatabase dataHelper;
|
private AppDatabase dataHelper;
|
||||||
private List<String> user,tweet,noRT,noFav,noAns, pbLink;
|
private List<String> user,tweet,noRT,noFav,noAns, pbLink;
|
||||||
private List<Long> userId, tweetId;
|
private List<Long> userId, tweetId;
|
||||||
@ -56,8 +50,7 @@ public class TweetDatabase
|
|||||||
SQLiteDatabase db = dataHelper.getWritableDatabase();
|
SQLiteDatabase db = dataHelper.getWritableDatabase();
|
||||||
ContentValues usr = new ContentValues();
|
ContentValues usr = new ContentValues();
|
||||||
ContentValues tl = new ContentValues();
|
ContentValues tl = new ContentValues();
|
||||||
Status stat;
|
|
||||||
User user;
|
|
||||||
for(int pos = 0; pos < getSize(); pos++) {
|
for(int pos = 0; pos < getSize(); pos++) {
|
||||||
// USER
|
// USER
|
||||||
usr.put("userID", getUserID(pos));
|
usr.put("userID", getUserID(pos));
|
||||||
@ -66,7 +59,7 @@ public class TweetDatabase
|
|||||||
// TWEET
|
// TWEET
|
||||||
tl.put("userID", getUserID(pos));
|
tl.put("userID", getUserID(pos));
|
||||||
tl.put("tweetID", getTweetId(pos));
|
tl.put("tweetID", getTweetId(pos));
|
||||||
tl.put("time", dateToLong(newDate.get(pos)));
|
tl.put("time", getTime(pos));
|
||||||
tl.put("tweet", getTweet(pos));
|
tl.put("tweet", getTweet(pos));
|
||||||
tl.put("retweet", getRetweet(pos));
|
tl.put("retweet", getRetweet(pos));
|
||||||
tl.put("favorite", getFavorite(pos));
|
tl.put("favorite", getFavorite(pos));
|
||||||
@ -81,7 +74,7 @@ public class TweetDatabase
|
|||||||
int index;
|
int index;
|
||||||
String SQL_GET_HOME = c.getString(R.string.SQL_HOME_TL);
|
String SQL_GET_HOME = c.getString(R.string.SQL_HOME_TL);
|
||||||
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
|
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
|
||||||
cursor.moveToFirst();
|
|
||||||
if(cursor.moveToFirst()) {
|
if(cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
index = cursor.getColumnIndex("time"); // time
|
index = cursor.getColumnIndex("time"); // time
|
||||||
@ -116,6 +109,7 @@ public class TweetDatabase
|
|||||||
public String getRetweet(int pos){return noRT.get(pos);}
|
public String getRetweet(int pos){return noRT.get(pos);}
|
||||||
public String getFavorite(int pos){return noFav.get(pos);}
|
public String getFavorite(int pos){return noFav.get(pos);}
|
||||||
public String getDate(int pos){return getTweetTime(newDate.get(pos));}
|
public String getDate(int pos){return getTweetTime(newDate.get(pos));}
|
||||||
|
public long getTime(int pos){return newDate.get(pos).getTime();}
|
||||||
public String getAnswer(int pos){return noAns.get(pos);}
|
public String getAnswer(int pos){return noAns.get(pos);}
|
||||||
public String getPbImg (int pos){return pbLink.get(pos);}
|
public String getPbImg (int pos){return pbLink.get(pos);}
|
||||||
|
|
||||||
@ -129,10 +123,13 @@ public class TweetDatabase
|
|||||||
|
|
||||||
private String getTweetTime(Date time) {
|
private String getTweetTime(Date time) {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
int tweetDay = now.getDay() - time.getDay();
|
||||||
int tweetHour = now.getHours() - time.getHours();
|
int tweetHour = now.getHours() - time.getHours();
|
||||||
int tweetMin = now.getMinutes() - time.getMinutes();
|
int tweetMin = now.getMinutes() - time.getMinutes();
|
||||||
int tweetSec = now.getSeconds() - time.getSeconds();
|
int tweetSec = now.getSeconds() - time.getSeconds();
|
||||||
if (tweetHour > 0)
|
if (tweetDay > 0)
|
||||||
|
return "vor "+tweetDay+" d";
|
||||||
|
else if (tweetHour > 0)
|
||||||
return "vor "+tweetHour+" h";
|
return "vor "+tweetHour+" h";
|
||||||
else if(tweetMin > 0)
|
else if(tweetMin > 0)
|
||||||
return "vor "+tweetMin+" min";
|
return "vor "+tweetMin+" min";
|
||||||
@ -143,9 +140,6 @@ public class TweetDatabase
|
|||||||
private Date longToDate(long mills) {
|
private Date longToDate(long mills) {
|
||||||
return new Date(mills);
|
return new Date(mills);
|
||||||
}
|
}
|
||||||
private long dateToLong(Date d) {
|
|
||||||
return d.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initArray() {
|
private void initArray() {
|
||||||
user = new ArrayList<>();
|
user = new ArrayList<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user