mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-03 12:37:33 +01:00
Bugfix
Major Cleanup
This commit is contained in:
parent
6296179746
commit
3f82373613
@ -351,9 +351,13 @@ public class MainActivity extends AppCompatActivity implements
|
||||
TrendDatabase trendDeck = new TrendDatabase(con);
|
||||
trendRc = new TrendRecycler(trendDeck, MainActivity.this);
|
||||
}
|
||||
|
||||
boolean imageload = settings.getBoolean("image_load", true);
|
||||
rlRc.setColor(highlight,font_color);
|
||||
trendRc.setColor(background,font_color);
|
||||
mentRc.setColor(highlight,font_color);
|
||||
rlRc.toggleImage(imageload);
|
||||
mentRc.toggleImage(imageload);
|
||||
timelineList.setAdapter(rlRc);
|
||||
trendList.setAdapter(trendRc);
|
||||
mentionList.setAdapter(mentRc);
|
||||
|
@ -111,6 +111,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
}
|
||||
homeTl = new TimelineRecycler(tweets,ui.get());
|
||||
homeTl.setColor(highlight,font);
|
||||
homeTl.toggleImage(imgEnabled);
|
||||
}
|
||||
else if(MODE == GET_FAVS)
|
||||
{
|
||||
@ -128,6 +129,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||
}
|
||||
homeFav = new TimelineRecycler(favorits,ui.get());
|
||||
homeFav.setColor(highlight,font);
|
||||
homeFav.toggleImage(imgEnabled);
|
||||
}
|
||||
else if(MODE == ACTION_FOLLOW)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@ -32,6 +33,7 @@ import org.nuclearfog.twidda.viewadapter.TimelineRecycler;
|
||||
import org.nuclearfog.twidda.window.ColorPreferences;
|
||||
import org.nuclearfog.twidda.window.TweetDetail;
|
||||
import org.nuclearfog.twidda.backend.listitems.*;
|
||||
import org.nuclearfog.twidda.window.UserProfile;
|
||||
|
||||
public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
|
||||
@ -52,7 +54,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
private String errMSG = "";
|
||||
private boolean retweeted, favorited, toggleImg, verified;
|
||||
private boolean rtFlag = false;
|
||||
private long userReply, tweetReplyID;
|
||||
private long tweetReplyID, userID;
|
||||
private int rt, fav;
|
||||
private int highlight, font;
|
||||
|
||||
@ -97,6 +99,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
verified = tweet.verified;
|
||||
tweetStr = tweet.tweet;
|
||||
usernameStr = tweet.username;
|
||||
userID = tweet.userID;
|
||||
scrNameStr = '@'+tweet.screenname;
|
||||
apiName = formatString(tweet.source);
|
||||
dateString = DateFormat.getDateTimeInstance().format(new Date(tweet.time));
|
||||
@ -154,9 +157,8 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
int err = e.getErrorCode();
|
||||
if(err == 144) { // gelöscht
|
||||
TweetDatabase.removeStatus(ui.get(),tweetID);
|
||||
errMSG = e.getMessage();
|
||||
}
|
||||
e.printStackTrace();
|
||||
errMSG = e.getMessage();
|
||||
return ERROR;
|
||||
} catch(Exception err) {
|
||||
errMSG = err.getMessage();
|
||||
@ -171,7 +173,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
if(connect == null)
|
||||
return;
|
||||
final Context c = connect;
|
||||
|
||||
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);
|
||||
@ -230,11 +231,21 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(c, TweetDetail.class);
|
||||
intent.putExtra("tweetID",tweetReplyID);
|
||||
intent.putExtra("userID",userReply);
|
||||
intent.putExtra("username", repliedUsername);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
});
|
||||
profile_img.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(ui.get(), UserProfile.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("userID",userID);
|
||||
b.putString("username", usernameStr);
|
||||
intent.putExtras(b);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(mode == RETWEET) {
|
||||
String rtStr = Integer.toString(rt);
|
||||
|
@ -446,7 +446,7 @@ public class TwitterEngine {
|
||||
Tweet embeddedStat = getStatus(tweetID).embedded;
|
||||
if(embeddedStat != null)
|
||||
tweetID = embeddedStat.tweetID;
|
||||
long[] userIds = twitter.getRetweeterIds(tweetID,load).getIDs();
|
||||
long[] userIds = twitter.getRetweeterIds(tweetID,load,cursor).getIDs();
|
||||
if(userIds.length == 0) {
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -27,6 +28,7 @@ public class TwitterSearch extends AsyncTask<String, Void, Void> {
|
||||
private WeakReference<SearchPage> ui;
|
||||
private int background, highlight, font_color;
|
||||
private String error;
|
||||
boolean imageload;
|
||||
|
||||
public TwitterSearch(Context context) {
|
||||
ui = new WeakReference<>((SearchPage)context);
|
||||
@ -37,6 +39,8 @@ public class TwitterSearch extends AsyncTask<String, Void, Void> {
|
||||
background = mcolor.getColor(ColorPreferences.BACKGROUND);
|
||||
highlight = mcolor.getColor(ColorPreferences.HIGHLIGHTING);
|
||||
font_color = mcolor.getColor(ColorPreferences.FONT_COLOR);
|
||||
SharedPreferences settings = ui.get().getSharedPreferences("settings", 0);
|
||||
imageload = settings.getBoolean("image_load", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,7 +67,8 @@ public class TwitterSearch extends AsyncTask<String, Void, Void> {
|
||||
}
|
||||
|
||||
tlRc.setColor(highlight,font_color);
|
||||
uAdp.setColor(background,font_color);
|
||||
tlRc.toggleImage(imageload);
|
||||
uAdp.toggleImage(imageload);
|
||||
|
||||
} catch(Exception err) {
|
||||
error = err.getMessage();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
@ -9,6 +10,7 @@ import android.widget.Toast;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.viewadapter.UserRecycler;
|
||||
import org.nuclearfog.twidda.window.ColorPreferences;
|
||||
import org.nuclearfog.twidda.window.UserDetail;
|
||||
import org.nuclearfog.twidda.backend.listitems.*;
|
||||
|
||||
@ -28,6 +30,8 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
private RecyclerView userList;
|
||||
private ProgressBar uProgress;
|
||||
private String errmsg;
|
||||
private boolean imageload;
|
||||
|
||||
|
||||
/**
|
||||
*@see UserDetail
|
||||
@ -37,6 +41,8 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
userList = (RecyclerView) ui.get().findViewById(R.id.userlist);
|
||||
uProgress = (ProgressBar) ui.get().findViewById(R.id.user_progress);
|
||||
SharedPreferences settings = context.getSharedPreferences("settings", 0);
|
||||
imageload = settings.getBoolean("image_load", true);
|
||||
}
|
||||
|
||||
|
||||
@ -60,9 +66,7 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
|
||||
List<TwitterUser> user = mTwitter.getRetweeter(id,cursor);
|
||||
usrAdp = new UserRecycler(user,ui.get());
|
||||
}
|
||||
/*else if(mode == FAVORISER) {
|
||||
// GET FAV USERS TODO
|
||||
}*/
|
||||
usrAdp.toggleImage(imageload);
|
||||
}
|
||||
catch(Exception err) {
|
||||
errmsg = "Fehler: "+err.getMessage();
|
||||
|
@ -73,7 +73,6 @@ public class TweetDatabase {
|
||||
"INNER JOIN tweet ON timeline.mTweetID = tweet.tweetID " +
|
||||
"INNER JOIN user ON tweet.userID=user.userID ORDER BY tweetID ASC";
|
||||
}
|
||||
|
||||
else if(mode == TWEET) {
|
||||
SQL_GET_HOME = "SELECT * FROM user " +
|
||||
"INNER JOIN tweet ON tweet.userID = user.userID"+
|
||||
@ -88,9 +87,6 @@ public class TweetDatabase {
|
||||
if(cursor.moveToFirst()) {
|
||||
do {
|
||||
Tweet tweet = getTweet(cursor);
|
||||
/* if(tweet.embedded != null)
|
||||
tweetlist.add(tweet.embedded);
|
||||
else*/
|
||||
tweetlist.add(tweet);
|
||||
} while(cursor.moveToNext());
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class TimelineRecycler extends Adapter<TimelineRecycler.ItemHolder> imple
|
||||
private List<Tweet> tweets;
|
||||
private int highlight = 0xFFFFFFFF;
|
||||
private int font_color = 0xFFFFFFFF;
|
||||
private boolean img_ldr = true;
|
||||
|
||||
/**
|
||||
* @param mListener Item Click Listener
|
||||
@ -43,6 +44,10 @@ public class TimelineRecycler extends Adapter<TimelineRecycler.ItemHolder> imple
|
||||
this.font_color = font_color;
|
||||
}
|
||||
|
||||
public void toggleImage(boolean image_load) {
|
||||
img_ldr = image_load;
|
||||
}
|
||||
|
||||
|
||||
public List<Tweet> getData() {
|
||||
return tweets;
|
||||
@ -82,7 +87,7 @@ public class TimelineRecycler extends Adapter<TimelineRecycler.ItemHolder> imple
|
||||
vh.retweet.setText(retweet);
|
||||
vh.favorite.setText(favorit);
|
||||
vh.time.setText(stringTime(tweet.time));
|
||||
if(tweet.profileImg != null) {
|
||||
if(img_ldr) {
|
||||
Picasso.with(parent.getContext()).load(tweet.profileImg).into(vh.profile);
|
||||
}
|
||||
if(tweet.verified) {
|
||||
|
@ -18,8 +18,7 @@ public class UserRecycler extends RecyclerView.Adapter<UserRecycler.ItemHolder>
|
||||
private List<TwitterUser> mUser;
|
||||
private OnItemClicked mListener;
|
||||
private ViewGroup parent;
|
||||
private int background = 0x00000000;
|
||||
private int font_color = 0xFFFFFFFF;
|
||||
private boolean loadImage = true;
|
||||
|
||||
public UserRecycler(List<TwitterUser> mUser, OnItemClicked mListener) {
|
||||
this.mListener = mListener;
|
||||
@ -30,9 +29,8 @@ public class UserRecycler extends RecyclerView.Adapter<UserRecycler.ItemHolder>
|
||||
public List<TwitterUser> getData(){return mUser; }
|
||||
|
||||
|
||||
public void setColor(int background, int font_color) {
|
||||
this.background = background;
|
||||
this.font_color = font_color;
|
||||
public void toggleImage(boolean image) {
|
||||
loadImage = image;
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +50,6 @@ public class UserRecycler extends RecyclerView.Adapter<UserRecycler.ItemHolder>
|
||||
public ItemHolder onCreateViewHolder(ViewGroup parent, int index) {
|
||||
this.parent = parent;
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.useritem, parent,false);
|
||||
v.setBackgroundColor(background);
|
||||
v.setOnClickListener(this);
|
||||
return new ItemHolder(v);
|
||||
}
|
||||
@ -63,7 +60,7 @@ public class UserRecycler extends RecyclerView.Adapter<UserRecycler.ItemHolder>
|
||||
TwitterUser user = mUser.get(index);
|
||||
vh.screenname.setText(user.screenname);
|
||||
vh.username.setText(user.username);
|
||||
if(user.profileImg != null) {
|
||||
if(loadImage) {
|
||||
Picasso.with(parent.getContext()).load(user.profileImg).into(vh.profileImg);
|
||||
}
|
||||
if(user.isVerified) {
|
||||
|
@ -165,7 +165,7 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton b, boolean checked) {
|
||||
imgEnabled = true;
|
||||
imgEnabled = checked;
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
|
@ -50,7 +50,6 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
Button retweet = (Button) findViewById(R.id.rt_button_detail);
|
||||
Button favorite = (Button) findViewById(R.id.fav_button_detail);
|
||||
Button delete = (Button) findViewById(R.id.delete);
|
||||
ImageView pb =(ImageView) findViewById(R.id.profileimage_detail);
|
||||
SwipeRefreshLayout answerReload = (SwipeRefreshLayout) findViewById(R.id.answer_reload);
|
||||
TextView txtRt = (TextView) findViewById(R.id.no_rt_detail);
|
||||
TextView txtFav = (TextView) findViewById(R.id.no_fav_detail);
|
||||
@ -67,7 +66,6 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
txtRt.setOnClickListener(this);
|
||||
date.setOnClickListener(this);
|
||||
delete.setOnClickListener(this);
|
||||
pb.setOnClickListener(this);
|
||||
setContent();
|
||||
}
|
||||
|
||||
@ -128,14 +126,6 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
alerta.setNegativeButton(R.string.no_confirm, this);
|
||||
alerta.show();
|
||||
break;
|
||||
case R.id.profileimage_detail:
|
||||
intent = new Intent(getApplicationContext(), UserProfile.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("userID",userID);
|
||||
b.putString("username", username);
|
||||
intent.putExtras(b);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.timedetail:
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
String tweetlink = "https://twitter.com/"+username+"/status/"+tweetID;
|
||||
|
@ -37,6 +37,8 @@ public class UserDetail extends AppCompatActivity implements UserRecycler.OnItem
|
||||
userListview.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.user_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
int background = ColorPreferences.getInstance(this).getColor(ColorPreferences.BACKGROUND);
|
||||
userListview.setBackgroundColor(background);
|
||||
getUsers();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
private SwipeRefreshLayout homeReload, favoriteReload;
|
||||
private RecyclerView homeTweets, homeFavorits;
|
||||
private long userId;
|
||||
private boolean home;
|
||||
private boolean home, imageload;
|
||||
private String username = "";
|
||||
private String currentTab = "tweets";
|
||||
|
||||
@ -51,6 +51,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
|
||||
SharedPreferences settings = getSharedPreferences("settings", 0);
|
||||
home = userId == settings.getLong("userID", -1);
|
||||
imageload = settings.getBoolean("image_load", true);
|
||||
homeTweets = (RecyclerView) findViewById(R.id.ht_list);
|
||||
homeFavorits = (RecyclerView)findViewById(R.id.hf_list);
|
||||
homeTweets.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
@ -181,12 +182,10 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
|
||||
private void setTabs(TabHost mTab) {
|
||||
mTab.setup();
|
||||
// Tab #1
|
||||
TabHost.TabSpec tab1 = mTab.newTabSpec("tweets");
|
||||
tab1.setContent(R.id.hometweets);
|
||||
tab1.setIndicator("",getResources().getDrawable(R.drawable.home));
|
||||
mTab.addTab(tab1);
|
||||
// Tab #2
|
||||
TabHost.TabSpec tab2 = mTab.newTabSpec("favorites");
|
||||
tab2.setContent(R.id.homefavorits);
|
||||
tab2.setIndicator("",getResources().getDrawable(R.drawable.favorite));
|
||||
@ -202,6 +201,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
@Override
|
||||
public void run() {
|
||||
ColorPreferences mcolor = ColorPreferences.getInstance(getApplicationContext());
|
||||
|
||||
int highlight = mcolor.getColor(ColorPreferences.HIGHLIGHTING);
|
||||
int background = mcolor.getColor(ColorPreferences.BACKGROUND);
|
||||
int font_color = mcolor.getColor(ColorPreferences.FONT_COLOR);
|
||||
@ -215,9 +215,11 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
mFavorits = new ProfileLoader(UserProfile.this);
|
||||
homeTweets.setBackgroundColor(background);
|
||||
homeFavorits.setBackgroundColor(background);
|
||||
|
||||
if( userTweets.size() > 0 ) {
|
||||
TimelineRecycler tlRc = new TimelineRecycler(userTweets,UserProfile.this);
|
||||
tlRc.setColor(highlight,font_color);
|
||||
tlRc.toggleImage(imageload);
|
||||
homeTweets.setAdapter(tlRc);
|
||||
} else {
|
||||
mTweets.execute(userId, ProfileLoader.GET_TWEETS,1L);
|
||||
@ -225,6 +227,7 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
if( userFavorit.size() > 0 ) {
|
||||
TimelineRecycler tlRc = new TimelineRecycler(userFavorit,UserProfile.this);
|
||||
tlRc.setColor(highlight,font_color);
|
||||
tlRc.toggleImage(imageload);
|
||||
homeFavorits.setAdapter(tlRc);
|
||||
} else {
|
||||
mFavorits.execute(userId, ProfileLoader.GET_FAVS,1L);
|
||||
|
Loading…
x
Reference in New Issue
Block a user