mindsporeInHand 1.2.8 verson add dance
mindsporeInHand 1.2.8 verson add dance version 1.2.8 delete some codes
|
|
@ -1,2 +1,4 @@
|
|||
/build
|
||||
/src/main/cpp/mindspore-lite-1.0.0-minddata-arm64-cpu/
|
||||
/release/
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ android {
|
|||
applicationId "com.mindspore.himindspore"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 14
|
||||
versionName "1.2.7"
|
||||
versionCode 15
|
||||
versionName "1.2.8"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
|
|
@ -80,4 +80,5 @@ dependencies {
|
|||
implementation project(':imageObject')
|
||||
implementation project(':styletransfer')
|
||||
implementation project(':hms')
|
||||
implementation project(':dance')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,51 +29,6 @@
|
|||
android:name=".ui.webview.WebViewUtilsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegeReferencevideoActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegeBrokensideActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegePerformReasoningActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegeTrainingmodelActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegeForumActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegeFAQActivity"
|
||||
android:hardwareAccelerated="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.CollegeOneHourActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.MeThumbsupActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.MeOfficialwebsiteActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.MeCodeRepositoryActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.webview.MeProblemFeedbackActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.me.MyQRCodeActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package com.mindspore.himindspore.ui.college;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
|
@ -31,12 +32,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.common.sp.Preferences;
|
||||
import com.mindspore.common.utils.Utils;
|
||||
import com.mindspore.customview.dialog.NoticeDialog;
|
||||
import com.mindspore.himindspore.R;
|
||||
import com.mindspore.himindspore.ui.college.adapter.CollegeItemAdapter;
|
||||
import com.mindspore.himindspore.ui.college.bean.CollegeItemBean;
|
||||
import com.mindspore.himindspore.ui.webview.WebViewUtilsActivity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -140,19 +143,19 @@ public class CollegeFragment extends Fragment implements CollegeItemAdapter.Coll
|
|||
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_CLOUD, true).apply();
|
||||
collegeDataList.get(1).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_CLOUD, false));
|
||||
collegeItemAdapter.notifyData();
|
||||
ARouter.getInstance().build("/app/CollegeOneHourActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_MAIN_CLOUD));
|
||||
break;
|
||||
case 3:
|
||||
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_FAQ, true).apply();
|
||||
collegeDataList.get(3).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_FAQ, false));
|
||||
collegeItemAdapter.notifyData();
|
||||
ARouter.getInstance().build("/app/CollegeFAQActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_MAIN_FAQ));
|
||||
break;
|
||||
case 4:
|
||||
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_ASK, true).apply();
|
||||
collegeDataList.get(4).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_ASK, false));
|
||||
collegeItemAdapter.notifyData();
|
||||
ARouter.getInstance().build("/app/CollegeForumActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_MAIN_ASK));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -168,13 +171,13 @@ public class CollegeFragment extends Fragment implements CollegeItemAdapter.Coll
|
|||
collegeDataList.get(2).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_QUICK, false));
|
||||
collegeItemAdapter.notifyData();
|
||||
if (position == 0) {
|
||||
ARouter.getInstance().build("/app/CollegeTrainingmodelActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_QUICK_TRAIN));
|
||||
} else if (position == 1) {
|
||||
ARouter.getInstance().build("/app/CollegePerformReasoningActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_QUICK_EXECUTE));
|
||||
} else if (position == 2) {
|
||||
ARouter.getInstance().build("/app/CollegeBrokensideActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_QUICK_APP));
|
||||
} else if (position == 3) {
|
||||
ARouter.getInstance().build("/app/CollegeReferencevideoActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.COLLEGE_QUICK_VIDEO));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ public class VisionFragment extends Fragment implements View.OnClickListener {
|
|||
view.findViewById(R.id.btn_style_transfer).setOnClickListener(this); //onClickStyleTransfer
|
||||
view.findViewById(R.id.btn_segmentation).setOnClickListener(this); //onClickSegmentation
|
||||
view.findViewById(R.id.btn_image).setOnClickListener(this); //onClickImage
|
||||
view.findViewById(R.id.btn_scene).setOnClickListener(this); //onClickSceneDetection
|
||||
view.findViewById(R.id.btn_dance).setOnClickListener(this); //onClickSceneDetection
|
||||
view.findViewById(R.id.btn_image_Intelligent_poetry).setOnClickListener(this); //onClickIntelligentPoetry
|
||||
view.findViewById(R.id.btn_text_recognition).setOnClickListener(this); //onClickTextRecognition
|
||||
view.findViewById(R.id.btn_gesture).setOnClickListener(this); //onClickGestureRecognition
|
||||
|
|
@ -94,15 +94,13 @@ public class VisionFragment extends Fragment implements View.OnClickListener {
|
|||
ARouter.getInstance().build("/styletransfer/StyleMainActivity").navigation();
|
||||
break;
|
||||
case R.id.btn_segmentation:
|
||||
ARouter.getInstance().build("/hms/PortraitSegmentationActivity").navigation();
|
||||
// ARouter.getInstance().build("/hms/ImageSegmentationLiveAnalyseActivity").navigation();
|
||||
// ARouter.getInstance().build("/hms/ImageSegmentationActivity").navigation();
|
||||
ARouter.getInstance().build("/hms/ImageSegmentationLiveAnalyseActivity").navigation();
|
||||
break;
|
||||
case R.id.btn_image:
|
||||
ARouter.getInstance().build("/imageobject/ImageCameraActivity").navigation();
|
||||
break;
|
||||
case R.id.btn_scene:
|
||||
ARouter.getInstance().build("/hms/SenceDetectionStillAnalyseActivity").navigation();
|
||||
case R.id.btn_dance:
|
||||
ARouter.getInstance().build("/dance/DanceMainActivity").navigation();
|
||||
break;
|
||||
case R.id.btn_image_Intelligent_poetry:
|
||||
ARouter.getInstance().build("/app/IntelligentPoetryWritingActivity").navigation();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import com.mindspore.common.sp.Preferences;
|
|||
import com.mindspore.common.utils.Utils;
|
||||
import com.mindspore.customview.countdown.MSCountDownView;
|
||||
import com.mindspore.himindspore.R;
|
||||
import com.mindspore.himindspore.base.BaseActivity;
|
||||
import com.mindspore.common.base.mvp.BaseActivity;
|
||||
import com.mindspore.himindspore.ui.main.MainActivity;
|
||||
import com.mindspore.himindspore.ui.main.PrivacyPolicyActivity;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,17 +38,17 @@ import com.google.android.material.tabs.TabLayout;
|
|||
import com.mindspore.common.base.adapter.BasePagerAdapter;
|
||||
import com.mindspore.customview.dialog.UpdateDialog;
|
||||
import com.mindspore.himindspore.R;
|
||||
import com.mindspore.himindspore.base.BaseActivity;
|
||||
import com.mindspore.common.base.mvp.BaseActivity;
|
||||
import com.mindspore.himindspore.comment.FragmentFactory;
|
||||
import com.mindspore.himindspore.net.FileDownLoadObserver;
|
||||
import com.mindspore.himindspore.net.UpdateInfoBean;
|
||||
import com.mindspore.common.net.FileDownLoadObserver;
|
||||
import com.mindspore.common.net.UpdateInfoBean;
|
||||
import com.mindspore.himindspore.ui.view.MSTabEntity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View {
|
||||
public class MainActivity extends BaseActivity<MainActivityPresenter> implements MainContract.View {
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
private ViewPager mVpHome;
|
||||
|
|
@ -61,7 +61,7 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
|
|||
|
||||
@Override
|
||||
protected void init() {
|
||||
presenter = new MainPresenter(this);
|
||||
presenter = new MainActivityPresenter(this);
|
||||
mVpHome = findViewById(R.id.vp_home);
|
||||
mTabLayout = findViewById(R.id.tab_layout);
|
||||
showPackaeInfo();
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ package com.mindspore.himindspore.ui.main;
|
|||
import android.content.res.TypedArray;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mindspore.common.base.mvp.BaseActivityPresenter;
|
||||
import com.mindspore.common.utils.Utils;
|
||||
import com.mindspore.himindspore.R;
|
||||
import com.mindspore.himindspore.base.BasePresenter;
|
||||
import com.mindspore.himindspore.bean.TabEntity;
|
||||
import com.mindspore.himindspore.net.FileDownLoadObserver;
|
||||
import com.mindspore.himindspore.net.RetrofitHelper;
|
||||
import com.mindspore.himindspore.net.UpdateInfoBean;
|
||||
import com.mindspore.common.net.FileDownLoadObserver;
|
||||
import com.mindspore.common.net.RetrofitHelper;
|
||||
import com.mindspore.common.net.UpdateInfoBean;
|
||||
import com.mindspore.himindspore.ui.view.MSTabEntity;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -37,14 +37,14 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class MainPresenter extends BasePresenter<MainActivity> implements MainContract.Presenter {
|
||||
public class MainActivityPresenter extends BaseActivityPresenter<MainActivity> implements MainContract.Presenter {
|
||||
|
||||
private static final String TAG = "MainPresenter";
|
||||
private static final String TAG = "MainActivityPresenter";
|
||||
|
||||
private MainContract.View mView;
|
||||
private RetrofitHelper retrofitHelper;
|
||||
|
||||
public MainPresenter(MainContract.View androidView) {
|
||||
public MainActivityPresenter(MainContract.View androidView) {
|
||||
this.mView = androidView;
|
||||
retrofitHelper = new RetrofitHelper();
|
||||
}
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package com.mindspore.himindspore.ui.main;
|
||||
|
||||
import com.mindspore.himindspore.net.FileDownLoadObserver;
|
||||
import com.mindspore.himindspore.net.UpdateInfoBean;
|
||||
import com.mindspore.common.net.FileDownLoadObserver;
|
||||
import com.mindspore.common.net.UpdateInfoBean;
|
||||
import com.mindspore.himindspore.ui.view.MSTabEntity;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import androidx.fragment.app.Fragment;
|
|||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
import com.mindspore.himindspore.ui.webview.WebViewUtilsActivity;
|
||||
|
||||
public class MeFragment extends Fragment implements View.OnClickListener {
|
||||
|
||||
|
|
@ -88,16 +89,16 @@ public class MeFragment extends Fragment implements View.OnClickListener {
|
|||
onClickShare();
|
||||
break;
|
||||
case R.id.rl_me_thumbsup:
|
||||
ARouter.getInstance().build("/app/MeThumbsupActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.ME_STAR_URL));
|
||||
break;
|
||||
case R.id.rl_me_official:
|
||||
ARouter.getInstance().build("/app/MeOfficialwebsiteActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.BASE_URL));
|
||||
break;
|
||||
case R.id.rl_me_official_code:
|
||||
ARouter.getInstance().build("/app/MeCodeRepositoryActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.ME_CODE_URL));
|
||||
break;
|
||||
case R.id.rl_me_qa:
|
||||
ARouter.getInstance().build("/app/MeProblemFeedbackActivity").navigation();
|
||||
startActivity(new Intent(getActivity(), WebViewUtilsActivity.class).putExtra("WebView", MSLinkUtils.ME_HELP_URL));
|
||||
break;
|
||||
case R.id.me_user_protocol:
|
||||
ARouter.getInstance().build("/app/PrivacyPolicyActivity").navigation();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.mindspore.himindspore.ui.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
public class IconButtonStyleView extends RelativeLayout {
|
||||
|
||||
private RelativeLayout mBtnView;
|
||||
private ImageView mBtnImage;
|
||||
private TextView mBtnTextName, mBtnTextAngle;
|
||||
private CharSequence text_name, text_angle;
|
||||
private Drawable btn_icon;
|
||||
|
||||
public IconButtonStyleView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public IconButtonStyleView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
TypedArray btnStyle = context.obtainStyledAttributes(attrs, R.styleable.iconButtonStyle);
|
||||
btn_icon = btnStyle.getDrawable(R.styleable.iconButtonStyle_buttonImage);
|
||||
text_name = btnStyle.getText(R.styleable.iconButtonStyle_buttonTextName);
|
||||
text_angle = btnStyle.getText(R.styleable.iconButtonStyle_buttonTextAngle);
|
||||
|
||||
btnStyle.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mBtnView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.button_style_layout, this, true);
|
||||
|
||||
mBtnImage = mBtnView.findViewById(R.id.btnImage);
|
||||
mBtnTextName = mBtnView.findViewById(R.id.textName);
|
||||
mBtnTextAngle = mBtnView.findViewById(R.id.textAngle);
|
||||
|
||||
mBtnImage.setImageDrawable(btn_icon);
|
||||
mBtnTextName.setText(text_name);
|
||||
mBtnTextAngle.setText(text_angle);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.mindspore.himindspore.ui.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
public class LeftImageRightTextButton extends RelativeLayout {
|
||||
|
||||
public LeftImageRightTextButton(Context context)
|
||||
{
|
||||
super(context, null);
|
||||
}
|
||||
|
||||
public LeftImageRightTextButton(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater.from(context).inflate(R.layout.btn_left_iamge_right_text, this,true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.mindspore.himindspore.ui.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
public class MyButton extends RelativeLayout {
|
||||
|
||||
public MyButton(Context context)
|
||||
{
|
||||
super(context, null);
|
||||
}
|
||||
|
||||
public MyButton(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater.from(context).inflate(R.layout.my_button, this,true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
|
||||
@Route(path = "/app/CollegeBrokensideActivity")
|
||||
public class CollegeBrokensideActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_brokenside);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.brokenside_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
WebSettings wSet = mWebView.getSettings();
|
||||
wSet.setJavaScriptEnabled(true);
|
||||
wSet.setDomStorageEnabled(true);
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_QUICK_APP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/CollegeFAQActivity")
|
||||
public class CollegeFAQActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_f_a_q);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.CollegeFAQActivity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebChromeClient(new WebChromeClient());
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_MAIN_FAQ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/CollegeForumActivity")
|
||||
public class CollegeForumActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_forum);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.CollegeForumActivity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebChromeClient(new WebChromeClient());
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_MAIN_ASK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/CollegeOneHourActivity")
|
||||
public class CollegeOneHourActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_one_hour);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.OneHour_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebChromeClient(new WebChromeClient());
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_MAIN_CLOUD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/CollegePerformReasoningActivity")
|
||||
public class CollegePerformReasoningActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_perform_reasoning);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.perform_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebChromeClient(new WebChromeClient());
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient(){
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if(newProgress==100){
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else{
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_QUICK_EXECUTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/CollegeReferencevideoActivity")
|
||||
public class CollegeReferencevideoActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_referencevideo);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.referencevideo_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebChromeClient(new WebChromeClient());
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_QUICK_VIDEO);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/CollegeTrainingmodelActivity")
|
||||
public class CollegeTrainingmodelActivity extends AppCompatActivity {
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_college_trainingmodel);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.Trainingmodel_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebChromeClient(new WebChromeClient());
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
cookieManager.setAcceptThirdPartyCookies(mWebView, true);
|
||||
mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.COLLEGE_QUICK_TRAIN);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/MeCodeRepositoryActivity")
|
||||
public class MeCodeRepositoryActivity extends AppCompatActivity {
|
||||
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_me_code_repository);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.MeCodeRepositoryActivity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
WebSettings wSet = mWebView.getSettings();
|
||||
wSet.setJavaScriptEnabled(true);
|
||||
wSet.setDomStorageEnabled(true);
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.ME_CODE_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/MeOfficialwebsiteActivity")
|
||||
public class MeOfficialwebsiteActivity extends AppCompatActivity {
|
||||
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_me_officialwebsite);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.MeOfficialwebsiteActivity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
WebSettings wSet = mWebView.getSettings();
|
||||
wSet.setJavaScriptEnabled(true);
|
||||
wSet.setDomStorageEnabled(true);
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.BASE_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/MeProblemFeedbackActivity")
|
||||
public class MeProblemFeedbackActivity extends AppCompatActivity {
|
||||
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_me_problem_feedback);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.MeProblemFeedbackActivity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
WebSettings wSet = mWebView.getSettings();
|
||||
wSet.setJavaScriptEnabled(true);
|
||||
wSet.setDomStorageEnabled(true);
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.ME_HELP_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.ui.webview;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
@Route(path = "/app/MeThumbsupActivity")
|
||||
public class MeThumbsupActivity extends AppCompatActivity {
|
||||
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_me_thumbsup);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.MeThumbsupActivity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
WebSettings wSet = mWebView.getSettings();
|
||||
wSet.setJavaScriptEnabled(true);
|
||||
wSet.setDomStorageEnabled(true);
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(MSLinkUtils.ME_STAR_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mWebView.removeAllViews();
|
||||
mWebView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -27,40 +27,39 @@ import android.widget.ProgressBar;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.mindspore.common.config.MSLinkUtils;
|
||||
import com.mindspore.himindspore.R;
|
||||
|
||||
public class WebViewUtilsActivity extends AppCompatActivity {
|
||||
|
||||
private WebView mWebView;
|
||||
private ProgressBar progressBar;
|
||||
private final String mWebViewUtil = "";
|
||||
private Toolbar mToolbar;
|
||||
private String mWebViewUrl;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_web_view_utils);
|
||||
mWebViewUrl = getIntent().getStringExtra("WebView");
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
String mMeThumbsup = getIntent().getStringExtra("MeThumbsup");
|
||||
String mMeOfficial = getIntent().getStringExtra("MeOfficial");
|
||||
String mMeCodeRepository = getIntent().getStringExtra("MeCodeRepository");
|
||||
String mMeProblemFeedback = getIntent().getStringExtra("MeProblemFeedback");
|
||||
progressBar = findViewById(R.id.progress);
|
||||
Toolbar mToolbar = findViewById(R.id.OneHour_toolbar);
|
||||
mToolbar = findViewById(R.id.mWebView_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
mWebView = findViewById(R.id.mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.setWebChromeClient(new WebChromeClient(){
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if(newProgress==100){
|
||||
|
||||
if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(newProgress);
|
||||
}
|
||||
|
|
@ -69,6 +68,52 @@ public class WebViewUtilsActivity extends AppCompatActivity {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
showWebViewTitle(mWebViewUrl);
|
||||
mWebView.loadUrl(mWebViewUrl);
|
||||
}
|
||||
|
||||
private void showWebViewTitle(String mWebViewUrl) {
|
||||
switch (mWebViewUrl) {
|
||||
case MSLinkUtils.ME_STAR_URL:
|
||||
mToolbar.setTitle(R.string.me_up_title);
|
||||
break;
|
||||
case MSLinkUtils.BASE_URL:
|
||||
mToolbar.setTitle(R.string.me_official_title);
|
||||
break;
|
||||
case MSLinkUtils.ME_CODE_URL:
|
||||
mToolbar.setTitle(R.string.me_official_code_title);
|
||||
break;
|
||||
case MSLinkUtils.ME_HELP_URL:
|
||||
mToolbar.setTitle(R.string.me_qa_title);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_QUICK_APP:
|
||||
mToolbar.setTitle(R.string.title_college_broken_side);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_MAIN_FAQ:
|
||||
mToolbar.setTitle(R.string.title_college_faq);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_MAIN_ASK:
|
||||
mToolbar.setTitle(R.string.title_college_forum);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_MAIN_CLOUD:
|
||||
mToolbar.setTitle(R.string.title_college_one_hour);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_QUICK_EXECUTE:
|
||||
mToolbar.setTitle(R.string.title_college_perform);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_QUICK_VIDEO:
|
||||
mToolbar.setTitle(R.string.title_college_video);
|
||||
break;
|
||||
case MSLinkUtils.COLLEGE_QUICK_TRAIN:
|
||||
mToolbar.setTitle(R.string.title_college_training);
|
||||
break;
|
||||
case MSLinkUtils.USER_PRIVACY_RULES:
|
||||
mToolbar.setTitle(R.string.me_user_agreements);
|
||||
break;
|
||||
default:
|
||||
mToolbar.setTitle(R.string.me_official_title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
tools:context=".ui.webview.WebViewUtilsActivity">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/OneHour_toolbar"
|
||||
android:id="@+id/mWebView_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/white"
|
||||
|
|
@ -19,14 +19,19 @@
|
|||
app:navigationIcon="@drawable/icon_back"
|
||||
app:titleTextColor="@color/black" />
|
||||
|
||||
<View
|
||||
android:id="@+id/w_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dip"
|
||||
android:progressDrawable="@drawable/progressbar"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<WebView
|
||||
android:id="@+id/mWebView"
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/btn_intelligent_poetry" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_poetry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_toRightOf="@id/btn"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/title_intelligent_poetry"
|
||||
android:textColor="@color/text_black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_new"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:layout_toRightOf="@id/text_poetry"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/title_intelligent_poetry_new"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="7sp"
|
||||
android:textStyle="italic" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -4,30 +4,29 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn"
|
||||
android:id="@+id/btnImage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/btn_intelligent_poetry" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_poetry"
|
||||
android:id="@+id/textName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_toRightOf="@id/btn"
|
||||
android:layout_toRightOf="@id/btnImage"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/title_intelligent_poetry"
|
||||
android:textColor="@color/text_black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_new"
|
||||
android:id="@+id/textAngle"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:layout_toRightOf="@id/text_poetry"
|
||||
android:layout_toRightOf="@id/textName"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/title_intelligent_poetry_new"
|
||||
android:text="@string/title_button_text_angle"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="7sp"
|
||||
android:textStyle="italic" />
|
||||
|
|
@ -163,8 +163,8 @@
|
|||
app:layout_constraintWidth_percent="0.44" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_scene"
|
||||
<com.mindspore.himindspore.ui.view.IconButtonStyleView
|
||||
android:id="@+id/btn_dance"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/btn_vision_item"
|
||||
|
|
@ -172,11 +172,13 @@
|
|||
android:gravity="left|center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="4dp"
|
||||
android:text="@string/title_scene"
|
||||
android:text="@string/title_dance"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/text_black"
|
||||
android:textSize="12sp"
|
||||
app:drawableStartCompat="@drawable/btn_scene"
|
||||
app:buttonImage="@drawable/btn_scene"
|
||||
app:buttonTextName="@string/title_dance"
|
||||
app:buttonTextAngle="@string/title_button_text_angle"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btn_gesture"
|
||||
app:layout_constraintEnd_toEndOf="@+id/btn_image"
|
||||
app:layout_constraintWidth_percent="0.44" />
|
||||
|
|
@ -232,7 +234,7 @@
|
|||
app:layout_constraintWidth_percent="0.44" />
|
||||
|
||||
|
||||
<com.mindspore.himindspore.ui.view.MyButton
|
||||
<com.mindspore.himindspore.ui.view.IconButtonStyleView
|
||||
android:id="@+id/btn_image_Intelligent_poetry"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
|
|
@ -244,6 +246,9 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="@color/text_black"
|
||||
android:textSize="12sp"
|
||||
app:buttonImage="@drawable/btn_intelligent_poetry"
|
||||
app:buttonTextName="@string/title_intelligent_poetry"
|
||||
app:buttonTextAngle="@string/title_button_text_angle"
|
||||
app:layout_constraintStart_toStartOf="@+id/title_vertical_line_two"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title_vertical_line_two"
|
||||
app:layout_constraintWidth_percent="0.44" />
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_intelligent_poter"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/btn_intelligent_poetry"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_poetry"
|
||||
android:layout_toRightOf="@id/image_intelligent_poter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/title_intelligent_poetry"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_black"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_toRightOf="@id/text_poetry"
|
||||
android:id="@+id/text_new"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="7sp"
|
||||
android:textColor="@color/text_red"
|
||||
android:text="@string/title_intelligent_poetry_new"
|
||||
android:textStyle="italic"
|
||||
/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
<string name="title_image">Image Classification</string>
|
||||
<string name="title_image_garbage">Garbage Classification</string>
|
||||
<string name="title_intelligent_poetry">Intelligent poetry</string>
|
||||
<string name="title_intelligent_poetry_new">NEW</string>
|
||||
<string name="title_button_text_angle">HOT</string>
|
||||
<string name="title_object">Object Detection(Photo)</string>
|
||||
<string name="title_object_camera">Object Detection(Real-time)</string>
|
||||
<string name="title_pose_net">PoseNet</string>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<string name="title_college_broken_side">Broken side application</string>
|
||||
<string name="title_college_video">Reference video</string>
|
||||
<string name="title_source">Code</string>
|
||||
<string name="title_scene">Scene Detection</string>
|
||||
<string name="title_dance">Dance Factory</string>
|
||||
<string name="title_help">FeedBack</string>
|
||||
<string name="title_star">Star</string>
|
||||
<string name="title_version">"Version: "</string>
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@
|
|||
<string name="title_image">图像分类</string>
|
||||
<string name="title_image_garbage">垃圾分类</string>
|
||||
<string name="title_intelligent_poetry">智能写诗</string>
|
||||
<string name="title_intelligent_poetry_new">NEW</string>
|
||||
<string name="title_button_text_angle">HOT</string>
|
||||
<string name="title_object">对象检测(图片)</string>
|
||||
<string name="title_object_camera">对象检测(实时)</string>
|
||||
<string name="title_pose_net"> 骨骼检测</string>
|
||||
<string name="title_style_transfer">风格迁移</string>
|
||||
<string name="title_segmentation">人像分割</string>
|
||||
<string name="title_source">代码</string>
|
||||
<string name="title_scene">场景检测</string>
|
||||
<string name="title_dance">舞蹈梦工厂</string>
|
||||
<string name="title_help">反馈</string>
|
||||
<string name="title_star">打星</string>
|
||||
<string name="title_version">版本号: </string>
|
||||
|
|
|
|||
|
|
@ -3,4 +3,10 @@
|
|||
<attr name="fullscreenBackgroundColor" format="color" />
|
||||
<attr name="fullscreenTextColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="iconButtonStyle">
|
||||
<attr name="buttonImage" format="reference"/>
|
||||
<attr name="buttonTextName" format="reference"/>
|
||||
<attr name="buttonTextAngle" format="reference"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<string name="title_image">Image Classification</string>
|
||||
<string name="title_image_garbage">Garbage Classification</string>
|
||||
<string name="title_intelligent_poetry">Intelligent poetry</string>
|
||||
<string name="title_intelligent_poetry_new">NEW</string>
|
||||
<string name="title_button_text_angle">HOT</string>
|
||||
<string name="title_object">Object Detection(Photo)</string>
|
||||
<string name="title_object_camera">Object Detection(Real-time)</string>
|
||||
<string name="title_pose_net">PoseNet</string>
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
<string name="title_college_broken_side">端侧应用</string>
|
||||
<string name="title_college_video">参考视频</string>
|
||||
<string name="title_source">Code</string>
|
||||
<string name="title_scene">Scene Detection</string>
|
||||
<string name="title_dance">Dance Factory</string>
|
||||
<string name="title_help">FeedBack</string>
|
||||
<string name="title_star">Star</string>
|
||||
<string name="title_version">Version: </string>
|
||||
|
|
|
|||
|
|
@ -34,4 +34,13 @@ dependencies {
|
|||
implementation 'com.google.android.material:material:1.2.1'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
|
||||
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
}
|
||||
|
|
@ -1,6 +1,20 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.base.adapter;
|
||||
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
@ -9,24 +23,17 @@ import androidx.fragment.app.FragmentPagerAdapter;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class BasePagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private List<?> mFragment;
|
||||
private List<String> mTitleList;
|
||||
|
||||
/**
|
||||
* 普通,主页使用
|
||||
*/
|
||||
|
||||
public BasePagerAdapter(FragmentManager fm, List<?> mFragment) {
|
||||
super(fm);
|
||||
this.mFragment = mFragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收首页传递的标题
|
||||
*/
|
||||
public BasePagerAdapter(FragmentManager fm, List<?> mFragment, List<String> mTitleList) {
|
||||
super(fm);
|
||||
this.mFragment = mFragment;
|
||||
|
|
@ -48,10 +55,6 @@ public class BasePagerAdapter extends FragmentPagerAdapter {
|
|||
super.destroyItem(container, position, object);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页显示title,每日推荐等..
|
||||
* 若有问题,移到对应单独页面
|
||||
*/
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
if (mTitleList != null) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.base.grid;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -13,13 +13,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.base;
|
||||
package com.mindspore.common.base.mvp;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public abstract class BaseActivity<T extends BasePresenter> extends AppCompatActivity {
|
||||
public abstract class BaseActivity<T extends BaseActivityPresenter> extends AppCompatActivity {
|
||||
|
||||
protected T presenter;
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.base.mvp;
|
||||
|
||||
public abstract class BaseActivityPresenter<T extends BaseActivity> {
|
||||
|
||||
protected T view;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.base.mvp;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class BaseFragment<T extends BaseFragmentPresenter> extends Fragment {
|
||||
protected T presenter;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -13,8 +13,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.base;
|
||||
package com.mindspore.common.base.mvp;
|
||||
|
||||
public class BaseFragmentPresenter <T extends BaseFragment>{
|
||||
|
||||
public abstract class BasePresenter<T extends BaseActivity> {
|
||||
protected T view;
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.net;
|
||||
package com.mindspore.common.net;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.net;
|
||||
package com.mindspore.common.net;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -57,4 +57,8 @@ public class RetrofitHelper {
|
|||
return retrofitService.downloadApk();
|
||||
}
|
||||
|
||||
public Observable<ResponseBody> downloadDanceVideo() {
|
||||
return retrofitService.downloadDanceVideo();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.net;
|
||||
package com.mindspore.common.net;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.ResponseBody;
|
||||
|
|
@ -29,4 +29,11 @@ public interface RetrofitService {
|
|||
@Streaming
|
||||
@GET("MindSpore_inhand.apk")
|
||||
Observable<ResponseBody> downloadApk();
|
||||
|
||||
@Streaming
|
||||
@GET("danceFactory/dance_factory_demo2.mp4")
|
||||
Observable<ResponseBody> downloadDanceVideo();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.himindspore.net;
|
||||
package com.mindspore.common.net;
|
||||
|
||||
public class UpdateInfoBean {
|
||||
|
||||
|
|
@ -1,3 +1,18 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.sp;
|
||||
|
||||
public final class Preferences {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.common.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
|
|
|||
|
|
@ -17,4 +17,6 @@
|
|||
<string name="image_camera_title">Image Classification</string>
|
||||
<string name="object_camery_title">Camera Detection</string>
|
||||
<string name="activity_photo_title">Photo Detection</string>
|
||||
<string name="image_save_success">Save Success</string>
|
||||
<string name="image_save_failed">Save Failed</string>
|
||||
</resources>
|
||||
|
|
@ -17,4 +17,7 @@
|
|||
<string name="object_camery_title">视频检测</string>
|
||||
<string name="activity_photo_title">照片检测</string>
|
||||
<string name="segmentation_toolbar_title">人像分割</string>
|
||||
<string name="image_save_success">保存成功</string>
|
||||
<string name="image_save_failed">保存失败</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -19,5 +19,8 @@
|
|||
<string name="posenet_activity_title">骨骼检测</string>
|
||||
<string name="style_transfer_title">风格迁移</string>
|
||||
<string name="segmentation_toolbar_title">人像分割</string>
|
||||
<string name="image_save_success">保存成功</string>
|
||||
<string name="image_save_failed">保存失败</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.2.2'
|
||||
implementation 'androidx.navigation:navigation-ui:2.2.2'
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
|
||||
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha05"
|
||||
|
||||
implementation 'com.alibaba:arouter-api:1.5.1'
|
||||
annotationProcessor 'com.alibaba:arouter-compiler:1.5.1'
|
||||
implementation project(path: ':common')
|
||||
|
||||
def camerax_version = "1.0.0-rc03"
|
||||
implementation "androidx.camera:camera-core:${camerax_version}"
|
||||
implementation "androidx.camera:camera-camera2:${camerax_version}"
|
||||
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
|
||||
implementation "androidx.camera:camera-view:1.0.0-alpha22"
|
||||
implementation "androidx.camera:camera-extensions:1.0.0-alpha22"
|
||||
implementation 'androidx.core:core:1.5.0-alpha05'
|
||||
implementation 'com.huawei.hms:ml-computer-vision-skeleton:2.0.4.300'
|
||||
implementation 'com.huawei.hms:ml-computer-vision-skeleton-model:2.0.4.300'
|
||||
implementation 'com.huawei.hms:ml-computer-vision-yoga-model:2.0.4.300'
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
|
||||
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mindspore.dance">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true">
|
||||
<activity
|
||||
android:name=".view.DanceActivity"
|
||||
android:label="@string/dance"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/Theme.MyApplication.NoActionBar" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.algorithm;
|
||||
|
||||
public class ModelDataBean {
|
||||
// RightElbow cos, RightWrist cos, LeftElbow cos, LeftWrist cos, LeftKnee cos, LeftAnkle cos
|
||||
private int id;
|
||||
private double sinRightElbow;
|
||||
private double sinRightWrist;
|
||||
private double sinLeftElbow;
|
||||
private double sinLeftWrist;
|
||||
private double sinLeftKnee;
|
||||
private double sinLeftAnkle;
|
||||
|
||||
private int rightElbowXY;
|
||||
private int rightWristXY;
|
||||
private int leftElbowXY;
|
||||
private int leftWristXY;
|
||||
private int leftKneeXY;
|
||||
private int leftAnkleXY;
|
||||
|
||||
public int getRightElbowXY() {
|
||||
return rightElbowXY;
|
||||
}
|
||||
|
||||
public ModelDataBean setRightElbowXY(int rightElbowXY) {
|
||||
this.rightElbowXY = rightElbowXY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getRightWristXY() {
|
||||
return rightWristXY;
|
||||
}
|
||||
|
||||
public ModelDataBean setRightWristXY(int rightWristXY) {
|
||||
this.rightWristXY = rightWristXY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getLeftElbowXY() {
|
||||
return leftElbowXY;
|
||||
}
|
||||
|
||||
public ModelDataBean setLeftElbowXY(int leftElbowXY) {
|
||||
this.leftElbowXY = leftElbowXY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getLeftWristXY() {
|
||||
return leftWristXY;
|
||||
}
|
||||
|
||||
public ModelDataBean setLeftWristXY(int leftWristXY) {
|
||||
this.leftWristXY = leftWristXY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getLeftKneeXY() {
|
||||
return leftKneeXY;
|
||||
}
|
||||
|
||||
public ModelDataBean setLeftKneeXY(int leftKneeXY) {
|
||||
this.leftKneeXY = leftKneeXY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getLeftAnkleXY() {
|
||||
return leftAnkleXY;
|
||||
}
|
||||
|
||||
public ModelDataBean setLeftAnkleXY(int leftAnkleXY) {
|
||||
this.leftAnkleXY = leftAnkleXY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModelDataBean() {
|
||||
}
|
||||
|
||||
public double getSinRightElbow() {
|
||||
return sinRightElbow;
|
||||
}
|
||||
|
||||
public ModelDataBean setSinRightElbow(double sinRightElbow) {
|
||||
this.sinRightElbow = sinRightElbow;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getSinRightWrist() {
|
||||
return sinRightWrist;
|
||||
}
|
||||
|
||||
public ModelDataBean setSinRightWrist(double sinRightWrist) {
|
||||
this.sinRightWrist = sinRightWrist;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getSinLeftElbow() {
|
||||
return sinLeftElbow;
|
||||
}
|
||||
|
||||
public ModelDataBean setSinLeftElbow(double sinLeftElbow) {
|
||||
this.sinLeftElbow = sinLeftElbow;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getSinLeftWrist() {
|
||||
return sinLeftWrist;
|
||||
}
|
||||
|
||||
public ModelDataBean setSinLeftWrist(double sinLeftWrist) {
|
||||
this.sinLeftWrist = sinLeftWrist;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getSinLeftKnee() {
|
||||
return sinLeftKnee;
|
||||
}
|
||||
|
||||
public ModelDataBean setSinLeftKnee(double sinLeftKnee) {
|
||||
this.sinLeftKnee = sinLeftKnee;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getSinLeftAnkle() {
|
||||
return sinLeftAnkle;
|
||||
}
|
||||
|
||||
public ModelDataBean setSinLeftAnkle(double sinLeftAnkle) {
|
||||
this.sinLeftAnkle = sinLeftAnkle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ModelDataBean setId(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.algorithm;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.huawei.hms.mlsdk.skeleton.MLSkeleton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_LEFT_ANKLE;
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_LEFT_ELBOW;
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_LEFT_KNEE;
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_LEFT_WRIST;
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_NECK;
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_RIGHT_ELBOW;
|
||||
import static com.huawei.hms.mlsdk.skeleton.MLJoint.TYPE_RIGHT_WRIST;
|
||||
|
||||
public class ModelDataUtils {
|
||||
public static final int NO_POINT = -2;
|
||||
public static final int NO_ACT = -1;
|
||||
|
||||
private static final String TAG = ModelDataUtils.class.getSimpleName();
|
||||
private static final double[] MODEL_DATA_ARRAY = new double[]{
|
||||
1, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
2, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
3, -0.447213595, -0.447213595, 0.5, -0.447213595, -0.948683298, -0.707106781,
|
||||
4, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
5, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
6, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
7, -0.447213595, -0.447213595, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
8, -0.447213595, -0.447213595, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
9, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
10, -0.447213595, -0.707106781, 0.5, 0.5, -0.948683298, -0.707106781,
|
||||
11, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
12, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
13, -0.707106781, -0.707106781, 0.5, -1, -1, -0.948683298,
|
||||
14, -0.707106781, -0.707106781, 0.5, -0.707106781, -1, -0.948683298,
|
||||
15, -0.707106781, -0.447213595, 0.5, -1, -1, -0.948683298,
|
||||
16, -0.707106781, -0.447213595, 0.5, -0.707106781, -1, -0.948683298,
|
||||
17, -0.707106781, -0.447213595, 0.5, -0.707106781, -1, -0.948683298,
|
||||
18, -0.447213595, -0.447213595, -0.707106781, -0.707106781, -0.948683298, -0.707106781,
|
||||
19, -0.707106781, -0.707106781, -0.894427191, -1, -0.948683298, -0.832050294,
|
||||
20, -0.447213595, -0.707106781, -0.707106781, -0.447213595, -0.948683298, -0.948683298,
|
||||
21, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
22, -0.316227766, -0.316227766, -0.371390676, -0.447213595, -0.948683298, -0.6,
|
||||
23, -0.447213595, -0.447213595, -0.196116135, -0.447213595, -0.948683298, -0.948683298,
|
||||
24, -0.447213595, -0.707106781, -0.316227766, -1, -1, -0.832050294,
|
||||
25, -0.447213595, -0.707106781, -0.316227766, -1, -1, -0.832050294,
|
||||
26, -1, -1, -1, 0.5, -0.948683298, -0.948683298,
|
||||
27, -1, -1, -1, -0.894427191, -0.948683298, -0.948683298,
|
||||
28, -0.447213595, -0.447213595, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
29, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
30, -0.447213595, 0.624695048, -0.196116135, 0.9701425, -0.948683298, -0.707106781,
|
||||
31, -0.447213595, 0.514495755, -0.196116135, 0.948683298, -0.948683298, -0.707106781,
|
||||
32, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
33, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
34, -0.447213595, -0.707106781, -0.196116135, -0.316227766, -0.948683298, -0.707106781,
|
||||
35, -0.447213595, 0.554700196, -0.196116135, 0.948683298, -0.948683298, -0.707106781,
|
||||
36, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.948683298,
|
||||
37, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
38, -0.447213595, -0.316227766, -0.196116135, -0.316227766, -0.948683298, -0.707106781,
|
||||
39, -0.447213595, -0.554700196, -0.196116135, -0.316227766, -0.948683298, -0.707106781,
|
||||
40, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
41, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
42, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
43, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
44, -0.447213595, -0.447213595, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
45, -0.447213595, -0.707106781, -0.196116135, -0.554700196, -0.948683298, -0.707106781,
|
||||
46, -0.447213595, -0.447213595, -0.196116135, -0.894427191, -0.948683298, -0.707106781,
|
||||
47, -0.447213595, -0.554700196, -0.196116135, -0.894427191, -0.948683298, -0.707106781,
|
||||
48, -0.707106781, -0.447213595, -0.447213595, -0.707106781, -0.948683298, -0.894427191,
|
||||
49, -0.447213595, -0.447213595, -0.447213595, -0.707106781, -0.948683298, -0.948683298,
|
||||
50, -0.447213595, -0.447213595, -0.447213595, -0.707106781, -0.948683298, -0.948683298,
|
||||
51, -0.447213595, -0.707106781, -0.447213595, -0.707106781, -0.948683298, -0.948683298,
|
||||
52, -0.447213595, -0.447213595, -0.447213595, -0.894427191, -0.948683298, -1,
|
||||
53, -0.447213595, -0.447213595, 0.707106781, -0.447213595, -0.948683298, -0.707106781,
|
||||
54, -0.707106781, -0.707106781, 0.5, -0.707106781, -0.948683298, -0.832050294,
|
||||
55, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
56, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
57, -0.316227766, -0.447213595, -0.316227766, -0.316227766, -0.948683298, -0.6,
|
||||
58, -0.316227766, -0.447213595, -0.316227766, -0.316227766, -0.948683298, -0.707106781,
|
||||
59, -0.447213595, -0.707106781, -0.242535625, -0.707106781, -0.948683298, -0.707106781,
|
||||
60, -0.447213595, -0.707106781, -0.242535625, -0.707106781, -0.948683298, -0.707106781,
|
||||
61, -0.447213595, -0.707106781, -0.242535625, -0.707106781, -0.948683298, -0.832050294,
|
||||
62, -0.447213595, -0.707106781, -0.242535625, -0.894427191, -0.948683298, -0.832050294,
|
||||
63, -0.447213595, -0.707106781, -0.242535625, -0.894427191, -0.948683298, -0.707106781,
|
||||
64, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
65, -0.447213595, -0.447213595, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
66, -0.316227766, -0.316227766, -0.371390676, -0.447213595, -0.948683298, -0.6,
|
||||
67, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
68, -0.447213595, -0.707106781, -0.196116135, -0.707106781, -0.948683298, -0.707106781,
|
||||
69, -0.447213595, -0.707106781, -0.196116135, -0.447213595, -0.948683298, -0.707106781,
|
||||
70, -0.447213595, -0.447213595, -0.196116135, -0.707106781, -0.948683298, -0.707106781};
|
||||
|
||||
private static final float NO_POINT_SCALE = 0.4f;
|
||||
private static final float NO_ACT_SCALE = 0.4f;
|
||||
|
||||
public static List<ModelDataBean> getModelDataList() {
|
||||
List<ModelDataBean> modelDataBeanList = new ArrayList<>();
|
||||
for (int i = 0; i < MODEL_DATA_ARRAY.length; i += 7) {
|
||||
if (i % 7 == 0) {
|
||||
ModelDataBean bean = new ModelDataBean();
|
||||
bean.setId((int) MODEL_DATA_ARRAY[i]);
|
||||
bean.setSinRightElbow(MODEL_DATA_ARRAY[i + 1]);
|
||||
bean.setSinRightWrist(MODEL_DATA_ARRAY[i + 2]);
|
||||
bean.setSinLeftElbow(MODEL_DATA_ARRAY[i + 3]);
|
||||
bean.setSinLeftWrist(MODEL_DATA_ARRAY[i + 4]);
|
||||
bean.setSinLeftKnee(MODEL_DATA_ARRAY[i + 5]);
|
||||
bean.setSinLeftAnkle(MODEL_DATA_ARRAY[i + 6]);
|
||||
modelDataBeanList.add(bean);
|
||||
}
|
||||
}
|
||||
return modelDataBeanList;
|
||||
}
|
||||
|
||||
public static ModelDataBean hmsData2ModelData(MLSkeleton mlSkeleton) {
|
||||
|
||||
ModelDataBean bean = new ModelDataBean();
|
||||
|
||||
float rightElbowA = mlSkeleton.getJointPoint(TYPE_RIGHT_ELBOW).getPointY()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointY();
|
||||
float rightElbowB = mlSkeleton.getJointPoint(TYPE_RIGHT_ELBOW).getPointX()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointX();
|
||||
float rightElbowC = (float) Math.sqrt(Math.pow(rightElbowA, 2) + Math.pow(rightElbowB, 2));
|
||||
if (mlSkeleton.getJointPoint(TYPE_RIGHT_ELBOW).getPointY() == 0 && mlSkeleton.getJointPoint(TYPE_RIGHT_ELBOW).getPointX() == 0) {
|
||||
bean.setRightElbowXY(1);
|
||||
} else {
|
||||
bean.setRightElbowXY(0);
|
||||
}
|
||||
bean.setSinRightElbow(rightElbowC == 0 ? 0.5 : (rightElbowA / rightElbowC));
|
||||
|
||||
float rightWristA = mlSkeleton.getJointPoint(TYPE_RIGHT_WRIST).getPointY()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointY();
|
||||
float rightWristB = mlSkeleton.getJointPoint(TYPE_RIGHT_WRIST).getPointX()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointX();
|
||||
float rightWristC = (float) Math.sqrt(Math.pow(rightWristA, 2) + Math.pow(rightWristB, 2));
|
||||
if (mlSkeleton.getJointPoint(TYPE_RIGHT_WRIST).getPointY() == 0 && mlSkeleton.getJointPoint(TYPE_RIGHT_WRIST).getPointX() == 0) {
|
||||
bean.setRightWristXY(1);
|
||||
} else {
|
||||
bean.setRightWristXY(0);
|
||||
}
|
||||
bean.setSinRightWrist(rightWristC == 0 ? 0.5 : (rightWristA / rightWristC));
|
||||
|
||||
float leftElbowA = mlSkeleton.getJointPoint(TYPE_LEFT_ELBOW).getPointY()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointY();
|
||||
float leftElbowB = mlSkeleton.getJointPoint(TYPE_LEFT_ELBOW).getPointX()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointX();
|
||||
float leftElbowC = (float) Math.sqrt(Math.pow(leftElbowA, 2) + Math.pow(leftElbowB, 2));
|
||||
if (mlSkeleton.getJointPoint(TYPE_LEFT_ELBOW).getPointY() == 0 && mlSkeleton.getJointPoint(TYPE_LEFT_ELBOW).getPointX() == 0) {
|
||||
bean.setLeftElbowXY(1);
|
||||
} else {
|
||||
bean.setLeftElbowXY(0);
|
||||
}
|
||||
bean.setSinLeftElbow(leftElbowC == 0 ? 0.5 : (leftElbowA / leftElbowC));
|
||||
|
||||
float leftWristA = mlSkeleton.getJointPoint(TYPE_LEFT_WRIST).getPointY()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointY();
|
||||
float leftWristB = mlSkeleton.getJointPoint(TYPE_LEFT_WRIST).getPointX()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointX();
|
||||
float leftWristC = (float) Math.sqrt(Math.pow(TYPE_LEFT_WRIST, 2) + Math.pow(leftWristB, 2));
|
||||
if (mlSkeleton.getJointPoint(TYPE_LEFT_WRIST).getPointY() == 0 && mlSkeleton.getJointPoint(TYPE_LEFT_WRIST).getPointX() == 0) {
|
||||
bean.setLeftWristXY(1);
|
||||
} else {
|
||||
bean.setLeftWristXY(0);
|
||||
}
|
||||
bean.setSinLeftWrist(leftWristC == 0 ? 0.5 : (leftWristA / leftWristC));
|
||||
|
||||
float leftKneeA = mlSkeleton.getJointPoint(TYPE_LEFT_KNEE).getPointY()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointY();
|
||||
float leftKneeB = mlSkeleton.getJointPoint(TYPE_LEFT_KNEE).getPointX()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointX();
|
||||
float leftKneeC = (float) Math.sqrt(Math.pow(leftKneeA, 2) + Math.pow(leftKneeB, 2));
|
||||
if (mlSkeleton.getJointPoint(TYPE_LEFT_KNEE).getPointY() == 0 && mlSkeleton.getJointPoint(TYPE_LEFT_KNEE).getPointX() == 0) {
|
||||
bean.setLeftKneeXY(1);
|
||||
} else {
|
||||
bean.setLeftKneeXY(0);
|
||||
}
|
||||
bean.setSinLeftKnee(leftKneeC == 0 ? 0.5 : (leftKneeA / leftKneeC));
|
||||
|
||||
float leftAnkleA = mlSkeleton.getJointPoint(TYPE_LEFT_ANKLE).getPointY()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointY();
|
||||
float leftAnkleB = mlSkeleton.getJointPoint(TYPE_LEFT_ANKLE).getPointX()
|
||||
- mlSkeleton.getJointPoint(TYPE_NECK).getPointX();
|
||||
float leftAnkleC = (float) Math.sqrt(Math.pow(leftAnkleA, 2) + Math.pow(leftAnkleB, 2));
|
||||
if (mlSkeleton.getJointPoint(TYPE_LEFT_ANKLE).getPointY() == 0 && mlSkeleton.getJointPoint(TYPE_LEFT_ANKLE).getPointX() == 0) {
|
||||
bean.setLeftAnkleXY(1);
|
||||
} else {
|
||||
bean.setLeftAnkleXY(0);
|
||||
}
|
||||
bean.setSinLeftAnkle(leftAnkleC == 0 ? 0.5 : (leftAnkleA / leftAnkleC));
|
||||
Log.d(TAG, "hmsData2ModelData"
|
||||
+ ", getSinRightElbow=" + bean.getSinRightElbow()
|
||||
+ ", getSinRightWrist=" + bean.getSinRightWrist()
|
||||
+ ", getSinLeftElbow=" + bean.getSinLeftElbow()
|
||||
+ ", getSinLeftWrist=" + bean.getSinLeftWrist()
|
||||
+ ", getSinLeftKnee=" + bean.getSinLeftKnee()
|
||||
+ ", getSinLeftAnkle=" + bean.getSinLeftAnkle()
|
||||
|
||||
);
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
public static double getScore(List<ModelDataBean> realDataList) {
|
||||
List<ModelDataBean> originList = getModelDataList();
|
||||
if (realDataList.size() > originList.size()) {
|
||||
for (int i = originList.size(); i < realDataList.size(); i++) {
|
||||
realDataList.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
double sum = 0;
|
||||
int noDataNumble = 0;
|
||||
|
||||
int sumRightElbowXY = 0;
|
||||
int sumRightWristXY = 0;
|
||||
int sumLeftElbowXY = 0;
|
||||
int sumLeftWristXY = 0;
|
||||
int sumLeftKneeXY = 0;
|
||||
int sumLeftAnkleXY = 0;
|
||||
|
||||
for (int i = 0; i < realDataList.size(); i++) {
|
||||
ModelDataBean realBean = realDataList.get(i);
|
||||
ModelDataBean originBean = originList.get(i);
|
||||
if (realBean == null) {
|
||||
noDataNumble++;
|
||||
Log.d(TAG, "getScore, i= " + i + ", this data is null");
|
||||
continue;
|
||||
}
|
||||
double rightElbow = Math.abs(originBean.getSinRightElbow()) == 0.5 ?
|
||||
Math.abs(originBean.getSinRightElbow() - realBean.getSinRightElbow() - 0.5) / 2 :
|
||||
Math.abs(originBean.getSinRightElbow() - realBean.getSinRightElbow()) / 2;
|
||||
double rightWrist = Math.abs(originBean.getSinRightWrist()) == 0.5 ?
|
||||
Math.abs(originBean.getSinRightWrist() - realBean.getSinRightWrist() - 0.5) / 2 :
|
||||
Math.abs(originBean.getSinRightWrist() - realBean.getSinRightWrist()) / 2;
|
||||
double leftElbow = Math.abs(originBean.getSinLeftElbow()) == 0.5 ?
|
||||
Math.abs(originBean.getSinLeftElbow() - realBean.getSinLeftElbow() - 0.5) / 2 :
|
||||
Math.abs(originBean.getSinLeftElbow() - realBean.getSinLeftElbow()) / 2;
|
||||
double leftWrist = Math.abs(originBean.getSinLeftWrist()) == 0.5 ?
|
||||
Math.abs(originBean.getSinLeftWrist() - realBean.getSinLeftWrist() - 0.5) / 2 :
|
||||
Math.abs(originBean.getSinLeftWrist() - realBean.getSinLeftWrist()) / 2;
|
||||
double leftKnee = Math.abs(originBean.getSinLeftKnee()) == 0.5 ?
|
||||
Math.abs(originBean.getSinLeftKnee() - realBean.getSinLeftKnee() - 0.5) / 2 :
|
||||
Math.abs(originBean.getSinLeftKnee() - realBean.getSinLeftKnee()) / 2;
|
||||
double leftAnkle = Math.abs(originBean.getSinLeftAnkle()) == 0.5 ?
|
||||
Math.abs(originBean.getSinLeftAnkle() - realBean.getSinLeftAnkle() - 0.5) / 2 :
|
||||
Math.abs(originBean.getSinLeftAnkle() - realBean.getSinLeftAnkle()) / 2;
|
||||
double total = rightElbow + rightWrist + leftElbow + leftWrist + leftKnee + leftAnkle;
|
||||
sum += total;
|
||||
|
||||
sumRightElbowXY += realBean.getRightElbowXY();
|
||||
sumRightWristXY += realBean.getRightWristXY();
|
||||
sumLeftElbowXY += realBean.getLeftElbowXY();
|
||||
sumLeftWristXY += realBean.getLeftWristXY();
|
||||
sumLeftKneeXY += realBean.getLeftKneeXY();
|
||||
sumLeftAnkleXY += realBean.getLeftAnkleXY();
|
||||
|
||||
Log.d(TAG, "getScore, i= " + i
|
||||
+ ", total=" + total
|
||||
+ ", rightElbow=" + rightElbow
|
||||
+ ", rightWrist=" + rightWrist
|
||||
+ ", leftElbow=" + leftElbow
|
||||
+ ", leftWrist=" + leftWrist
|
||||
+ ", leftKnee=" + leftKnee
|
||||
+ ", leftAnkle=" + leftAnkle);
|
||||
}
|
||||
|
||||
|
||||
float onPointValue = (realDataList.size() - noDataNumble) * NO_POINT_SCALE;
|
||||
if (sumRightElbowXY >= onPointValue || sumRightWristXY >= onPointValue || sumLeftElbowXY >= onPointValue ||
|
||||
sumLeftWristXY >= onPointValue || sumLeftKneeXY >= onPointValue || sumLeftAnkleXY > +onPointValue) {
|
||||
return NO_POINT; // Invalid point position scanned
|
||||
} else {
|
||||
double StandardDeviation = StandardDeviation(realDataList);
|
||||
Log.e(TAG, "getScore, StandardDeviation= " + StandardDeviation);
|
||||
if (StandardDeviation <= NO_ACT_SCALE) {
|
||||
return NO_ACT;
|
||||
} else {
|
||||
double average = sum / (realDataList.size() - noDataNumble) / 6;
|
||||
Log.e(TAG, "getScore, average= " + average
|
||||
+ ", sum=" + sum
|
||||
+ ", noDataNumble=" + noDataNumble
|
||||
+ ", realDataList.size()=" + realDataList.size());
|
||||
|
||||
double score = 100 - 120 * (average - 0.5);
|
||||
if (score >= 100) {
|
||||
score = 98;
|
||||
} else if (score < 60) {
|
||||
score = 63;
|
||||
}
|
||||
return score;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// standard deviation σ=sqrt(s^2)
|
||||
public static double StandardDeviation(List<ModelDataBean> realDataList) {
|
||||
int frameNum = realDataList.size();
|
||||
int nullSum = 0;
|
||||
double sum = 0;
|
||||
for (int i = 0; i < frameNum; i++) {// Sum
|
||||
if (realDataList.get(i) != null) {
|
||||
ModelDataBean bean = realDataList.get(i);
|
||||
if (bean.getSinRightElbow() == 0.5 || bean.getSinRightElbow() == 0.5 || bean.getSinLeftElbow() == 0.5 ||
|
||||
bean.getSinLeftWrist() == 0.5 || bean.getSinLeftKnee() == 0.5 || bean.getSinLeftAnkle() == 0.5) {
|
||||
nullSum++;
|
||||
} else {
|
||||
sum += bean.getSinRightElbow() + bean.getSinRightElbow()
|
||||
+ bean.getSinLeftElbow() + bean.getSinLeftWrist()
|
||||
+ bean.getSinLeftKnee() + bean.getSinLeftAnkle();
|
||||
}
|
||||
} else {
|
||||
nullSum++;
|
||||
}
|
||||
}
|
||||
double dAve = sum / (frameNum - nullSum);// Averaging
|
||||
double dVar = 0;
|
||||
for (int i = 0; i < frameNum; i++) {// Seek variance
|
||||
if (realDataList.get(i) != null) {
|
||||
ModelDataBean bean = realDataList.get(i);
|
||||
if (bean.getSinRightElbow() != 0.5 && bean.getSinRightElbow() != 0.5 && bean.getSinLeftElbow() != 0.5 &&
|
||||
bean.getSinLeftWrist() != 0.5 && bean.getSinLeftKnee() != 0.5 && bean.getSinLeftAnkle() != 0.5) {
|
||||
double sumSin = bean.getSinRightElbow() + bean.getSinRightElbow()
|
||||
+ bean.getSinLeftElbow() + bean.getSinLeftWrist()
|
||||
+ bean.getSinLeftKnee() + bean.getSinLeftAnkle();
|
||||
dVar += (sumSin - dAve) * (sumSin - dAve);
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "getScore, Standard111 nullSum= " + nullSum);
|
||||
return Math.sqrt(dVar / (frameNum - nullSum));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.global;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
public class Constants {
|
||||
public static String VIDEO_NAME = "danceVideo2.mp4";
|
||||
public static final int VIDEO_LENGTH = 41282333;
|
||||
public static String VIDEO_PATH = Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_DOWNLOADS + "/";
|
||||
public static String BITMAP_PATH = VIDEO_PATH + "bitmap";
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.global;
|
||||
|
||||
public class Variables {
|
||||
public static boolean hasVideo = false;
|
||||
public static long downloadId = -1;
|
||||
public static int score = 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.present.video;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.mindspore.dance.R;
|
||||
import com.mindspore.dance.task.GoneViewTask;
|
||||
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MyVideoView extends VideoView {
|
||||
private static final String TAG = MyVideoView.class.getSimpleName();
|
||||
private MediaController mediaController;
|
||||
private Context mContext;
|
||||
private TextView mCountdownView;
|
||||
|
||||
public MyVideoView(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mediaController = new MediaController(context);
|
||||
this.setMediaController(mediaController);
|
||||
initMediaController();
|
||||
}
|
||||
|
||||
public void setCountdownView(TextView countdownView) {
|
||||
mCountdownView = countdownView;
|
||||
|
||||
}
|
||||
|
||||
private void initMediaController() {
|
||||
mediaController.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
super.pause();
|
||||
Log.d(TAG, "pause");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
super.resume();
|
||||
Log.d(TAG, "resume");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
Log.d(TAG, "start");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
Log.d(TAG, "onTouchEvent");
|
||||
int remainingTime = this.getDuration() - this.getCurrentPosition();
|
||||
String timeStr = stringForTime(remainingTime);
|
||||
if (mCountdownView != null) {
|
||||
if (mCountdownView.getVisibility() == GONE) {
|
||||
mCountdownView.setText(getContext().getString(R.string.countdown) + timeStr);
|
||||
mCountdownView.setVisibility(VISIBLE);
|
||||
new Thread(new GoneViewTask(mCountdownView)).start();
|
||||
} else {
|
||||
mCountdownView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String stringForTime(int timeMs) {
|
||||
if (timeMs < 0) {
|
||||
return "00:00";
|
||||
}
|
||||
StringBuilder mFormatBuilder = new StringBuilder();
|
||||
Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
|
||||
int totalSeconds = timeMs / 1000;
|
||||
|
||||
int seconds = totalSeconds % 60;
|
||||
int minutes = (totalSeconds / 60) % 60;
|
||||
int hours = totalSeconds / 3600;
|
||||
|
||||
mFormatBuilder.setLength(0);
|
||||
if (hours > 0) {
|
||||
return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
|
||||
} else {
|
||||
return mFormatter.format("%02d:%02d", minutes, seconds).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.task;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
|
||||
public class GoneViewTask implements Runnable {
|
||||
private View mView;
|
||||
|
||||
public GoneViewTask(View view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null && mView.getVisibility() != View.GONE) {
|
||||
mView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.task;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.camera.view.PreviewView;
|
||||
|
||||
import com.huawei.hmf.tasks.OnFailureListener;
|
||||
import com.huawei.hmf.tasks.Task;
|
||||
import com.huawei.hms.mlsdk.common.MLFrame;
|
||||
import com.huawei.hms.mlsdk.skeleton.MLSkeleton;
|
||||
import com.huawei.hms.mlsdk.skeleton.MLSkeletonAnalyzer;
|
||||
import com.huawei.hms.mlsdk.skeleton.MLSkeletonAnalyzerFactory;
|
||||
import com.mindspore.dance.algorithm.ModelDataBean;
|
||||
import com.mindspore.dance.algorithm.ModelDataUtils;
|
||||
import com.mindspore.dance.global.Variables;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SampleTask implements Runnable {
|
||||
private static final String TAG = SampleTask.class.getSimpleName();
|
||||
private PreviewView previewView;
|
||||
private MLSkeletonAnalyzer analyzer;
|
||||
private List<List<MLSkeleton>> bitmapsSkeleton;
|
||||
private List<ModelDataBean> modelDataBeanList;
|
||||
|
||||
public SampleTask(PreviewView previewView) {
|
||||
this.previewView = previewView;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
analyzer = MLSkeletonAnalyzerFactory.getInstance().getSkeletonAnalyzer();
|
||||
bitmapsSkeleton = new ArrayList<List<MLSkeleton>>();
|
||||
modelDataBeanList = new ArrayList<ModelDataBean>();
|
||||
}
|
||||
|
||||
public void setNeedStop(boolean needStop) {
|
||||
this.needStop = needStop;
|
||||
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
bitmapsSkeleton.clear();
|
||||
analyzer = null;
|
||||
previewView = null;
|
||||
}
|
||||
|
||||
private int num = 0;
|
||||
private boolean needStop = false;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while ((!needStop) && num < 70) {
|
||||
sample();
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
double score = ModelDataUtils.getScore(modelDataBeanList);
|
||||
Log.d(TAG, "getScore:" + score);
|
||||
Variables.score = (int) score;
|
||||
}
|
||||
|
||||
private void getBitmap() {
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mainHandler.post(() -> {
|
||||
if (previewView == null) {
|
||||
return;
|
||||
}
|
||||
Bitmap tempBitmap = previewView.getBitmap();
|
||||
if (tempBitmap == null) {
|
||||
modelDataBeanList.add(null);
|
||||
Log.w(TAG, "bitmap is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
MLFrame frame = MLFrame.fromBitmap(tempBitmap);
|
||||
try {
|
||||
Task<List<MLSkeleton>> task = analyzer.asyncAnalyseFrame(frame);
|
||||
task.addOnSuccessListener(results -> {
|
||||
// check successful
|
||||
if (results.size() > 0) {
|
||||
Log.d(TAG, "onSuccess " + "skeleton:" + results.get(0));
|
||||
modelDataBeanList.add(ModelDataUtils.hmsData2ModelData(results.get(0)));
|
||||
} else {
|
||||
Log.w(TAG, "onSuccess, but no have skeleton in bitmap.");
|
||||
modelDataBeanList.add(null);
|
||||
}
|
||||
}).addOnFailureListener(new OnFailureListener() {
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
// check failed.
|
||||
Log.d(TAG, "onFailure sample:" + num);
|
||||
}
|
||||
});
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(TAG, "getBitmap," + e.getMessage());
|
||||
} catch (IllegalStateException e) {
|
||||
Log.d(TAG, "getBitmap," + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sample() {
|
||||
Log.d(TAG, "sample:" + num);
|
||||
if (previewView != null) {
|
||||
getBitmap();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.util;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.mindspore.dance.global.Constants;
|
||||
import com.mindspore.dance.global.Variables;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Tools {
|
||||
private static String TAG = Tools.class.getSimpleName();
|
||||
public static int WIDTH_INDEX = 0;
|
||||
public static int HEIGHT_INDEX = 1;
|
||||
public static final int TYPE_VIDEO_VIEW = 0;
|
||||
public static final int TYPE_CAMERA_VIEW = 1;
|
||||
|
||||
/**
|
||||
* Get the download status, get the width and height of a view, (There is a problem, you may get {0,0})
|
||||
*
|
||||
* @param view
|
||||
* @return int[2] int[0] = view.width; int[1] = view.height;
|
||||
*/
|
||||
public static int[] getWH(View view) {
|
||||
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
view.measure(w, h);
|
||||
int width = view.getMeasuredWidth();
|
||||
int height = view.getMeasuredHeight();
|
||||
Log.d(TAG, "rootLayout width:" + width + ", height:" + height);
|
||||
int[] a = {width, height};
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width and height of an activity (including the status bar)
|
||||
*
|
||||
* @return int[2] int[0] = width; int[1] = height;
|
||||
*/
|
||||
public static int[] getActivityWH(Activity activity) {
|
||||
Display display = activity.getWindowManager().getDefaultDisplay();
|
||||
Log.d(TAG, "Activity width:" + display.getWidth() + ", height:" + display.getHeight());
|
||||
int[] a = {display.getWidth(), display.getHeight()};
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visual area of a view
|
||||
*
|
||||
* @param view
|
||||
* @return int[2] int[0] = width; int[1] = height;
|
||||
*/
|
||||
public static int[] getRect(View view) {
|
||||
Rect rectangle = new Rect();
|
||||
view.getWindowVisibleDisplayFrame(rectangle);
|
||||
Log.d(TAG, "getRect parentView width:" + rectangle.width() + ", height:" + rectangle.height());
|
||||
int[] a = {rectangle.width(), rectangle.height()};
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding childView to parentView must be done in the main thread.
|
||||
*
|
||||
* @param parentView Parent container
|
||||
* @param childView Control to add
|
||||
* @param widthRatio Control width / parent container width
|
||||
* @param highRatio Control height / parent container height
|
||||
* if leftMarginRatio = -1; the horizontal center; topMarginRatio = -1 Indicates vertical center
|
||||
* @param topMarginRatio Control top margin / parent container height
|
||||
* @param leftMarginRatio Control left margin / parent container width
|
||||
*/
|
||||
@MainThread
|
||||
public static void addView(ViewGroup parentView, View childView, float widthRatio, float highRatio,
|
||||
float topMarginRatio, float leftMarginRatio) {
|
||||
int[] parentMeasure = Tools.getRect(parentView);
|
||||
int width = (int) (parentMeasure[0] * widthRatio);
|
||||
int high = (int) (parentMeasure[1] * highRatio);
|
||||
int left = leftMarginRatio == -1 ? (parentMeasure[0] - width) / 2
|
||||
: (int) (parentMeasure[0] * leftMarginRatio);
|
||||
int top = topMarginRatio == -1 ? (parentMeasure[1] - high) / 2
|
||||
: (int) (parentMeasure[1] * topMarginRatio);
|
||||
Log.d(TAG, "addView width:" + width + ", height:" + high + ", left:" + left + ", top:" + top);
|
||||
FrameLayout.LayoutParams fLayoutParams = new FrameLayout.LayoutParams(width, high);
|
||||
fLayoutParams.setMargins(left, top, 0, 0);
|
||||
|
||||
childView.setLayoutParams(fLayoutParams);
|
||||
parentView.addView(childView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding childView to parentView must be done in the main thread.
|
||||
*
|
||||
* @param parentView Parent container
|
||||
* @param childView Control to add
|
||||
* @param widthRatio Control width / parent container width
|
||||
* @param highRatio Control height / parent container height
|
||||
* @param widthHighRatio Control width / control height
|
||||
* if leftMarginRatio = -1; the horizontal center; topMarginRatio = -1 Indicates vertical center
|
||||
* @param topMarginRatio Control top margin / parent container height
|
||||
* @param leftMarginRatio Control left margin / parent container width
|
||||
* @param type Control is video 0 , a camera 1
|
||||
*/
|
||||
@MainThread
|
||||
public static void addViewFixedScale(ViewGroup parentView, View childView, float widthRatio,
|
||||
float highRatio, float widthHighRatio,
|
||||
float topMarginRatio, float leftMarginRatio, int type) {
|
||||
if (widthHighRatio == 0) {
|
||||
return;
|
||||
}
|
||||
int[] parentMeasure = Tools.getRect(parentView);
|
||||
int width = (int) (parentMeasure[0] * widthRatio);
|
||||
int highBorder = (int) (parentMeasure[1] * highRatio);
|
||||
int high = (int) ((float) width / widthHighRatio);
|
||||
int left = leftMarginRatio == -1 ? (parentMeasure[0] - width) / 2
|
||||
: (int) (parentMeasure[0] * leftMarginRatio);
|
||||
int top = topMarginRatio == -1 ? (parentMeasure[1] - high) / 2
|
||||
: (int) (parentMeasure[1] * topMarginRatio);
|
||||
Log.d(TAG, "addViewFixedScale width:" + width + ", height:" + high + ", highBorder:" + highBorder + ", left:" + left + ", top:" + top);
|
||||
FrameLayout.LayoutParams fLayoutParams = new FrameLayout.LayoutParams(width, high);
|
||||
int adjustment = 0;
|
||||
if (high != highBorder) {
|
||||
switch (type) {
|
||||
case Tools.TYPE_VIDEO_VIEW:
|
||||
adjustment = (highBorder - high) / 2;
|
||||
break;
|
||||
case Tools.TYPE_CAMERA_VIEW:
|
||||
adjustment = (highBorder - high);
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "type is invalid. don't adjust.");
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "addViewFixedScale adjustment." + adjustment);
|
||||
fLayoutParams.setMargins(left, top + adjustment, 0, 0);
|
||||
|
||||
childView.setLayoutParams(fLayoutParams);
|
||||
parentView.addView(childView);
|
||||
}
|
||||
|
||||
public static boolean checkDiskHasVideo() {
|
||||
File f = new File(Constants.VIDEO_PATH + Constants.VIDEO_NAME);
|
||||
if (f.exists() && f.length() == Constants.VIDEO_LENGTH) {
|
||||
Variables.hasVideo = true;
|
||||
} else {
|
||||
Variables.hasVideo = false;
|
||||
}
|
||||
return Variables.hasVideo;
|
||||
}
|
||||
|
||||
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||
private static final int REQUEST_CAMERA = 1;
|
||||
private static String[] PERMISSIONS_STORAGE = {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
};
|
||||
|
||||
private static String[] PERMISSIONS_CAMERA = {
|
||||
Manifest.permission.CAMERA
|
||||
};
|
||||
|
||||
public static void verifyStoragePermissions(Activity activity) {
|
||||
// Check if we have write permission
|
||||
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
// We don't have permission so prompt the user
|
||||
ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void verifyCameraPermissions(Activity activity) {
|
||||
// Check if we have write permission
|
||||
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.CAMERA);
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
// We don't have permission so prompt the user
|
||||
ActivityCompat.requestPermissions(activity, PERMISSIONS_CAMERA, REQUEST_CAMERA);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,35 +13,39 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.hms.texttranslation;
|
||||
|
||||
package com.mindspore.dance.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mindspore.hms.R;
|
||||
import com.mindspore.hms.camera.GraphicOverlay;
|
||||
import com.mindspore.hms.camera.LensEnginePreview;
|
||||
import com.mindspore.dance.R;
|
||||
|
||||
@Route(path = "/hms/TextTranslationRealTimeActivity")
|
||||
public class TextTranslationRealTimeActivity extends AppCompatActivity {
|
||||
|
||||
private LensEnginePreview mPreview;
|
||||
|
||||
private GraphicOverlay mOverlay;
|
||||
@Route(path = "/dance/DanceMainActivity")
|
||||
public class DanceActivity extends AppCompatActivity {
|
||||
|
||||
@SuppressLint("InvalidWakeLockTag")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_text_translation_real_time);
|
||||
init();
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
||||
|
||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
setContentView(R.layout.activity_dance);
|
||||
|
||||
|
||||
}
|
||||
private void init(){
|
||||
Toolbar mToolbar = findViewById(R.id.TextVideo_activity_toolbar);
|
||||
mToolbar.setNavigationOnClickListener(view -> finish());
|
||||
this.mPreview = this.findViewById(R.id.scene_preview);
|
||||
this.mOverlay = this.findViewById(R.id.scene_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.view.fragment;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.mindspore.common.base.mvp.BaseFragment;
|
||||
import com.mindspore.common.net.FileDownLoadObserver;
|
||||
import com.mindspore.dance.R;
|
||||
import com.mindspore.dance.global.Constants;
|
||||
import com.mindspore.dance.global.Variables;
|
||||
import com.mindspore.dance.present.video.MyVideoView;
|
||||
import com.mindspore.dance.util.Tools;
|
||||
import com.mindspore.dance.view.mvp.PrepareContract;
|
||||
import com.mindspore.dance.view.mvp.PreparePresenter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.mindspore.common.utils.Utils.getApp;
|
||||
|
||||
public class PrepareFragment extends BaseFragment<PreparePresenter> implements PrepareContract.View {
|
||||
private final String TAG = PrepareFragment.class.getSimpleName();
|
||||
|
||||
private FrameLayout root;
|
||||
private TextView downloadText;
|
||||
private MyVideoView videoView;
|
||||
private MediaController mediaController;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
presenter = new PreparePresenter(this);
|
||||
|
||||
Tools.verifyStoragePermissions(getActivity());
|
||||
Tools.verifyCameraPermissions(getActivity());
|
||||
Tools.checkDiskHasVideo();
|
||||
if (!Variables.hasVideo) {
|
||||
downFile();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_prepare, container, false);
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
root = view.findViewById(R.id.root);
|
||||
downloadText = view.findViewById(R.id.download_text);
|
||||
initView();
|
||||
}
|
||||
|
||||
public void downFile() {
|
||||
presenter.downloadDanceVideo(new FileDownLoadObserver<File>() {
|
||||
@Override
|
||||
public void onDownLoadSuccess(File file) {
|
||||
Tools.checkDiskHasVideo();
|
||||
downloadText.setVisibility(View.GONE);
|
||||
if (videoView != null && !videoView.isPlaying()) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownLoadFail(Throwable throwable) {
|
||||
Toast.makeText(getApp(), R.string.download_faild, Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(final int progress, long total) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
downloadText.setText(String.format(getString(R.string.downloading), progress, "%"));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (!Variables.hasVideo) {
|
||||
downFile();
|
||||
} else {
|
||||
if (videoView != null && !videoView.isPlaying()) {
|
||||
videoView.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (videoView != null && videoView.isPlaying()) {
|
||||
videoView.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
onStop();
|
||||
videoView = null;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
addVideoView();
|
||||
addBackground();
|
||||
addButton();
|
||||
if (!Variables.hasVideo) {
|
||||
downloadText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void addVideoView() {
|
||||
videoView = new MyVideoView(getActivity());
|
||||
Tools.addViewFixedScale(root, videoView, 0.625f, 0.596f, 16f / 9f,
|
||||
0.227f, 0.187f, Tools.TYPE_VIDEO_VIEW);
|
||||
|
||||
videoView.setOnCompletionListener(mp -> videoView.start());
|
||||
if (Variables.hasVideo) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
private void addBackground() {
|
||||
ImageView backgroundView = new ImageView(getContext());
|
||||
backgroundView.setBackgroundResource(R.drawable.prepare_bk);
|
||||
Tools.addView(root, backgroundView, 1f, 1f, -1, -1);
|
||||
}
|
||||
|
||||
private void addButton() {
|
||||
ImageButton buttonView = new ImageButton(getContext());
|
||||
buttonView.setBackgroundResource(R.drawable.begin_run_bt);
|
||||
buttonView.setOnClickListener(v -> {
|
||||
int permission = ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA);
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
Toast.makeText(getActivity(), R.string.toast_no_camera_permission, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
permission = ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
Toast.makeText(getActivity(), R.string.toast_no_storage_permission,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (!Variables.hasVideo) {
|
||||
return;
|
||||
}
|
||||
NavHostFragment.findNavController(PrepareFragment.this)
|
||||
.navigate(R.id.action_PrepareFragment_to_RunFragment);
|
||||
});
|
||||
Tools.addView(root, buttonView, 0.256f, 0.132f, 0.843f, 0.372f);
|
||||
|
||||
ImageButton backButton = new ImageButton(getContext());
|
||||
backButton.setBackgroundResource(R.drawable.dance_back);
|
||||
backButton.setOnClickListener(view -> {
|
||||
getActivity().finish();
|
||||
});
|
||||
Tools.addView(root, backButton, 0.1f, 0.2f, 0.2f, 0.06f);
|
||||
}
|
||||
|
||||
private void start() {
|
||||
mediaController = new MediaController(getContext());
|
||||
String uri = Constants.VIDEO_PATH + Constants.VIDEO_NAME;
|
||||
Log.d(TAG, "start uri:" + uri);
|
||||
videoView.setVideoPath(uri);
|
||||
videoView.setMediaController(mediaController);
|
||||
mediaController.setMediaPlayer(videoView);
|
||||
videoView.requestFocus();
|
||||
videoView.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.view.fragment;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.mindspore.common.utils.ImageUtils;
|
||||
import com.mindspore.dance.R;
|
||||
import com.mindspore.dance.algorithm.ModelDataUtils;
|
||||
import com.mindspore.dance.global.Variables;
|
||||
|
||||
|
||||
public class ResultFragment extends Fragment {
|
||||
|
||||
private String comment;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_result, container, false);
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
TextView textFirstView = view.findViewById(R.id.get_score);
|
||||
String score = level(Variables.score);
|
||||
textFirstView.setText(score);
|
||||
|
||||
TextView textSecondView = view.findViewById(R.id.get_comment);
|
||||
if (Variables.score >= 0 && Variables.score <= 100) {
|
||||
textSecondView.setText(comment);
|
||||
} else {
|
||||
textSecondView.setVisibility(View.GONE);
|
||||
}
|
||||
view.findViewById(R.id.play_again).setOnClickListener(view1 ->
|
||||
NavHostFragment.findNavController(ResultFragment.this)
|
||||
.navigate(R.id.action_ResultFragment_to_PrepareFragment));
|
||||
|
||||
view.findViewById(R.id.save).setOnClickListener(view12 -> {
|
||||
Uri imgPath = ImageUtils.saveToAlbum(getActivity(), view, null, false);
|
||||
if (imgPath != null) {
|
||||
Toast.makeText(getActivity(), R.string.image_save_success, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), R.string.image_save_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.back).setOnClickListener(view12 -> {
|
||||
getActivity().finish();
|
||||
});
|
||||
}
|
||||
|
||||
private String level(int score) {
|
||||
if (score == ModelDataUtils.NO_ACT) {
|
||||
return getContext().getString(R.string.get_score_level0);
|
||||
} else if (score == ModelDataUtils.NO_POINT) {
|
||||
return getContext().getString(R.string.get_score_level8);
|
||||
} else if (50 <= score && score < 60) {
|
||||
comment = getContext().getString(R.string.get_score_level1);
|
||||
} else if (60 <= score && score < 70) {
|
||||
comment = getContext().getString(R.string.get_score_level2);
|
||||
} else if (70 <= score && score < 80) {
|
||||
comment = getContext().getString(R.string.get_score_level3);
|
||||
} else if (80 <= score && score < 90) {
|
||||
comment = getContext().getString(R.string.get_score_level4);
|
||||
} else if (90 <= score && score < 95) {
|
||||
comment = getContext().getString(R.string.get_score_level5);
|
||||
} else if (95 <= score && score < 100) {
|
||||
comment = getContext().getString(R.string.get_score_level6);
|
||||
} else if (score == 100) {
|
||||
comment = getContext().getString(R.string.get_score_level7);
|
||||
} else {
|
||||
comment = "";
|
||||
}
|
||||
return getContext().getString(R.string.get_score) + score;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mindspore.dance.view.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.camera.camera2.Camera2Config;
|
||||
import androidx.camera.core.Camera;
|
||||
import androidx.camera.core.CameraSelector;
|
||||
import androidx.camera.core.CameraXConfig;
|
||||
import androidx.camera.core.Preview;
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||
import androidx.camera.view.PreviewView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.mindspore.dance.R;
|
||||
import com.mindspore.dance.global.Constants;
|
||||
import com.mindspore.dance.present.video.MyVideoView;
|
||||
import com.mindspore.dance.task.SampleTask;
|
||||
import com.mindspore.dance.util.Tools;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class RunFragment extends Fragment {
|
||||
private final String TAG = RunFragment.class.getSimpleName();
|
||||
private FrameLayout root;
|
||||
private MyVideoView videoView;
|
||||
private PreviewView cameraView;
|
||||
private ListenableFuture<ProcessCameraProvider> cameraProviderFuture;
|
||||
private SampleTask sampleTask;
|
||||
private TextView countdownView;
|
||||
private ImageView info;
|
||||
private Handler handler;
|
||||
private final int NEED_CANCEL = -1;
|
||||
private MediaController mediaController;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_run, container, false);
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
root = view.findViewById(R.id.root);
|
||||
handler = new Handler();
|
||||
mediaController = new MediaController(this.getContext());
|
||||
initView();
|
||||
|
||||
cameraProviderFuture = ProcessCameraProvider.getInstance(getContext());
|
||||
cameraProviderFuture.addListener(() -> {
|
||||
try {
|
||||
ProcessCameraProvider cameraProvider = cameraProviderFuture.get();
|
||||
bindPreview(cameraProvider);
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
// No errors need to be handled for this Future.
|
||||
// This should never be reached.
|
||||
}
|
||||
}, ContextCompat.getMainExecutor(getContext()));
|
||||
}
|
||||
|
||||
private void complete() {
|
||||
if (videoView != null && videoView.isPlaying()) {
|
||||
videoView.stopPlayback();
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
@Override
|
||||
public void onResume() {
|
||||
info.setVisibility(View.VISIBLE);
|
||||
info.setBackgroundResource(R.drawable.countdown_three);
|
||||
super.onResume();
|
||||
handler.postDelayed(() -> {
|
||||
//execute the task
|
||||
info.setVisibility(View.VISIBLE);
|
||||
info.setBackgroundResource(R.drawable.countdown_two);
|
||||
}, NEED_CANCEL, 1000);
|
||||
handler.postDelayed(() -> {
|
||||
//execute the task
|
||||
info.setVisibility(View.VISIBLE);
|
||||
info.setBackgroundResource(R.drawable.countdown_one);
|
||||
}, NEED_CANCEL, 2000);
|
||||
handler.postDelayed(() -> {
|
||||
//execute the task
|
||||
beginPlay();
|
||||
info.setVisibility(View.GONE);
|
||||
}, NEED_CANCEL, 3080);
|
||||
}
|
||||
|
||||
private void start() {
|
||||
String uri = Constants.VIDEO_PATH + Constants.VIDEO_NAME;
|
||||
Log.d(TAG, "start uri:" + uri);
|
||||
videoView.setVideoPath(uri);
|
||||
videoView.setMediaController(mediaController);
|
||||
mediaController.setMediaPlayer(videoView);
|
||||
videoView.requestFocus();
|
||||
videoView.start();
|
||||
}
|
||||
|
||||
public void beginPlay() {
|
||||
addButtonView();
|
||||
start();
|
||||
sampleTask = new SampleTask(cameraView);
|
||||
new Thread(sampleTask).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
handler.removeMessages(NEED_CANCEL);
|
||||
if (sampleTask != null) {
|
||||
sampleTask.setNeedStop(true);
|
||||
sampleTask.clear();
|
||||
sampleTask = null;
|
||||
}
|
||||
if (videoView.isPlaying()) {
|
||||
videoView.stopPlayback();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
private void bindPreview(@NonNull ProcessCameraProvider cameraProvider) {
|
||||
Preview preview = new Preview.Builder().build();
|
||||
|
||||
CameraSelector cameraSelector = new CameraSelector.Builder()
|
||||
.requireLensFacing(CameraSelector.LENS_FACING_FRONT).build();
|
||||
|
||||
preview.setSurfaceProvider(cameraView.getSurfaceProvider());
|
||||
Camera camera = cameraProvider.bindToLifecycle((LifecycleOwner) this, cameraSelector, preview);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
addVideoView();
|
||||
addTextInfoView();
|
||||
addCameraView();
|
||||
addCountdownView();
|
||||
addBackground();
|
||||
|
||||
}
|
||||
|
||||
private void addTextInfoView() {
|
||||
info = new ImageView(getActivity());
|
||||
info.setBackgroundResource(R.drawable.countdown_three);
|
||||
Tools.addView(root, info, 0.872f, 0.875f, 0.091f, 0.062f);
|
||||
}
|
||||
|
||||
private void addCountdownView() {
|
||||
countdownView = new TextView(getContext());
|
||||
countdownView.setTextSize(20);
|
||||
countdownView.setTextColor(0xFFFFFFFF);
|
||||
countdownView.setBackgroundColor(0xff333333);
|
||||
countdownView.setGravity(Gravity.CENTER);
|
||||
Tools.addView(root, countdownView, 0.256f, 0.113f, 0.091f, 0.062f);
|
||||
if (videoView != null) {
|
||||
videoView.setCountdownView(countdownView);
|
||||
}
|
||||
countdownView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void addBackground() {
|
||||
ImageView backgroundView = new ImageView(getContext());
|
||||
backgroundView.setBackgroundResource(R.drawable.run_bk);
|
||||
Tools.addView(root, backgroundView, 1f, 1f, -1, -1);
|
||||
}
|
||||
|
||||
private void addVideoView() {
|
||||
videoView = new MyVideoView(getActivity());
|
||||
Tools.addViewFixedScale(root, videoView, 0.872f, 0.875f, 16f / 9f,
|
||||
0.091f, 0.062f, Tools.TYPE_VIDEO_VIEW);
|
||||
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
complete();
|
||||
NavHostFragment.findNavController(RunFragment.this)
|
||||
.navigate(R.id.action_RunFragment_to_ResultFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addCameraView() {
|
||||
cameraView = new PreviewView(getContext());
|
||||
cameraView.setScaleType(PreviewView.ScaleType.FIT_CENTER);
|
||||
Tools.addViewFixedScale(root, cameraView, 0.248f, 0.331f, 4f / 3f,
|
||||
0.635f, 0.686f, Tools.TYPE_CAMERA_VIEW);
|
||||
}
|
||||
|
||||
private void addButtonView() {
|
||||
ImageButton backButton = new ImageButton(getContext());
|
||||
backButton.setBackgroundResource(R.drawable.dance_back);
|
||||
backButton.setOnClickListener(view -> {
|
||||
getActivity().finish();
|
||||
});
|
||||
Tools.addView(root, backButton, 0.1f, 0.2f, 0.12f, 0.1f);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.dance.view.mvp;
|
||||
|
||||
import com.mindspore.common.net.FileDownLoadObserver;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface PrepareContract {
|
||||
|
||||
interface View {
|
||||
}
|
||||
|
||||
interface Presenter {
|
||||
void downloadDanceVideo(FileDownLoadObserver<File> fileDownLoadObserver);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mindspore.dance.view.mvp;
|
||||
|
||||
import com.mindspore.common.base.mvp.BaseFragmentPresenter;
|
||||
import com.mindspore.common.net.FileDownLoadObserver;
|
||||
import com.mindspore.common.net.RetrofitHelper;
|
||||
import com.mindspore.dance.global.Constants;
|
||||
import com.mindspore.dance.view.fragment.PrepareFragment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class PreparePresenter extends BaseFragmentPresenter<PrepareFragment> implements PrepareContract.Presenter {
|
||||
|
||||
private PrepareContract.View view;
|
||||
|
||||
private RetrofitHelper retrofitHelper;
|
||||
|
||||
public PreparePresenter(PrepareContract.View view) {
|
||||
this.view = view;
|
||||
retrofitHelper = new RetrofitHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadDanceVideo(FileDownLoadObserver<File> fileDownLoadObserver) {
|
||||
retrofitHelper.downloadDanceVideo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.computation())
|
||||
.map(responseBody -> fileDownLoadObserver.saveFile(responseBody, Constants.VIDEO_PATH, Constants.VIDEO_NAME))
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(fileDownLoadObserver);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 292 KiB |
|
After Width: | Height: | Size: 296 KiB |
|
After Width: | Height: | Size: 295 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 882 KiB |
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/content_dance" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/nav_dance" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".view.fragment.PrepareFragment">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/downloading"
|
||||
android:textSize="32sp"
|
||||
android:textColor="@color/upsdk_blue_text_007dff"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.5" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/result_bk"
|
||||
tools:context=".view.fragment.ResultFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/get_score"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:shadowColor="#ffC8E4F0"
|
||||
android:shadowDx="3"
|
||||
android:shadowDy="3"
|
||||
android:shadowRadius="5"
|
||||
android:textColor="#FF40ADFF"
|
||||
android:textSize="86.46px"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.277" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/get_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:shadowColor="#ffC8E4F0"
|
||||
android:shadowDx="3"
|
||||
android:shadowDy="3"
|
||||
android:shadowRadius="5"
|
||||
android:textColor="#FF40ADFF"
|
||||
android:textSize="70px"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.402" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/save"
|
||||
android:layout_width="492px"
|
||||
android:layout_height="145px"
|
||||
android:background="@drawable/save"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.739" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/play_again"
|
||||
android:layout_width="492px"
|
||||
android:layout_height="145px"
|
||||
android:background="@drawable/play_again"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.912" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/back"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/dance_back"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragment.RunFragment"
|
||||
android:background="@drawable/run_bk">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/root"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.myapplication.MainActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_dance"
|
||||
app:startDestination="@id/PrepareFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/PrepareFragment"
|
||||
android:name="com.mindspore.dance.view.fragment.PrepareFragment"
|
||||
android:label="@string/second_fragment_label"
|
||||
tools:layout="@layout/fragment_prepare">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_PrepareFragment_to_RunFragment"
|
||||
app:destination="@id/RunFragment" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/RunFragment"
|
||||
android:name="com.mindspore.dance.view.fragment.RunFragment"
|
||||
android:label="@string/run_fragment_label"
|
||||
tools:layout="@layout/fragment_run">
|
||||
<action
|
||||
android:id="@+id/action_RunFragment_to_ResultFragment"
|
||||
app:destination="@id/ResultFragment" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/ResultFragment"
|
||||
android:name="com.mindspore.dance.view.fragment.ResultFragment"
|
||||
android:label="@string/Result_fragment_label"
|
||||
tools:layout="@layout/fragment_result">
|
||||
<action
|
||||
android:id="@+id/action_ResultFragment_to_PrepareFragment"
|
||||
app:destination="@id/PrepareFragment" />
|
||||
</fragment>
|
||||
</navigation>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.MindSpore" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<resources>
|
||||
<string name="app_name">舞蹈梦工厂</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<!-- Strings used for fragments for navigation -->
|
||||
<string name="first_fragment_label">First Fragment</string>
|
||||
<string name="second_fragment_label">Prepare Fragment</string>
|
||||
<string name="run_fragment_label">Run Fragment</string>
|
||||
<string name="next">Next</string>
|
||||
<string name="previous">Previous</string>
|
||||
|
||||
<string name="hello_first_fragment">这里是掌中宝的功能列表页面,请点击next进入舞蹈梦工厂模块</string>
|
||||
<string name="dance">Dance</string>
|
||||
<string name="Result_fragment_label">result</string>
|
||||
<string name="toast_no_video">抱歉,还没有可用视频</string>
|
||||
<string name="toast_no_storage_permission">抱歉,您没有授予存储权限</string>
|
||||
<string name="toast_no_camera_permission">抱歉,您没有授予相机访问权限</string>
|
||||
<string name="download">下载</string>
|
||||
<string name="download_faild">下载失败</string>
|
||||
|
||||
<string name="downloading">"舞蹈视频下载中 ...%1$d%2$s"</string>
|
||||
<string name="get_score">恭喜完成,综合得分:</string>
|
||||
<string name="get_score_level1">有点那个味了!</string>
|
||||
<string name="get_score_level2">萌新说得就是你!</string>
|
||||
<string name="get_score_level3">好厉害,你是专业的吗?</string>
|
||||
<string name="get_score_level4">你是这条街最靓的仔!</string>
|
||||
<string name="get_score_level5">隐藏在民间的高手!</string>
|
||||
<string name="get_score_level6">给大神献上膝盖!</string>
|
||||
<string name="get_score_level7">这个舞台属于你!</string>
|
||||
<string name="get_score_level0">请动起来哦!</string>
|
||||
<string name="get_score_level8">请全身出镜展示你的风采!</string>
|
||||
<string name="countdown"> 剩余时长:</string>
|
||||
<string name="game_rules"> 跟随视频中小人的动作起舞,AI会采集你的动作进行实时匹配,想拿高分吗,请注意你的xx部位的动作哈</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.MyApplication.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.MyApplication.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="Theme.MyApplication.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
|
||||
<style name="no_title">
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
beach
|
||||
bluesky
|
||||
sunset
|
||||
food
|
||||
flower
|
||||
greenplant
|
||||
snow
|
||||
night
|
||||
text
|
||||
cat
|
||||
dog
|
||||
fireworks
|
||||
overcast
|
||||
fallen
|
||||
panda
|
||||
car
|
||||
oldbuildings
|
||||
bicycle
|
||||
waterfall
|
||||
playground
|
||||
corridor
|
||||
cabin
|
||||
washroom
|
||||
kitchen
|
||||
bedroom
|
||||
diningroom
|
||||
livingroom
|
||||
skyscraper
|
||||
bridge
|
||||
waterside
|
||||
mountain
|
||||
overlook
|
||||
construction
|
||||
islam
|
||||
european
|
||||
footballfield
|
||||
baseballfield
|
||||
tenniscourt
|
||||
carinside
|
||||
badmintoncourt
|
||||
pingpangcourt
|
||||
swimmingpool
|
||||
alpaca
|
||||
library
|
||||
supermarket
|
||||
restaurant
|
||||
tiger
|
||||
penguin
|
||||
elephant
|
||||
dinosaur
|
||||
watersurface
|
||||
indoorbasketballcourt
|
||||
bowlingalley
|
||||
classroom
|
||||
rabbit
|
||||
rhinoceros
|
||||
camel
|
||||
tortoise
|
||||
leopard
|
||||
giraffe
|
||||
peacock
|
||||
kangaroo
|
||||
lion
|
||||
motorcycle
|
||||
aircraft
|
||||
train
|
||||
ship
|
||||
glasses
|
||||
watch
|
||||
highwheels
|
||||
washingmachine
|
||||
airconditioner
|
||||
camera
|
||||
map
|
||||
keyboard
|
||||
redenvelope
|
||||
fucharacter
|
||||
xicharacter
|
||||
dragondance
|
||||
liondance
|
||||
go
|
||||
teddybear
|
||||
transformer
|
||||
thesmurfs
|
||||
littlepony
|
||||
butterfly
|
||||
ladybug
|
||||
dragonfly
|
||||
billiardroom
|
||||
meetingroom
|
||||
office
|
||||
bar
|
||||
mallcourtyard
|
||||
deer
|
||||
cathedralhall
|
||||
bee
|
||||
helicopter
|
||||
mahjong
|
||||
chess
|
||||
McDonalds
|
||||
ornamentalfish
|
||||
widebuildings
|
||||
|
||||
|
||||
|
||||
沙滩
|
||||
蓝天
|
||||
日出日落
|
||||
美食
|
||||
花朵
|
||||
绿植
|
||||
雪景
|
||||
夜景
|
||||
文字
|
||||
猫
|
||||
狗
|
||||
烟花
|
||||
阴天
|
||||
秋叶
|
||||
熊猫
|
||||
汽车
|
||||
中式建筑
|
||||
自行车
|
||||
瀑布
|
||||
游乐场
|
||||
走廊巷道
|
||||
火车飞机内部
|
||||
卫生间
|
||||
厨房
|
||||
卧室
|
||||
餐厅
|
||||
客厅
|
||||
摩天大楼+塔
|
||||
桥梁
|
||||
海滨/湖滨
|
||||
山峰
|
||||
城市俯瞰
|
||||
工地
|
||||
伊斯兰式建筑
|
||||
欧式建筑
|
||||
足球场
|
||||
棒球场
|
||||
网球场
|
||||
轿车内部
|
||||
羽毛球馆
|
||||
乒乓球馆
|
||||
游泳馆
|
||||
羊驼
|
||||
图书馆
|
||||
超市
|
||||
饭店
|
||||
老虎
|
||||
企鹅
|
||||
大象
|
||||
恐龙
|
||||
水面
|
||||
室内篮球场
|
||||
保龄球馆
|
||||
教室
|
||||
兔子
|
||||
犀牛
|
||||
骆驼
|
||||
乌龟
|
||||
豹子
|
||||
长颈鹿
|
||||
孔雀
|
||||
袋鼠
|
||||
狮子
|
||||
电动车/摩托车
|
||||
飞机
|
||||
火车
|
||||
轮船
|
||||
眼镜
|
||||
手表
|
||||
高跟鞋
|
||||
洗衣机
|
||||
空调
|
||||
相机
|
||||
地图
|
||||
键盘
|
||||
红包
|
||||
福 字
|
||||
囍 字
|
||||
舞龙
|
||||
舞狮
|
||||
围棋
|
||||
泰迪熊
|
||||
京剧脸谱
|
||||
蓝精灵
|
||||
小马宝莉
|
||||
蝴蝶
|
||||
瓢虫
|
||||
蜻蜓
|
||||
桌球房
|
||||
会议室
|
||||
办公室
|
||||
酒吧
|
||||
商场中庭
|
||||
梅花鹿
|
||||
教堂正厅
|
||||
蜜蜂
|
||||
直升机
|
||||
麻将
|
||||
象棋
|
||||
麦当劳
|
||||
观赏鱼
|
||||
广角城楼
|
||||
|
|
@ -18,10 +18,6 @@
|
|||
android:name=".bonedetection.LiveSkeletonAnalyseActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".texttranslation.TextTranslationRealTimeActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".gesturerecognition.LiveHandGestureAnalyseActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
|
@ -33,10 +29,6 @@
|
|||
<activity
|
||||
android:name=".gesturerecognition.StillHandGestureAnalyseActivity"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".textrecognition.VideoTextRecognitionActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".scenedetection.SenceDetectionStillAnalyseActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
|
|
|||
|
|
@ -185,8 +185,7 @@ public class ImageSegmentationLiveAnalyseActivity extends AppCompatActivity impl
|
|||
public void transactResult(MLAnalyzer.Result<MLImageSegmentation> result) {
|
||||
mOverlay.clear();
|
||||
SparseArray<MLImageSegmentation> imageSegmentationResult = result.getAnalyseList();
|
||||
MLSegmentGraphic graphic = new MLSegmentGraphic(ImageSegmentationLiveAnalyseActivity.this, mPreview, mOverlay, imageSegmentationResult.valueAt(0), isFront);
|
||||
//mOverlay.setBackgroundColor(Color.BLUE);
|
||||
MLSegmentGraphic graphic = new MLSegmentGraphic(mPreview, mOverlay, imageSegmentationResult.valueAt(0), isFront);
|
||||
mOverlay.add(graphic);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,18 +16,13 @@
|
|||
|
||||
package com.mindspore.hms.camera;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
|
||||
import com.huawei.hms.mlsdk.imgseg.MLImageSegmentation;
|
||||
import com.mindspore.hms.R;
|
||||
|
||||
public class MLSegmentGraphic extends GraphicOverlay.Graphic {
|
||||
private static final String TAG = MLSegmentGraphic.class.getSimpleName();
|
||||
|
|
@ -36,12 +31,8 @@ public class MLSegmentGraphic extends GraphicOverlay.Graphic {
|
|||
private final Bitmap bitmapForeground;
|
||||
private final Boolean isFront;
|
||||
|
||||
private final Bitmap mDstBitmap;
|
||||
private final Context context;
|
||||
|
||||
public MLSegmentGraphic(Context context, LensEnginePreview preview, GraphicOverlay overlay, MLImageSegmentation segmentation, Boolean isFront) {
|
||||
public MLSegmentGraphic(LensEnginePreview preview, GraphicOverlay overlay, MLImageSegmentation segmentation, Boolean isFront) {
|
||||
super(overlay);
|
||||
this.context = context;
|
||||
this.bitmapForeground = segmentation.getForeground();
|
||||
this.isFront = isFront;
|
||||
|
||||
|
|
@ -49,25 +40,14 @@ public class MLSegmentGraphic extends GraphicOverlay.Graphic {
|
|||
int height = bitmapForeground.getHeight();
|
||||
int div = overlay.getWidth() - preview.getWidth();
|
||||
int left = overlay.getWidth() - width + div / 2;
|
||||
|
||||
// Set the image display area.
|
||||
// Partial display.
|
||||
mDestRect = new Rect(left, 0, overlay.getWidth() - div / 2, height / 2);
|
||||
|
||||
// All display.
|
||||
// mDestRect = new Rect(0, 0, overlay.getWidth(), overlay.getHeight());
|
||||
this.resultPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
this.resultPaint.setFilterBitmap(true);
|
||||
this.resultPaint.setDither(true);
|
||||
|
||||
mDstBitmap = Bitmap.createBitmap(mDestRect.width(), mDestRect.height(), Bitmap.Config.ARGB_8888).copy(Bitmap.Config.ARGB_8888, true);
|
||||
mDstBitmap.eraseColor(Color.parseColor("#FF0000"));//填充颜色
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawBitmap(mDstBitmap, null, mDestRect, resultPaint);
|
||||
canvas.drawBitmap(isFront ? convert(bitmapForeground) : bitmapForeground, null, mDestRect, resultPaint);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import androidx.appcompat.widget.Toolbar;
|
|||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.huawei.hmf.tasks.OnFailureListener;
|
||||
import com.huawei.hmf.tasks.OnSuccessListener;
|
||||
|
|
@ -124,11 +123,6 @@ public class TextRecognitionActivity extends AppCompatActivity {
|
|||
textOriginImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
public void onClickRealTime(View view) {
|
||||
ARouter.getInstance().build("/hms/VideoTextRecognitionActivity").navigation();
|
||||
}
|
||||
|
||||
private void openGallay(int request) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
|
|
|
|||