Skip to content

Commit

Permalink
minor bug fix; updated to v0.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
PureDark committed Mar 15, 2017
1 parent 99c7304 commit 6e9dfab
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
resValue "string", "app_name", "H-Viewer"
minSdkVersion 17
targetSdkVersion 25
versionCode 68
versionName "0.9.7"
versionCode 69
versionName "0.9.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class HViewerApplication extends SwipeBackApplication {
* 是否开启日志输出,在Debug状态下开启,
* 在Release状态下关闭以提示程序性能
*/
public final static boolean DEBUG = true;
public final static boolean DEBUG = false;

// 全局变量,用于跨Activity传递复杂对象的引用
public static Object temp, temp2, temp3, temp4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ public void deleteSearchSuggestion(String item) {
}

public void trimSearchSuggestion() {
while (searchSuggestions.size() > 500)
searchSuggestions.remove(searchSuggestions.size()-1);
try {
while (searchSuggestions.size() > 500)
searchSuggestions.remove(searchSuggestions.size() - 1);
}catch (IndexOutOfBoundsException e){
e.printStackTrace();
}
}

public List<String> getSearchSuggestion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public static long getContentLength(String url, List<Pair<String, String>> heade
}

public static Response getResponseHeader(String url, List<Pair<String, String>> headers) {
if (url == null || !url.startsWith("http")) {
return null;
}
HRequestBuilder builder = new HRequestBuilder();
if (headers != null) {
for (Pair<String, String> header : headers) {
Expand Down Expand Up @@ -113,7 +116,7 @@ public static void get(String url, boolean disableHProxy, List<Pair<String, Stri
if (!post)
get(url, disableHProxy, headers, false, null, callback);
else {
String params = (url == null) ? "" : url.substring(url.indexOf('?'));
String params = (url == null) ? "" : (url.indexOf('?') > 0) ? url.substring(url.indexOf('?')) : url;
post(url, disableHProxy, params, headers, callback);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
Expand Down Expand Up @@ -132,7 +130,7 @@ protected void onCreate(Bundle savedInstanceState) {
mRecyclerViewDragDropManager.attachRecyclerView(rvCollection);
mRecyclerViewExpandableItemManager.attachRecyclerView(rvCollection);

if(adapter.getDataProvider().getGroupCount() > 0)
if (adapter.getDataProvider().getGroupCount() > 0)
mRecyclerViewExpandableItemManager.expandGroup(0);

adapter.setOnItemClickListener(new LocalCollectionAdapter.OnItemClickListener() {
Expand Down Expand Up @@ -163,7 +161,7 @@ public void onGroupClick(View v, int groupPosition) {

@Override
public boolean onGroupLongClick(View v, final int groupPosition) {
if(mRecyclerViewDragDropManager.isDragging())
if (mRecyclerViewDragDropManager.isDragging())
return true;
// 分类上长按,选择操作
final FavGroup group = adapter.getDataProvider().getGroupItem(groupPosition);
Expand Down Expand Up @@ -200,11 +198,15 @@ public boolean onGroupLongClick(View v, final int groupPosition) {

@Override
public void onItemClick(View v, int groupPosition, int childPosition) {
LocalCollection collection = adapter.getDataProvider().getChildItem(groupPosition, childPosition);
HViewerApplication.temp = collection.site;
HViewerApplication.temp2 = collection;
Intent intent = new Intent(FavouriteActivity.this, CollectionActivity.class);
startActivity(intent);
try {
LocalCollection collection = adapter.getDataProvider().getChildItem(groupPosition, childPosition);
HViewerApplication.temp = collection.site;
HViewerApplication.temp2 = collection;
Intent intent = new Intent(FavouriteActivity.this, CollectionActivity.class);
startActivity(intent);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}

@Override
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/ml/puredark/hviewer/utils/DocumentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ public static OutputStream getFileOutputSteam(Context context, String fileName,
if (parent == null)
return null;
DocumentFile file = parent.findFile(fileName);
if (file == null)
return null;
return getFileOutputSteam(context, file.getUri());
}

Expand All @@ -296,6 +298,8 @@ public static OutputStream getFileOutputSteam(Context context, String fileName,
if (parent == null)
return null;
DocumentFile file = parent.findFile(fileName);
if (file == null)
return null;
return getFileOutputSteam(context, file.getUri());
}

Expand All @@ -304,6 +308,8 @@ public static OutputStream getFileOutputSteam(Context context, String fileName,
if (parent == null)
return null;
DocumentFile file = parent.findFile(fileName);
if (file == null)
return null;
return getFileOutputSteam(context, file.getUri());
}

Expand All @@ -326,6 +332,8 @@ public static InputStream getFileInputSteam(Context context, String fileName, St
if (parent == null)
return null;
DocumentFile file = parent.findFile(fileName);
if (file == null)
return null;
return getFileInputSteam(context, file.getUri());
}

Expand All @@ -335,6 +343,8 @@ public static InputStream getFileInputSteam(Context context, String fileName, Ur
return null;
fileName = filenameFilter(Uri.decode(fileName));
DocumentFile file = parent.findFile(fileName);
if (file == null)
return null;
return getFileInputSteam(context, file.getUri());
}

Expand All @@ -343,6 +353,8 @@ public static InputStream getFileInputSteam(Context context, String fileName, Do
if (parent == null)
return null;
DocumentFile file = parent.findFile(fileName);
if (file == null)
return null;
return getFileInputSteam(context, file.getUri());
}

Expand Down

0 comments on commit 6e9dfab

Please sign in to comment.