Commit 10a36bf5 authored by Donald's avatar Donald

gif preview (ION)

material dialogs
tweaks
parent e90fda6e
......@@ -46,16 +46,19 @@ dependencies {
compile 'com.android.support:palette-v7:+'
compile 'com.github.bumptech.glide:glide:+'
compile 'com.android.support:support-v4:+'
compile 'com.koushikdutta.ion:ion:2.+'
compile('com.mikepenz:materialdrawer:4.6.4@aar') {
transitive = true
}
compile 'com.mikepenz:iconics-core:2.5.5@aar'
compile 'com.mikepenz:google-material-typeface:2.1.0.1.original@aar'
compile 'com.mikepenz:fontawesome-typeface:4.5.0.1@aar'
/* compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') {
compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') {
transitive = true
}
compile('com.github.afollestad.material-dialogs:commons:0.8.5.3@aar') {
transitive = true
}*/
}
}
......@@ -8,6 +8,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.koushikdutta.ion.Ion;
import com.leafpic.app.Photo;
import com.leafpic.app.R;
......@@ -42,15 +43,9 @@ public class PhotosAdapter extends RecyclerView.Adapter<PhotosAdapter.ViewHolder
if (f.MIME.equals("image/gif")) {
//TODO gif preview with ION
Glide.with(holder.imageView.getContext())
Ion.with(holder.imageView.getContext())
.load(f.Path)
.asBitmap()
.centerCrop()
.placeholder(R.drawable.ic_empty)
//.crossFade()
.into(holder.imageView);
.intoImageView(holder.imageView);
holder.gifIcon.setVisibility(View.VISIBLE);
} else {
holder.gifIcon.setVisibility(View.INVISIBLE);
......@@ -59,11 +54,11 @@ public class PhotosAdapter extends RecyclerView.Adapter<PhotosAdapter.ViewHolder
.asBitmap()
.centerCrop()
.placeholder(R.drawable.ic_empty)
//.crossFade()
.into(holder.imageView);
}
holder.path.setTag(f.Path);
if (f.isSelected()) {
holder.selectHolder.setVisibility(View.VISIBLE);
holder.imageView.setPadding(15, 15, 15, 15);
......
......@@ -5,11 +5,13 @@ import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.koushikdutta.ion.Ion;
import com.leafpic.app.Photo;
import com.leafpic.app.R;
......@@ -48,19 +50,34 @@ public class PhotosPagerAdapter extends android.support.v4.view.PagerAdapter {
@Override
public Object instantiateItem(ViewGroup container, int position) {
View itemView = mLayoutInflater.inflate(R.layout.pager_item, container, false);
final SubsamplingScaleImageView picture = (SubsamplingScaleImageView) itemView.findViewById(R.id.imageView);
Glide.with(container.getContext())
.load(mResources.get(position).Path)
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
picture.setImage(ImageSource.bitmap(bitmap));
}
});
picture.setOnTouchListener(onTouchListener);
picture.setMaxScale(10);
Photo f = mResources.get(position);
View itemView;
if (f.MIME.equals("image/gif")) {
itemView = mLayoutInflater.inflate(R.layout.gif_pager_layout, container, false);
ImageView picture = (ImageView) itemView.findViewById(R.id.imageView);
Ion.with(container.getContext())
.load(f.Path)
.intoImageView(picture);
} else {
itemView = mLayoutInflater.inflate(R.layout.image_pager_item, container, false);
final SubsamplingScaleImageView picture = (SubsamplingScaleImageView) itemView.findViewById(R.id.imageView);
Glide.with(container.getContext())
.load(mResources.get(position).Path)
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
picture.setImage(ImageSource.bitmap(bitmap));
}
});
picture.setOnTouchListener(onTouchListener);
picture.setMaxScale(10);
}
container.addView(itemView);
return itemView;
......
package com.leafpic.app;
import android.Manifest;
import android.app.ActivityManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
......@@ -12,14 +9,19 @@ import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.*;
import android.view.*;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.leafpic.app.Adapters.AlbumsAdapter;
import com.leafpic.app.utils.string;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
......@@ -44,25 +46,12 @@ public class AlbumsActivity extends AppCompatActivity {
SharedPreferences SP;
MadiaStoreHandler asd = new MadiaStoreHandler(AlbumsActivity.this);
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_albums);
/*if (!isMyServiceRunning(PhotoRecordingService.class)) {
string.showToast(getApplicationContext(), "service startde");
Intent myIntent = new Intent(AlbumsActivity.this, PhotoRecordingService.class);
startService(myIntent);
}*/
SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
initUiTweaks();
checkPermissions();
......@@ -294,46 +283,35 @@ public class AlbumsActivity extends AppCompatActivity {
break;
case R.id.excludeAlbumButton:
AlertDialog.Builder dasdf = new AlertDialog.Builder(
new ContextThemeWrapper(this, R.style.AlertDialogCustom));
dasdf.setMessage(getString(R.string.exclude_album_message));
dasdf.setCancelable(true);
dasdf.setPositiveButton("EXCLUDE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
albums.excludeSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
});
dasdf.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
dasdf.show();
new MaterialDialog.Builder(this)
.content(R.string.exclude_album_message)
.positiveText("EXCLUDE")
.negativeText("CANCEL")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
albums.excludeSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
})
.show();
break;
case R.id.deleteAction:
AlertDialog.Builder dlg = new AlertDialog.Builder(
new ContextThemeWrapper(this, R.style.AlertDialogCustom));
dlg.setMessage(getString(R.string.delete_album_message));
dlg.setCancelable(true);
dlg.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
albums.deleteSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
});
dlg.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
dlg.show();
new MaterialDialog.Builder(this)
.content(R.string.delete_album_message)
.positiveText("DELETE")
.negativeText("CANCEL")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
albums.deleteSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
})
.show();
break;
case R.id.hideAlbumButton:
......@@ -342,31 +320,28 @@ public class AlbumsActivity extends AppCompatActivity {
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
} else {
AlertDialog.Builder dlg1 = new AlertDialog.Builder(
new ContextThemeWrapper(this, R.style.AlertDialogCustom));
dlg1.setMessage(getString(R.string.hide_album_message));
dlg1.setPositiveButton("HIDE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int j) {
albums.hideSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
});
dlg1.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
dlg1.setNeutralButton("EXCLUDE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
albums.excludeSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
});
dlg1.show();
new MaterialDialog.Builder(this)
.content(R.string.hide_album_message)
.positiveText("HIDE")
.negativeText("CANCEL")
.neutralText("EXCLUDE")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
albums.hideSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
})
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
albums.excludeSelectedAlbums();
adapt.notifyDataSetChanged();
invalidateOptionsMenu();
}
})
.show();
}
break;
......@@ -403,8 +378,9 @@ public class AlbumsActivity extends AppCompatActivity {
private void loadAlbums() {
if (hidden)
albums.loadPreviewHiddenAlbums();
if (hidden) {
}
//albums.loadPreviewHiddenAlbums();
else {
// db.updatePhotos();
albums.loadPreviewAlbums();
......
package com.leafpic.app;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.leafpic.app.utils.string;
/**
* Created by dnld on 1/27/16.
*/
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
string.showToast(context, "service startde");
// Intent myIntent = new Intent(context, PhotoRecordingService.class);
//context.startService(myIntent);
}
}
\ No newline at end of file
package com.leafpic.app;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.os.FileObserver;
import android.os.IBinder;
import android.util.Log;
/**
* Created by dnld on 1/27/16.
*/
public class PhotoRecordingService extends Service {
static final String TAG = "FILEOBSERVER";
FileObserver observer;
//PinMarkerDataSource pinMarkerDataSource;
Context context;
String provider;
private String photoDirectory;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
photoDirectory = android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() + "/Camera";
//init the watching function of photo directory
observer = initSingleDirectoryObserver(photoDirectory);
observer.startWatching();
}
@Override
public void onDestroy() {
observer.stopWatching();
super.onDestroy();
}
private FileObserver initSingleDirectoryObserver(String directoryPath) {
final String rootPath = directoryPath;
FileObserver observer = new FileObserver(directoryPath) {
@Override
public void onEvent(int event, String path) {
String filePath = rootPath + "/" + path;
switch (event) {
case FileObserver.CREATE:
Log.d(TAG, "CREATE:" + rootPath + path);
break;
case FileObserver.DELETE:
Log.d(TAG, "DELETE:" + rootPath + path);
break;
case FileObserver.DELETE_SELF:
Log.d(TAG, "DELETE_SELF:" + rootPath + path);
break;
case FileObserver.MODIFY:
Log.d(TAG, "MODIFY:" + rootPath + path);
break;
case FileObserver.MOVED_FROM:
Log.d(TAG, "MOVED_FROM:" + rootPath + path);
break;
case FileObserver.MOVED_TO:
Log.d(TAG, "MOVED_TO:" + path);
break;
case FileObserver.MOVE_SELF:
Log.d(TAG, "MOVE_SELF:" + path);
break;
default:
// just ignore
break;
}
}
};
return observer;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
\ No newline at end of file
......@@ -15,5 +15,6 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment