Skip to content

Commit

Permalink
Merge pull request #7 from HanteIsHante/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
HanteIsHante committed Apr 26, 2017
2 parents badf099 + ff5a0b5 commit 3cc38ec
Show file tree
Hide file tree
Showing 28 changed files with 1,093 additions and 382 deletions.
8 changes: 8 additions & 0 deletions .idea/markdown-exported-files.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.hante.thirdopen"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true // 会告诉 proguard 删除所有未使用的方法和指令,进一步的减少 .dex 文件的大小。
shrinkResources true // 设置 shrinkResources 属性为 true,这会在打包时删除未使用的资源:
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand All @@ -24,9 +25,13 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'

// 最新更新
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-dynamic-animation:25.3.1'

// butterknife
dependencies {
compile 'com.jakewharton:butterknife:8.4.0'
Expand All @@ -45,8 +50,6 @@ dependencies {
//okhttp
compile 'com.squareup.okhttp3:okhttp:3.5.0'

// Design
compile 'com.android.support:design:25.0.1'

// 添加 ConstraintLayout 约束布局
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".ThirdOpenApplication"
android:name=".application.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -24,6 +24,7 @@
</activity>
<activity android:name=".flashpage.FlashActivity">
</activity>
<activity android:name=".activity.BookInfoActivity"/>
</application>

</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import com.example.hante.thirdopen.base.BaseActivity;
import com.example.hante.thirdopen.mvp.fragment.BookFragment;

import java.util.ArrayList;
Expand All @@ -15,7 +21,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;

public class ThirdOpenHomeActivity extends AppCompatActivity {
public class ThirdOpenHomeActivity extends BaseActivity {

@BindView(R.id.toolbar_home)
Toolbar mToolbarHome;
Expand All @@ -41,10 +47,9 @@ private void initUI () {
}
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//---
List<Fragment> mFragmentList = new ArrayList<>();
List<String> mStringList = new ArrayList<>();
BookFragment mBookFragment;
BookFragment mBookFragment = null;
for(int i = 0; i < 6; i++) {
mBookFragment = new BookFragment();
mFragmentList.add(mBookFragment);
Expand All @@ -64,4 +69,35 @@ private void initUI () {
mTabLayoutViewpager.setAdapter(mViewPagerAdapter);
mHomeTabLayout.setupWithViewPager(mTabLayoutViewpager);
}


@Override
public boolean onCreateOptionsMenu (Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
/**
* 搜索按钮的相关逻辑
* */
MenuItem menuItem=menu.findItem(R.id.action_search);//
SearchView searchView= (SearchView) MenuItemCompat.getActionView(menuItem);//加载searchview
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Toast.makeText(ThirdOpenHomeActivity.this, query, Toast.LENGTH_SHORT).show();
return true;
}

@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty((newText))){
Toast.makeText(ThirdOpenHomeActivity.this,"isEmpty",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(ThirdOpenHomeActivity.this, newText,Toast.LENGTH_SHORT).show();
}
return true;}
});//为搜索框设置监听事件
searchView.setSubmitButtonEnabled(true);//设置是否显示搜索按钮
searchView.setQueryHint("查找");//设置提示信息
searchView.setIconifiedByDefault(true);//设置搜索默认为图标
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.example.hante.thirdopen.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.hante.thirdopen.R;
import com.example.hante.thirdopen.base.BaseActivity;
import com.example.hante.thirdopen.mvp.model.FreeBookModel;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* Created By HanTe
*/

public class BookInfoActivity extends BaseActivity {


@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.book_image)
ImageView bookImage;
@BindView(R.id.book_name)
TextView bookName;
@BindView(R.id.book_auth)
TextView bookAuth;
@BindView(R.id.booktype)
TextView bookype;
@BindView(R.id.book_progress)
TextView bookProgress;
@BindView(R.id.download)
TextView download;
@BindView(R.id.book_desc)
TextView bookDesc;

@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.book_info);
ButterKnife.bind(this);
int id = getIntent().getIntExtra("id", 0);
if (id != 0){
FreeBookModel.getFreeBookInfo(id);
}
}

