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