mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-03 12:37:33 +01:00
Bugfix
Cleanup
This commit is contained in:
parent
6f107ba97a
commit
1fee5209e6
@ -18,7 +18,6 @@ import java.net.URL;
|
||||
|
||||
public class ImagePopup extends AsyncTask<String, Void, Boolean> implements Button.OnClickListener {
|
||||
|
||||
private ProgressBar mBar;
|
||||
private ImageView mImg;
|
||||
private Dialog popup;
|
||||
private Bitmap imgArray[];
|
||||
@ -29,14 +28,10 @@ public class ImagePopup extends AsyncTask<String, Void, Boolean> implements Butt
|
||||
|
||||
public ImagePopup(Context c) {
|
||||
popup = new Dialog(c);
|
||||
mBar = new ProgressBar(c);
|
||||
ProgressBar mBar = new ProgressBar(c);
|
||||
inf = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
popup.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
popup.getWindow().setBackgroundDrawableResource(R.color.transparent);
|
||||
popup.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
popup.setContentView(mBar);
|
||||
popup.show();
|
||||
popup.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
|
@ -14,6 +14,8 @@ import android.widget.Toast;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
|
||||
public static final int HOME = 0;
|
||||
@ -21,9 +23,8 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
public static final int MENT = 2;
|
||||
private static final int FAIL = -1;
|
||||
|
||||
private WeakReference<MainActivity> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private Context context;
|
||||
private SwipeRefreshLayout timelineRefresh, trendRefresh, mentionRefresh;
|
||||
private RecyclerView timelineList, trendList, mentionList;
|
||||
private TimelineRecycler timelineAdapter, mentionAdapter;
|
||||
private TrendRecycler trendsAdapter;
|
||||
@ -34,23 +35,13 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
* @see MainActivity
|
||||
*/
|
||||
public MainPage(Context context) {
|
||||
this.context = context;
|
||||
ui = new WeakReference<>((MainActivity)context);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
SharedPreferences settings = context.getSharedPreferences("settings", 0);
|
||||
woeid = settings.getInt("woeid",23424829); // Germany WOEID
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
// Timeline Tab
|
||||
timelineRefresh = (SwipeRefreshLayout)((MainActivity)context).findViewById(R.id.timeline);
|
||||
timelineList = (RecyclerView)((MainActivity)context).findViewById(R.id.tl_list);
|
||||
// Trend Tab
|
||||
trendRefresh = (SwipeRefreshLayout)((MainActivity)context).findViewById(R.id.trends);
|
||||
trendList = (RecyclerView)((MainActivity)context).findViewById(R.id.tr_list);
|
||||
// Mention Tab
|
||||
mentionRefresh = (SwipeRefreshLayout)((MainActivity)context).findViewById(R.id.mention);
|
||||
mentionList = (RecyclerView)((MainActivity)context).findViewById(R.id.m_list);
|
||||
timelineList = (RecyclerView)ui.get().findViewById(R.id.tl_list);
|
||||
trendList = (RecyclerView)ui.get().findViewById(R.id.tr_list);
|
||||
mentionList = (RecyclerView)ui.get().findViewById(R.id.m_list);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,8 +61,8 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
id = timelineAdapter.getItemId(0);
|
||||
timelineAdapter.getData().insert(mTwitter.getHome(page,id),true);
|
||||
} else {
|
||||
TweetDatabase mTweets = new TweetDatabase(mTwitter.getHome(page,id), context,TweetDatabase.HOME_TL,0);
|
||||
timelineAdapter = new TimelineRecycler(mTweets,(MainActivity)context);
|
||||
TweetDatabase mTweets = new TweetDatabase(mTwitter.getHome(page,id), ui.get(),TweetDatabase.HOME_TL,0);
|
||||
timelineAdapter = new TimelineRecycler(mTweets,ui.get());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -80,7 +71,7 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
if(trendsAdapter != null && trendsAdapter.getItemCount() > 0)
|
||||
trendsAdapter.getData().setTrends( mTwitter.getTrends(woeid) );
|
||||
else
|
||||
trendsAdapter = new TrendRecycler(new TrendDatabase(mTwitter.getTrends(woeid),context),(MainActivity)context);
|
||||
trendsAdapter = new TrendRecycler(new TrendDatabase(mTwitter.getTrends(woeid),ui.get()), ui.get());
|
||||
break;
|
||||
|
||||
case MENT:
|
||||
@ -89,8 +80,8 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
id = mentionAdapter.getItemId(0);
|
||||
mentionAdapter.getData().insert(mTwitter.getMention(page,id),true);
|
||||
} else {
|
||||
TweetDatabase mention = new TweetDatabase(mTwitter.getMention(page,id), context,TweetDatabase.GET_MENT,0);
|
||||
mentionAdapter = new TimelineRecycler(mention,(MainActivity)context);
|
||||
TweetDatabase mention = new TweetDatabase(mTwitter.getMention(page,id), ui.get(),TweetDatabase.GET_MENT,0);
|
||||
mentionAdapter = new TimelineRecycler(mention,ui.get());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -103,6 +94,14 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer MODE) {
|
||||
MainActivity connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
Context context = connect.getApplicationContext();
|
||||
SwipeRefreshLayout timelineRefresh = (SwipeRefreshLayout)connect.findViewById(R.id.timeline);
|
||||
SwipeRefreshLayout trendRefresh = (SwipeRefreshLayout)connect.findViewById(R.id.trends);
|
||||
SwipeRefreshLayout mentionRefresh = (SwipeRefreshLayout)connect.findViewById(R.id.mention);
|
||||
|
||||
switch(MODE) {
|
||||
case HOME:
|
||||
timelineRefresh.setRefreshing(false);
|
||||
|
@ -16,7 +16,8 @@ import org.nuclearfog.twidda.database.TweetDatabase;
|
||||
import org.nuclearfog.twidda.viewadapter.TimelineRecycler;
|
||||
import org.nuclearfog.twidda.window.UserProfile;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import twitter4j.User;
|
||||
import com.squareup.picasso.Picasso;
|
||||
@ -31,14 +32,11 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
private static final long FAILURE = 0x6;
|
||||
|
||||
private String screenName, username, description, location, follower, following;
|
||||
private TextView txtUser,txtScrName,txtBio,txtLocation,txtLink,txtFollowing,txtFollower,txtCreated;
|
||||
private ImageView profile, banner, linkIcon, locationIcon, verifier, locked, followback;
|
||||
private SwipeRefreshLayout tweetsReload, favoritsReload;
|
||||
private RecyclerView profileTweets, profileFavorits;
|
||||
private String imageLink, bannerLink, fullPbLink, link, dateString;
|
||||
private TimelineRecycler homeTl, homeFav;
|
||||
private Context context;
|
||||
private Toolbar tool;
|
||||
private WeakReference<UserProfile> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private boolean isHome = false;
|
||||
private boolean imgEnabled = false;
|
||||
private boolean isFollowing = false;
|
||||
@ -52,41 +50,20 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
* @see UserProfile
|
||||
*/
|
||||
public ProfileLoader(Context context) {
|
||||
this.context=context;
|
||||
ui = new WeakReference<>((UserProfile)context);
|
||||
profileTweets = (RecyclerView) ui.get().findViewById(R.id.ht_list);
|
||||
profileFavorits = (RecyclerView) ui.get().findViewById(R.id.hf_list);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
SharedPreferences settings = context.getSharedPreferences("settings", 0);
|
||||
imgEnabled = settings.getBoolean("image_load",true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
txtUser = (TextView)((UserProfile)context).findViewById(R.id.profile_username);
|
||||
txtScrName = (TextView)((UserProfile)context).findViewById(R.id.profile_screenname);
|
||||
txtBio = (TextView)((UserProfile)context).findViewById(R.id.bio);
|
||||
txtLocation = (TextView)((UserProfile)context).findViewById(R.id.location);
|
||||
txtLink = (TextView)((UserProfile)context).findViewById(R.id.links);
|
||||
txtCreated = (TextView)((UserProfile)context).findViewById(R.id.profile_date);
|
||||
txtFollowing = (TextView)((UserProfile)context).findViewById(R.id.following);
|
||||
txtFollower = (TextView)((UserProfile)context).findViewById(R.id.follower);
|
||||
profile = (ImageView)((UserProfile)context).findViewById(R.id.profile_img);
|
||||
banner = (ImageView)((UserProfile)context).findViewById(R.id.banner);
|
||||
linkIcon = (ImageView)((UserProfile)context).findViewById(R.id.link_img);
|
||||
verifier = (ImageView)((UserProfile)context).findViewById(R.id.profile_verify);
|
||||
followback = (ImageView)((UserProfile)context).findViewById(R.id.followback);
|
||||
locked = (ImageView)((UserProfile)context).findViewById(R.id.profile_locked);
|
||||
locationIcon = (ImageView)((UserProfile)context).findViewById(R.id.location_img);
|
||||
tweetsReload = (SwipeRefreshLayout)((UserProfile)context).findViewById(R.id.hometweets);
|
||||
favoritsReload = (SwipeRefreshLayout)((UserProfile)context).findViewById(R.id.homefavorits);
|
||||
profileTweets = (RecyclerView)((UserProfile)context).findViewById(R.id.ht_list);
|
||||
profileFavorits = (RecyclerView)((UserProfile)context).findViewById(R.id.hf_list);
|
||||
tool = (Toolbar) ((UserProfile)context).findViewById(R.id.profile_toolbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long doInBackground(Long... args) {
|
||||
long userId = args[0];
|
||||
final long MODE = args[1];
|
||||
long id = 1L;
|
||||
TwitterEngine mTwitter = TwitterEngine.getInstance(context);
|
||||
|
||||
try {
|
||||
isHome = TwitterEngine.getHomeId() == userId;
|
||||
if(!isHome)
|
||||
@ -111,7 +88,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
bannerLink = user.getProfileBannerMobileURL();
|
||||
fullPbLink = user.getOriginalProfileImageURL();
|
||||
Date d = user.getCreatedAt();
|
||||
dateString = "seit "+new SimpleDateFormat("dd.MM.yyyy").format(d);
|
||||
dateString = "seit "+ DateFormat.getDateTimeInstance().format(d);
|
||||
}
|
||||
else if(MODE == GET_TWEETS)
|
||||
{
|
||||
@ -120,8 +97,8 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
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);
|
||||
TweetDatabase hTweets = new TweetDatabase(mTwitter.getUserTweets(userId,args[2],id),ui.get(),TweetDatabase.USER_TL,userId);
|
||||
homeTl = new TimelineRecycler(hTweets,ui.get());
|
||||
}
|
||||
}
|
||||
else if(MODE == GET_FAVS)
|
||||
@ -131,8 +108,8 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
id = homeFav.getItemId(0);
|
||||
homeFav.getData().insert(mTwitter.getUserFavs(userId,args[2],id),true);
|
||||
} else {
|
||||
TweetDatabase fTweets = new TweetDatabase(mTwitter.getUserFavs(userId,args[2],id),context,TweetDatabase.FAV_TL,userId);
|
||||
homeFav = new TimelineRecycler(fTweets,(UserProfile)context);
|
||||
TweetDatabase fTweets = new TweetDatabase(mTwitter.getUserFavs(userId,args[2],id),ui.get(),TweetDatabase.FAV_TL,userId);
|
||||
homeFav = new TimelineRecycler(fTweets,ui.get());
|
||||
}
|
||||
}
|
||||
else if(MODE == ACTION_FOLLOW)
|
||||
@ -158,6 +135,32 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Long mode) {
|
||||
|
||||
UserProfile connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
|
||||
final Context context = connect.getApplicationContext();
|
||||
|
||||
TextView txtUser = (TextView)connect.findViewById(R.id.profile_username);
|
||||
TextView txtScrName = (TextView)connect.findViewById(R.id.profile_screenname);
|
||||
TextView txtBio = (TextView)connect.findViewById(R.id.bio);
|
||||
TextView txtLocation = (TextView)connect.findViewById(R.id.location);
|
||||
TextView txtLink = (TextView)connect.findViewById(R.id.links);
|
||||
TextView txtCreated = (TextView)connect.findViewById(R.id.profile_date);
|
||||
TextView txtFollowing = (TextView)connect.findViewById(R.id.following);
|
||||
TextView txtFollower = (TextView)connect.findViewById(R.id.follower);
|
||||
ImageView profile = (ImageView)connect.findViewById(R.id.profile_img);
|
||||
ImageView banner = (ImageView)connect.findViewById(R.id.banner);
|
||||
ImageView linkIcon = (ImageView)connect.findViewById(R.id.link_img);
|
||||
ImageView verifier = (ImageView)connect.findViewById(R.id.profile_verify);
|
||||
ImageView followback = (ImageView)connect.findViewById(R.id.followback);
|
||||
ImageView locked = (ImageView)connect.findViewById(R.id.profile_locked);
|
||||
ImageView locationIcon = (ImageView)connect.findViewById(R.id.location_img);
|
||||
SwipeRefreshLayout tweetsReload = (SwipeRefreshLayout)connect.findViewById(R.id.hometweets);
|
||||
SwipeRefreshLayout favoritsReload = (SwipeRefreshLayout)connect.findViewById(R.id.homefavorits);
|
||||
Toolbar tool = (Toolbar) connect.findViewById(R.id.profile_toolbar);
|
||||
|
||||
if(mode == GET_INFORMATION) {
|
||||
txtUser.setText(username);
|
||||
txtScrName.setText(screenName);
|
||||
@ -192,6 +195,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
}
|
||||
});
|
||||
}
|
||||
ui.get().onLoaded();
|
||||
}
|
||||
else if(mode == GET_TWEETS)
|
||||
{
|
||||
@ -226,4 +230,8 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
tool.getMenu().getItem(2).setIcon(R.drawable.block);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnProfileFinished {
|
||||
void onLoaded();
|
||||
}
|
||||
}
|
@ -6,8 +6,12 @@ import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
import org.nuclearfog.twidda.window.LoginPage;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class Registration extends AsyncTask<String, Void, Boolean> {
|
||||
private Context context;
|
||||
|
||||
private WeakReference<LoginPage> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private String errMSG = "";
|
||||
|
||||
/**
|
||||
@ -17,18 +21,18 @@ public class Registration extends AsyncTask<String, Void, Boolean> {
|
||||
* @param context current Activity's Context.
|
||||
*/
|
||||
public Registration(Context context) {
|
||||
this.context = context;
|
||||
ui = new WeakReference<>((LoginPage)context);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground( String... twitterPin ) {
|
||||
String pin = twitterPin[0];
|
||||
TwitterEngine mTwitter = TwitterEngine.getInstance(context);
|
||||
try {
|
||||
if( pin.trim().isEmpty() ) {
|
||||
mTwitter.request();
|
||||
}else {
|
||||
} else {
|
||||
mTwitter.initialize(pin);
|
||||
return true;
|
||||
}
|
||||
@ -41,10 +45,14 @@ public class Registration extends AsyncTask<String, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
LoginPage connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
if(success) {
|
||||
((LoginPage)context).setResult(Activity.RESULT_OK);
|
||||
((LoginPage)context).finish();
|
||||
connect.setResult(Activity.RESULT_OK);
|
||||
connect.finish();
|
||||
} else if(!errMSG.isEmpty()) {
|
||||
Context context = connect.getApplicationContext();
|
||||
Toast.makeText(context,"Fehler: "+errMSG,Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,19 +43,13 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
public static final long LOAD_TWEET = 3;
|
||||
public static final long LOAD_REPLY = 4;
|
||||
|
||||
private Context c;
|
||||
private TwitterEngine mTwitter;
|
||||
private List<twitter4j.Status> answers;
|
||||
private TimelineRecycler tlAdp;
|
||||
private RecyclerView replyList;
|
||||
private TextView username,scrName,replyName,tweet,userRetweet;
|
||||
private TextView used_api,txtAns,txtRet,txtFav,date;
|
||||
private ImageView profile_img,tweet_verify;
|
||||
private Button retweetButton,favoriteButton, mediabutton;
|
||||
private SwipeRefreshLayout ansReload;
|
||||
private Bitmap profile_btm;
|
||||
private String usernameStr, scrNameStr, tweetStr, dateString;
|
||||
private String repliedUsername, apiName, retweeter, tweetlink;
|
||||
private String repliedUsername, apiName, retweeter;
|
||||
private String medialinks[];
|
||||
private String errMSG = "";
|
||||
private boolean retweeted, favorited, toggleImg, verified;
|
||||
@ -63,7 +58,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
private int rt, fav;
|
||||
private int highlight;
|
||||
|
||||
|
||||
private WeakReference<TweetDetail> ui;
|
||||
|
||||
public StatusLoader(Context c) {
|
||||
mTwitter = TwitterEngine.getInstance(c);
|
||||
@ -71,32 +66,11 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
SharedPreferences settings = c.getSharedPreferences("settings", 0);
|
||||
toggleImg = settings.getBoolean("image_load", true);
|
||||
highlight = ColorPreferences.getInstance(c).getColor(ColorPreferences.HIGHLIGHTING);
|
||||
this.c = c;
|
||||
|
||||
ui = new WeakReference<>((TweetDetail)c);
|
||||
replyList = (RecyclerView) ui.get().findViewById(R.id.answer_list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
replyList = (RecyclerView) ((TweetDetail)c).findViewById(R.id.answer_list);
|
||||
tweet = (TextView) ((TweetDetail)c).findViewById(R.id.tweet_detailed);
|
||||
username = (TextView) ((TweetDetail)c).findViewById(R.id.usernamedetail);
|
||||
scrName = (TextView) ((TweetDetail)c).findViewById(R.id.scrnamedetail);
|
||||
date = (TextView) ((TweetDetail)c).findViewById(R.id.timedetail);
|
||||
replyName = (TextView) ((TweetDetail)c).findViewById(R.id.answer_reference_detail);
|
||||
txtAns = (TextView) ((TweetDetail)c).findViewById(R.id.no_ans_detail);
|
||||
txtRet = (TextView) ((TweetDetail)c).findViewById(R.id.no_rt_detail);
|
||||
txtFav = (TextView) ((TweetDetail)c).findViewById(R.id.no_fav_detail);
|
||||
used_api = (TextView) ((TweetDetail)c).findViewById(R.id.used_api);
|
||||
used_api = (TextView) ((TweetDetail)c).findViewById(R.id.used_api);
|
||||
userRetweet = (TextView) ((TweetDetail)c).findViewById(R.id.rt_info);
|
||||
ansReload = (SwipeRefreshLayout) ((TweetDetail)c).findViewById(R.id.answer_reload);
|
||||
|
||||
profile_img = (ImageView) ((TweetDetail)c).findViewById(R.id.profileimage_detail);
|
||||
tweet_verify =(ImageView)((TweetDetail)c).findViewById(R.id.tweet_verify);
|
||||
|
||||
retweetButton = (Button) ((TweetDetail)c).findViewById(R.id.rt_button_detail);
|
||||
favoriteButton = (Button) ((TweetDetail)c).findViewById(R.id.fav_button_detail);
|
||||
mediabutton = (Button) ((TweetDetail)c).findViewById(R.id.image_attach);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data [0] TWEET ID , [1] Mode
|
||||
@ -129,7 +103,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
usernameStr = user.getName();
|
||||
scrNameStr = '@'+user.getScreenName();
|
||||
apiName = formatString(currentTweet.getSource());
|
||||
dateString = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss").format(currentTweet.getCreatedAt());
|
||||
dateString = DateFormat.getDateTimeInstance().format(currentTweet.getCreatedAt());
|
||||
|
||||
if(userReply > 0)
|
||||
repliedUsername = currentTweet.getInReplyToScreenName();
|
||||
@ -148,7 +122,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
else if(mode == RETWEET) {
|
||||
if(retweeted) {
|
||||
mTwitter.retweet(tweetID, true);
|
||||
TweetDatabase.delete(c, tweetID);
|
||||
TweetDatabase.delete(ui.get(), tweetID);
|
||||
retweeted = false;
|
||||
rt--;
|
||||
} else {
|
||||
@ -177,12 +151,12 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
}
|
||||
else if(mode == DELETE) {
|
||||
mTwitter.deleteTweet(tweetID);
|
||||
TweetDatabase.delete(c,tweetID);
|
||||
TweetDatabase.delete(ui.get(),tweetID);
|
||||
}
|
||||
}catch(TwitterException e) {
|
||||
int err = e.getErrorCode();
|
||||
if(err == 144) { // gelöscht
|
||||
TweetDatabase.delete(c,tweetID);
|
||||
TweetDatabase.delete(ui.get(),tweetID);
|
||||
errMSG = e.getMessage();
|
||||
}
|
||||
e.printStackTrace();
|
||||
@ -196,6 +170,30 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Long mode) {
|
||||
|
||||
TweetDetail connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
|
||||
final Context c = connect.getApplicationContext();
|
||||
|
||||
TextView tweet = (TextView)connect.findViewById(R.id.tweet_detailed);
|
||||
TextView username = (TextView)connect.findViewById(R.id.usernamedetail);
|
||||
TextView scrName = (TextView)connect.findViewById(R.id.scrnamedetail);
|
||||
TextView date = (TextView)connect.findViewById(R.id.timedetail);
|
||||
TextView replyName = (TextView)connect.findViewById(R.id.answer_reference_detail);
|
||||
TextView txtAns = (TextView)connect.findViewById(R.id.no_ans_detail);
|
||||
TextView txtRet = (TextView)connect.findViewById(R.id.no_rt_detail);
|
||||
TextView txtFav = (TextView)connect.findViewById(R.id.no_fav_detail);
|
||||
TextView used_api = (TextView)connect.findViewById(R.id.used_api);
|
||||
TextView userRetweet = (TextView)connect.findViewById(R.id.rt_info);
|
||||
SwipeRefreshLayout ansReload = (SwipeRefreshLayout)connect.findViewById(R.id.answer_reload);
|
||||
ImageView profile_img = (ImageView)connect.findViewById(R.id.profileimage_detail);
|
||||
ImageView tweet_verify =(ImageView)connect.findViewById(R.id.tweet_verify);
|
||||
Button retweetButton = (Button)connect.findViewById(R.id.rt_button_detail);
|
||||
Button favoriteButton = (Button)connect.findViewById(R.id.fav_button_detail);
|
||||
Button mediabutton = (Button)connect.findViewById(R.id.image_attach);
|
||||
|
||||
if(mode == LOAD_TWEET) {
|
||||
tweet.setText(highlight(tweetStr));
|
||||
username.setText(usernameStr);
|
||||
@ -208,9 +206,9 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
txtFav.setText(favStr);
|
||||
txtRet.setText(rtStr);
|
||||
|
||||
setIcons();
|
||||
if(repliedUsername != null) {
|
||||
replyName.setText("antwort @"+repliedUsername);
|
||||
String reply = "antwort @"+repliedUsername;
|
||||
replyName.setText(reply);
|
||||
replyName.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if(rtFlag) {
|
||||
@ -231,7 +229,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
});
|
||||
}
|
||||
}
|
||||
setIcons();
|
||||
setIcons(favoriteButton, retweetButton);
|
||||
replyName.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -246,24 +244,24 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
else if(mode == RETWEET) {
|
||||
String rtStr = Integer.toString(rt);
|
||||
txtRet.setText(rtStr);
|
||||
setIcons();
|
||||
setIcons(favoriteButton, retweetButton);
|
||||
}
|
||||
else if(mode == FAVORITE) {
|
||||
String favStr = Integer.toString(fav);
|
||||
txtFav.setText(favStr);
|
||||
setIcons();
|
||||
setIcons(favoriteButton, retweetButton);
|
||||
}
|
||||
else if(mode == LOAD_REPLY) {
|
||||
if(tlAdp == null || tlAdp.getItemCount() == 0) {
|
||||
TweetDatabase tweetDatabase = new TweetDatabase(answers,c);
|
||||
tlAdp = new TimelineRecycler(tweetDatabase,(TweetDetail)c);
|
||||
tlAdp = new TimelineRecycler(tweetDatabase,(ui.get()));
|
||||
replyList.setAdapter(tlAdp);
|
||||
} else {
|
||||
TweetDatabase twDb = tlAdp.getData();
|
||||
twDb.insert(answers,false);
|
||||
tlAdp.notifyDataSetChanged();
|
||||
ansReload.setRefreshing(false);
|
||||
}
|
||||
ansReload.setRefreshing(false);
|
||||
String ansStr = Integer.toString(tlAdp.getItemCount());
|
||||
txtAns.setText(ansStr);
|
||||
}
|
||||
@ -280,7 +278,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
}
|
||||
|
||||
private String formatString(String input) {
|
||||
String output = "gesendet von: ";
|
||||
StringBuilder output = new StringBuilder("gesendet von: ");
|
||||
boolean openTag = false;
|
||||
for(int i = 0 ; i < input.length() ; i++){
|
||||
char current = input.charAt(i);
|
||||
@ -289,10 +287,10 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
} else if(current == '<'){
|
||||
openTag = false;
|
||||
} else if(openTag) {
|
||||
output += current;
|
||||
output.append(current);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
private SpannableStringBuilder highlight(String tweet) {
|
||||
@ -332,7 +330,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
return sTweet;
|
||||
}
|
||||
|
||||
private void setIcons() {
|
||||
private void setIcons(Button favoriteButton, Button retweetButton) {
|
||||
if(favorited)
|
||||
favoriteButton.setBackgroundResource(R.drawable.favorite_enabled);
|
||||
else
|
||||
|
@ -2,11 +2,20 @@ package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.window.TweetPopup;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class StatusUpload extends AsyncTask<Object, Void, Boolean> {
|
||||
|
||||
private Context context;
|
||||
private WeakReference<TweetPopup> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private ProgressBar load;
|
||||
private String[] path;
|
||||
private String error;
|
||||
|
||||
@ -15,10 +24,17 @@ public class StatusUpload extends AsyncTask<Object, Void, Boolean> {
|
||||
* @param path Internal Path of the Image
|
||||
*/
|
||||
public StatusUpload(Context context, String[] path) {
|
||||
this.context = context;
|
||||
ui = new WeakReference<>((TweetPopup)context);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
load = (ProgressBar) ui.get().findViewById(R.id.tweet_sending);
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
load.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args Argument + Text
|
||||
* args[0] = TWEET TEXT
|
||||
@ -33,9 +49,9 @@ public class StatusUpload extends AsyncTask<Object, Void, Boolean> {
|
||||
id = (Long) args[1];
|
||||
}
|
||||
if(path.length == 0) {
|
||||
TwitterEngine.getInstance(context).sendStatus(tweet,id);
|
||||
mTwitter.sendStatus(tweet,id);
|
||||
} else {
|
||||
TwitterEngine.getInstance(context).sendStatus(tweet,id,path);
|
||||
mTwitter.sendStatus(tweet,id,path);
|
||||
}
|
||||
return true;
|
||||
} catch(Exception err) {
|
||||
@ -46,10 +62,15 @@ public class StatusUpload extends AsyncTask<Object, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
TweetPopup connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
Context context = connect.getApplicationContext();
|
||||
if(success) {
|
||||
Toast.makeText(context, "gesendet!", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(context, "Fehler: "+error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
connect.finish();
|
||||
}
|
||||
}
|
@ -164,6 +164,7 @@ public class TwitterEngine {
|
||||
/**
|
||||
* Get Tweet search result
|
||||
* @param search Search String
|
||||
* @param id Since ID
|
||||
* @return List of Tweets
|
||||
* @throws TwitterException if acces is unavailable
|
||||
*/
|
||||
|
@ -15,58 +15,61 @@ import org.nuclearfog.twidda.viewadapter.UserRecycler;
|
||||
import org.nuclearfog.twidda.window.ColorPreferences;
|
||||
import org.nuclearfog.twidda.window.SearchPage;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class TwitterSearch extends AsyncTask<String, Void, Void> {
|
||||
|
||||
private TimelineRecycler tlRc;
|
||||
private UserRecycler uAdp;
|
||||
private SwipeRefreshLayout tweetReload;
|
||||
private RecyclerView tweetSearch, userSearch;
|
||||
private ProgressBar circleLoad;
|
||||
private Context context;
|
||||
private TwitterEngine mTwitter;
|
||||
private WeakReference<SearchPage> ui;
|
||||
private int background, font_color;
|
||||
|
||||
public TwitterSearch(Context context) {
|
||||
this.context=context;
|
||||
ui = new WeakReference<>((SearchPage)context);
|
||||
tweetSearch = (RecyclerView) ui.get().findViewById(R.id.tweet_result);
|
||||
userSearch = (RecyclerView) ui.get().findViewById(R.id.user_result);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
ColorPreferences mcolor = ColorPreferences.getInstance(context);
|
||||
background = mcolor.getColor(ColorPreferences.BACKGROUND);
|
||||
font_color = mcolor.getColor(ColorPreferences.FONT_COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
tweetSearch = (RecyclerView) ((SearchPage)context).findViewById(R.id.tweet_result);
|
||||
userSearch = (RecyclerView) ((SearchPage)context).findViewById(R.id.user_result);
|
||||
tweetReload = (SwipeRefreshLayout) ((SearchPage)context).findViewById(R.id.searchtweets);
|
||||
circleLoad = (ProgressBar) ((SearchPage)context).findViewById(R.id.search_progress);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(String... search) {
|
||||
String get = search[0];
|
||||
String strSearch = search[0];
|
||||
long id = 1L;
|
||||
try {
|
||||
tlRc = (TimelineRecycler) tweetSearch.getAdapter();
|
||||
if(tlRc != null) {
|
||||
id = tlRc.getItemId(0);
|
||||
tlRc.getData().insert(mTwitter.searchTweets(get,id),false);
|
||||
tlRc.getData().insert(mTwitter.searchTweets(strSearch,id),false);
|
||||
} else {
|
||||
tlRc = new TimelineRecycler(new TweetDatabase(mTwitter.searchTweets(get,id),context),((SearchPage)context));
|
||||
tlRc = new TimelineRecycler(new TweetDatabase(mTwitter.searchTweets(strSearch,id),ui.get()),ui.get());
|
||||
tlRc.setColor(background,font_color);
|
||||
}
|
||||
uAdp = new UserRecycler(new UserDatabase(context, mTwitter.searchUsers(get)),((SearchPage)context));
|
||||
uAdp = new UserRecycler(new UserDatabase(ui.get(), mTwitter.searchUsers(strSearch)),ui.get());
|
||||
} catch(Exception err){err.printStackTrace();}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
|
||||
SearchPage connect = ui.get();
|
||||
if(connect == null)
|
||||
return;
|
||||
|
||||
SwipeRefreshLayout tweetReload = (SwipeRefreshLayout)connect.findViewById(R.id.searchtweets);
|
||||
ProgressBar circleLoad = (ProgressBar)connect.findViewById(R.id.search_progress);
|
||||
|
||||
circleLoad.setVisibility(View.INVISIBLE);
|
||||
if(tweetSearch.getAdapter() == null)
|
||||
if(tweetSearch.getAdapter() == null) {
|
||||
tweetSearch.setAdapter(tlRc);
|
||||
else
|
||||
} else {
|
||||
tlRc.notifyDataSetChanged();
|
||||
}
|
||||
userSearch.setAdapter(uAdp);
|
||||
tweetReload.setRefreshing(false);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.viewadapter.UserRecycler;
|
||||
import org.nuclearfog.twidda.window.UserDetail;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
|
||||
public static final long FOLLOWING = 0L;
|
||||
@ -19,7 +21,7 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
public static final long RETWEETER = 2L;
|
||||
public static final long FAVORISER = 3L;
|
||||
|
||||
private Context context;
|
||||
private WeakReference<UserDetail> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private UserRecycler usrAdp;
|
||||
private RecyclerView userList;
|
||||
@ -30,15 +32,13 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
*@see UserDetail
|
||||
*/
|
||||
public UserLists(Context context) {
|
||||
this.context = context;
|
||||
ui = new WeakReference<>((UserDetail)context);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
userList = (RecyclerView) ui.get().findViewById(R.id.userlist);
|
||||
uProgress = (ProgressBar) ui.get().findViewById(R.id.user_progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
userList = (RecyclerView) ((UserDetail)context).findViewById(R.id.userlist);
|
||||
uProgress = (ProgressBar)((UserDetail)context).findViewById(R.id.user_progress);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Long... data) {
|
||||
@ -49,8 +49,8 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
usrAdp = (UserRecycler) userList.getAdapter();
|
||||
if(mode == FOLLOWING) {
|
||||
if(usrAdp == null) {
|
||||
UserDatabase udb = new UserDatabase(context,mTwitter.getFollowing(id,cursor));
|
||||
usrAdp = new UserRecycler(udb,(UserDetail)context);
|
||||
UserDatabase udb = new UserDatabase(ui.get(),mTwitter.getFollowing(id,cursor));
|
||||
usrAdp = new UserRecycler(udb,ui.get());
|
||||
} else {
|
||||
UserDatabase uDb = usrAdp.getData();
|
||||
uDb.addLast(mTwitter.getFollowing(id,cursor));
|
||||
@ -59,8 +59,8 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
}
|
||||
else if(mode == FOLLOWERS) {
|
||||
if(usrAdp == null) {
|
||||
UserDatabase udb = new UserDatabase(context,mTwitter.getFollower(id,cursor));
|
||||
usrAdp = new UserRecycler(udb,(UserDetail)context);
|
||||
UserDatabase udb = new UserDatabase(ui.get(),mTwitter.getFollower(id,cursor));
|
||||
usrAdp = new UserRecycler(udb,ui.get());
|
||||
} else {
|
||||
UserDatabase uDb = usrAdp.getData();
|
||||
uDb.addLast(mTwitter.getFollower(id,cursor));
|
||||
@ -68,12 +68,12 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
}
|
||||
}
|
||||
else if(mode == RETWEETER) {
|
||||
UserDatabase udb = new UserDatabase(context,mTwitter.getRetweeter(id,cursor));
|
||||
usrAdp = new UserRecycler(udb,(UserDetail)context);
|
||||
UserDatabase udb = new UserDatabase(ui.get(),mTwitter.getRetweeter(id,cursor));
|
||||
usrAdp = new UserRecycler(udb,ui.get());
|
||||
}
|
||||
else if(mode == FAVORISER) {
|
||||
/*else if(mode == FAVORISER) {
|
||||
// GET FAV USERS TODO
|
||||
}
|
||||
}*/
|
||||
}
|
||||
catch(Exception err) {
|
||||
errmsg = "Fehler: "+err.getMessage();
|
||||
@ -83,10 +83,12 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
if(ui.get() == null)
|
||||
return;
|
||||
if(errmsg == null) {
|
||||
userList.setAdapter(usrAdp);
|
||||
} else {
|
||||
Toast.makeText(context,errmsg,Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ui.get().getApplicationContext(),errmsg,Toast.LENGTH_LONG).show();
|
||||
}
|
||||
uProgress.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
@ -6,28 +6,34 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
public class AppDatabase extends SQLiteOpenHelper
|
||||
{
|
||||
private static final String uQuery = "CREATE TABLE IF NOT EXISTS user ("+
|
||||
private static final String userTable = "CREATE TABLE IF NOT EXISTS user ("+
|
||||
"userID INTEGER PRIMARY KEY, username TEXT," +
|
||||
"scrname TEXT, pbLink TEXT, banner TEXT, bio TEXT,"+
|
||||
"location TEXT, link TEXT, verify INTEGER);";
|
||||
|
||||
private static final String tQuery = "CREATE TABLE IF NOT EXISTS tweet (" +
|
||||
"tweetID INTEGER PRIMARY KEY, userID INTEGER, retweeter TEXT," +
|
||||
private static final String tweetTable = "CREATE TABLE IF NOT EXISTS tweet (" +
|
||||
"tweetID INTEGER PRIMARY KEY, userID INTEGER, retweetID INTEGER," +
|
||||
"time INTEGER, tweet TEXT, retweet INTEGER, favorite INTEGER," +
|
||||
"retweeterID INTEGER, FOREIGN KEY (userID) REFERENCES user(userID));";
|
||||
"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);";
|
||||
private static final String favoriteTable = "CREATE TABLE IF NOT EXISTS favorit (" +
|
||||
"userID INTEGER, tweetID INTEGER UNIQUE," +
|
||||
"FOREIGN KEY (userID) REFERENCES user(userID)," +
|
||||
"FOREIGN KEY (tweetID) REFERENCES tweet(tweetID));";
|
||||
|
||||
private static final String hQuery = "CREATE TABLE IF NOT EXISTS timeline (" +
|
||||
private static final String retweetTable = "CREATE TABLE IF NOT EXISTS retweet ("+
|
||||
"userID INTEGER, tweetID INTEGER UNIQUE," +
|
||||
"FOREIGN KEY (userID) REFERENCES user(userID)," +
|
||||
"FOREIGN KEY (tweetID) REFERENCES tweet(tweetID));";
|
||||
|
||||
private static final String timelineTable = "CREATE TABLE IF NOT EXISTS timeline (" +
|
||||
"tweetID INTEGER UNIQUE, mTweetID INTEGER UNIQUE," +
|
||||
"FOREIGN KEY (tweetID) REFERENCES tweet(tweetID));" +
|
||||
"FOREIGN KEY (mTweetID) REFERENCES tweet(tweetID));";
|
||||
|
||||
private static final String fQuery = "CREATE TABLE IF NOT EXISTS favorit (" +
|
||||
"ownerID INTEGER, tweetID INTEGER UNIQUE," +
|
||||
"FOREIGN KEY (ownerID) REFERENCES user(userID)," +
|
||||
"FOREIGN KEY (tweetID) REFERENCES tweet(tweetID));";
|
||||
private static final String trendTable = "CREATE TABLE IF NOT EXISTS trend (" +
|
||||
"trendpos INTEGER PRIMARY KEY, trendname TEXT, trendlink TEXT);";
|
||||
|
||||
|
||||
private static AppDatabase mData;
|
||||
|
||||
@ -37,11 +43,12 @@ public class AppDatabase extends SQLiteOpenHelper
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(uQuery);
|
||||
db.execSQL(tQuery);
|
||||
db.execSQL(trQuery);
|
||||
db.execSQL(hQuery);
|
||||
db.execSQL(fQuery);
|
||||
db.execSQL(userTable);
|
||||
db.execSQL(tweetTable);
|
||||
db.execSQL(trendTable);
|
||||
db.execSQL(timelineTable);
|
||||
db.execSQL(favoriteTable);
|
||||
db.execSQL(retweetTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,6 +57,7 @@ public class AppDatabase extends SQLiteOpenHelper
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "tweet");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "favorit");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "timeline");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "retweet");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + "trend");
|
||||
onCreate(db);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ public class TweetDatabase {
|
||||
public static final int GET_MENT = 4;
|
||||
|
||||
private AppDatabase dataHelper;
|
||||
private List<String> user,scrname,tweet,pbLink,retweeter;
|
||||
private List<Long> userId,tweetId,timeMillis;
|
||||
private List<String> user,scrname,tweet,pbLink;
|
||||
private List<Long> userId,tweetId,timeMillis, retweetId;
|
||||
private List<Integer> noRT,noFav, verify;
|
||||
private boolean toggleImg;
|
||||
private int limit;
|
||||
@ -109,12 +109,10 @@ 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);
|
||||
tweet.put("retweeter","\t");
|
||||
}
|
||||
|
||||
user.put("userID",usr.getId());
|
||||
@ -135,7 +133,7 @@ public class TweetDatabase {
|
||||
|
||||
home.put("tweetID", stat.getId());
|
||||
fav.put("tweetID", stat.getId());
|
||||
fav.put("ownerID", CurrentId);
|
||||
fav.put("userID", CurrentId);
|
||||
|
||||
ment.put("mTweetID",stat.getId());
|
||||
|
||||
@ -173,14 +171,14 @@ public class TweetDatabase {
|
||||
}
|
||||
|
||||
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";
|
||||
SQL_GET_HOME = "SELECT * FROM user " +
|
||||
"INNER JOIN tweet ON tweet.userID = user.userID"+
|
||||
" WHERE user.userID = "+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";
|
||||
"INNER JOIN user ON tweet.userID = user.userID " +
|
||||
"WHERE favorit.userID = "+CurrentId+" ORDER BY tweetID DESC";
|
||||
}
|
||||
|
||||
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
|
||||
@ -207,8 +205,8 @@ public class TweetDatabase {
|
||||
userId.add(cursor.getLong(index));
|
||||
index = cursor.getColumnIndex("tweetID");
|
||||
tweetId.add(cursor.getLong(index));
|
||||
index = cursor.getColumnIndex("retweeter");
|
||||
retweeter.add(cursor.getString(index));
|
||||
// index = cursor.getColumnIndex("retweetID");
|
||||
//retweetId.add(cursor.getLong(index));
|
||||
size++;
|
||||
} while(cursor.moveToNext() && size < limit);
|
||||
}
|
||||
@ -231,10 +229,6 @@ public class TweetDatabase {
|
||||
public String getPbLink(int pos){return pbLink.get(pos);}
|
||||
public boolean loadImages(){return toggleImg;}
|
||||
public boolean isVerified(int pos){return verify.get(pos) == 1;}
|
||||
public String getRetweeter(int pos) {
|
||||
if(retweeter.get(pos).trim().isEmpty()) return "";
|
||||
else return " RT @"+retweeter.get(pos);
|
||||
}
|
||||
|
||||
public SpannableStringBuilder getHighlightedTweet(Context c, int pos) {
|
||||
String tweet = getTweet(pos);
|
||||
@ -322,11 +316,8 @@ public class TweetDatabase {
|
||||
User usr = stat.getUser();
|
||||
tweetId.add(stat.getId());
|
||||
if(rtStat != null) {
|
||||
retweeter.add(usr.getScreenName());
|
||||
stat = rtStat;
|
||||
usr = rtStat.getUser();
|
||||
} else {
|
||||
retweeter.add("\0");
|
||||
}
|
||||
user.add(usr.getName());
|
||||
scrname.add('@'+usr.getScreenName());
|
||||
@ -348,11 +339,9 @@ public class TweetDatabase {
|
||||
User usr = stat.getUser();
|
||||
tweetId.add(0,stat.getId());
|
||||
if(rtStat != null) {
|
||||
retweeter.add(usr.getScreenName());
|
||||
// retweetId.add(usr.getScreenName());
|
||||
stat = rtStat;
|
||||
usr = rtStat.getUser();
|
||||
} else {
|
||||
retweeter.add(0,"\0");
|
||||
}
|
||||
user.add(0,usr.getName());
|
||||
scrname.add(0,'@'+usr.getScreenName());
|
||||
@ -377,7 +366,7 @@ public class TweetDatabase {
|
||||
pbLink = new ArrayList<>();
|
||||
tweetId = new ArrayList<>();
|
||||
verify = new ArrayList<>();
|
||||
retweeter = new ArrayList<>();
|
||||
retweetId = new ArrayList<>();
|
||||
timeMillis = new ArrayList<>();
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ import com.squareup.picasso.Picasso;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.database.TweetDatabase;
|
||||
|
||||
|
||||
public class TimelineRecycler extends Adapter<TimelineRecycler.ItemHolder> implements View.OnClickListener {
|
||||
|
||||
private TweetDatabase mTweets;
|
||||
@ -70,7 +69,6 @@ public class TimelineRecycler extends Adapter<TimelineRecycler.ItemHolder> imple
|
||||
vh.tweet.setText(mTweets.getHighlightedTweet(parent.getContext(),index));
|
||||
vh.retweet.setText(Integer.toString(mTweets.getRetweet(index)));
|
||||
vh.favorite.setText(Integer.toString(mTweets.getFavorite(index)));
|
||||
vh.retweeter.setText(mTweets.getRetweeter(index));
|
||||
vh.time.setText(mTweets.getDate(index));
|
||||
if(mTweets.loadImages()) {
|
||||
Picasso.with(parent.getContext()).load(mTweets.getPbLink(index)).into(vh.profile);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.nuclearfog.twidda.window;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@ -10,8 +12,6 @@ import com.flask.colorpicker.ColorPickerView;
|
||||
import com.flask.colorpicker.OnColorChangedListener;
|
||||
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
|
||||
public class ColorPreferences implements OnColorChangedListener, DialogInterface.OnDismissListener {
|
||||
|
||||
public static final int BACKGROUND = 0x0;
|
||||
@ -28,6 +28,7 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
|
||||
private static ColorPreferences ourInstance;
|
||||
private SharedPreferences settings;
|
||||
private Context context;
|
||||
private Dialog d;
|
||||
|
||||
private ColorPreferences(Context context) {
|
||||
settings = context.getSharedPreferences("settings", 0);
|
||||
@ -65,6 +66,7 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
|
||||
colorButton2.setBackgroundColor(font);
|
||||
colorButton3.setBackgroundColor(tweet);
|
||||
colorButton4.setBackgroundColor(highlight);
|
||||
d.dismiss();
|
||||
}
|
||||
|
||||
public int getColor(final int Mode){
|
||||
@ -101,7 +103,7 @@ public class ColorPreferences implements OnColorChangedListener, DialogInterface
|
||||
default:
|
||||
preColor = 0xFFFFFFFF;
|
||||
}
|
||||
Dialog d = ColorPickerDialogBuilder.with(context)
|
||||
d = ColorPickerDialogBuilder.with(context)
|
||||
.showAlphaSlider(false).initialColor(preColor)
|
||||
.wheelType(ColorPickerView.WHEEL_TYPE.CIRCLE).density(20)
|
||||
.setOnColorChangedListener(this).build();
|
||||
|
@ -76,7 +76,8 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mStat.cancel(true);
|
||||
mReply.cancel(true);
|
||||
if(mReply != null)
|
||||
mReply.cancel(true);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||
public class TweetPopup extends AppCompatActivity implements View.OnClickListener,
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
private StatusUpload sendTweet;
|
||||
private EditText tweetfield;
|
||||
private Button imageButton, previewBtn;
|
||||
private TextView imgcount;
|
||||
@ -60,7 +61,6 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
||||
previewBtn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
showClosingMsg();
|
||||
@ -80,6 +80,8 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
||||
super.onActivityResult(reqCode,returnCode,i);
|
||||
if(returnCode == RESULT_OK){
|
||||
String[] mode = {MediaStore.Images.Media.DATA};
|
||||
if(i.getData() == null)
|
||||
return;
|
||||
Cursor c = getContentResolver().query(i.getData(),mode,null,null,null);
|
||||
if(c != null && c.moveToFirst()) {
|
||||
if(imgIndex == 0) {
|
||||
@ -103,6 +105,8 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
||||
public void onClick(DialogInterface d, int id) {
|
||||
switch(id) {
|
||||
case BUTTON_POSITIVE:
|
||||
if(sendTweet != null)
|
||||
sendTweet.cancel(true);
|
||||
finish();
|
||||
break;
|
||||
case BUTTON_NEGATIVE:
|
||||
@ -145,15 +149,12 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
||||
String tweet = tweetfield.getText().toString();
|
||||
String[] paths = new String[mediaPath.size()];
|
||||
paths = mediaPath.toArray(paths);
|
||||
StatusUpload sendTweet;
|
||||
sendTweet = new StatusUpload(getApplicationContext(),paths);
|
||||
|
||||
sendTweet = new StatusUpload(this ,paths);
|
||||
if(inReplyId > 0) {
|
||||
sendTweet.execute(tweet, inReplyId);
|
||||
} else {
|
||||
sendTweet.execute(tweet);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantCondidions")
|
||||
|
@ -16,6 +16,7 @@ import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.StatusLoader;
|
||||
import org.nuclearfog.twidda.database.TweetDatabase;
|
||||
import org.nuclearfog.twidda.backend.ProfileLoader;
|
||||
import org.nuclearfog.twidda.viewadapter.TimelineRecycler;
|
||||
@ -26,7 +27,7 @@ import org.nuclearfog.twidda.viewadapter.TimelineRecycler;
|
||||
*/
|
||||
public class UserProfile extends AppCompatActivity implements View.OnClickListener,
|
||||
SwipeRefreshLayout.OnRefreshListener, TabHost.OnTabChangeListener,
|
||||
TimelineRecycler.OnItemClicked {
|
||||
TimelineRecycler.OnItemClicked, ProfileLoader.OnProfileFinished {
|
||||
|
||||
private ProfileLoader mProfile, mTweets, mFavorits;
|
||||
private SwipeRefreshLayout homeReload, favoriteReload;
|
||||
@ -65,19 +66,15 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
favoriteReload.setOnRefreshListener(this);
|
||||
|
||||
initElements();
|
||||
getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
public void onBackPressed() {
|
||||
mProfile.cancel(true);
|
||||
mTweets.cancel(true);
|
||||
mFavorits.cancel(true);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed(){
|
||||
if(mTweets != null)
|
||||
mTweets.cancel(true);
|
||||
if(mFavorits != null)
|
||||
mFavorits.cancel(true);
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@ -195,7 +192,8 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
/**
|
||||
* Tab Content
|
||||
*/
|
||||
private void getContent() {
|
||||
@Override
|
||||
public void onLoaded() {
|
||||
new Thread( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -34,8 +34,7 @@
|
||||
android:id="@+id/banner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/banner"
|
||||
app:srcCompat="@android:color/holo_red_dark" />
|
||||
android:contentDescription="@string/banner" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -8,17 +8,30 @@
|
||||
android:background="@color/tweetwindow"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tweet_input"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:layout_marginRight="5dip"
|
||||
android:layout_marginTop="5dip"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
android:labelFor="@id/tweet_input" />
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tweet_input"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:layout_marginRight="5dip"
|
||||
android:layout_marginTop="5dip"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
android:labelFor="@id/tweet_input" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/tweet_sending"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="invisible" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -4,9 +4,7 @@
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/soylentgreen</item>
|
||||
<item name="android:windowAnimationStyle">@style/TransactionPending</item>
|
||||
<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">
|
||||
|
Loading…
x
Reference in New Issue
Block a user