-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1199 from dji-sdk/sdk_releases/4.16.4
Sdk releases/4.16.4
- Loading branch information
Showing
7 changed files
with
161 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
Sample Code/app/src/main/java/com/dji/sdk/sample/demo/rid/UASView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.dji.sdk.sample.demo.rid; | ||
|
||
import android.app.Service; | ||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import com.dji.sdk.sample.R; | ||
import com.dji.sdk.sample.internal.utils.Helper; | ||
import com.dji.sdk.sample.internal.utils.PopupUtils; | ||
import com.dji.sdk.sample.internal.view.PresentableView; | ||
|
||
import androidx.annotation.NonNull; | ||
import dji.sdk.sdkmanager.DJISDKManager; | ||
import dji.sdk.uas.AreaCode; | ||
import dji.sdk.uas.UASRemoteIDStatus; | ||
import dji.sdk.uas.UASRemoteIDStatusListener; | ||
|
||
import static com.google.android.gms.internal.zzahn.runOnUiThread; | ||
|
||
public class UASView extends LinearLayout implements View.OnClickListener, PresentableView { | ||
|
||
Button changeUasCountryBtn; | ||
TextView uasInfoTV; | ||
|
||
private final UASRemoteIDStatusListener uasRemoteIDStatusListener = new UASRemoteIDStatusListener() { | ||
@Override | ||
public void onUpdate(UASRemoteIDStatus uasRemoteIDStatus) { | ||
runOnUiThread(()-> uasInfoTV.setText(uasRemoteIDStatus.toString())); | ||
} | ||
}; | ||
|
||
public UASView(Context context) { | ||
super(context); | ||
setOrientation(LinearLayout.HORIZONTAL); | ||
setClickable(true); | ||
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE); | ||
layoutInflater.inflate(R.layout.view_uas, this, true); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
|
||
} | ||
|
||
private void initUI() { | ||
changeUasCountryBtn = findViewById(R.id.btn_change_uas_country); | ||
uasInfoTV = findViewById(R.id.tv_uas_info); | ||
initOnclickListener(); | ||
} | ||
|
||
private void initOnclickListener() { | ||
changeUasCountryBtn.setOnClickListener(this); | ||
} | ||
|
||
@Override | ||
protected void onAttachedToWindow() { | ||
super.onAttachedToWindow(); | ||
initUI(); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
if (v != null) { | ||
switch (v.getId()) { | ||
case R.id.btn_change_uas_country: | ||
changeUasCountry(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void changeUasCountry() { | ||
final AreaCode[] areaCodes = AreaCode.values(); | ||
final Runnable r = () -> { | ||
DJISDKManager.getInstance().getUasRemoteIDManager().setAreaCode(areaCodes[PopupUtils.INSTANCE.getIndex()[0]]); | ||
initUasListener(); | ||
PopupUtils.INSTANCE.resetIndex(); | ||
}; | ||
PopupUtils.INSTANCE.initPopupNumberPicker(Helper.makeList(areaCodes), r,this); | ||
} | ||
|
||
private void initUasListener() { | ||
uasInfoTV.setText(""); | ||
DJISDKManager.getInstance().getUasRemoteIDManager().addUASRemoteIDStatusListener(uasRemoteIDStatusListener); | ||
} | ||
|
||
@Override | ||
public int getDescription() { | ||
return R.string.uas_view; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getHint() { | ||
return this.getClass().getSimpleName() + ".java"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<merge xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/btn_change_uas_country" | ||
style="@style/common_button" | ||
android:layout_alignParentLeft="true" | ||
android:layout_marginLeft="5dp" | ||
android:layout_marginTop="20dp" | ||
android:text="Change UAS Country" /> | ||
</LinearLayout> | ||
|
||
<ScrollView | ||
android:layout_width="250dp" | ||
android:layout_height="200dp" | ||
android:layout_alignParentRight="true" | ||
android:layout_marginLeft="5dp" | ||
android:layout_marginTop="10dp" | ||
android:layout_marginRight="5dp" | ||
android:scrollbars="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/tv_uas_info" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:scrollbars="vertical" | ||
android:textColor="@color/black" /> | ||
</ScrollView> | ||
|
||
</LinearLayout> | ||
|
||
</merge> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters