Skip to content

Commit

Permalink
BackupRestore: Refactor model layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mao Jun committed Apr 13, 2018
1 parent fed3e18 commit 6a26470
Show file tree
Hide file tree
Showing 47 changed files with 579 additions and 294 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

dataBinding {
enabled = true
}

//签名配置
signingConfigs {
release {
Expand Down Expand Up @@ -99,7 +103,6 @@ dependencies {
implementation project(':loglibrary')
implementation project(':commonlibrary')
implementation project(':vcardlibrary')
implementation project(':modellibrary')

testImplementation "junit:junit:$rootProject.ext.junit_version"
androidTestImplementation "com.android.support.test:runner:$rootProject.ext.runner_version"
Expand Down
8 changes: 8 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep class android.support.v4.widget.DrawerLayout { *; }

-keepclassmembers class **.R$* {
public static <fields>;
}

-keep class android.databinding.** { *; }

-ignorewarnings

-keepattributes *Annotation*

#RxJava
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import android.os.StrictMode;

import com.bumptech.glide.Glide;
import com.koma.backuprestore.modellibrary.ApplicationModule;
import com.koma.backuprestore.modellibrary.BackupRestoreRepositoryComponent;
import com.koma.backuprestore.modellibrary.BackupRestoreRepositoryModule;
import com.koma.backuprestore.modellibrary.DaggerBackupRestoreRepositoryComponent;
import com.koma.backuprestore.data.ApplicationModule;
import com.koma.backuprestore.data.BackupRestoreRepositoryComponent;
import com.koma.backuprestore.data.BackupRestoreRepositoryModule;
import com.koma.backuprestore.data.DaggerBackupRestoreRepositoryComponent;
import com.koma.loglibrary.KomaLog;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.koma.backuprestore.R;
import com.koma.backuprestore.commonlibrary.base.BaseActivity;
import com.koma.backuprestore.commonlibrary.util.ActivityUtils;
import com.koma.backuprestore.restore.dialog.RestoreProgressDialogFragment;
import com.koma.loglibrary.KomaLog;

import javax.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.koma.backuprestore.backup;

import com.koma.backuprestore.commonlibrary.util.ActivityScoped;
import com.koma.backuprestore.modellibrary.BackupRestoreRepositoryComponent;
import com.koma.backuprestore.data.BackupRestoreRepositoryComponent;

import dagger.Component;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package com.koma.backuprestore.backup;

import com.koma.backuprestore.modellibrary.BackupRestoreRepository;
import com.koma.backuprestore.modellibrary.entities.App;
import com.koma.backuprestore.data.BackupRestoreRepository;
import com.koma.backuprestore.data.entities.App;
import com.koma.loglibrary.KomaLog;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2017 Koma
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.koma.backuprestore.backup.category;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;

import com.koma.backuprestore.R;
import com.koma.backuprestore.commonlibrary.base.BaseActivity;
import com.koma.backuprestore.commonlibrary.util.Constants;
import com.koma.loglibrary.KomaLog;

import butterknife.BindView;

/**
* Created by koma on 4/11/18.
*/

public class CategoryActivity extends BaseActivity {
private static final String TAG = CategoryActivity.class.getSimpleName();

@BindView(R.id.toolbar)
Toolbar mToolbar;

private int mCategory;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

KomaLog.i(TAG, "onCreate");
}

@Override
protected int getLayoutId() {
return R.layout.activity_base;
}

@Override
protected String[] getPermissions() {
return new String[0];
}

@Override
protected void onPermissonGranted() {
KomaLog.i(TAG, "onPermissionGranted");

mCategory = getIntent().getIntExtra(Constants.CATEGORY_TAG, Constants.CATEGORY_CANTACT);

setSupportActionBar(mToolbar);
}

@Override
protected void onNewIntent(Intent newIntent) {
super.onNewIntent(newIntent);

setIntent(newIntent);

KomaLog.i(TAG, "onNewIntent");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2017 Koma
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.koma.backuprestore.backup.category;

import com.koma.backuprestore.commonlibrary.base.BasePresenter;
import com.koma.backuprestore.commonlibrary.base.BaseView;

/**
* Created by koma on 4/11/18.
*/

public interface CategoryContract {
interface View extends BaseView<Presenter> {
void setLoadingIndicator(boolean isActive);
}

interface Presenter extends BasePresenter {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.koma.backuprestore.backup.category;

import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.koma.backuprestore.R;
import com.koma.backuprestore.commonlibrary.base.BaseFragment;
import com.koma.loglibrary.KomaLog;

import butterknife.BindView;

/**
* Created by koma on 4/11/18.
*/

public class CategoryFragment extends BaseFragment implements CategoryContract.View {
private static final String TAG = CategoryFragment.class.getSimpleName();

@BindView(R.id.swipe_refresh_layout)
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view)
RecyclerView mRecyclerView;

private CategoryContract.Presenter mPresenter;

public static CategoryFragment newInstance() {
return new CategoryFragment();
}

public CategoryFragment() {
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

KomaLog.i(TAG, "onViewCreated");

mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {

}
});
}

@Override
public void onDestroyView() {
super.onDestroyView();

KomaLog.i(TAG, "onDestroyView");

if (mPresenter != null) {
mPresenter.unSubscribe();
}
}

@Override
public int getLayoutId() {
return R.layout.fragment_base;
}

@Override
public void setPresenter(CategoryContract.Presenter presenter) {
mPresenter = presenter;
}

@Override
public void setLoadingIndicator(final boolean isActive) {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(isActive);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.koma.backuprestore.modellibrary.source.restore;

import android.content.Context;

import javax.inject.Inject;
import javax.inject.Singleton;
package com.koma.backuprestore.backup.category;

/**
* Created by koma on 3/20/18.
* Created by koma on 4/11/18.
*/

@Singleton
public class RestoreDataSource implements IRestoreDataSource {
private final Context mContext;
public class CategoryPresenter implements CategoryContract.Presenter {
@Override
public void subscribe() {

}

@Override
public void unSubscribe() {

@Inject
public RestoreDataSource(Context context) {
mContext = context;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2017 Koma
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.koma.backuprestore.backup.category;

import dagger.Module;

/**
* Created by koma on 4/11/18.
*/

@Module
public class CategoryPresenterModule {

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.koma.backuprestore.modellibrary;
package com.koma.backuprestore.data;

import android.content.Context;

Expand Down
Loading

0 comments on commit 6a26470

Please sign in to comment.