Commit 0a0207dc authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent b7214ab8
...@@ -48,6 +48,7 @@ class BookSearchPresenter : BasePresenter<BookSearchView>() { ...@@ -48,6 +48,7 @@ class BookSearchPresenter : BasePresenter<BookSearchView>() {
} }
fun searchBook(searchName: String, pageNo: Int, pageSize: Int) { fun searchBook(searchName: String, pageNo: Int, pageSize: Int) {
view.showLoading("加载中...")
val vo = HashMap<String, Any>() val vo = HashMap<String, Any>()
vo["searchName"] = searchName vo["searchName"] = searchName
vo["pageNo"] = pageNo vo["pageNo"] = pageNo
......
...@@ -37,7 +37,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base ...@@ -37,7 +37,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Base
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// 禁止截图 // 禁止截图
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); // getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
if (android.os.Build.VERSION.SDK_INT != Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
......
...@@ -34,44 +34,19 @@ public class LoadingDialog extends BaseDialog { ...@@ -34,44 +34,19 @@ public class LoadingDialog extends BaseDialog {
private LayoutParams lp; private LayoutParams lp;
private TextView loadtext; private TextView loadtext;
private LinearLayout loading_ll; private LinearLayout loading_ll;
private ImageView loading_iv;
public LoadingDialog(Context context) { public LoadingDialog(Context context) {
super(context, R.style.dialog); super(context, R.style.dialog);
this.mContext = context; this.mContext = context;
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.loadingdialog, null); View layout = inflater.inflate(R.layout.loadingdialog, null);
// if (android.os.Build.VERSION.SDK_INT > 22) {//android 6.0替换clip的加载动画 if (android.os.Build.VERSION.SDK_INT > 22) {//android 6.0替换clip的加载动画
// final Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ufo_loading_refresh); final Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ufo_loading_refresh);
// ProgressBar loading_bar = (ProgressBar) layout.findViewById(R.id.loading_bar); ProgressBar loading_bar = (ProgressBar) layout.findViewById(R.id.loading_bar);
// loading_bar.setIndeterminateDrawable(drawable); loading_bar.setIndeterminateDrawable(drawable);
// } }
// loadtext = (TextView) layout.findViewById(R.id.loading_text);
// loading_ll = (LinearLayout) layout.findViewById(R.id.loading_ll);
// setContentView(layout);
// // 设置window属性
// lp = getWindow().getAttributes();
// lp.gravity = Gravity.CENTER;
// lp.dimAmount = 0; // 去背景遮盖
// // lp.alpha = 1.0f;//透明效果
// getWindow().setAttributes(lp);
loadtext = (TextView) layout.findViewById(R.id.loading_text); loadtext = (TextView) layout.findViewById(R.id.loading_text);
loading_iv = (ImageView) layout.findViewById(R.id.loading_iv); loading_ll = (LinearLayout) layout.findViewById(R.id.loading_ll);
LottieDrawable lottieDrawable = new LottieDrawable();
LottieCompositionFactory.fromAsset(context, "house_loading.json")
.addListener(new LottieListener<LottieComposition>() {
@Override
public void onResult(LottieComposition result) {
lottieDrawable.setImagesAssetsFolder("images/");
lottieDrawable.setComposition(result);
lottieDrawable.loop(true);
lottieDrawable.playAnimation();
}
});
loading_iv.setImageDrawable(lottieDrawable);
setContentView(layout); setContentView(layout);
// 设置window属性 // 设置window属性
lp = getWindow().getAttributes(); lp = getWindow().getAttributes();
...@@ -88,9 +63,9 @@ public class LoadingDialog extends BaseDialog { ...@@ -88,9 +63,9 @@ public class LoadingDialog extends BaseDialog {
*/ */
public void setLoadText(String content) { public void setLoadText(String content) {
if (TextUtils.isEmpty(content)) { if (TextUtils.isEmpty(content)) {
// loading_ll.setVisibility(View.GONE); loading_ll.setVisibility(View.GONE);
} else { } else {
// loading_ll.setVisibility(View.VISIBLE); loading_ll.setVisibility(View.VISIBLE);
loadtext.setText(content); loadtext.setText(content);
} }
} }
......
...@@ -88,7 +88,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall ...@@ -88,7 +88,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
long diff = currentTimeMillis - activityStoppedTime; long diff = currentTimeMillis - activityStoppedTime;
long diffInSeconds = diff / 1000; long diffInSeconds = diff / 1000;
System.out.println("mcg -->>>>>:: diffInSeconds=" + diffInSeconds + " adSuccessStatus=" + SplashManager.INSTANCE.isSuccessStatus()); System.out.println("mcg -->>>>>:: diffInSeconds=" + diffInSeconds + " adSuccessStatus=" + SplashManager.INSTANCE.isSuccessStatus());
if (diffInSeconds >= 10 && SplashManager.INSTANCE.isSuccessStatus()) { if (diffInSeconds >= 30 && SplashManager.INSTANCE.isSuccessStatus()) {
activity.startActivity(new Intent(activity, SplashForeAdActivity.class)); activity.startActivity(new Intent(activity, SplashForeAdActivity.class));
} }
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<!-- <item android:duration="100">-->
<!-- <clip-->
<!-- android:clipOrientation="horizontal"-->
<!-- android:drawable="@mipmap/loading_u0"-->
<!-- android:gravity="left" />-->
<!-- </item>-->
<item android:duration="100">
<clip
android:clipOrientation="horizontal"
android:drawable="@mipmap/loading_u1"
android:gravity="left" />
</item>
<item android:duration="100">
<clip
android:clipOrientation="horizontal"
android:drawable="@mipmap/loading_u2"
android:gravity="left" />
</item>
<item android:duration="100">
<clip
android:clipOrientation="horizontal"
android:drawable="@mipmap/loading_u3"
android:gravity="left" />
</item>
<item android:duration="100">
<clip
android:clipOrientation="horizontal"
android:drawable="@mipmap/loading_u4"
android:gravity="left" />
</item>
<item android:duration="100">
<clip
android:clipOrientation="horizontal"
android:drawable="@mipmap/loading_u5"
android:gravity="left" />
</item>
<item android:duration="100">
<clip
android:clipOrientation="horizontal"
android:drawable="@mipmap/loading_u6"
android:gravity="left" />
</item>
</animation-list>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@mipmap/loading_u1"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u2"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u3"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u4"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u5"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u7"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u8"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u9"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u10"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u11"
android:duration="100" />
<item
android:drawable="@mipmap/loading_u12"
android:duration="100" />
</animation-list>
\ No newline at end of file
...@@ -2,40 +2,34 @@ ...@@ -2,40 +2,34 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/shape_loading_white" android:background="@drawable/shape_loading_bg"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="14dp" android:paddingLeft="14dp"
android:paddingTop="10dp" android:paddingRight="14dp"
android:paddingRight="14dp"> android:paddingTop="10dp">
<!-- 正在加载 --> <!-- 正在加载 -->
<!-- <ProgressBar--> <ProgressBar
<!-- android:id="@+id/loading_bar"--> android:id="@+id/loading_bar"
<!-- style="@style/loading_small"--> style="@style/loading_small"
<!-- android:layout_width="74dip"--> android:layout_width="74dip"
<!-- android:layout_height="74dip" />--> android:layout_height="74dip" />
<ImageView
android:id="@+id/loading_iv"
android:scaleType="centerCrop"
android:layout_width="80dip"
android:layout_height="80dip" />
<LinearLayout <LinearLayout
android:id="@+id/loading_ll" android:id="@+id/loading_ll"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4.0dip" android:layout_marginBottom="8.0dip"
android:layout_marginBottom="8.0dip"> android:layout_marginTop="4.0dip">
<TextView <TextView
android:id="@+id/loading_text" android:id="@+id/loading_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="加载中..." android:text="加载中..."
android:textColor="@color/black" android:textColor="@color/white"
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>
......
...@@ -85,4 +85,12 @@ ...@@ -85,4 +85,12 @@
<item name="android:progressDrawable">@drawable/custom_seekbar_progress</item> <item name="android:progressDrawable">@drawable/custom_seekbar_progress</item>
<item name="android:thumb">@drawable/custom_seekbar_thumb</item> <item name="android:thumb">@drawable/custom_seekbar_thumb</item>
</style> </style>
<style name="loading_small" parent="@android:style/Widget.ProgressBar.Small">
<item name="android:indeterminateDrawable">@drawable/ufo_loading</item>
<item name="android:layout_width">25dip</item>
<item name="android:layout_height">25dip</item>
<item name="android:layout_gravity">center</item>
</style>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment