Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerr1Gan committed Nov 5, 2018
1 parent 8c98239 commit a0fd820
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 19 deletions.
15 changes: 15 additions & 0 deletions flesh/src/main/java/com/ecjtu/flesh/mvp/IPresenter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ecjtu.flesh.mvp;

public interface IPresenter<T> {
/**
* Binds presenter with a view when resumed. The Presenter will perform initialization here.
*
* @param view the view associated with this presenter
*/
void takeView(T view);

/**
* Drops the reference to the view when destroyed
*/
void dropView();
}
4 changes: 4 additions & 0 deletions flesh/src/main/java/com/ecjtu/flesh/mvp/IView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.ecjtu.flesh.mvp;

public interface IView<T> {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecjtu.flesh.presenter
package com.ecjtu.flesh.mvp.presenter

import android.app.Activity
import android.support.v7.widget.LinearLayoutManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecjtu.flesh.presenter
package com.ecjtu.flesh.mvp.presenter

import android.app.Activity
import android.app.Application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecjtu.flesh.presenter
package com.ecjtu.flesh.mvp.presenter

import android.graphics.Bitmap
import android.graphics.Canvas
Expand Down Expand Up @@ -43,7 +43,7 @@ import kotlin.concurrent.thread
/**
* Created by KerriGan on 2017/6/2.
*/
class MainActivityDelegate(owner: MainActivity) : Delegate<MainActivity>(owner) {
class MainActivityDelegate(owner: MainActivity) : Delegate<MainActivity>(owner), MainContract.Presenter {

companion object {
private const val KEY_LAST_TAB_ITEM = "key_last_tab_item"
Expand Down Expand Up @@ -176,26 +176,23 @@ class MainActivityDelegate(owner: MainActivity) : Delegate<MainActivity>(owner)
// }
}

fun onStop() {
override fun onStop() {
mViewPager.adapter?.let {
(mViewPager.adapter as TabPagerAdapter).onStop(owner)
val helper = MenuListCacheHelper(owner.filesDir.absolutePath)
helper.put(CACHE_MENU_LIST, (mViewPager.adapter as TabPagerAdapter).menu)

PreferenceManager.getDefaultSharedPreferences(owner).edit().
putInt(KEY_LAST_TAB_ITEM, mTabLayout.selectedTabPosition).
putBoolean(KEY_APPBAR_LAYOUT_COLLAPSED, isAppbarLayoutExpand()).
apply()
PreferenceManager.getDefaultSharedPreferences(owner).edit().putInt(KEY_LAST_TAB_ITEM, mTabLayout.selectedTabPosition).putBoolean(KEY_APPBAR_LAYOUT_COLLAPSED, isAppbarLayoutExpand()).apply()
}
}

fun onResume() {
override fun onResume() {
mViewPager.adapter?.let {
(mViewPager.adapter as TabPagerAdapter).onResume()
}
}

fun onDestroy() {
override fun onDestroy() {
// thread {
// val content = findViewById(R.id.drawer_layout)
// content?.let {
Expand Down
11 changes: 11 additions & 0 deletions flesh/src/main/java/com/ecjtu/flesh/mvp/presenter/MainContract.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ecjtu.flesh.mvp.presenter

class MainContract {
interface Presenter {
fun onStop()
fun onResume()
fun onDestroy()
}

interface View
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecjtu.flesh.presenter
package com.ecjtu.flesh.mvp.presenter

import android.database.sqlite.SQLiteDatabase
import android.support.v7.widget.LinearLayoutManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecjtu.flesh.presenter
package com.ecjtu.flesh.mvp.presenter

import android.app.Activity
import com.ecjtu.flesh.ui.adapter.CardListAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecjtu.flesh.presenter
package com.ecjtu.flesh.mvp.presenter

import android.app.Activity
import com.ecjtu.flesh.ui.adapter.CardListAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import com.bumptech.glide.Glide;
import com.ecjtu.flesh.Constants;
import com.ecjtu.flesh.R;
import com.ecjtu.flesh.presenter.MainActivityDelegate;
import com.ecjtu.flesh.mvp.presenter.MainActivityDelegate;
import com.ecjtu.flesh.mvp.presenter.MainContract;
import com.ecjtu.netcore.network.AsyncNetwork;
import com.ecjtu.netcore.network.IRequestCallback;

Expand All @@ -25,7 +26,7 @@
import java.lang.reflect.Field;
import java.net.HttpURLConnection;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements MainContract.View{

private MainActivityDelegate mDelegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import android.widget.Toast
import com.ecjtu.flesh.R
import com.ecjtu.flesh.db.DatabaseManager
import com.ecjtu.flesh.db.table.impl.LikeTableImpl
import com.ecjtu.flesh.presenter.PageDetailActivityDelegate
import com.ecjtu.flesh.mvp.presenter.PageDetailActivityDelegate

/**
* Created by Ethan_Xiang on 2017/9/11.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import android.view.ViewGroup
import com.ecjtu.flesh.R
import com.ecjtu.flesh.db.DatabaseManager
import com.ecjtu.flesh.db.table.impl.HistoryTableImpl
import com.ecjtu.flesh.presenter.PageHistoryFragmentDelegate
import com.ecjtu.flesh.mvp.presenter.PageHistoryFragmentDelegate

/**
* Created by Ethan_Xiang on 2017/9/18.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import android.view.ViewGroup
import com.ecjtu.flesh.R
import com.ecjtu.flesh.db.DatabaseManager
import com.ecjtu.flesh.db.table.impl.LikeTableImpl
import com.ecjtu.flesh.presenter.PageLikeFragmentDelegate
import com.ecjtu.flesh.mvp.presenter.PageLikeFragmentDelegate

/**
* Created by Ethan_Xiang on 2017/9/18.
Expand Down

0 comments on commit a0fd820

Please sign in to comment.