Skip to content

Commit

Permalink
Merge pull request #367 from BlythMeister/MyBetaVersion
Browse files Browse the repository at this point in the history
Fix for #363 change the way a media scan is triggered.
  • Loading branch information
BlythMeister committed Dec 9, 2013
2 parents 6c91692 + 767d174 commit 3a6ef61
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions android/libraries/TweetLanesCore/res/xml/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<change>Fix - Improved performance for status display</change>
<change>Fix - Split Names/Handles on multiple lines to support longer text</change>
<change>Fix - Updated DM to show the same format names as standard statuses</change>
<change>Fix - Image saving on KitKat devices</change>
<change>Other - Updated version of crittersim for better app tracking</change>
</release>
<release version="1.2.1" versioncode="51">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.tweetlanes.android.core.util;

import java.io.File;
import android.content.Context;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;

public class SingleMediaScanner implements MediaScannerConnectionClient {

private MediaScannerConnection mMs;
private File mFile;

public SingleMediaScanner(Context context, File f) {
mFile = f;
mMs = new MediaScannerConnection(context, this);
mMs.connect();
}

@Override
public void onMediaScannerConnected() {
mMs.scanFile(mFile.getAbsolutePath(), null);
}

@Override
public void onScanCompleted(String path, Uri uri) {
mMs.disconnect();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.tweetlanes.android.core.Constant;
import com.tweetlanes.android.core.ConsumerKeyConstants;
import com.tweetlanes.android.core.R;
import com.tweetlanes.android.core.util.SingleMediaScanner;
import com.tweetlanes.android.core.widget.gestureimageview.GestureImageView;
import com.tweetlanes.android.core.widget.urlimageviewhelper.UrlImageViewCallback;
import com.tweetlanes.android.core.widget.urlimageviewhelper.UrlImageViewHelper;
Expand Down Expand Up @@ -160,7 +161,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
File f = new File(dir, UrlImageViewHelper.getJpgFilenameForUrl(mediaUrl));
copy(existingFile, f);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
new SingleMediaScanner(this, f);
toastMessage = getString(R.string.image_save_success);
} catch (FileNotFoundException e) {
e.printStackTrace();
Expand Down

0 comments on commit 3a6ef61

Please sign in to comment.