Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
qincis committed Jul 3, 2016
1 parent cf4b575 commit c24f525
Show file tree
Hide file tree
Showing 80 changed files with 1,622 additions and 1,288 deletions.
Binary file modified .gradle/2.10/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/taskArtifacts.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* kprogresshud
* android-bottom-sheet
* marked
* SystemBarUtils
* FlycoSystemBar
* 编辑中的撤销和恢复已经提取为单独的库[AndroidEdit] (https://github.com/qinci/AndroidEdit)

感谢
Expand Down
32 changes: 16 additions & 16 deletions app/src/main/java/ren/qinc/markdowneditors/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
package ren.qinc.markdowneditors;

/**
* 相关配置
* 相关配置(后续用到)
* Created by 沈钦赐 on 16/1/16.
*/
public class AppConfig {
//==================缓存文件相关==================
// 设置文件sharedPreference的文件名字
public static String SETTING_FILE_NAME = "setting_file";

//全局变量缓存目录,一般不删除
public static String GLOBA_CACHE_NAME = "globa_file";

//文件缓存(程序缓存数据保存在这里,可以删除)
public static String FILE_CACHE = "cacle_file";

//数据库保存的文件
public static String DB_NAME = "qinc.db";

//null:全部打印,不然{1,2}就打印1和2为flag的api请求
public static final int[] SHOW_LOG =null;
// //==================缓存文件相关==================
// // 设置文件sharedPreference的文件名字
// public static String SETTING_FILE_NAME = "setting_file";
//
// //全局变量缓存目录,一般不删除
// public static String GLOBA_CACHE_NAME = "globa_file";
//
// //文件缓存(程序缓存数据保存在这里,可以删除)
// public static String FILE_CACHE = "cacle_file";
//
// //数据库保存的文件
// public static String DB_NAME = "qinc.db";
//
// //null:全部打印,不然{1,2}就打印1和2为flag的api请求
// public static final int[] SHOW_LOG = null;
}
3 changes: 1 addition & 2 deletions app/src/main/java/ren/qinc/markdowneditors/AppContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import ren.qinc.markdowneditors.base.BaseApplication;

/**
*
* Created by 沈钦赐 on 16/1/26.
*/
public class AppContext extends BaseApplication{
public class AppContext extends BaseApplication {
@Override
protected boolean hasMemoryLeak() {
// return BuildConfig.DEBUG;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ren/qinc/markdowneditors/AppManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public boolean removeActivity(Activity activity) {
return false;
}

if(activityStack==null){
if (activityStack == null) {
return false;
}
return activityStack.remove(activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -53,10 +52,11 @@ public FileListAdapter(Context context, List<FileBean> datas) {
initColor();
}

public void addData(int position,FileBean fileBean) {
public void addData(int position, FileBean fileBean) {
mDatas.add(position, fileBean);
notifyItemInserted(position);
}

public void removeData(FileBean file) {
int position = mDatas.indexOf(file);
mDatas.remove(position);
Expand Down Expand Up @@ -109,7 +109,7 @@ public void onBindViewHolder(FileViewHolder holder, int position) {

//选择模式 颜色设置
if (bean.isSelect) {//选择了
if(colorFilter == null)
if (colorFilter == null)
colorFilter = new PorterDuffColorFilter(colorPrimary, PorterDuff.Mode.SRC_IN);

holder.itemView.setBackgroundColor(alphaColorPrimary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.view.View;

public interface OnItemClickLitener {
void onItemClick(View view, int position);
void onItemClick(View view, int position);

void onItemLongClick(View view, int position);
}
void onItemLongClick(View view, int position);
}
68 changes: 22 additions & 46 deletions app/src/main/java/ren/qinc/markdowneditors/base/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2016. SHENQINCI(沈钦赐)<[email protected]>
*
* 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 ren.qinc.markdowneditors.base;

import android.content.Context;
Expand Down Expand Up @@ -29,7 +45,6 @@
import java.lang.reflect.Field;

import butterknife.ButterKnife;

import ren.qinc.markdowneditors.AppManager;
import ren.qinc.markdowneditors.event.RxEvent;
import ren.qinc.markdowneditors.event.RxEventBus;
Expand Down Expand Up @@ -60,9 +75,6 @@ protected void onCreate(Bundle savedInstanceState) {
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
// }
if (isNeedLogin()) {//如果子类返回true,代表当前界面需要登录才能进去
// AppContext.showToast("请先登录");
//跳到登录界面
//xxxx
finish();
}
registerEvent();
Expand Down Expand Up @@ -249,55 +261,19 @@ public void dismissInput(EditText editTextTemp) {
inputManager.hideSoftInputFromWindow(editTextTemp.getWindowToken(), 0);
}
}
//
// /**
// * 代替findViewById 自动类型转换
// *
// * @param <T> the type parameter
// * @param id the id
// * @return t
// */
// @SuppressWarnings("unchecked")
// @Deprecated
// protected final <T extends View> T findView(@IdRes int id) {
// return (T) findViewById(id);
// }
//
// /**
// * 设置view的点击事件
// * Set view click listener t.
// *
// * @param <T> the type parameter
// * @param v the v
// * @param clickListener the click listener
// * @return the t
// */
// protected final <T extends View> T setViewClickListener(T v, @NonNull View.OnClickListener clickListener) {
// v.setOnClickListener(clickListener);
// return v;
// }
//
// /**
// * Set view click listener by id t.
// *
// * @param <T> the type parameter
// * @param id the id
// * @param clickListener the click listener
// * @return the t
// */
// @SuppressWarnings("unchecked")
// protected final <T extends View> T setViewClickListenerById(@IdRes int id, @NonNull View.OnClickListener clickListener) {
// return setViewClickListener((T) findView(id), clickListener);
// }


@Override
public void onSupportActionModeStarted(ActionMode mode) {
super.onSupportActionModeStarted(mode);
//Call this method
fixActionModeCallback(this, mode);
}

/**
* 修复长按文本启动系统的复制粘贴ActionMode的状态栏颜色
*
* @param activity
* @param mode
*/
private void fixActionModeCallback(AppCompatActivity activity, ActionMode mode) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2016. SHENQINCI(沈钦赐)<[email protected]>
*
* 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 ren.qinc.markdowneditors.base;

import android.app.Application;
Expand Down Expand Up @@ -70,10 +86,6 @@ public void onTerminate() {
super.onTerminate();
AppManager.getAppManager().AppExit(this);
}
//------------SharedPreferences操作封装


// ----------- resource资源操作相关

/**
* 根据资源返回String值
Expand Down Expand Up @@ -114,6 +126,7 @@ public static Snackbar showSnackbar(@NonNull View view, @NonNull String message,
snackbar.show();
return snackbar;
}

public static Snackbar showSnackbar(@NonNull View view, @NonNull int messageRes, @Snackbar.Duration int duration, @Nullable View.OnClickListener listener, @Nullable String actionStr) {
Snackbar snackbar = Snackbar.make(view, messageRes, duration);
if (listener != null && Check.isEmpty(actionStr)) {
Expand All @@ -126,6 +139,7 @@ public static Snackbar showSnackbar(@NonNull View view, @NonNull int messageRes,
public static Snackbar showSnackbar(@NonNull View view, @NonNull String message) {
return showSnackbar(view, message, Snackbar.LENGTH_SHORT, null, null);
}

public static Snackbar showSnackbar(@NonNull View view, @StringRes int messageRes) {
return showSnackbar(view, messageRes, Snackbar.LENGTH_SHORT, null, null);
}
Expand All @@ -149,6 +163,7 @@ public static Snackbar showSnackbarLong(@NonNull View view, @NonNull String mess
public static Snackbar showSnackbarIndefinite(@NonNull View view, @NonNull String message, @Nullable View.OnClickListener listener, @Nullable String actionStr) {
return showSnackbar(view, message, Snackbar.LENGTH_INDEFINITE, listener, actionStr);
}

public static Snackbar showSnackbar(@NonNull View view, @NonNull String message, @Nullable View.OnClickListener listener) {
return showSnackbar(view, message, Snackbar.LENGTH_SHORT, listener, "确定");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2016. SHENQINCI(沈钦赐)<[email protected]>
*
* 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 ren.qinc.markdowneditors.base;

import android.content.res.ColorStateList;
Expand Down Expand Up @@ -33,16 +49,17 @@ protected NavigationView getNavigationView() {
@Override
protected void init() {
super.init();
if (mDrawerLayout == null || mNavigationView == null) // 如果布局文件没有找到toolbar,则不设置actionbar
{
// 如果要用这个类,这两个东西不能为空
if (mDrawerLayout == null || mNavigationView == null) {
throw new IllegalStateException(this.getClass().getSimpleName() + ":要使用BaseDrawerLayoutActivity,必须在布局里面增加id为‘id_drawer’的DrawerLayout");
}
initDrawer();
}

protected void initStatusBar() {
SystemBarUtils.tintStatusBarForDrawer(this,mDrawerLayout, getResources().getColor(R.color.colorPrimary));
SystemBarUtils.tintStatusBarForDrawer(this, mDrawerLayout, getResources().getColor(R.color.colorPrimary));
}

private void initDrawer() {
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, mDrawerLayout, getToolbar(), R.string.navigation_drawer_open, R.string.navigation_drawer_close);
Expand Down
Loading

0 comments on commit c24f525

Please sign in to comment.