Skip to content

Commit

Permalink
removed butterknife from sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Kwiecień committed Nov 3, 2017
1 parent 6f3440d commit 2044f13
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 55 deletions.
1 change: 0 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {
compile(project(':library'))
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation "com.android.support:design:$support_library_version"
implementation 'com.jakewharton:butterknife:7.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.tajchert:nammu:1.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import java.io.File;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
* Created by Jacek Kwiecień on 08.11.2016.
*/
Expand Down Expand Up @@ -51,12 +48,11 @@ public int getItemCount() {

protected static class ViewHolder extends RecyclerView.ViewHolder {

@Bind(R.id.image_view)
public ImageView imageView;

public ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
imageView = itemView.findViewById(R.id.image_view);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import pl.aprilapps.easyphotopicker.DefaultCallback;
import pl.aprilapps.easyphotopicker.EasyImage;
import pl.tajchert.nammu.Nammu;
Expand All @@ -26,10 +23,8 @@ public class MainActivity extends AppCompatActivity {

private static final String PHOTOS_KEY = "easy_image_photos_list";

@Bind(R.id.recycler_view)
protected RecyclerView recyclerView;

@Bind(R.id.gallery_button)
protected View galleryButton;

private ImagesAdapter imagesAdapter;
Expand All @@ -40,9 +35,11 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
Nammu.init(this);

recyclerView = findViewById(R.id.recycler_view);
galleryButton = findViewById(R.id.gallery_button);

if (savedInstanceState != null) {
photos = (ArrayList<File>) savedInstanceState.getSerializable(PHOTOS_KEY);
}
Expand Down Expand Up @@ -74,6 +71,63 @@ public void permissionRefused() {
.setAllowMultiplePickInGallery(true);

checkGalleryAppAvailability();


findViewById(R.id.gallery_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
/** Some devices such as Samsungs which have their own gallery app require write permission. Testing is advised! */
EasyImage.openGallery(MainActivity.this, 0);
}
});


findViewById(R.id.camera_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EasyImage.openCamera(MainActivity.this, 0);
}
});

findViewById(R.id.documents_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
/** Some devices such as Samsungs which have their own gallery app require write permission. Testing is advised! */

int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
EasyImage.openDocuments(MainActivity.this, 0);
} else {
Nammu.askForPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
@Override
public void permissionGranted() {
EasyImage.openDocuments(MainActivity.this, 0);
}

@Override
public void permissionRefused() {

}
});
}
}
});

findViewById(R.id.chooser_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EasyImage.openChooserWithDocuments(MainActivity.this, "Pick source", 0);
}
});


findViewById(R.id.chooser_button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EasyImage.openChooserWithGallery(MainActivity.this, "Pick source", 0);
}
});

}

@Override
Expand All @@ -95,49 +149,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
Nammu.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

@OnClick(R.id.camera_button)
protected void onTakePhotoClicked() {
EasyImage.openCamera(this, 0);
}

@OnClick(R.id.documents_button)
protected void onPickFromDocumentsClicked() {
/** Some devices such as Samsungs which have their own gallery app require write permission. Testing is advised! */

int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
EasyImage.openDocuments(this, 0);
} else {
Nammu.askForPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
@Override
public void permissionGranted() {
EasyImage.openDocuments(MainActivity.this, 0);
}

@Override
public void permissionRefused() {

}
});
}
}

@OnClick(R.id.gallery_button)
protected void onPickFromGaleryClicked() {
/** Some devices such as Samsungs which have their own gallery app require write permission. Testing is advised! */
EasyImage.openGallery(this, 0);
}

@OnClick(R.id.chooser_button)
protected void onChooserClicked() {
EasyImage.openChooserWithDocuments(this, "Pick source", 0);
}

@OnClick(R.id.chooser_button2)
protected void onChooserWithGalleryClicked() {
EasyImage.openChooserWithGallery(this, "Pick source", 0);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand Down

0 comments on commit 2044f13

Please sign in to comment.