unsplash / unsplash-photopicker-android

📱An Android photo picker to search and download photos from Unsplash.
MIT License
340 stars 65 forks source link

Java usage #4

Closed DatL4g closed 5 years ago

DatL4g commented 5 years ago

Problem

It's annoying that the methods aren't usable in Java, only in Kotlin!

Solution

I'm only using Java because I don't like Kotlin cuz of it's stupid syntax, so I this library needs to be updated to make it useable in Java too.

ExploiTR commented 5 years ago

I don't know why they're one-sided!?

ExploiTR commented 5 years ago

@DATL4G I think the documentation is a little bit old. There are ways to use in Java. Let me check a little bit.

ExploiTR commented 5 years ago

I think it would work, gimme some time to check:

Initialization :

UnsplashPhotoPicker.INSTANCE.init(this,
        "api key",,
        "secrect key", 
        20);

Fetching Data


public class UnsplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_unsplash);

        startActivityForResult(
                UnsplashPickerActivity.Companion.getStartingIntent(this, false),
                100
        );

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        if (requestCode == 100 && resultCode == Activity.RESULT_OK && data != null) {
            ArrayList<UnsplashPhoto> photos = data.getParcelableArrayListExtra(UnsplashPickerActivity.EXTRA_PHOTOS);

        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
ExploiTR commented 5 years ago

@DATL4G it's working!

@unsplash this issue can be closed