-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
194 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/src/main/java/sample/kingja/loadsir/base/BaseTitleActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package sample.kingja.loadsir.base; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.FrameLayout; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import com.kingja.loadsir.callback.Callback; | ||
import com.kingja.loadsir.core.LoadService; | ||
import com.kingja.loadsir.core.LoadSir; | ||
|
||
import butterknife.ButterKnife; | ||
import sample.kingja.loadsir.R; | ||
|
||
/** | ||
* Description:TODO | ||
* Create Time:2017/3/20 14:17 | ||
* Author:KingJA | ||
* Email:[email protected] | ||
*/ | ||
public abstract class BaseTitleActivity extends AppCompatActivity { | ||
protected View rootView; | ||
protected LoadService mBaseLoadService; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
rootView = View.inflate(this, R.layout.activity_title, null); | ||
addContent(); | ||
setContentView(rootView); | ||
initView(); | ||
initNet(); | ||
} | ||
|
||
|
||
private void addContent() { | ||
FrameLayout flContent = (FrameLayout) rootView.findViewById(R.id.fl_content); | ||
TextView tvTitleTitle = (TextView) rootView.findViewById(R.id.tv_title_title); | ||
LinearLayout llTitleBack = (LinearLayout) rootView.findViewById(R.id.ll_title_back); | ||
tvTitleTitle.setText(getContentTitle() == null ? "" : getContentTitle()); | ||
llTitleBack.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
backClick(); | ||
} | ||
}); | ||
View content = View.inflate(this, getContentView(), null); | ||
if (content != null) { | ||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, | ||
FrameLayout.LayoutParams.MATCH_PARENT); | ||
flContent.addView(content, params); | ||
ButterKnife.bind(this, rootView); | ||
mBaseLoadService = LoadSir.getDefault().register(content, new Callback.OnReloadListener() { | ||
@Override | ||
public void onReload(View v) { | ||
onNetReload(v); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private void backClick() { | ||
finish(); | ||
} | ||
|
||
protected abstract String getContentTitle(); | ||
|
||
protected abstract int getContentView(); | ||
|
||
protected abstract void initView(); | ||
|
||
protected abstract void initNet(); | ||
|
||
protected abstract void onNetReload(View v); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package sample.kingja.loadsir.target; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.Window; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import butterknife.BindView; | ||
import sample.kingja.loadsir.PostUtil; | ||
import sample.kingja.loadsir.R; | ||
import sample.kingja.loadsir.base.BaseTitleActivity; | ||
import sample.kingja.loadsir.callback.ErrorCallback; | ||
import sample.kingja.loadsir.callback.LoadingCallback; | ||
|
||
/** | ||
* Description: | ||
|
@@ -13,15 +17,36 @@ | |
* Email:[email protected] | ||
*/ | ||
|
||
public class KeepTitleActivity extends AppCompatActivity { | ||
public class KeepTitleActivity extends BaseTitleActivity { | ||
@BindView(R.id.tv_title) | ||
TextView mTvTitle; | ||
|
||
|
||
@Override | ||
protected String getContentTitle() { | ||
return "Title"; | ||
} | ||
|
||
@Override | ||
protected int getContentView() { | ||
return R.layout.activity_content; | ||
} | ||
|
||
@Override | ||
protected void initView() { | ||
TextView tv_msg = (TextView) findViewById(R.id.tv_subTitle); | ||
tv_msg.setText("Keep Title In Activity"); | ||
mTvTitle.setText("Yes, Success"); | ||
} | ||
|
||
@Override | ||
protected void initNet() { | ||
PostUtil.postCallbackDelayed(mBaseLoadService, ErrorCallback.class); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
setContentView(R.layout.activity_content); | ||
if (getSupportActionBar() != null) { | ||
getSupportActionBar().hide(); | ||
} | ||
protected void onNetReload(View v) { | ||
mBaseLoadService.showCallback(LoadingCallback.class); | ||
PostUtil.postSuccessDelayed(mBaseLoadService); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportHeight="24.0" | ||
android:viewportWidth="24.0"> | ||
<path | ||
android:fillColor="@color/red" | ||
android:pathData="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/> | ||
</vector> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="48dp" | ||
android:background="@color/black"> | ||
|
||
<LinearLayout | ||
android:id="@+id/ll_title_back" | ||
android:layout_width="48dp" | ||
android:layout_height="48dp" | ||
android:gravity="center"> | ||
|
||
<ImageView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/svg_top_back" | ||
android:tint="@color/white"/> | ||
</LinearLayout> | ||
|
||
|
||
<TextView | ||
android:id="@+id/tv_title_title" | ||
style="@style/font_f_18" | ||
android:text="标题" | ||
android:layout_centerInParent="true" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"/> | ||
|
||
</RelativeLayout> | ||
|
||
<FrameLayout | ||
android:id="@+id/fl_content" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters