feat: 系统功能抽象
This commit is contained in:
1 parent
b0ea6eff0a
commit
4dcb82b9f4
82 files changed
+4758
-1019
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package com.ttstd.dialer.activity.contact.add;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
@@ -11,6 +10,7 @@ import com.ttstd.dialer.base.mvvm.BaseViewModel;
|
||||
import com.ttstd.dialer.databinding.ActivityContactAddBinding;
|
||||
import com.ttstd.dialer.db.contact.ContactInfo;
|
||||
import com.ttstd.dialer.db.contact.ContactRepository;
|
||||
import com.ttstd.dialer.utils.Logger;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
@@ -39,7 +39,7 @@ public class ContactAddViewModel extends BaseViewModel<ActivityContactAddBinding
|
||||
public void subscribe(@NonNull ObservableEmitter<Long> emitter) throws Throwable {
|
||||
int count = mRepository.getTotalCount() + 1;
|
||||
ContactInfo contactInfo = new ContactInfo(name, phone, count);
|
||||
Log.e(TAG, "saveContact: " + contactInfo);
|
||||
Logger.e(TAG, "saveContact: " + contactInfo);
|
||||
emitter.onNext(mRepository.insert(contactInfo));
|
||||
emitter.onComplete();
|
||||
}
|
||||
@@ -49,23 +49,23 @@ public class ContactAddViewModel extends BaseViewModel<ActivityContactAddBinding
|
||||
.subscribe(new Observer<Long>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("saveContact", "onSubscribe: ");
|
||||
Logger.e("saveContact", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull Long aLong) {
|
||||
Log.e("saveContact", "onNext: " + aLong);
|
||||
Logger.e("saveContact", "onNext: " + aLong);
|
||||
mIntegerMutableLiveData.setValue(aLong);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("saveContact", "onError: " + e.getMessage());
|
||||
Logger.e("saveContact", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("saveContact", "onComplete: ");
|
||||
Logger.e("saveContact", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ttstd.dialer.activity.contact.list;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -17,6 +16,7 @@ import com.ttstd.dialer.base.mvvm.BaseMvvmActivity;
|
||||
import com.ttstd.dialer.databinding.ActivityContactListBinding;
|
||||
import com.ttstd.dialer.db.contact.ContactInfo;
|
||||
import com.ttstd.dialer.fragment.dialog.call.CallFragment;
|
||||
import com.ttstd.dialer.utils.Logger;
|
||||
import com.ttstd.dialer.view.ItemTouchHelperCallback;
|
||||
|
||||
import java.util.List;
|
||||
@@ -59,7 +59,7 @@ public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel,
|
||||
mContactInfoAdapter.setItemMoveCallback(new ContactInfoAdapter.ItemMoveCallback() {
|
||||
@Override
|
||||
public void onItemMove(int fromPosition, int toPosition) {
|
||||
Log.e(TAG, "onItemMove: ");
|
||||
Logger.e(TAG, "onItemMove: ");
|
||||
ContactInfo fromContactInfo = mContactInfos.get(fromPosition);
|
||||
int fromContactPosition = fromContactInfo.getPosition();
|
||||
ContactInfo toContactInfo = mContactInfos.get(toPosition);
|
||||
@@ -72,7 +72,7 @@ public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel,
|
||||
|
||||
@Override
|
||||
public void onItemRemoved(int position) {
|
||||
Log.e(TAG, "onItemRemoved: ");
|
||||
Logger.e(TAG, "onItemRemoved: ");
|
||||
|
||||
}
|
||||
});
|
||||
@@ -98,7 +98,7 @@ public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel,
|
||||
mViewModel.mContactListData.observe(this, new Observer<List<ContactInfo>>() {
|
||||
@Override
|
||||
public void onChanged(List<ContactInfo> contactInfos) {
|
||||
Log.e(TAG, "mContactListData: " + contactInfos);
|
||||
Logger.e(TAG, "mContactListData: " + contactInfos);
|
||||
mContactInfos = contactInfos;
|
||||
mContactInfoAdapter.setContactInfos(mContactInfos);
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,7 +1,6 @@
|
||||
package com.ttstd.dialer.activity.contact.list;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
@@ -11,6 +10,7 @@ import com.ttstd.dialer.base.mvvm.BaseViewModel;
|
||||
import com.ttstd.dialer.databinding.ActivityContactListBinding;
|
||||
import com.ttstd.dialer.db.contact.ContactInfo;
|
||||
import com.ttstd.dialer.db.contact.ContactRepository;
|
||||
import com.ttstd.dialer.utils.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,12 +49,12 @@ public class ContactListViewModel extends BaseViewModel<ActivityContactListBindi
|
||||
.subscribe(new Observer<List<ContactInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAllContacts", "onSubscribe: ");
|
||||
Logger.e("getAllContacts", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<ContactInfo> contactInfos) {
|
||||
Log.e("getAllContacts", "onNext: ");
|
||||
Logger.e("getAllContacts", "onNext: ");
|
||||
mContactListData.setValue(contactInfos);
|
||||
|
||||
// List<Contact> sorted = contacts.stream().sorted(new Comparator<Contact>() {
|
||||
@@ -68,18 +68,18 @@ public class ContactListViewModel extends BaseViewModel<ActivityContactListBindi
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAllContacts", "onError: " + e.getMessage());
|
||||
Logger.e("getAllContacts", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAllContacts", "onComplete: ");
|
||||
Logger.e("getAllContacts", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateItemPosition(ContactInfo contactInfo) {
|
||||
Log.e(TAG, "updateItemPosition: " + contactInfo);
|
||||
Logger.e(TAG, "updateItemPosition: " + contactInfo);
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Throwable {
|
||||
@@ -93,22 +93,22 @@ public class ContactListViewModel extends BaseViewModel<ActivityContactListBindi
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("updateItemPosition", "onComplete: ");
|
||||
Logger.e("updateItemPosition", "onComplete: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull Integer integer) {
|
||||
Log.e("updateItemPosition", "onNext: " + integer);
|
||||
Logger.e("updateItemPosition", "onNext: " + integer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("updateItemPosition", "onError: " + e.getMessage());
|
||||
Logger.e("updateItemPosition", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("updateItemPosition", "onComplete: ");
|
||||
Logger.e("updateItemPosition", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user