public static void setId (Activity activity, int id) {
Intent intent = new Intent(activity, BookInfoActivity.class);
intent.putExtra("id", id);
activity.startActivity(intent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.example.hante.thirdopen.animation;

import android.content.Context;
import android.support.animation.SpringAnimation;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
* 在刚推出的 Support Library 25.3.0
* 里面新增了一个叫 SpringAnimation 的动画,也就是弹簧动画。
* 用它来做一个滑动控件下拉回弹的效果
* 回弹 动画
*/

public class SpringScrollView extends NestedScrollView {

private float startDragY;
private SpringAnimation mSpringAnimation;

public SpringScrollView (Context context) {
super(context);
}

public SpringScrollView (Context context, AttributeSet attrs) {
super(context, attrs, 0);
}

public SpringScrollView (Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mSpringAnimation = new SpringAnimation(this, SpringAnimation.TRANSLATION_Y, 0);
// 刚度 默认1200 值越大回弹的速度越快
mSpringAnimation.getSpring().setStiffness(800.0f);
// 阻尼 默认0.5 值越小,回弹之后来回的次数越多
mSpringAnimation.getSpring().setDampingRatio(0.50f);
}

@Override
public boolean onTouchEvent (MotionEvent ev) {
switch(ev.getAction()){
case MotionEvent.ACTION_MOVE:
if(getScrollY() <= 0) {
// 顶部下拉
if (startDragY == 0){
startDragY = ev.getRawY();
}
if (ev.getRawX() - startDragY > 0){
setTranslationY((ev.getRawY() - startDragY) / 3);
return true;
} else {
startDragY = 0;
mSpringAnimation.cancel();
setTranslationY(0);
}
} else if ((getScrollY() + getHeight()) >= getChildAt(0).getMeasuredHeight()) {
//底部上拉
if (startDragY == 0) {
startDragY = ev.getRawY();
}
if (ev.getRawY() - startDragY < 0) {
setTranslationY((ev.getRawY() - startDragY) / 3);
return true;
} else {
startDragY = 0;
mSpringAnimation.cancel();
setTranslationY(0);
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (getTranslationY() != 0) {
mSpringAnimation.start();
}
startDragY = 0;
break;
}
return super.onTouchEvent(ev);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.Activity;
import android.app.Application;

import com.example.hante.thirdopen.util.LogUtils;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -22,6 +24,9 @@ public class MyApplication extends Application {
public void onCreate () {
super.onCreate();
instance = this;

new LogUtils.Builder();

}

/**
Expand Down Expand Up @@ -93,6 +98,4 @@ public void exit() {
}
System.exit(0);
}


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public class Contract {



public static final String FREEBOOK_BASE_URL = "http://mylance.top/";
public static final String FreeBook_Base_Url = "http://mylance.top/";

public static final String ZHIHU_BASE_URL = "";
public static final String ZhiHu_Base_Url = "";

public static final String DOUBAN_BASE_URL = "https://api.douban.com/v2/";
public static final String DouBan_Base_Url = "https://api.douban.com/v2/";

//data/all/{条数}/{page}
public static final String GITHUB_BASE_URL = "http://www.gank.io/api/data/all/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.hante.thirdopen.base;
package com.example.hante.thirdopen.mvp;

/**
* Created By HanTe
Expand All @@ -7,7 +7,7 @@

public interface BasePresenter<T> {

void onSuccess(T data);
void onFail(String msg);
void onSuccess (T data);
void onFail (String msg);

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.hante.thirdopen.base;
package com.example.hante.thirdopen.mvp;

/**
* Created By HanTe
Expand Down
Loading

0 comments on commit 3cc38ec

Please sign in to comment.