Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
firelotus committed Jul 17, 2018
2 parents 8f25a65 + dc32503 commit 6937812
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 41 deletions.
7 changes: 2 additions & 5 deletions MeteoriteLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ dependencies {
//https://github.com/pwittchen/ReactiveNetwork
compile "com.github.pwittchen:reactivenetwork-rx2:${versions.reactivenetwork}"

//https://github.com/permissions-dispatcher/PermissionsDispatcher
compile("com.github.hotchemi:permissionsdispatcher:${versions.permissionsdispatcher}") {
// if you don't use android.app.Fragment you can exclude support for them
exclude module: "support-v13"
}
//https://github.com/tbruyelle/RxPermissions
compile "com.github.tbruyelle:rxpermissions:${versions.rxpermissions}"

//https://github.com/crazycodeboy/TakePhoto
compile "com.jph.takephoto:takephoto_library:${versions.takephoto}"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- 1、MVP
- 2、网络请求(Novate基于rxjava,okhttp,retrofit封装架构)
- 3、DbFlow(可保存文件入SD卡)
- 4、6.0权限申请
- 4、6.0权限申请(rxpermissions)
- 5、XRecyclerView
- 6、万能Adapter
- 7、异常处理
Expand All @@ -19,10 +19,15 @@
- 15、升级更新
- 16、极光推送
- 17、butterknife
- 18、APP启动图标多环境区分(easylauncher)
- 19、函数输入参数打印(Hugo)

<img width="320" height=“480” src="https://github.com/firelotus/Meteorite/blob/develop/image/app.gif"></img>
<img width="320" height=“480” src="https://github.com/firelotus/Meteorite/blob/develop/image/log.gif"></img>
<img width="320" height=“480” src="https://github.com/firelotus/Meteorite/blob/develop/image/signedApk.gif"></img>
<img width="320" height=“480” src="https://github.com/firelotus/Meteorite/blob/develop/image/permission.gif"></img>
<img width="1329" height=“365” src="https://github.com/firelotus/Meteorite/blob/develop/image/hugo.png"></img>
<img width="144" height=“144” src="https://github.com/firelotus/Meteorite/blob/develop/image/easylauncher.png"></img>


License
Expand Down
41 changes: 26 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'com.akaita.android.easylauncher'
apply plugin: 'com.jakewharton.hugo'
apply from: '../dependencies.gradle'
def PRODUCT_NAME = "陨石"

Expand Down Expand Up @@ -77,17 +79,6 @@ android {
def versionName = defaultConfig.versionName
// 开发环境
buildConfigField "String", "APP_ENV", "\"${flavorName}\""
// 修改打包环境的url
def base_url = ''
if(flavorName.equals("rls")){//生产环境
base_url = 'http://gank.io/api/'
}else if(flavorName.equals("dev")){//开发环境(模拟)
base_url = 'http://dev.gank.io/api/'
}else if(flavorName.equals("sit")){//测试环境(模拟)
base_url = 'http://sit.gank.io/api/'
}
buildConfigField "String", "BASE_URL", "\"${base_url}\""

// yourapkname_release_myapk_ver1.0.0_build20130312.apk 输出格式
def fileName = "${PRODUCT_NAME}_V${versionName}_${buildTypeName}_${flavorName}_${BUILD_TIME_FORMAT}.apk"

Expand All @@ -98,11 +89,17 @@ android {

productFlavors {
//生产环境
rls {}
rls {
buildConfigField "String", "BASE_URL", "\"http://gank.io/api/\""
}
//开发环境
dev {}
dev {
buildConfigField "String", "BASE_URL", "\"http://dev.gank.io/api/\""
}
//测试环境
sit {}
sit {
buildConfigField "String", "BASE_URL", "\"http://sit.gank.io/api/\""
}
}

lintOptions {
Expand Down Expand Up @@ -133,5 +130,19 @@ dependencies {
exclude group: 'com.google.code.gson', module: 'gson'
}

annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:${versions.permissionsdispatcher}"
}

//更改程序图标
easylauncher {
defaultFlavorNaming = true // Use flavor name for default ribbon, instead of the type name
variants {
devRelease {
filters = customColorRibbonFilter("dev", "#6600CC")
enable true
}
sitRelease {
filters = customColorRibbonFilter("sit", "#6600CC")
enable true
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name=".base.BaseApplication"
android:allowBackup="true"
Expand All @@ -32,6 +33,7 @@
android:launchMode="singleTop"/>
<activity android:name=".ui.ImageViewerActivity" android:launchMode="singleTop"/>
<activity android:name=".ui.FeedBackActivity" />
<activity android:name=".ui.ViewPagerActivity" />
</application>

</manifest>
35 changes: 28 additions & 7 deletions app/src/main/java/com/firelotus/meteorite/ui/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.firelotus.meteorite.ui;

import android.Manifest;
import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
Expand All @@ -19,17 +20,23 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.firelotus.meteorite.R;
import com.firelotus.meteorite.ui.content.SubFragment;
import com.firelotus.meteoritelibrary.base.BaseActivity;
import com.firelotus.meteoritelibrary.toast.MToast;
import com.firelotus.meteoritelibrary.tools.MLog;
import com.orhanobut.logger.Logger;
import com.shizhefei.view.indicator.FixedIndicatorView;
import com.shizhefei.view.indicator.IndicatorViewPager;
import com.shizhefei.view.indicator.transition.OnTransitionTextListener;
import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;

import butterknife.BindView;
import de.hdodenhof.circleimageview.CircleImageView;
import io.reactivex.functions.Consumer;

public class MainActivity extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener,View.OnClickListener {
Expand Down Expand Up @@ -72,7 +79,7 @@ public void onClick(View view) {

navigationView.setNavigationItemSelectedListener(this);

profile_image = (CircleImageView) navigationView.getHeaderView(0).findViewById(R.id.profile_image);
profile_image = navigationView.getHeaderView(0).findViewById(R.id.profile_image);
profile_image.setOnClickListener(this);

float unSelectSize = 16;
Expand All @@ -94,12 +101,26 @@ public void onClick(View view) {

@Override
protected void initData() {

//rxpermissions实现6.0权限申请
RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions.requestEach(Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA)
.subscribe(new Consumer<Permission>() {
@Override
public void accept(Permission permission) throws Exception {
if(permission.granted){
MLog.d("Permission granted !");
}else if(permission.shouldShowRequestPermissionRationale){
MToast.show(getApplicationContext(),"Denied permission without ask never again !", Toast.LENGTH_LONG);
}else{
MToast.show(getApplicationContext(),"Permission denied !", Toast.LENGTH_LONG);
}
}
});
}

@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
Expand Down Expand Up @@ -137,18 +158,18 @@ public boolean onNavigationItemSelected(MenuItem item) {
if (id == R.id.nav_home) {
} else if (id == R.id.nav_about) {
tv_content.setText("about");
AboutActivity.start(getApplicationContext());
AboutActivity.start(this);
} else if (id == R.id.nav_login) {
WebActivity.loadUrl(getApplicationContext(), "https://github.com/login", "登录GitHub");
WebActivity.loadUrl(this, "https://github.com/login", "登录GitHub");
} else if (id == R.id.nav_set) {
tv_content.setText("set");
} else if (id == R.id.nav_comments) {
FeedBackActivity.start(getApplicationContext());
FeedBackActivity.start(this);
} else if (id == R.id.nav_logout) {
finish();
}
Logger.d(tv_content.getText().toString());
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
Expand Down
100 changes: 100 additions & 0 deletions app/src/main/java/com/firelotus/meteorite/ui/ViewPagerActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.firelotus.meteorite.ui;

/**
* Created by firelotus on 2018/1/1.
*/

import android.content.Context;
import android.content.Intent;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;

import com.bumptech.glide.Glide;
import com.firelotus.meteorite.R;
import com.firelotus.meteorite.ui.bean.GankBean;
import com.firelotus.meteoritelibrary.base.BaseActivity;
import com.github.chrisbanes.photoview.PhotoView;

import java.util.ArrayList;

public class ViewPagerActivity extends BaseActivity {
private int pos;
private ArrayList<GankBean> list = new ArrayList<>();
private ViewPager viewPager;
private ViewPagerAdapter adapter;

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

@Override
protected void initView() {
viewPager = findViewById(R.id.view_pager);
adapter = new ViewPagerAdapter(list);
viewPager.setAdapter(adapter);
}

@Override
protected void initData() {
Intent intent = getIntent();
if(intent == null){
return;
}
pos = intent.getIntExtra("pos",0);
ArrayList<GankBean> tmpList = (ArrayList<GankBean>) intent.getSerializableExtra("list");
if(tmpList != null){
list.clear();
list.addAll(tmpList);
adapter.notifyDataSetChanged();
}

//切换到选中页
viewPager.setCurrentItem(pos);
}

static class ViewPagerAdapter extends PagerAdapter {
private ArrayList<GankBean> gankBeans = new ArrayList<>();

public ViewPagerAdapter(ArrayList<GankBean> list){
this.gankBeans = list;
}

@Override
public int getCount() {
return gankBeans.size();
}

@Override
public View instantiateItem(ViewGroup container, int position) {
PhotoView photoView = new PhotoView(container.getContext());
//photoView.setImageURI(Uri.parse(gankBeans.get(position).getUrl()));
Glide.with(container.getContext()).load(gankBeans.get(position).getUrl()).into(photoView);
// Now just add PhotoView to ViewPager and return it
container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

return photoView;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}

}

public static void start(Context context, int pos, ArrayList<GankBean> gankBeans){
Intent intent = new Intent(context,ViewPagerActivity.class);
intent.putExtra("pos",pos);
intent.putExtra("list",gankBeans);
context.startActivity(intent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import android.support.annotation.Keep;

import java.io.Serializable;
import java.util.List;

/**
* Created by firelotus on 2017/10/15.
*/
@Keep
public class GankBean {
public class GankBean implements Serializable{

/**
* _id : 59e46c6a421aa90fe50c0174
Expand Down
Loading

0 comments on commit 6937812

Please sign in to comment.