This commit is contained in:
nuclearfog 2022-01-19 09:58:05 +01:00
parent 4ef51423f8
commit 822a6ab77d
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98
4 changed files with 46 additions and 28 deletions

View File

@ -142,11 +142,16 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
public void onClick(View v) {
// get login request link
if (v.getId() == R.id.login_get_link) {
if (requestToken == null) {
if (registerAsync == null || registerAsync.getStatus() != RUNNING) {
Toast.makeText(this, R.string.info_fetching_link, LENGTH_LONG).show();
registerAsync = new Registration(this);
registerAsync.execute();
}
} else {
// re-use request token
connect();
}
}
// verify user
else if (v.getId() == R.id.login_verifier) {
@ -166,22 +171,6 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
}
}
/**
* Called when a twitter login link was created
*
* @param requestToken temporary request token
*/
public void connect(String requestToken) {
this.requestToken = requestToken;
String link = Twitter.REQUEST_URL + requestToken;
Intent loginIntent = new Intent(ACTION_VIEW, Uri.parse(link));
try {
startActivity(loginIntent);
} catch (ActivityNotFoundException err) {
Toast.makeText(this, R.string.error_connection_failed, LENGTH_SHORT).show();
}
}
/**
* Called when the app is registered successfully to twitter
*/
@ -198,4 +187,25 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
public void onError(TwitterError error) {
ErrorHandler.handleFailure(this, error);
}
/**
* Called when a twitter login link was created
*
* @param requestToken temporary request token
*/
public void connect(String requestToken) {
this.requestToken = requestToken;
connect();
}
private void connect() {
String link = Twitter.REQUEST_URL + requestToken;
Intent loginIntent = new Intent(ACTION_VIEW, Uri.parse(link));
try {
startActivity(loginIntent);
} catch (ActivityNotFoundException err) {
Toast.makeText(this, R.string.error_connection_failed, LENGTH_SHORT).show();
}
}
}

View File

@ -505,6 +505,7 @@ public class MediaViewer extends MediaActivity implements OnImageClickListener,
* clear the image cache
*/
private void clearCache() {
try {
File cacheFolder = new File(getExternalCacheDir(), CACHE_FOLDER);
File[] files = cacheFolder.listFiles();
if (files != null && files.length > 0) {
@ -512,5 +513,8 @@ public class MediaViewer extends MediaActivity implements OnImageClickListener,
file.delete();
}
}
} catch (SecurityException e) {
e.printStackTrace();
}
}
}

View File

@ -115,8 +115,10 @@ public class TweetAction extends AsyncTask<TweetAction.Action, Tweet, TweetActio
publishProgress(tweet);
db.updateStatus(tweet);
// removing retweet reference to this tweet
if (tweet.getMyRetweetId() > 0)
if (retweetId > 0)
db.removeStatus(retweetId);
else
db.removeStatus(tweetId);
break;
case FAVORITE:

View File

@ -180,10 +180,12 @@ public class MessageFragment extends ListFragment implements OnItemSelected, OnC
@Override
public void onConfirm(DialogType type) {
if (type == DialogType.MESSAGE_DELETE) {
if (messageTask != null && messageTask.getStatus() != RUNNING) {
messageTask = new MessageLoader(this, MessageLoader.Action.DEL, null);
messageTask.execute(deleteId);
}
}
}
/**
* set data to list