parent
e3a27ab7a2
commit
40c210c751
@ -0,0 +1,76 @@ |
||||
package com.arialyy.simple; |
||||
|
||||
import android.os.Bundle; |
||||
|
||||
import android.util.Log; |
||||
import android.view.View; |
||||
import com.arialyy.aria.core.download.DownloadEntity; |
||||
import com.arialyy.aria.core.download.DownloadTaskEntity; |
||||
import com.arialyy.aria.core.inf.AbsEntity; |
||||
import com.arialyy.aria.orm.DbEntity; |
||||
import com.arialyy.simple.base.BaseActivity; |
||||
import com.arialyy.simple.databinding.ActivityDbTestBinding; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
|
||||
public class DbTestActivity extends BaseActivity<ActivityDbTestBinding> { |
||||
@Override |
||||
protected int setLayoutId() { |
||||
return R.layout.activity_db_test; |
||||
} |
||||
|
||||
@Override |
||||
protected void init(Bundle savedInstanceState) { |
||||
super.init(savedInstanceState); |
||||
} |
||||
|
||||
public void onClick(View view) { |
||||
switch (view.getId()) { |
||||
case R.id.insert: |
||||
insertManyRecord(10000); |
||||
break; |
||||
case R.id.search: |
||||
break; |
||||
case R.id.search_all: |
||||
searchAll(); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
private void searchAll(){ |
||||
long startT = System.currentTimeMillis(); |
||||
//List<DownloadTaskEntity> data = DownloadEntity.findRelationData(DownloadEntity.class);
|
||||
|
||||
long endT = System.currentTimeMillis(); |
||||
Log.d(TAG, "search_time=" + (endT - startT)); |
||||
} |
||||
|
||||
private void insertManyRecord(int len) { |
||||
long startT = System.currentTimeMillis(); |
||||
List<DbEntity> datas = new ArrayList<>(); |
||||
for (int i = 0; i < len; i++) { |
||||
String key = UUID.randomUUID().toString(); |
||||
String url = "https://blog.csdn.net/carefree31441/article/details/3998553"; |
||||
|
||||
DownloadEntity entity = new DownloadEntity(); |
||||
entity.setUrl(url); |
||||
entity.setFileName("ssssssssssssssssss"); |
||||
entity.setDownloadPath(key); |
||||
|
||||
DownloadTaskEntity dte = new DownloadTaskEntity(); |
||||
dte.setUrl(url); |
||||
dte.setKey(key); |
||||
dte.setEntity(entity); |
||||
|
||||
datas.add(entity); |
||||
datas.add(dte); |
||||
} |
||||
|
||||
//AbsEntity.insertManyData(DownloadEntity.class, datas);
|
||||
AbsEntity.saveAll(datas); |
||||
long endT = System.currentTimeMillis(); |
||||
|
||||
Log.d(TAG, "insert_time=" + (endT - startT)); |
||||
} |
||||
} |
@ -0,0 +1,33 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<include layout="@layout/layout_bar"/> |
||||
|
||||
<Button |
||||
android:id="@+id/insert" |
||||
android:onClick="onClick" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:text="插入"/> |
||||
|
||||
<Button |
||||
android:id="@+id/search" |
||||
android:onClick="onClick" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:text="查询"/> |
||||
|
||||
<Button |
||||
android:id="@+id/search_all" |
||||
android:onClick="onClick" |
||||
android:text="查询全部" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content"/> |
||||
|
||||
</LinearLayout> |
||||
</layout> |
Loading…
Reference in new issue