Skip to content

Commit

Permalink
update 4.16
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel.chen committed Dec 31, 2021
1 parent a37cb63 commit 378746a
Show file tree
Hide file tree
Showing 572 changed files with 25,422 additions and 9,085 deletions.
16 changes: 11 additions & 5 deletions Sample Code/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
}

android {
compileSdkVersion 30
compileSdkVersion 31
buildToolsVersion '30.0.2'
useLibrary 'org.apache.http.legacy'

Expand All @@ -17,6 +17,7 @@ android {
minSdkVersion 23
targetSdkVersion 30
multiDexEnabled true
versionCode 1
ndk {
// On x86 devices that run Android API 23 or above, if the application is targeted with API 23 or
// above, FFmpeg lib might lead to runtime crashes or warnings.
Expand All @@ -26,11 +27,12 @@ android {

buildTypes {
release {
shrinkResources false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
shrinkResources true
shrinkResources false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Expand Down Expand Up @@ -72,11 +74,10 @@ android {
}
}


dependencies {
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.squareup:otto:1.3.8'
implementation('com.dji:dji-sdk:4.15.1', {
implementation('com.dji:dji-sdk:4.16', {
/**
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
Expand All @@ -86,7 +87,7 @@ dependencies {
exclude module: 'library-anti-distortion'
//exclude module: 'fly-safe-database'
})
compileOnly 'com.dji:dji-sdk-provided:4.15.1'
compileOnly 'com.dji:dji-sdk-provided:4.16'

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.core:core:1.0.0'
Expand All @@ -101,6 +102,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
implementation 'com.google.android.gms:play-services:11.8.0'

implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.1'
implementation 'androidx.lifecycle:lifecycle-runtime:2.3.1'
Expand All @@ -109,4 +111,8 @@ dependencies {

implementation 'com.google.guava:guava:29.0-android'
implementation 'org.apache.commons:commons-math3:3.6.1'

implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
}
5 changes: 5 additions & 0 deletions Sample Code/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
android:configChanges="orientation|screenSize"
android:screenOrientation="landscape"/>

<activity
android:name="com.dji.sdk.sample.demo.payload.PayloadWidgetActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="landscape"/>

<activity android:name=".demo.utmiss.UTMISSActivity" />
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
package com.dji.sdk.sample.demo.camera;

import android.app.Service;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.dji.sdk.sample.R;
import com.dji.sdk.sample.demo.camera.adapter.MediaFileRecyclerAdapter;
import com.dji.sdk.sample.internal.controller.DJISampleApplication;
import com.dji.sdk.sample.internal.utils.DownloadHandler;
import com.dji.sdk.sample.internal.utils.ModuleVerificationUtil;
Expand All @@ -21,10 +34,19 @@
import dji.common.camera.SettingsDefinitions;
import dji.common.error.DJIError;
import dji.common.util.CommonCallbacks;
import dji.sdk.media.order.MediaFilter;
import dji.sdk.media.order.MediaOrderType;
import dji.sdk.media.order.MediaRequest;
import dji.sdk.media.order.MediaSizeOrder;
import dji.sdk.media.order.MediaTimeOrder;


import java.util.List;

/**
* Class for fetching the media.
*
* 更多功能请参考:https://github.com/DJI-Mobile-SDK-Tutorials/Android-MediaManagerDemo
*/
public class FetchMediaView extends BaseThreeBtnView {

Expand All @@ -33,6 +55,17 @@ public class FetchMediaView extends BaseThreeBtnView {
private FetchMediaTaskScheduler taskScheduler;
private FetchMediaTask.Callback fetchMediaFileTaskCallback;

private SwipeRefreshLayout mSwipeRefreshLayout;
private RecyclerView mRecycler;
private MediaFileRecyclerAdapter mAdapter;
private LinearLayoutManager mLinearLayoutManager;
private int mLastVisibleItem;

private static int mFileBeginIndex = 1;
private static final int FILE_PAGE_COUNT = 100;
private Handler mHandler = new Handler(Looper.getMainLooper());


public FetchMediaView(Context context) {
super(context);
}
Expand Down Expand Up @@ -62,7 +95,22 @@ public void onResult(DJIError djiError) {
});
}
}
if (DJISampleApplication.getProductInstance()
.getCamera().isFlatCameraModeSupported()) {
DJISampleApplication.getProductInstance()
.getCamera().enterPlayback(djiError->{
if (djiError != null) {
ToastUtils.setResultToToast("enter Playback failed " + djiError.getDescription());
} else {
boolean isSupport = mediaManager.isPlaybackPageSupported();
Log.v("testPack" , " isSupport " + isSupport );
if (isSupport) {
post(()->{ addMedaiRequstFootView();});

}
}
});
} else {
DJISampleApplication.getProductInstance()
.getCamera()
.setMode(SettingsDefinitions.CameraMode.MEDIA_DOWNLOAD,
Expand All @@ -74,6 +122,7 @@ public void onResult(DJIError djiError) {
}
}
});
}
} else {
changeDescription(R.string.not_support_mediadownload);
}
Expand All @@ -91,6 +140,12 @@ protected void onDetachedFromWindow() {
if (taskScheduler != null) {
taskScheduler.suspend(null);
}
if (DJISampleApplication.getProductInstance()
.getCamera().isFlatCameraModeSupported()) {
DJISampleApplication.getProductInstance()
.getCamera().exitPlayback(null);
}
mFileBeginIndex = 1;
}

@Override
Expand Down Expand Up @@ -212,4 +267,83 @@ public void onResult(DJIError djiError) {
public int getDescription() {
return R.string.camera_listview_download_media;
}


private void addMedaiRequstFootView() {

LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(Service.LAYOUT_INFLATER_SERVICE);
View footview = layoutInflater.inflate(R.layout.media_recycler_layout, this, false);
addView(footview);

mSwipeRefreshLayout = (SwipeRefreshLayout)footview.findViewById(R.id.swiperefreshlayout);
mRecycler = (RecyclerView)footview.findViewById(R.id.recycler);
// mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(android.R.color.white);
// mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light);

mLinearLayoutManager = new LinearLayoutManager(getContext());
mLinearLayoutManager.setOrientation(RecyclerView.VERTICAL);
mRecycler.setLayoutManager(mLinearLayoutManager);

mRecycler.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
mRecycler.setAdapter(mAdapter = new MediaFileRecyclerAdapter(getContext()));
mSwipeRefreshLayout.setOnRefreshListener(()->{ mSwipeRefreshLayout.setRefreshing(false);});


getFileWithMediaRequest();

mRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE && mLastVisibleItem + 1 == mAdapter.getItemCount()) {
getFileWithMediaRequest();
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mLastVisibleItem = mLinearLayoutManager.findLastVisibleItemPosition();
}
});
}


private void getFileWithMediaRequest() {
mAdapter.changeLoadStatus(MediaFileRecyclerAdapter.LOADING);
MediaRequest.Builder builder = MediaRequest.Builder.aMediaRequest();
builder.beginIndex(mFileBeginIndex);
builder.count(FILE_PAGE_COUNT);
builder.filter(MediaFilter.NONE);
builder.location(SettingsDefinitions.StorageLocation.SDCARD);
builder.orderType(MediaOrderType.TIME);
builder.timeOrder(MediaTimeOrder.NEW);

mHandler.post(() -> {
mediaManager.fetchFileList(builder.build(), new CommonCallbacks.CompletionCallbackWith<List<MediaFile>>() {
@Override
public void onSuccess(List<MediaFile> mediaFiles) {
int count = mediaFiles != null ? mediaFiles.size():0;
if (count != 0 ) {
mFileBeginIndex = mediaFiles.get(count - 1).getIndex();
post(()->{
mAdapter.addMoreItem(mediaFiles);
mAdapter.changeLoadStatus(MediaFileRecyclerAdapter.PULL_UP_LOADMORE);
});
} else {
post(()->{mAdapter.changeLoadStatus(MediaFileRecyclerAdapter.LOAD_FINISH);});

}

}

@Override
public void onFailure(DJIError error) {
post(()->{ mAdapter.changeLoadStatus(MediaFileRecyclerAdapter.LOADING);});

}
});
});


}
}

0 comments on commit 378746a

Please sign in to comment.