cleanup
This commit is contained in:
parent
f172153585
commit
caee4813fe
|
@ -21,7 +21,6 @@ import android.widget.TabHost.TabSpec;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.backend.GlobalSettings;
|
import org.nuclearfog.twidda.backend.GlobalSettings;
|
||||||
import org.nuclearfog.twidda.backend.MainPage;
|
import org.nuclearfog.twidda.backend.MainPage;
|
||||||
import org.nuclearfog.twidda.backend.TwitterEngine;
|
|
||||||
import org.nuclearfog.twidda.backend.listitems.Tweet;
|
import org.nuclearfog.twidda.backend.listitems.Tweet;
|
||||||
import org.nuclearfog.twidda.viewadapter.TimelineRecycler;
|
import org.nuclearfog.twidda.viewadapter.TimelineRecycler;
|
||||||
import org.nuclearfog.twidda.viewadapter.TrendRecycler;
|
import org.nuclearfog.twidda.viewadapter.TrendRecycler;
|
||||||
|
@ -53,9 +52,9 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.mainpage);
|
setContentView(R.layout.mainpage);
|
||||||
TwitterEngine mTwitter = TwitterEngine.getInstance(this);
|
|
||||||
settings = GlobalSettings.getInstance(this);
|
settings = GlobalSettings.getInstance(this);
|
||||||
boolean login = mTwitter.loggedIn();
|
boolean login = settings.getLogin();
|
||||||
|
|
||||||
if( !login ) {
|
if( !login ) {
|
||||||
Intent i = new Intent(this, LoginPage.class);
|
Intent i = new Intent(this, LoginPage.class);
|
||||||
|
@ -128,9 +127,7 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String s) {
|
public boolean onQueryTextSubmit(String s) {
|
||||||
Intent intent = new Intent(getApplicationContext(), SearchPage.class);
|
Intent intent = new Intent(getApplicationContext(), SearchPage.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("search", s);
|
||||||
bundle.putString("search", s);
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -148,18 +145,14 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
switch(item.getItemId()) {
|
switch(item.getItemId()) {
|
||||||
case R.id.action_profile:
|
case R.id.action_profile:
|
||||||
intent = new Intent(this, UserProfile.class);
|
intent = new Intent(this, UserProfile.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("userID", homeId);
|
||||||
bundle.putLong("userID",homeId);
|
intent.putExtra("username", "");
|
||||||
bundle.putString("username", "");
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_tweet:
|
case R.id.action_tweet:
|
||||||
intent = new Intent(this, TweetPopup.class);
|
intent = new Intent(this, TweetPopup.class);
|
||||||
Bundle b = new Bundle();
|
intent.putExtra("TweetID", -1);
|
||||||
b.putLong("TweetID", -1);
|
|
||||||
intent.putExtras(b);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -168,8 +161,10 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
intent = new Intent(this, AppSettings.class);
|
intent = new Intent(this, AppSettings.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -238,12 +233,14 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
tweet.setVisible(true);
|
tweet.setVisible(true);
|
||||||
setting.setVisible(false);
|
setting.setVisible(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "trends":
|
case "trends":
|
||||||
profile.setVisible(false);
|
profile.setVisible(false);
|
||||||
search.setVisible(true);
|
search.setVisible(true);
|
||||||
tweet.setVisible(false);
|
tweet.setVisible(false);
|
||||||
setting.setVisible(true);
|
setting.setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "mention":
|
case "mention":
|
||||||
searchQuery.onActionViewCollapsed();
|
searchQuery.onActionViewCollapsed();
|
||||||
profile.setVisible(false);
|
profile.setVisible(false);
|
||||||
|
@ -261,54 +258,46 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
if(!timelineReload.isRefreshing()) {
|
if(!timelineReload.isRefreshing()) {
|
||||||
TimelineRecycler tlAdp = (TimelineRecycler) timelineList.getAdapter();
|
TimelineRecycler tlAdp = (TimelineRecycler) timelineList.getAdapter();
|
||||||
Tweet tweet = tlAdp.getData().get(position);
|
Tweet tweet = tlAdp.getData().get(position);
|
||||||
|
|
||||||
Intent intent = new Intent(this,TweetDetail.class);
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
|
|
||||||
if(tweet.embedded != null) {
|
if(tweet.embedded != null) {
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.embedded;
|
||||||
}
|
}
|
||||||
bundle.putLong("tweetID",tweet.tweetID);
|
|
||||||
bundle.putLong("userID",tweet.user.userID);
|
|
||||||
bundle.putString("username", tweet.user.screenname);
|
|
||||||
|
|
||||||
intent.putExtras(bundle);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
|
intent.putExtra("tweetID", tweet.tweetID);
|
||||||
|
intent.putExtra("userID", tweet.user.userID);
|
||||||
|
intent.putExtra("username", tweet.user.screenname);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tr_list:
|
case R.id.tr_list:
|
||||||
if(!trendReload.isRefreshing()) {
|
if(!trendReload.isRefreshing()) {
|
||||||
TrendRecycler trend = (TrendRecycler) trendList.getAdapter();
|
TrendRecycler trend = (TrendRecycler) trendList.getAdapter();
|
||||||
String search = trend.getData().get(position).trend;
|
String search = trend.getData().get(position).trend;
|
||||||
Intent intent = new Intent(this, SearchPage.class);
|
Intent intent = new Intent(this, SearchPage.class);
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
if(search.startsWith("#")) {
|
if(search.startsWith("#")) {
|
||||||
bundle.putString("Addition", search);
|
intent.putExtra("Addition", search);
|
||||||
bundle.putString("search", search);
|
intent.putExtra("search", search);
|
||||||
} else {
|
} else {
|
||||||
search = '\"'+ search + '\"';
|
search = '\"'+ search + '\"';
|
||||||
bundle.putString("search", search);
|
intent.putExtra("search", search);
|
||||||
}
|
}
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.m_list:
|
case R.id.m_list:
|
||||||
if(!mentionReload.isRefreshing()) {
|
if(!mentionReload.isRefreshing()) {
|
||||||
TimelineRecycler tlAdp = (TimelineRecycler) mentionList.getAdapter();
|
TimelineRecycler tlAdp = (TimelineRecycler) mentionList.getAdapter();
|
||||||
Tweet tweet = tlAdp.getData().get(position);
|
Tweet tweet = tlAdp.getData().get(position);
|
||||||
|
|
||||||
Intent intent = new Intent(this,TweetDetail.class);
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
|
|
||||||
if(tweet.embedded != null) {
|
if(tweet.embedded != null) {
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.embedded;
|
||||||
}
|
}
|
||||||
bundle.putLong("tweetID",tweet.tweetID);
|
|
||||||
bundle.putLong("userID",tweet.user.userID);
|
|
||||||
bundle.putString("username", tweet.user.screenname);
|
|
||||||
|
|
||||||
intent.putExtras(bundle);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
|
intent.putExtra("tweetID", tweet.tweetID);
|
||||||
|
intent.putExtra("userID", tweet.user.userID);
|
||||||
|
intent.putExtra("username", tweet.user.screenname);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -325,27 +314,27 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
trendList.setBackgroundColor(background);
|
trendList.setBackgroundColor(background);
|
||||||
mentionList.setBackgroundColor(background);
|
mentionList.setBackgroundColor(background);
|
||||||
|
|
||||||
TimelineRecycler homeRc = (TimelineRecycler) timelineList.getAdapter();
|
TimelineRecycler hAdapter = (TimelineRecycler) timelineList.getAdapter();
|
||||||
TrendRecycler trendRc = (TrendRecycler) trendList.getAdapter();
|
TrendRecycler tAdapter = (TrendRecycler) trendList.getAdapter();
|
||||||
TimelineRecycler mentRc = (TimelineRecycler) mentionList.getAdapter();
|
TimelineRecycler mAdapter = (TimelineRecycler) mentionList.getAdapter();
|
||||||
|
|
||||||
if(homeRc == null || homeRc.getItemCount() == 0) {
|
if (hAdapter == null || hAdapter.getItemCount() == 0) {
|
||||||
new MainPage(this).execute(MainPage.H_LOAD,1);
|
new MainPage(this).execute(MainPage.H_LOAD,1);
|
||||||
} else {
|
} else {
|
||||||
homeRc.setColor(highlight,fontColor);
|
hAdapter.setColor(highlight, fontColor);
|
||||||
homeRc.notifyDataSetChanged();
|
hAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
if(mentRc == null || mentRc.getItemCount() == 0) {
|
if (tAdapter == null || tAdapter.getItemCount() == 0) {
|
||||||
new MainPage(this).execute(MainPage.M_LOAD,1);
|
|
||||||
} else {
|
|
||||||
mentRc.setColor(highlight,fontColor);
|
|
||||||
mentRc.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
if(trendRc == null || trendRc.getItemCount() == 0) {
|
|
||||||
new MainPage(this).execute(MainPage.T_LOAD,1);
|
new MainPage(this).execute(MainPage.T_LOAD,1);
|
||||||
} else {
|
} else {
|
||||||
trendRc.setColor(fontColor);
|
tAdapter.setColor(fontColor);
|
||||||
trendRc.notifyDataSetChanged();
|
tAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
if (mAdapter == null || mAdapter.getItemCount() == 0) {
|
||||||
|
new MainPage(this).execute(MainPage.M_LOAD, 1);
|
||||||
|
} else {
|
||||||
|
mAdapter.setColor(highlight, fontColor);
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
lastTab = tabhost.getCurrentView();
|
lastTab = tabhost.getCurrentView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||||
private int highlight, font;
|
private int highlight, font;
|
||||||
private boolean image;
|
private boolean image;
|
||||||
private String errMsg = "E: Main Page, ";
|
private String errMsg = "E: Main Page, ";
|
||||||
private int retryAfter = 0;
|
private int returnCode = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main View
|
* Main View
|
||||||
|
@ -158,10 +158,8 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch(TwitterException e) {
|
} catch(TwitterException e) {
|
||||||
int errCode = e.getErrorCode();
|
returnCode = e.getErrorCode();
|
||||||
if(errCode == 420) {
|
if (returnCode != 420) {
|
||||||
retryAfter = e.getRetryAfter();
|
|
||||||
} else {
|
|
||||||
errMsg += e.getMessage();
|
errMsg += e.getMessage();
|
||||||
}
|
}
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -203,7 +201,7 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAIL:
|
case FAIL:
|
||||||
if (retryAfter > 0) {
|
if (returnCode == 420) {
|
||||||
Toast.makeText(connect, R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
|
Toast.makeText(connect, R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(connect, errMsg, Toast.LENGTH_LONG).show();
|
Toast.makeText(connect, errMsg, Toast.LENGTH_LONG).show();
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||||
private boolean isLocked = false;
|
private boolean isLocked = false;
|
||||||
private boolean blocked = false;
|
private boolean blocked = false;
|
||||||
private String errMsg = "E: Profile Load, ";
|
private String errMsg = "E: Profile Load, ";
|
||||||
private int retryAfter = 0;
|
private int returnCode = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param context Context to Activity
|
* @param context Context to Activity
|
||||||
|
@ -186,11 +186,9 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (TwitterException err) {
|
} catch (TwitterException err) {
|
||||||
int errCode = err.getErrorCode();
|
returnCode = err.getErrorCode();
|
||||||
if(errCode == 420) {
|
|
||||||
retryAfter = err.getRetryAfter();
|
if (returnCode != 136) {
|
||||||
}
|
|
||||||
else if(errCode != 136) {
|
|
||||||
errMsg += err.getMessage();
|
errMsg += err.getMessage();
|
||||||
errorLog.add(errMsg);
|
errorLog.add(errMsg);
|
||||||
}
|
}
|
||||||
|
@ -285,12 +283,14 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||||
else if(mode == FAILURE)
|
else if(mode == FAILURE)
|
||||||
{
|
{
|
||||||
SwipeRefreshLayout tweetsReload = connect.findViewById(R.id.hometweets);
|
SwipeRefreshLayout tweetsReload = connect.findViewById(R.id.hometweets);
|
||||||
SwipeRefreshLayout favoritsReload = connect.findViewById(R.id.homefavorits);
|
SwipeRefreshLayout favoriteReload = connect.findViewById(R.id.homefavorits);
|
||||||
tweetsReload.setRefreshing(false);
|
tweetsReload.setRefreshing(false);
|
||||||
favoritsReload.setRefreshing(false);
|
favoriteReload.setRefreshing(false);
|
||||||
|
|
||||||
if (retryAfter > 0) {
|
if (returnCode == 420) {
|
||||||
Toast.makeText(connect, R.string.rate_limit_exceeded, Toast.LENGTH_LONG).show();
|
Toast.makeText(connect, R.string.rate_limit_exceeded, Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(connect, errMsg, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isHome && (mode==ACTION_FOLLOW||mode==ACTION_MUTE||mode==GET_INFORMATION)) {
|
if(!isHome && (mode==ACTION_FOLLOW||mode==ACTION_MUTE||mode==GET_INFORMATION)) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||||
private long tweetReplyID, replyUserId;
|
private long tweetReplyID, replyUserId;
|
||||||
private int rtCount, favCount;
|
private int rtCount, favCount;
|
||||||
private int highlight, font;
|
private int highlight, font;
|
||||||
|
private int returnCode = 0;
|
||||||
|
|
||||||
private WeakReference<TweetDetail> ui;
|
private WeakReference<TweetDetail> ui;
|
||||||
|
|
||||||
|
@ -168,14 +169,10 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(TwitterException e) {
|
catch(TwitterException e) {
|
||||||
int errCode = e.getErrorCode();
|
returnCode = e.getErrorCode();
|
||||||
if(errCode == 144) {
|
if (returnCode == 144) {
|
||||||
database.removeStatus(tweetID); //TODO
|
database.removeStatus(tweetID);
|
||||||
errorMessage = "Tweet nicht gefunden!\nID:"+tweetID;
|
} else if (returnCode != 136) {
|
||||||
} else if(errCode == 420) {
|
|
||||||
int retry = e.getRetryAfter(); //TODO
|
|
||||||
errorMessage = "Rate limit erreicht!\n Weiter in "+retry+" Sekunden";
|
|
||||||
} else {
|
|
||||||
errorMessage += e.getMessage();
|
errorMessage += e.getMessage();
|
||||||
}
|
}
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
@ -302,7 +299,13 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||||
ui.get().finish();
|
ui.get().finish();
|
||||||
}
|
}
|
||||||
else if(mode == ERROR) {
|
else if(mode == ERROR) {
|
||||||
Toast.makeText(ui.get(),errorMessage,Toast.LENGTH_LONG).show();
|
if (returnCode == 420) {
|
||||||
|
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_LONG).show();
|
||||||
|
} else if (returnCode == 144) {
|
||||||
|
Toast.makeText(ui.get(), R.string.tweet_not_found, Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(ui.get(), errorMessage, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
SwipeRefreshLayout ansReload = connect.findViewById(R.id.answer_reload);
|
SwipeRefreshLayout ansReload = connect.findViewById(R.id.answer_reload);
|
||||||
if(ansReload.isRefreshing()) {
|
if(ansReload.isRefreshing()) {
|
||||||
ansReload.setRefreshing(false);
|
ansReload.setRefreshing(false);
|
||||||
|
|
|
@ -138,14 +138,6 @@ public class TwitterEngine {
|
||||||
load = settings.getRowLimit();
|
load = settings.getRowLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if Twitter4J is registered
|
|
||||||
*/
|
|
||||||
public boolean loggedIn() {
|
|
||||||
return login;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* recall Keys from Shared-Preferences
|
* recall Keys from Shared-Preferences
|
||||||
* & initialize Twitter
|
* & initialize Twitter
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class TwitterSearch extends AsyncTask<String, Void, Boolean> {
|
||||||
private int highlight, font_color;
|
private int highlight, font_color;
|
||||||
private boolean imageLoad;
|
private boolean imageLoad;
|
||||||
private String errorMessage = "E: Twitter search, ";
|
private String errorMessage = "E: Twitter search, ";
|
||||||
private int retryAfter = 0;
|
private int returnCode = 0;
|
||||||
|
|
||||||
public TwitterSearch(Context context) {
|
public TwitterSearch(Context context) {
|
||||||
ui = new WeakReference<>((SearchPage)context);
|
ui = new WeakReference<>((SearchPage)context);
|
||||||
|
@ -83,10 +83,8 @@ public class TwitterSearch extends AsyncTask<String, Void, Boolean> {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (TwitterException err) {
|
} catch (TwitterException err) {
|
||||||
int errCode = err.getErrorCode();
|
returnCode = err.getErrorCode();
|
||||||
if(errCode == 420) {
|
if (returnCode != 420) {
|
||||||
retryAfter = err.getRetryAfter();
|
|
||||||
} else {
|
|
||||||
errorMessage += err.getMessage();
|
errorMessage += err.getMessage();
|
||||||
errorLog.add(errorMessage);
|
errorLog.add(errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -104,10 +102,11 @@ public class TwitterSearch extends AsyncTask<String, Void, Boolean> {
|
||||||
if(connect == null)
|
if(connect == null)
|
||||||
return;
|
return;
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (retryAfter > 0)
|
if (returnCode == 420) {
|
||||||
Toast.makeText(connect, R.string.rate_limit_exceeded, Toast.LENGTH_LONG).show();
|
Toast.makeText(connect, R.string.rate_limit_exceeded, Toast.LENGTH_LONG).show();
|
||||||
else
|
} else {
|
||||||
Toast.makeText(connect, errorMessage, Toast.LENGTH_LONG).show();
|
Toast.makeText(connect, errorMessage, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SwipeRefreshLayout tweetReload = connect.findViewById(R.id.searchtweets);
|
SwipeRefreshLayout tweetReload = connect.findViewById(R.id.searchtweets);
|
||||||
View circleLoad = connect.findViewById(R.id.search_progress);
|
View circleLoad = connect.findViewById(R.id.search_progress);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class UserLists extends AsyncTask <Long, Void, Boolean> {
|
||||||
private ErrorLog errorLog;
|
private ErrorLog errorLog;
|
||||||
private boolean imageLoad;
|
private boolean imageLoad;
|
||||||
private String errorMessage = "E: Userlist, ";
|
private String errorMessage = "E: Userlist, ";
|
||||||
private int retryAfter = 0;
|
private int returnCode = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@see UserDetail
|
*@see UserDetail
|
||||||
|
@ -72,10 +72,8 @@ public class UserLists extends AsyncTask <Long, Void, Boolean> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(TwitterException err) {
|
catch(TwitterException err) {
|
||||||
int errCode = err.getErrorCode();
|
returnCode = err.getErrorCode();
|
||||||
if(errCode == 420) {
|
if (returnCode != 420) {
|
||||||
retryAfter = err.getRetryAfter();
|
|
||||||
} else {
|
|
||||||
errorMessage += err.getMessage();
|
errorMessage += err.getMessage();
|
||||||
errorLog.add(errorMessage);
|
errorLog.add(errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +96,7 @@ public class UserLists extends AsyncTask <Long, Void, Boolean> {
|
||||||
if(success) {
|
if(success) {
|
||||||
usrAdp.notifyDataSetChanged();
|
usrAdp.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
if (retryAfter > 0)
|
if (returnCode == 420)
|
||||||
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
|
||||||
else
|
else
|
||||||
Toast.makeText(ui.get(), errorMessage, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ui.get(), errorMessage, Toast.LENGTH_SHORT).show();
|
||||||
|
|
|
@ -126,12 +126,10 @@ public class SearchPage extends AppCompatActivity implements UserRecycler.OnItem
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case R.id.search_tweet:
|
case R.id.search_tweet:
|
||||||
intent = new Intent(this, TweetPopup.class);
|
intent = new Intent(this, TweetPopup.class);
|
||||||
Bundle b = new Bundle();
|
intent.putExtra("TweetID", -1);
|
||||||
b.putLong("TweetID", -1);
|
|
||||||
if(search.startsWith("#")) {
|
if(search.startsWith("#")) {
|
||||||
b.putString("Addition", search);
|
intent.putExtra("Addition", search);
|
||||||
}
|
}
|
||||||
intent.putExtras(b);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -140,20 +138,17 @@ public class SearchPage extends AppCompatActivity implements UserRecycler.OnItem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view, ViewGroup parent, int position) {
|
public void onItemClick(View view, ViewGroup parent, int position) {
|
||||||
|
Intent intent;
|
||||||
switch(parent.getId()) {
|
switch(parent.getId()) {
|
||||||
case R.id.tweet_result:
|
case R.id.tweet_result:
|
||||||
if(!tweetReload.isRefreshing()) {
|
if(!tweetReload.isRefreshing()) {
|
||||||
TimelineRecycler tlAdp = (TimelineRecycler) tweetSearch.getAdapter();
|
TimelineRecycler tlAdp = (TimelineRecycler) tweetSearch.getAdapter();
|
||||||
Tweet tweet = tlAdp.getData().get(position);
|
Tweet tweet = tlAdp.getData().get(position);
|
||||||
|
|
||||||
Intent intent = new Intent(this,TweetDetail.class);
|
intent = new Intent(this, TweetDetail.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("tweetID", tweet.tweetID);
|
||||||
|
intent.putExtra("userID", tweet.user.userID);
|
||||||
bundle.putLong("tweetID",tweet.tweetID);
|
intent.putExtra("username", tweet.user.screenname);
|
||||||
bundle.putLong("userID",tweet.user.userID);
|
|
||||||
bundle.putString("username", tweet.user.screenname);
|
|
||||||
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -161,13 +156,10 @@ public class SearchPage extends AppCompatActivity implements UserRecycler.OnItem
|
||||||
UserRecycler uAdp = (UserRecycler) userSearch.getAdapter();
|
UserRecycler uAdp = (UserRecycler) userSearch.getAdapter();
|
||||||
TwitterUser user = uAdp.getData().get(position);
|
TwitterUser user = uAdp.getData().get(position);
|
||||||
|
|
||||||
Intent profile = new Intent(getApplicationContext(), UserProfile.class);
|
intent = new Intent(getApplicationContext(), UserProfile.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("userID", user.userID);
|
||||||
|
intent.putExtra("username", user.screenname);
|
||||||
bundle.putLong("userID",user.userID);
|
startActivity(intent);
|
||||||
bundle.putString("username", user.screenname);
|
|
||||||
profile.putExtras(bundle);
|
|
||||||
startActivity(profile);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent;
|
Intent intent;
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
StatusLoader mStat = new StatusLoader(this);
|
StatusLoader mStat = new StatusLoader(this);
|
||||||
switch(v.getId()) {
|
switch(v.getId()) {
|
||||||
case R.id.rt_button_detail:
|
case R.id.rt_button_detail:
|
||||||
|
@ -156,36 +155,30 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||||
|
|
||||||
case R.id.no_rt_detail:
|
case R.id.no_rt_detail:
|
||||||
intent = new Intent(this, UserDetail.class);
|
intent = new Intent(this, UserDetail.class);
|
||||||
bundle.putLong("tweetID",tweetID);
|
intent.putExtra("tweetID", tweetID);
|
||||||
bundle.putLong("mode",2L);
|
intent.putExtra("mode", 2L);
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.no_fav_detail:
|
case R.id.no_fav_detail:
|
||||||
intent = new Intent(this, UserDetail.class);
|
intent = new Intent(this, UserDetail.class);
|
||||||
bundle.putLong("tweetID",tweetID);
|
intent.putExtra("tweetID", tweetID);
|
||||||
bundle.putLong("mode",3L);
|
intent.putExtra("mode", 3L);
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.profileimage_detail:
|
case R.id.profileimage_detail:
|
||||||
Intent profile = new Intent(this, UserProfile.class);
|
intent = new Intent(this, UserProfile.class);
|
||||||
Bundle b = new Bundle();
|
intent.putExtra("userID", userID);
|
||||||
b.putLong("userID",userID);
|
intent.putExtra("username", username);
|
||||||
b.putString("username", username);
|
startActivity(intent);
|
||||||
profile.putExtras(b);
|
|
||||||
startActivity(profile);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.answer_button:
|
case R.id.answer_button:
|
||||||
Intent tweetPopup = new Intent(this, TweetPopup.class);
|
intent = new Intent(this, TweetPopup.class);
|
||||||
Bundle ext = new Bundle();
|
intent.putExtra("TweetID", tweetID);
|
||||||
ext.putLong("TweetID", tweetID);
|
intent.putExtra("Addition", username);
|
||||||
ext.putString("Addition", username);
|
startActivity(intent);
|
||||||
tweetPopup.putExtras(ext);
|
|
||||||
startActivity(tweetPopup);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,13 +195,9 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||||
Tweet tweet = tlAdp.getData().get(position);
|
Tweet tweet = tlAdp.getData().get(position);
|
||||||
|
|
||||||
Intent intent = new Intent(this,TweetDetail.class);
|
Intent intent = new Intent(this,TweetDetail.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("tweetID", tweet.tweetID);
|
||||||
|
intent.putExtra("userID", tweet.user.userID);
|
||||||
bundle.putLong("tweetID",tweet.tweetID);
|
intent.putExtra("username", tweet.user.screenname);
|
||||||
bundle.putLong("userID",tweet.user.userID);
|
|
||||||
bundle.putString("username", tweet.user.screenname);
|
|
||||||
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,17 +123,16 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.image:
|
case R.id.image:
|
||||||
|
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
int check = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
|
int check = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||||
if(check == PackageManager.PERMISSION_GRANTED) {
|
if(check == PackageManager.PERMISSION_GRANTED) {
|
||||||
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
||||||
startActivityForResult(i, 0);
|
startActivityForResult(i, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},1);
|
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
||||||
startActivityForResult(i, 0);
|
startActivityForResult(i, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -78,30 +78,32 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||||
TwitterUser user = uAdp.getData().get(position);
|
TwitterUser user = uAdp.getData().get(position);
|
||||||
long userID = user.userID;
|
long userID = user.userID;
|
||||||
String username = user.screenname;
|
String username = user.screenname;
|
||||||
Intent intent = new Intent(getApplicationContext(), UserProfile.class);
|
Intent intent = new Intent(this, UserProfile.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("userID", userID);
|
||||||
bundle.putLong("userID",userID);
|
intent.putExtra("username", username);
|
||||||
bundle.putString("username", username);
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getUsers() {
|
private void getUsers() {
|
||||||
uList = new UserLists(UserDetail.this);
|
uList = new UserLists(UserDetail.this);
|
||||||
if(getSupportActionBar() != null) {
|
String title = "";
|
||||||
if (mode == 0L) {
|
|
||||||
getSupportActionBar().setTitle(R.string.following);
|
if (mode == 0L) {
|
||||||
uList.execute(userID, UserLists.FOLLOWING, -1L);
|
title = getString(R.string.following);
|
||||||
} else if (mode == 1L) {
|
uList.execute(userID, UserLists.FOLLOWING, -1L);
|
||||||
getSupportActionBar().setTitle(R.string.follower);
|
} else if (mode == 1L) {
|
||||||
uList.execute(userID, UserLists.FOLLOWERS, -1L);
|
title = getString(R.string.follower);
|
||||||
} else if (mode == 2L) {
|
uList.execute(userID, UserLists.FOLLOWERS, -1L);
|
||||||
getSupportActionBar().setTitle(R.string.retweet);
|
} else if (mode == 2L) {
|
||||||
uList.execute(tweetID, UserLists.RETWEETER, -1L);
|
title = getString(R.string.retweet);
|
||||||
} else if (mode == 3L) {
|
uList.execute(tweetID, UserLists.RETWEETER, -1L);
|
||||||
getSupportActionBar().setTitle(R.string.favorite);
|
} else if (mode == 3L) {
|
||||||
uList.execute(tweetID, UserLists.FAVORISER, -1L);
|
title = getString(R.string.favorite);
|
||||||
}
|
uList.execute(tweetID, UserLists.FAVORISER, -1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSupportActionBar() != null) {
|
||||||
|
getSupportActionBar().setTitle(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -133,11 +133,9 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||||
mProfile = new ProfileLoader(this);
|
mProfile = new ProfileLoader(this);
|
||||||
switch(item.getItemId()) {
|
switch(item.getItemId()) {
|
||||||
case R.id.profile_tweet:
|
case R.id.profile_tweet:
|
||||||
Bundle extra = new Bundle();
|
|
||||||
intent = new Intent(this, TweetPopup.class);
|
intent = new Intent(this, TweetPopup.class);
|
||||||
if(!home)
|
if(!home)
|
||||||
extra.putString("Addition", username);
|
intent.putExtra("Addition", username);
|
||||||
intent.putExtras(extra);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -197,18 +195,15 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||||
tlAdp = (TimelineRecycler) favoriteList.getAdapter();
|
tlAdp = (TimelineRecycler) favoriteList.getAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(this,TweetDetail.class);
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
|
|
||||||
Tweet tweet = tlAdp.getData().get(position);
|
Tweet tweet = tlAdp.getData().get(position);
|
||||||
if(tweet.embedded != null) {
|
if(tweet.embedded != null) {
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.embedded;
|
||||||
}
|
}
|
||||||
bundle.putLong("tweetID",tweet.tweetID);
|
|
||||||
bundle.putLong("userID",tweet.user.userID);
|
|
||||||
bundle.putString("username", tweet.user.screenname);
|
|
||||||
|
|
||||||
intent.putExtras(bundle);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
|
intent.putExtra("tweetID", tweet.tweetID);
|
||||||
|
intent.putExtra("userID", tweet.user.userID);
|
||||||
|
intent.putExtra("username", tweet.user.screenname);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,10 +260,8 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||||
|
|
||||||
private void getConnection(long mode) {
|
private void getConnection(long mode) {
|
||||||
Intent intent = new Intent(this, UserDetail.class);
|
Intent intent = new Intent(this, UserDetail.class);
|
||||||
Bundle bundle = new Bundle();
|
intent.putExtra("userID", userId);
|
||||||
bundle.putLong("userID",userId);
|
intent.putExtra("mode", mode);
|
||||||
bundle.putLong("mode",mode);
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,4 +42,5 @@
|
||||||
<string name="error">Fehler!</string>
|
<string name="error">Fehler!</string>
|
||||||
<string name="tweet_delete">Tweet löschen</string>
|
<string name="tweet_delete">Tweet löschen</string>
|
||||||
<string name="get_tweetlink">Im Browser öffnen</string>
|
<string name="get_tweetlink">Im Browser öffnen</string>
|
||||||
|
<string name="tweet_not_found">Tweet wurde nicht gefunden</string>
|
||||||
</resources>
|
</resources>
|
|
@ -50,4 +50,5 @@
|
||||||
<string name="error">Error!</string>
|
<string name="error">Error!</string>
|
||||||
<string name="tweet_delete">Delete</string>
|
<string name="tweet_delete">Delete</string>
|
||||||
<string name="get_tweetlink">Open in Browser</string>
|
<string name="get_tweetlink">Open in Browser</string>
|
||||||
|
<string name="tweet_not_found">Tweet not found</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue