adapter bug fix, error message update, code fix
Signed-off-by: nuclearfog <hatespirit666@gmail.com>
This commit is contained in:
parent
2197d7273f
commit
0d456bb2b2
|
@ -21,6 +21,7 @@ import org.nuclearfog.twidda.backend.holder.TweetHolder;
|
||||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||||
import org.nuclearfog.twidda.backend.utils.DialogBuilder;
|
import org.nuclearfog.twidda.backend.utils.DialogBuilder;
|
||||||
import org.nuclearfog.twidda.backend.utils.DialogBuilder.OnDialogConfirmListener;
|
import org.nuclearfog.twidda.backend.utils.DialogBuilder.OnDialogConfirmListener;
|
||||||
|
import org.nuclearfog.twidda.backend.utils.DialogBuilder.OnProgressStopListener;
|
||||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
|
@ -42,11 +43,11 @@ import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.TWEET
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.TWEET_EDITOR_LEAVE;
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.TWEET_EDITOR_LEAVE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity to create a tweet
|
* Tweet editor activity. Media files and location can be attached to a tweet.
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public class TweetEditor extends MediaActivity implements OnClickListener, DialogBuilder.OnProgressStopListener, OnDialogConfirmListener {
|
public class TweetEditor extends MediaActivity implements OnClickListener, OnProgressStopListener, OnDialogConfirmListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* type of media attached to the tweet
|
* type of media attached to the tweet
|
||||||
|
@ -85,13 +86,11 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
private AlertDialog errorDialog;
|
private AlertDialog errorDialog;
|
||||||
private Dialog loadingCircle, closingDialog;
|
private Dialog loadingCircle, closingDialog;
|
||||||
private EditText tweetText;
|
private EditText tweetText;
|
||||||
private View locationProg;
|
private View locationPending;
|
||||||
|
|
||||||
private Location location;
|
private Location location;
|
||||||
private List<String> mediaPath = new LinkedList<>();
|
private List<String> mediaPath = new LinkedList<>();
|
||||||
private MediaType selectedFormat = MediaType.NONE;
|
private MediaType selectedFormat = MediaType.NONE;
|
||||||
private String tweetStr = "";
|
|
||||||
private long inReplyId = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle b) {
|
protected void onCreate(@Nullable Bundle b) {
|
||||||
|
@ -105,7 +104,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
mediaBtn = findViewById(R.id.tweet_add_media);
|
mediaBtn = findViewById(R.id.tweet_add_media);
|
||||||
previewBtn = findViewById(R.id.tweet_prev_media);
|
previewBtn = findViewById(R.id.tweet_prev_media);
|
||||||
tweetText = findViewById(R.id.tweet_input);
|
tweetText = findViewById(R.id.tweet_input);
|
||||||
locationProg = findViewById(R.id.location_progress);
|
locationPending = findViewById(R.id.location_progress);
|
||||||
loadingCircle = DialogBuilder.createProgress(this, this);
|
loadingCircle = DialogBuilder.createProgress(this, this);
|
||||||
errorDialog = DialogBuilder.create(this, TWEET_EDITOR_ERROR, this);
|
errorDialog = DialogBuilder.create(this, TWEET_EDITOR_ERROR, this);
|
||||||
closingDialog = DialogBuilder.create(this, TWEET_EDITOR_LEAVE, this);
|
closingDialog = DialogBuilder.create(this, TWEET_EDITOR_LEAVE, this);
|
||||||
|
@ -113,7 +112,6 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
settings = GlobalSettings.getInstance(this);
|
settings = GlobalSettings.getInstance(this);
|
||||||
|
|
||||||
Intent data = getIntent();
|
Intent data = getIntent();
|
||||||
inReplyId = data.getLongExtra(KEY_TWEETPOPUP_REPLYID, 0);
|
|
||||||
String prefix = data.getStringExtra(KEY_TWEETPOPUP_TEXT);
|
String prefix = data.getStringExtra(KEY_TWEETPOPUP_TEXT);
|
||||||
if (prefix != null)
|
if (prefix != null)
|
||||||
tweetText.append(prefix);
|
tweetText.append(prefix);
|
||||||
|
@ -151,7 +149,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// send tweet
|
// send tweet
|
||||||
if (v.getId() == R.id.tweet_send) {
|
if (v.getId() == R.id.tweet_send) {
|
||||||
tweetStr = tweetText.getText().toString();
|
String tweetStr = tweetText.getText().toString();
|
||||||
// check if tweet is empty
|
// check if tweet is empty
|
||||||
if (tweetStr.trim().isEmpty() && mediaPath.isEmpty()) {
|
if (tweetStr.trim().isEmpty() && mediaPath.isEmpty()) {
|
||||||
Toast.makeText(this, R.string.error_empty_tweet, LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.error_empty_tweet, LENGTH_SHORT).show();
|
||||||
|
@ -195,7 +193,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
}
|
}
|
||||||
// add location to the tweet
|
// add location to the tweet
|
||||||
else if (v.getId() == R.id.tweet_add_location) {
|
else if (v.getId() == R.id.tweet_add_location) {
|
||||||
locationProg.setVisibility(VISIBLE);
|
locationPending.setVisibility(VISIBLE);
|
||||||
locationBtn.setVisibility(INVISIBLE);
|
locationBtn.setVisibility(INVISIBLE);
|
||||||
getLocation();
|
getLocation();
|
||||||
}
|
}
|
||||||
|
@ -209,7 +207,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.error_gps, LENGTH_LONG).show();
|
Toast.makeText(this, R.string.error_gps, LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
locationProg.setVisibility(INVISIBLE);
|
locationPending.setVisibility(INVISIBLE);
|
||||||
locationBtn.setVisibility(VISIBLE);
|
locationBtn.setVisibility(VISIBLE);
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +232,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.info_cant_add_video, LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.info_cant_add_gif, LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -326,6 +324,9 @@ public class TweetEditor extends MediaActivity implements OnClickListener, Dialo
|
||||||
* update tweet information
|
* update tweet information
|
||||||
*/
|
*/
|
||||||
private void updateTweet() {
|
private void updateTweet() {
|
||||||
|
Intent data = getIntent();
|
||||||
|
long inReplyId = data.getLongExtra(KEY_TWEETPOPUP_REPLYID, 0);
|
||||||
|
String tweetStr = tweetText.getText().toString();
|
||||||
TweetHolder tweet = new TweetHolder(tweetStr, inReplyId);
|
TweetHolder tweet = new TweetHolder(tweetStr, inReplyId);
|
||||||
// add media
|
// add media
|
||||||
if (selectedFormat == MediaType.IMAGE || selectedFormat == MediaType.GIF)
|
if (selectedFormat == MediaType.IMAGE || selectedFormat == MediaType.GIF)
|
||||||
|
|
|
@ -72,6 +72,7 @@ public class ListAdapter extends Adapter<ViewHolder> {
|
||||||
*/
|
*/
|
||||||
@MainThread
|
@MainThread
|
||||||
public void setData(UserLists newData) {
|
public void setData(UserLists newData) {
|
||||||
|
disableLoading();
|
||||||
if (newData.isEmpty()) {
|
if (newData.isEmpty()) {
|
||||||
if (!data.isEmpty() && data.peekLast() == null) {
|
if (!data.isEmpty() && data.peekLast() == null) {
|
||||||
// remove footer
|
// remove footer
|
||||||
|
@ -96,7 +97,6 @@ public class ListAdapter extends Adapter<ViewHolder> {
|
||||||
data.addAt(newData, end);
|
data.addAt(newData, end);
|
||||||
notifyItemRangeInserted(end, newData.size());
|
notifyItemRangeInserted(end, newData.size());
|
||||||
}
|
}
|
||||||
disableLoading();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
||||||
*/
|
*/
|
||||||
@MainThread
|
@MainThread
|
||||||
public void setData(MessageList newData) {
|
public void setData(MessageList newData) {
|
||||||
|
disableLoading();
|
||||||
if (newData.isEmpty()) {
|
if (newData.isEmpty()) {
|
||||||
if (!data.isEmpty() && data.peekLast() == null) {
|
if (!data.isEmpty() && data.peekLast() == null) {
|
||||||
int end = data.size() - 1;
|
int end = data.size() - 1;
|
||||||
|
@ -85,7 +86,6 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
||||||
data.addAt(newData, end);
|
data.addAt(newData, end);
|
||||||
notifyItemRangeInserted(end, newData.size());
|
notifyItemRangeInserted(end, newData.size());
|
||||||
}
|
}
|
||||||
disableLoading();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,7 +219,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* disable loading animation in footer
|
* disable footer loading animation
|
||||||
*/
|
*/
|
||||||
public void disableLoading() {
|
public void disableLoading() {
|
||||||
if (loadingIndex != NO_LOADING) {
|
if (loadingIndex != NO_LOADING) {
|
||||||
|
@ -234,6 +234,9 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
||||||
*/
|
*/
|
||||||
public interface OnItemSelected extends OnTagClickListener {
|
public interface OnItemSelected extends OnTagClickListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actions performed by clicking the buttons
|
||||||
|
*/
|
||||||
enum Action {
|
enum Action {
|
||||||
ANSWER,
|
ANSWER,
|
||||||
DELETE,
|
DELETE,
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class UserAdapter extends Adapter<ViewHolder> {
|
||||||
*/
|
*/
|
||||||
@MainThread
|
@MainThread
|
||||||
public void setData(@NonNull UserList newData) {
|
public void setData(@NonNull UserList newData) {
|
||||||
|
disableLoading();
|
||||||
if (newData.isEmpty()) {
|
if (newData.isEmpty()) {
|
||||||
if (!data.isEmpty() && data.peekLast() == null) {
|
if (!data.isEmpty() && data.peekLast() == null) {
|
||||||
// remove footer
|
// remove footer
|
||||||
|
@ -102,7 +103,6 @@ public class UserAdapter extends Adapter<ViewHolder> {
|
||||||
data.addAt(newData, end);
|
data.addAt(newData, end);
|
||||||
notifyItemRangeInserted(end, newData.size());
|
notifyItemRangeInserted(end, newData.size());
|
||||||
}
|
}
|
||||||
disableLoading();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -189,4 +189,9 @@
|
||||||
<string name="info_location_pending">Ortung läuft, bitte warten.</string>
|
<string name="info_location_pending">Ortung läuft, bitte warten.</string>
|
||||||
<string name="app_info_twitter_rules">Twitter Regeln:</string>
|
<string name="app_info_twitter_rules">Twitter Regeln:</string>
|
||||||
<string name="error_twitter_search">Suchbegriff ist entweder zu lang oder enthält nicht erlaubte Zeichen!</string>
|
<string name="error_twitter_search">Suchbegriff ist entweder zu lang oder enthält nicht erlaubte Zeichen!</string>
|
||||||
|
<string name="button_backward">Zurückspulen</string>
|
||||||
|
<string name="button_forward">Vorspulen</string>
|
||||||
|
<string name="button_play_pause">Pause/Abspielen</string>
|
||||||
|
<string name="button_share">Videolink teilen</string>
|
||||||
|
<string name="info_cant_add_gif">GIF konnte nicht hinzugefügt werden!</string>
|
||||||
</resources>
|
</resources>
|
|
@ -118,6 +118,7 @@
|
||||||
<string name="info_login_to_twitter">login to Twitter</string>
|
<string name="info_login_to_twitter">login to Twitter</string>
|
||||||
<string name="error_wrong_connection_settings">Wrong connection settings!</string>
|
<string name="error_wrong_connection_settings">Wrong connection settings!</string>
|
||||||
<string name="info_cant_add_video">can\'t add video</string>
|
<string name="info_cant_add_video">can\'t add video</string>
|
||||||
|
<string name="info_cant_add_gif">can\'t add GIF</string>
|
||||||
<string name="info_get_link">get Twitter PIN from browser first. Please press the first button!</string>
|
<string name="info_get_link">get Twitter PIN from browser first. Please press the first button!</string>
|
||||||
<string name="info_gps_attached">GPS position added</string>
|
<string name="info_gps_attached">GPS position added</string>
|
||||||
<string name="info_tweet_retweeted">retweeted</string>
|
<string name="info_tweet_retweeted">retweeted</string>
|
||||||
|
|
Loading…
Reference in New Issue