Bugfix
Code Cleanup Added Multiple Image Upload
This commit is contained in:
parent
f9dd059855
commit
da490f26cf
@ -31,7 +31,7 @@ public class StatusUpload extends AsyncTask<Object, Void, Boolean> {
|
|||||||
if(args.length > 1)
|
if(args.length > 1)
|
||||||
id = (Long) args[1];
|
id = (Long) args[1];
|
||||||
|
|
||||||
if(path == null) {
|
if(path.length == 0) { //No Media included
|
||||||
TwitterEngine.getInstance(context).sendStatus(tweet,id);
|
TwitterEngine.getInstance(context).sendStatus(tweet,id);
|
||||||
} else {
|
} else {
|
||||||
TwitterEngine.getInstance(context).sendStatus(tweet,id,path);
|
TwitterEngine.getInstance(context).sendStatus(tweet,id,path);
|
||||||
|
@ -338,10 +338,8 @@ public class TwitterEngine {
|
|||||||
}
|
}
|
||||||
for(int i = 0 ; i < count; i++) {
|
for(int i = 0 ; i < count; i++) {
|
||||||
String current = path[i];
|
String current = path[i];
|
||||||
if(current != null) {
|
media = twitter.uploadMedia(new File(current));
|
||||||
media = twitter.uploadMedia(new File(current));
|
mIDs[i] = media.getMediaId();
|
||||||
mIDs[i] = media.getMediaId();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mStatus.setMediaIds(mIDs);
|
mStatus.setMediaIds(mIDs);
|
||||||
twitter.tweets().updateStatus(mStatus);
|
twitter.tweets().updateStatus(mStatus);
|
||||||
|
@ -99,14 +99,14 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
public void onBackPressed() {
|
||||||
wId = Integer.parseInt(woeId.getText().toString());
|
wId = Integer.parseInt(woeId.getText().toString());
|
||||||
Editor edit = settings.edit();
|
Editor edit = settings.edit();
|
||||||
edit.putInt("woeid", wId);
|
edit.putInt("woeid", wId);
|
||||||
edit.putInt("preload", row);
|
edit.putInt("preload", row);
|
||||||
edit.apply();
|
edit.commit();
|
||||||
mColor.commit();
|
mColor.commit();
|
||||||
super.onDestroy();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,6 +17,9 @@ import org.nuclearfog.twidda.backend.ImagePopup;
|
|||||||
import org.nuclearfog.twidda.backend.StatusUpload;
|
import org.nuclearfog.twidda.backend.StatusUpload;
|
||||||
import org.nuclearfog.twidda.R;
|
import org.nuclearfog.twidda.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tweet Window
|
* Tweet Window
|
||||||
* @see StatusUpload
|
* @see StatusUpload
|
||||||
@ -28,8 +31,8 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
|||||||
Button imageButton, previewBtn;
|
Button imageButton, previewBtn;
|
||||||
private long inReplyId =-1L;
|
private long inReplyId =-1L;
|
||||||
private String addition="";
|
private String addition="";
|
||||||
private final String[] filePath = new String[4];
|
|
||||||
private int imgIndex = 0;
|
private int imgIndex = 0;
|
||||||
|
private List<String> mediaPath;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle SavedInstance) {
|
protected void onCreate(Bundle SavedInstance) {
|
||||||
@ -40,8 +43,10 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
|||||||
if(getIntent().hasExtra("Addition"))
|
if(getIntent().hasExtra("Addition"))
|
||||||
addition = getIntent().getExtras().getString("Addition");
|
addition = getIntent().getExtras().getString("Addition");
|
||||||
|
|
||||||
final int size = LinearLayout.LayoutParams.WRAP_CONTENT;
|
// final int size = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||||
getWindow().setLayout(size, size);
|
// getWindow().setLayout(size, size);
|
||||||
|
mediaPath = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
Button tweetButton = (Button) findViewById(R.id.sendTweet);
|
Button tweetButton = (Button) findViewById(R.id.sendTweet);
|
||||||
Button closeButton = (Button) findViewById(R.id.close);
|
Button closeButton = (Button) findViewById(R.id.close);
|
||||||
@ -49,15 +54,15 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
|||||||
previewBtn = (Button) findViewById(R.id.img_preview);
|
previewBtn = (Button) findViewById(R.id.img_preview);
|
||||||
tweetfield = (EditText) findViewById(R.id.tweet_input);
|
tweetfield = (EditText) findViewById(R.id.tweet_input);
|
||||||
|
|
||||||
closeButton.setOnClickListener(this);
|
|
||||||
tweetButton.setOnClickListener(this);
|
|
||||||
imageButton.setOnClickListener(this);
|
|
||||||
previewBtn.setOnClickListener(this);
|
|
||||||
|
|
||||||
LinearLayout root = (LinearLayout) findViewById(R.id.tweet_popup);
|
LinearLayout root = (LinearLayout) findViewById(R.id.tweet_popup);
|
||||||
ColorPreferences mColor = ColorPreferences.getInstance(this);
|
ColorPreferences mColor = ColorPreferences.getInstance(this);
|
||||||
root.setBackgroundColor(mColor.getColor(ColorPreferences.TWEET_COLOR));
|
root.setBackgroundColor(mColor.getColor(ColorPreferences.TWEET_COLOR));
|
||||||
tweetfield.setText(addition);
|
tweetfield.setText(addition);
|
||||||
|
|
||||||
|
closeButton.setOnClickListener(this);
|
||||||
|
tweetButton.setOnClickListener(this);
|
||||||
|
imageButton.setOnClickListener(this);
|
||||||
|
previewBtn.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +83,7 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
|||||||
}
|
}
|
||||||
if(imgIndex < 4) {
|
if(imgIndex < 4) {
|
||||||
int index = c.getColumnIndex(mode[0]);
|
int index = c.getColumnIndex(mode[0]);
|
||||||
filePath[imgIndex++] = c.getString(index);
|
mediaPath.add(c.getString(index));
|
||||||
}
|
}
|
||||||
if(imgIndex == 4) {
|
if(imgIndex == 4) {
|
||||||
imageButton.setVisibility(View.INVISIBLE);
|
imageButton.setVisibility(View.INVISIBLE);
|
||||||
@ -113,7 +118,7 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
|||||||
startActivityForResult(i, 0);
|
startActivityForResult(i, 0);
|
||||||
break;
|
break;
|
||||||
case R.id.img_preview:
|
case R.id.img_preview:
|
||||||
new ImagePopup(this).execute(filePath);
|
new ImagePopup(this).execute((String[])mediaPath.toArray());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,12 +137,12 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
|||||||
|
|
||||||
private void send() {
|
private void send() {
|
||||||
String tweet = tweetfield.getText().toString();
|
String tweet = tweetfield.getText().toString();
|
||||||
|
String[] paths = new String[mediaPath.size()];
|
||||||
|
paths = mediaPath.toArray(paths);
|
||||||
StatusUpload sendTweet;
|
StatusUpload sendTweet;
|
||||||
if(filePath[0] == null) {
|
sendTweet = new StatusUpload(getApplicationContext(),paths);
|
||||||
sendTweet = new StatusUpload(getApplicationContext(),null);
|
|
||||||
} else {
|
if(inReplyId > 0) {
|
||||||
sendTweet = new StatusUpload(getApplicationContext(), filePath);
|
|
||||||
} if(inReplyId > 0) {
|
|
||||||
sendTweet.execute(tweet, inReplyId);
|
sendTweet.execute(tweet, inReplyId);
|
||||||
} else {
|
} else {
|
||||||
sendTweet.execute(tweet);
|
sendTweet.execute(tweet);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user