Skip to content

Commit

Permalink
Remove ButterKnife
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesa2 committed Aug 16, 2022
1 parent 5c988ab commit 1553df7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 61 deletions.
6 changes: 4 additions & 2 deletions SampleCode/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ android {
}
}

buildFeatures {
viewBinding = true
}

buildTypes {
release {
shrinkResources false
Expand Down Expand Up @@ -94,8 +98,6 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation "androidx.core:core-ktx:1.8.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.dji.sdk.sample.R;
import com.dji.sdk.sample.databinding.ActivityUtmissBinding;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import dji.common.error.DJIError;
import dji.sdk.utmiss.UTMISSFlightDataUploadStatus;
import dji.sdk.utmiss.UTMISSManager;
Expand All @@ -26,30 +20,30 @@

public class UTMISSActivity extends AppCompatActivity {

@BindView(R.id.txt_db_path)
TextView mTvDbPath;
@BindView(R.id.txt_status)
TextView mTvStatus;
@BindView(R.id.txt_info)
TextView mTvInfo;

@BindView(R.id.edt_token_key)
EditText mEdtTokenKey;
@BindView(R.id.edt_manufactureId)
EditText mEdtManufactureId;
@BindView(R.id.edt_uasId)
EditText mEdtUasId;

@BindView(R.id.btn_start)
Button mBtnInit;

String dbPath;

private ActivityUtmissBinding binding;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_utmiss);
ButterKnife.bind(this);
binding = ActivityUtmissBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);

binding.btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
start();
}
});

binding.btnStop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stop();
}
});
init();
}

Expand All @@ -64,51 +58,35 @@ private void init() {
showToast("dbPath dir create failed!");
}
}
mTvDbPath.setText(String.format("db path->%s\nlog path->%s", dbPath, UTMISSManager.getInstance().getUtmissLogPath()));
mEdtManufactureId.setText("test");
mEdtUasId.setText("UAS-DEFAULT");
binding.txtDbPath.setText(String.format("db path->%s\nlog path->%s", dbPath, UTMISSManager.getInstance().getUtmissLogPath()));
binding.edtManufactureId.setText("test");
binding.edtUasId.setText("UAS-DEFAULT");
UTMISSFlightDataUploadStatus uploadStatus = UTMISSManager.getInstance().getUploadStatus();
mTvStatus.setText(String.format("current status is %s", uploadStatus.toString()));
binding.txtStatus.setText(String.format("current status is %s", uploadStatus.toString()));
if (uploadStatus != UTMISSFlightDataUploadStatus.UNKNOWN) {
changeUI();
}
}


@OnClick({R.id.btn_start, R.id.btn_stop})
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_start:
start();
break;
case R.id.btn_stop:
stop();
break;
default:
throw new IllegalArgumentException("some btn click not implementation!");
}
}

private void stop() {
UTMISSManager.getInstance().stopToUpload();
changeInitBtnState(true);
}


private void start() {
String tokenKey = mEdtTokenKey.getText().toString().trim();
String tokenKey = binding.edtTokenKey.getText().toString().trim();
if (TextUtils.isEmpty(tokenKey)) {
showToast("pls enter token key first");
return;
}

String manufactureId = mEdtManufactureId.getText().toString().trim();
String manufactureId = binding.edtManufactureId.getText().toString().trim();
if (TextUtils.isEmpty(manufactureId)) {
showToast("pls enter manufactureId first");
return;
}

String uasId = mEdtManufactureId.getText().toString().trim();
String uasId = binding.edtManufactureId.getText().toString().trim();
if (TextUtils.isEmpty(uasId)) {
showToast("pls enter uasId first");
return;
Expand All @@ -125,18 +103,15 @@ private void start() {

private void changeUI() {
changeInitBtnState(false);
UTMISSManager.getInstance().setUTMISSFlightDataUpdatedUploadStatusCallback(status -> mTvStatus.setText(String.format("current status is %s", status.toString())));
UTMISSManager.getInstance().setUTMISSFlightDataUpdatedUploadStatusCallback(status -> binding.txtStatus.setText(String.format("current status is %s", status.toString())));
}

private void changeInitBtnState(boolean enable) {
mTvInfo.setVisibility(enable ? View.GONE : View.VISIBLE);
mBtnInit.setEnabled(enable);
mEdtTokenKey.setEnabled(enable);
mEdtManufactureId.setEnabled(enable);
mEdtUasId.setEnabled(enable);
binding.txtInfo.setVisibility(enable ? View.GONE : View.VISIBLE);
binding.btnStart.setEnabled(enable);
binding.edtTokenKey.setEnabled(enable);
binding.edtManufactureId.setEnabled(enable);
binding.edtUasId.setEnabled(enable);
}




}
}

0 comments on commit 1553df7

Please sign in to comment.