Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.asha.md360player4android;

import android.content.ContentResolver;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.util.Log;
import android.view.View;

Expand Down Expand Up @@ -38,45 +35,48 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
busy();
nextUri = getDrawableUri(R.drawable.texture);
getVRLibrary().notifyPlayerChanged();
}
});
}

private Target mTarget;// keep the reference for picasso.

private void loadImage(Uri uri, final MD360BitmapTexture.Callback callback){
mTarget = new Target() {
private void loadImage(final MD360BitmapTexture.Callback callback){
mTarget = new com.squareup.picasso.Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d(TAG, "loaded image, size:" + bitmap.getWidth() + "," + bitmap.getHeight());
Log.d(TAG, "onBitmapLoaded: "+bitmap);

// notify if size changed
getVRLibrary().onTextureResize(bitmap.getWidth(), bitmap.getHeight());

// texture
callback.texture(bitmap);
cancelBusy();

}

@Override
public void onBitmapFailed(Drawable errorDrawable) {
Log.d(TAG, "onBitmapFailed: "+errorDrawable);

}

@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
Log.d(TAG, "onPrepareLoad: "+placeHolderDrawable);

}
};
Log.d(TAG, "load image with max texture size:" + callback.getMaxTextureSize());
Picasso.with(getApplicationContext())
.load(uri)
.load("https://previews.123rf.com/images/svetlanasf/svetlanasf1803/svetlanasf180300010/97034756-panorama-with-the-iluminated-palace-of-fine-arts-during-the-blue-hour-at-sunset-in-san-francisco-cal.jpg")
.resize(callback.getMaxTextureSize(),callback.getMaxTextureSize())
.onlyScaleDown()
.centerInside()
.memoryPolicy(NO_CACHE, NO_STORE)
//.memoryPolicy(NO_CACHE, NO_STORE)
//.networkPolicy(NetworkPolicy.OFFLINE)
.into(mTarget);
}

Expand All @@ -92,11 +92,11 @@ private Uri currentUri(){
protected MDVRLibrary createVRLibrary() {
return MDVRLibrary.with(this)
.displayMode(MDVRLibrary.DISPLAY_MODE_NORMAL)
.interactiveMode(MDVRLibrary.INTERACTIVE_MODE_TOUCH)
.interactiveMode(MDVRLibrary.INTERACTIVE_MODE_CARDBORAD_MOTION_WITH_TOUCH)
.asBitmap(new MDVRLibrary.IBitmapProvider() {
@Override
public void onProvideBitmap(final MD360BitmapTexture.Callback callback) {
loadImage(currentUri(), callback);
public void onProvideBitmap(MD360BitmapTexture.Callback callback) {
loadImage(callback);
}
})
.listenTouchPick(new MDVRLibrary.ITouchPickListener() {
Expand All @@ -110,8 +110,5 @@ public void onHotspotHit(IMDHotspot hitHotspot, MDRay ray) {
.build(findViewById(R.id.gl_view));
}

private Uri getDrawableUri(@DrawableRes int resId){
Resources resources = getResources();
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources.getResourcePackageName(resId) + '/' + resources.getResourceTypeName(resId) + '/' + resources.getResourceEntryName(resId) );
}

}
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Mar 20 16:03:12 CST 2017
#Wed Oct 16 01:50:59 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip