我想为此代码绘制一个类图。
我正在使用Android Studio开展项目。我试过了,但我不确定我是否做得正确。这是STT的Activity类代码
我选择了我不确定的部分:
public class VoiceMain_Activity extends Activity {
//
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** Called TedPermission **/
PermissionListener permissionlistener = new PermissionListener() {
@Override
public void onPermissionGranted() {
Toast.makeText(VoiceMain_Activity.this, "granted", Toast.LENGTH_SHORT).show();
run();
}
@Override
public void onPermissionDenied(ArrayList<String> deniedPermissions) {
Toast.makeText(VoiceMain_Activity.this, "denined\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT)
.show();
}
};
TedPermission.with(this)
.setPermissionListener(permissionlistener)
.setRationaleTitle(R.string.rationale_title)
.setRationaleMessage(R.string.rationale_message)
.setDeniedTitle("denied")
.setDeniedMessage(
" on/off .")
.setGotoSettingButtonText("Setting")
.setPermissions(Manifest.permission.RECORD_AUDIO, Manifest.permission.INTERNET)
.check();
}
private RecognitionListener listener = new RecognitionListener() {
@Override public void onRmsChanged(float rmsdB) {
int step = (int)(rmsdB/7);
setVolumeImg(step);
}
@Override public void onResults(Bundle results) {
mHandler.removeMessages(END);
Intent i = new Intent();
i.putExtras(results);
setResult(RESULT_OK, i);
finish();
}
@Override public void onReadyForSpeech(Bundle params) {
mHandler.sendEmptyMessage(READY);
}
@Override public void onEndOfSpeech() {
mHandler.sendEmptyMessage(END);
}
@Override public void onError(int error) {
setResult(error);
}
@Override public void onBeginningOfSpeech() {}
@Override public void onPartialResults(Bundle partialResults) {}
@Override public void onEvent(int eventType, Bundle params) {}
@Override public void onBufferReceived(byte[] buffer) {}
};
这是图像 class diagram 不确定我是否正确地绘制了这3个部分
private RecognitionListener listener = new RecognitionListener()
public void onPermissionGranted()
public void onPermissionGranted()