This commit is contained in:
seven332 committed 2015-04-18 04:06:49 +08:00
1 parent 525ce72ec1
commit 4133bb4e7b
19 files changed
+368 -57

No files matched your search

@@ -26,7 +26,6 @@ import android.view.View;
import com.hippo.ehviewer.R;
import com.hippo.widget.HotspotTouchHelper;
public final class RippleSalon {
private static final Drawable MASK = new ColorDrawable(Color.BLACK);
@@ -15,11 +15,13 @@
package com.hippo.ehviewer.ui;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.widget.DrawerLayout;
import android.view.Gravity;
import com.hippo.content.VectorContext;
import com.hippo.ehviewer.R;
@@ -62,4 +64,13 @@ public class ContentActivity extends StageActivity {
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(VectorContext.wrapContext(newBase));
}
@SuppressLint("RtlHardcoded")
public void toggleDrawer() {
if (mDrawerLayout.isDrawerOpen(Gravity.LEFT) || mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
mDrawerLayout.closeDrawers();
} else {
mDrawerLayout.openDrawer(Gravity.LEFT);
}
}
}
@@ -16,7 +16,6 @@
package com.hippo.ehviewer.ui;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
@@ -37,7 +36,6 @@ public class StartActivity extends AbsActionBarActivity {
setContentView(R.layout.activity_start);
TextView text = (TextView) findViewById(R.id.text_welcome);
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/GloriaHallelujah.ttf"));
try {
SVG svg = new SVGBuilder().readFromResource(getResources(), R.raw.sad_pandroid).build();
@@ -23,10 +23,11 @@ import android.view.View;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.ui.ContentActivity;
import com.hippo.ehviewer.widget.ContentLayout;
import com.hippo.ehviewer.widget.SearchBar;
import com.hippo.scene.Scene;
import com.hippo.scene.TransitionCurtain;
public class GalleryListScene extends Scene {
public class GalleryListScene extends Scene implements SearchBar.Helper{
private final static int PAGE_INDEX_SEARCH = 0;
private final static int PAGE_INDEX_LIST = 1;
@@ -35,6 +36,7 @@ public class GalleryListScene extends Scene {
private ContentActivity mActivity;
private Resources mResources;
private SearchBar mSearchBar;
private ContentLayout mContentLayout;
@Override
@@ -45,8 +47,10 @@ public class GalleryListScene extends Scene {
mActivity = (ContentActivity) getStageActivity();
mResources = mActivity.getResources();
mSearchBar = (SearchBar) findViewById(R.id.search_bar);
mContentLayout = (ContentLayout) findViewById(R.id.content_layout);
mSearchBar.setHelper(this);
mContentLayout.showText("无法连接网络");
View view = getSceneView();
@@ -70,4 +74,9 @@ public class GalleryListScene extends Scene {
protected void onGetFitPaddingBottom(int b) {
// TODO
}
@Override
public void onClickMenu() {
mActivity.toggleDrawer();
}
}
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2015 Hippo Seven
*
* 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
* 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 com.hippo.ehviewer.widget;
import android.content.Context;
import android.graphics.Typeface;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.hippo.ehviewer.R;
import com.hippo.util.UiUtils;
public class SearchBar extends CardView implements View.OnClickListener {
private View mMenuButton;
private TextView mLogoTextView;
private Helper mHelper;
public SearchBar(Context context) {
super(context);
init(context);
}
public SearchBar(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SearchBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
setRadius(UiUtils.dp2pix(context, 2));
setCardElevation(UiUtils.dp2pix(context, 2));
LayoutInflater.from(context).inflate(R.layout.widget_search_bar, this);
mMenuButton = getChildAt(0);
mLogoTextView = (TextView) getChildAt(1);
mMenuButton.setOnClickListener(this);
mLogoTextView.setTypeface(Typeface.createFromAsset(context.getAssets(),
"fonts/Slabo.ttf"));
}
public void setHelper(Helper helper) {
mHelper = helper;
}
@Override
public void onClick(View v) {
if (v == mMenuButton) {
if (mHelper != null) {
mHelper.onClickMenu();
}
}
}
public interface Helper {
void onClickMenu();
}
}
@@ -20,7 +20,6 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -63,8 +62,8 @@ public class TransitionCurtain extends Curtain {
// Handle background
int bgColor = enter.getBackgroundColor();
enter.setBackgroundColor(Color.TRANSPARENT);
int startBgColor = bgColor & 0xffffff;
enter.setBackgroundColor(startBgColor);
ObjectAnimator colorAnim = ObjectAnimator.ofInt(enter, "backgroundColor", bgColor);
colorAnim.setEvaluator(ArgbEvaluator.getInstance());
colorAnim.setDuration(ANIMATE_TIME);
@@ -235,7 +234,9 @@ public class TransitionCurtain extends Curtain {
final Set<Animator> animatorCollection = new HashSet<>();
// Handle background
ObjectAnimator colorAnim = ObjectAnimator.ofInt(exit, "backgroundColor", Color.TRANSPARENT);
int bgColor = enter.getBackgroundColor();
int endBgColor = bgColor & 0xffffff;
ObjectAnimator colorAnim = ObjectAnimator.ofInt(exit, "backgroundColor", endBgColor);
colorAnim.setEvaluator(ArgbEvaluator.getInstance());
colorAnim.setDuration(ANIMATE_TIME);
animatorCollection.add(colorAnim);
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2015 Hippo Seven
*
* 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
* 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 com.hippo.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
public class SimpleImageView extends View {
private Drawable mDrawable;
private static final int[] LAYOUT_ATTRS = new int[] {
android.R.attr.src
};
public SimpleImageView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public SimpleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
mDrawable = a.getDrawable(0);
a.recycle();
}
@Override
protected int getSuggestedMinimumWidth() {
int superMinWidth = super.getSuggestedMinimumWidth();
return (mDrawable == null) ? superMinWidth :
Math.max(superMinWidth, mDrawable.getMinimumWidth() + getPaddingLeft() + getPaddingRight());
}
@Override
protected int getSuggestedMinimumHeight() {
int superMinHeight = super.getSuggestedMinimumHeight();
return (mDrawable == null) ? superMinHeight :
Math.max(superMinHeight, mDrawable.getMinimumHeight() + getPaddingTop() + getPaddingBottom());
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int width = right - left;
int height = bottom - top;
mDrawable.setBounds(getPaddingLeft(), getPaddingTop(),
width - getPaddingRight(), height - getPaddingBottom());
}
@Override
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
}
}