Repository: linmp4/quickmark
Branch: master
Commit: b933e8aa9f63
Files: 278
Total size: 1.0 MB
Directory structure:
gitextract_1ebxno1h/
├── LICENSE
├── MoneyCharge/
│ ├── .gitignore
│ ├── app/
│ │ ├── build.gradle
│ │ ├── libs/
│ │ │ ├── Android_Location_V1.3.2.jar
│ │ │ ├── Baidu-SpeechRecognitionUI-SDK-Android-1.6.2.jar
│ │ │ ├── VoiceRecognition-1.6.2.jar
│ │ │ ├── achartengine-1.1.0.jar
│ │ │ ├── androidpiechart.jar
│ │ │ ├── com.umeng.fb.v5.0.0.jar
│ │ │ ├── com.umeng.message.lib1.4.1.jar
│ │ │ ├── galaxy.jar
│ │ │ └── nineoldandroids-2.4.0.jar
│ │ ├── lint.xml
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ ├── cwp/
│ │ │ │ │ ├── chart/
│ │ │ │ │ │ ├── BaseFoldingLayout.java
│ │ │ │ │ │ ├── ChartProp.java
│ │ │ │ │ │ ├── ChartPropChangeListener.java
│ │ │ │ │ │ ├── CheckAdapter.java
│ │ │ │ │ │ ├── CustomMultiChoiceDialog.java
│ │ │ │ │ │ ├── FoldingLayout.java
│ │ │ │ │ │ ├── MenuFragment.java
│ │ │ │ │ │ ├── MyAdspter.java
│ │ │ │ │ │ ├── MyButton.java
│ │ │ │ │ │ ├── MyButtonClickListener.java
│ │ │ │ │ │ ├── OnFoldListener.java
│ │ │ │ │ │ ├── PieChart.java
│ │ │ │ │ │ ├── PieView.java
│ │ │ │ │ │ ├── PiewController.java
│ │ │ │ │ │ ├── PullToRefreshView.java
│ │ │ │ │ │ ├── RiseNumberBase.java
│ │ │ │ │ │ ├── RiseNumberTextView.java
│ │ │ │ │ │ ├── SystemBarTintManager.java
│ │ │ │ │ │ └── Util.java
│ │ │ │ │ ├── cmoneycharge/
│ │ │ │ │ │ ├── About.java
│ │ │ │ │ │ ├── AddPay.java
│ │ │ │ │ │ ├── Author.java
│ │ │ │ │ │ ├── BaseEffects.java
│ │ │ │ │ │ ├── BaseFrament.java
│ │ │ │ │ │ ├── Config.java
│ │ │ │ │ │ ├── Constants.java
│ │ │ │ │ │ ├── CrashApplication.java
│ │ │ │ │ │ ├── CrashHandler.java
│ │ │ │ │ │ ├── Description.java
│ │ │ │ │ │ ├── DialogShowUtil.java
│ │ │ │ │ │ ├── DigitUtil.java
│ │ │ │ │ │ ├── Effectstype.java
│ │ │ │ │ │ ├── FragmentPage1.java
│ │ │ │ │ │ ├── FragmentPage2.java
│ │ │ │ │ │ ├── FragmentPage3.java
│ │ │ │ │ │ ├── FragmentPage4.java
│ │ │ │ │ │ ├── InPtypeManager.java
│ │ │ │ │ │ ├── IncomeData.java
│ │ │ │ │ │ ├── KeyboardUtil.java
│ │ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ │ ├── ModifyInP.java
│ │ │ │ │ │ ├── NiftyDialogBuilder.java
│ │ │ │ │ │ ├── PayChart.java
│ │ │ │ │ │ ├── PayData.java
│ │ │ │ │ │ ├── RotateBottom.java
│ │ │ │ │ │ ├── SearchActivity.java
│ │ │ │ │ │ ├── SettingActivity.java
│ │ │ │ │ │ ├── Shake.java
│ │ │ │ │ │ ├── SlideTop.java
│ │ │ │ │ │ └── SysApplication.java
│ │ │ │ │ └── pattern/
│ │ │ │ │ ├── CreateGesturePasswordActivity.java
│ │ │ │ │ ├── GuideGesturePasswordActivity.java
│ │ │ │ │ ├── LockPatternUtils.java
│ │ │ │ │ ├── LockPatternView.java
│ │ │ │ │ ├── ParseXmlService.java
│ │ │ │ │ ├── UnlockGesturePasswordActivity.java
│ │ │ │ │ └── UpdateManager.java
│ │ │ │ ├── example/
│ │ │ │ │ └── testpic/
│ │ │ │ │ ├── AlbumHelper.java
│ │ │ │ │ ├── Bimp.java
│ │ │ │ │ ├── BitmapCache.java
│ │ │ │ │ ├── FileUtils.java
│ │ │ │ │ ├── ImageBucket.java
│ │ │ │ │ ├── ImageBucketAdapter.java
│ │ │ │ │ ├── ImageGridActivity.java
│ │ │ │ │ ├── ImageGridAdapter.java
│ │ │ │ │ ├── ImageItem.java
│ │ │ │ │ ├── NoScrollGridView.java
│ │ │ │ │ ├── PhotoActivity.java
│ │ │ │ │ ├── PublishedActivity.java
│ │ │ │ │ └── TestPicActivity.java
│ │ │ │ ├── slidingmenu/
│ │ │ │ │ └── lib/
│ │ │ │ │ ├── CanvasTransformerBuilder.java
│ │ │ │ │ ├── CustomViewAbove.java
│ │ │ │ │ ├── CustomViewBehind.java
│ │ │ │ │ ├── MenuInterface.java
│ │ │ │ │ ├── SlidingMenu.java
│ │ │ │ │ └── app/
│ │ │ │ │ ├── SlidingActivity.java
│ │ │ │ │ ├── SlidingActivityBase.java
│ │ │ │ │ ├── SlidingActivityHelper.java
│ │ │ │ │ ├── SlidingFragmentActivity.java
│ │ │ │ │ ├── SlidingListActivity.java
│ │ │ │ │ ├── SlidingMapActivity.java
│ │ │ │ │ ├── SlidingPreferenceActivity.java
│ │ │ │ │ └── SystemBarTintManager.java
│ │ │ │ ├── umeng/
│ │ │ │ │ └── fb/
│ │ │ │ │ └── example/
│ │ │ │ │ ├── AppApplication.java
│ │ │ │ │ ├── AppPush.java
│ │ │ │ │ ├── CustomActivity.java
│ │ │ │ │ └── MyPushIntentService.java
│ │ │ │ └── zhy/
│ │ │ │ └── view/
│ │ │ │ ├── HorizontalProgressBarWithNumber.java
│ │ │ │ └── RoundProgressBarWidthNumber.java
│ │ │ └── cwp/
│ │ │ └── moneycharge/
│ │ │ ├── dao/
│ │ │ │ ├── AccountDAO.java
│ │ │ │ ├── DBOpenHelper.java
│ │ │ │ ├── IncomeDAO.java
│ │ │ │ ├── ItypeDAO.java
│ │ │ │ ├── NoteDAO.java
│ │ │ │ ├── PayDAO.java
│ │ │ │ └── PtypeDAO.java
│ │ │ └── model/
│ │ │ ├── ActivityManager.java
│ │ │ ├── CustomDialog.java
│ │ │ ├── Datapicker.java
│ │ │ ├── KindData.java
│ │ │ ├── Tb_account.java
│ │ │ ├── Tb_income.java
│ │ │ ├── Tb_itype.java
│ │ │ ├── Tb_note.java
│ │ │ ├── Tb_pay.java
│ │ │ └── Tb_ptype.java
│ │ └── res/
│ │ ├── anim/
│ │ │ ├── animation_1.xml
│ │ │ ├── animation_2.xml
│ │ │ ├── fade_ins.xml
│ │ │ ├── hold.xml
│ │ │ ├── in_from_right.xml
│ │ │ ├── interpolator_cycle.xml
│ │ │ ├── out_to_left.xml
│ │ │ ├── push_bottom_in.xml
│ │ │ ├── push_bottom_in_2.xml
│ │ │ ├── push_up_in.xml
│ │ │ ├── push_up_out.xml
│ │ │ ├── shake.xml
│ │ │ ├── shake_x.xml
│ │ │ └── shake_y.xml
│ │ ├── color/
│ │ │ ├── cost_text.xml
│ │ │ ├── tab_friendfeed_text.xml
│ │ │ ├── tab_home_text.xml
│ │ │ ├── tab_more_text.xml
│ │ │ └── tab_myfeed_text.xml
│ │ ├── drawable/
│ │ │ ├── addphoto_btn.xml
│ │ │ ├── bg_border.xml
│ │ │ ├── bgd_relatly_line.xml
│ │ │ ├── bt_add_pic.xml
│ │ │ ├── bt_nobgd.xml
│ │ │ ├── bt_queding.xml
│ │ │ ├── bt_quxiao.xml
│ │ │ ├── bt_shanchu.xml
│ │ │ ├── btn_cancel_selector.xml
│ │ │ ├── btn_login_selector.xml
│ │ │ ├── btn_press.xml
│ │ │ ├── btn_selector.xml
│ │ │ ├── btn_unpress.xml
│ │ │ ├── chart_left_btn.xml
│ │ │ ├── chart_right_btn.xml
│ │ │ ├── chart_silding_btn.xml
│ │ │ ├── checkbox.xml
│ │ │ ├── common_btn_green.xml
│ │ │ ├── common_btn_red.xml
│ │ │ ├── corner_bdbdbd.xml
│ │ │ ├── corner_e0e0e0.xml
│ │ │ ├── corner_f2f2f2.xml
│ │ │ ├── dialog_bg.xml
│ │ │ ├── dialog_bottom_bg.xml
│ │ │ ├── fb_send_btn_bg.xml
│ │ │ ├── keyboard_key.xml
│ │ │ ├── locate_btn.xml
│ │ │ ├── search_button_type.xml
│ │ │ ├── selector.xml
│ │ │ ├── shadow.xml
│ │ │ ├── skin_color_button.xml
│ │ │ ├── tab_friendfeed_btn.xml
│ │ │ ├── tab_home_btn.xml
│ │ │ ├── tab_more_btn.xml
│ │ │ ├── tab_myfeed_btn.xml
│ │ │ ├── text_while.xml
│ │ │ └── welcome_bg.xml
│ │ ├── drawable-hdpi/
│ │ │ ├── common_lv_item_for_metadata_bg.xml
│ │ │ ├── common_lv_item_higher_bg.xml
│ │ │ ├── common_toolbar_btn.xml
│ │ │ ├── common_toolbar_btn_small.xml
│ │ │ ├── form_row_input_middle.xml
│ │ │ ├── form_row_input_middle_short_left.xml
│ │ │ ├── form_row_input_middle_short_right.xml
│ │ │ ├── form_row_input_top.xml
│ │ │ ├── income_tab_btn_radio.xml
│ │ │ ├── main_add_expense_quickly.xml
│ │ │ ├── main_row_stat.xml
│ │ │ └── payout_tab_btn_radio.xml
│ │ ├── layout/
│ │ │ ├── about.xml
│ │ │ ├── account.xml
│ │ │ ├── activity_custom.xml
│ │ │ ├── activity_image_bucket.xml
│ │ │ ├── activity_image_grid.xml
│ │ │ ├── activity_index.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── activity_photo.xml
│ │ │ ├── activity_selectimg.xml
│ │ │ ├── add.xml
│ │ │ ├── addincome.xml
│ │ │ ├── addnote.xml
│ │ │ ├── addpay.xml
│ │ │ ├── author.xml
│ │ │ ├── changepwd.xml
│ │ │ ├── child.xml
│ │ │ ├── custom_fb_dev_reply.xml
│ │ │ ├── custom_fb_user_reply.xml
│ │ │ ├── custom_view.xml
│ │ │ ├── data.xml
│ │ │ ├── description.xml
│ │ │ ├── dialog.xml
│ │ │ ├── dialog_layout.xml
│ │ │ ├── dialog_multichoice_item.xml
│ │ │ ├── dialog_multichoice_layout.xml
│ │ │ ├── fragment_1.xml
│ │ │ ├── fragment_2.xml
│ │ │ ├── fragment_3.xml
│ │ │ ├── fragment_4.xml
│ │ │ ├── fragment_5.xml
│ │ │ ├── fragnew_3.xml
│ │ │ ├── frame_menu.xml
│ │ │ ├── gesturepassword_create.xml
│ │ │ ├── gesturepassword_guide.xml
│ │ │ ├── gesturepassword_unlock.xml
│ │ │ ├── group.xml
│ │ │ ├── gvitem.xml
│ │ │ ├── income.xml
│ │ │ ├── incomedata.xml
│ │ │ ├── infomanage.xml
│ │ │ ├── inptypemanager.xml
│ │ │ ├── item_image_bucket.xml
│ │ │ ├── item_image_grid.xml
│ │ │ ├── item_popupwindows.xml
│ │ │ ├── item_published_grida.xml
│ │ │ ├── list.xml
│ │ │ ├── login.xml
│ │ │ ├── modifyinp.xml
│ │ │ ├── modifynote.xml
│ │ │ ├── note.xml
│ │ │ ├── notification_item.xml
│ │ │ ├── pay.xml
│ │ │ ├── paychart.xml
│ │ │ ├── paydata.xml
│ │ │ ├── pidata.xml
│ │ │ ├── popwindow_layout.xml
│ │ │ ├── preview_layout.xml
│ │ │ ├── refresh_footer.xml
│ │ │ ├── refresh_header.xml
│ │ │ ├── register.xml
│ │ │ ├── search_activity.xml
│ │ │ ├── setting.xml
│ │ │ ├── showinfo.xml
│ │ │ ├── slidingmenumain.xml
│ │ │ ├── softupdate_progress.xml
│ │ │ ├── spinner.xml
│ │ │ └── voice_setting.xml
│ │ ├── menu/
│ │ │ └── index.xml
│ │ ├── values/
│ │ │ ├── attr_progress_bar.xml
│ │ │ ├── attrs.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── ids.xml
│ │ │ ├── moneychargetype.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── values-sw600dp/
│ │ │ └── dimens.xml
│ │ ├── values-sw720dp-land/
│ │ │ └── dimens.xml
│ │ ├── values-v11/
│ │ │ └── styles.xml
│ │ ├── values-v14/
│ │ │ └── styles.xml
│ │ └── xml/
│ │ ├── menu.xml
│ │ └── symbols_num.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── import-summary.txt
│ └── settings.gradle
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 linmp4
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: MoneyCharge/.gitignore
================================================
### Android ###
.gradle
/local.properties
.DS_Store
/captures
.externalNativeBuild
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
### log ###
*.log
### Java build package###
src/main/java/META-INF/MANIFEST.MF
================================================
FILE: MoneyCharge/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.cwp.cmoneycharge"
minSdkVersion 15
targetSdkVersion 18
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/Android_Location_V1.3.2.jar')
compile files('libs/androidpiechart.jar')
compile files('libs/Baidu-SpeechRecognitionUI-SDK-Android-1.6.2.jar')
compile files('libs/com.umeng.fb.v5.0.0.jar')
compile files('libs/com.umeng.message.lib1.4.1.jar')
compile files('libs/galaxy.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/VoiceRecognition-1.6.2.jar')
}
================================================
FILE: MoneyCharge/app/lint.xml
================================================
================================================
FILE: MoneyCharge/app/src/main/AndroidManifest.xml
================================================
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/BaseFoldingLayout.java
================================================
/*
* Copyright (C) 2013 Priboi Tiberiu
* Copyright (C) 2013 The Android Open Source Project
*
* 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 com.cwp.chart;
import com.cwp.cmoneycharge.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.Shader.TileMode;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
/**
* The folding layout where the number of folds, the anchor point and the
* orientation of the fold can be specified. Each of these parameters can be
* modified individually and updates and resets the fold to a default (unfolded)
* state. The fold factor varies between 0 (completely unfolded flat image) to
* 1.0 (completely folded, non-visible image).
*
* This layout throws an exception if there is more than one child added to the
* view. For more complicated view hierarchy's inside the folding layout, the
* views should all be nested inside 1 parent layout.
*
* This layout folds the contents of its child in real time. By applying matrix
* transformations when drawing to canvas, the contents of the child may change
* as the fold takes place. It is important to note that there are jagged edges
* about the perimeter of the layout as a result of applying transformations to
* a rectangle. This can be avoided by having the child of this layout wrap its
* content inside a 1 pixel transparent border. This will cause an anti-aliasing
* like effect and smoothen out the edges.
*
*/
public class BaseFoldingLayout extends ViewGroup {
/*
* A bug was introduced in Android 4.3 that ignores changes to the Canvas
* state between multiple calls to super.dispatchDraw() when running with
* hardware acceleration. To account for this bug, a slightly different
* approach was taken to fold a static image whereby a bitmap of the
* original contents is captured and drawn in segments onto the canvas.
* However, this method does not permit the folding of a TextureView hosting
* a live camera feed which continuously updates. Furthermore, the sepia
* effect was removed from the bitmap variation of the demo to simplify the
* logic when running with this workaround."
*/
public static enum Orientation {
VERTICAL, HORIZONTAL
}
private final String FOLDING_VIEW_EXCEPTION_MESSAGE = "Folding Layout can only 1 child at "
+ "most";
private final float SHADING_ALPHA = 0.8f;
private final float SHADING_FACTOR = 0.5f;
private final int DEPTH_CONSTANT = 1500;
private final int NUM_OF_POLY_POINTS = 8;
private Rect[] mFoldRectArray;
private Matrix[] mMatrix;
protected Orientation mOrientation = Orientation.VERTICAL;
protected float mAnchorFactor = 0;
private float mFoldFactor = 0;
private int mNumberOfFolds = 2;
private boolean mIsHorizontal = true;
private int mOriginalWidth = 0;
private int mOriginalHeight = 0;
private float mFoldMaxWidth = 0;
private float mFoldMaxHeight = 0;
private float mFoldDrawWidth = 0;
private float mFoldDrawHeight = 0;
private boolean mIsFoldPrepared = false;
private boolean mShouldDraw = true;
private Paint mSolidShadow;
private Paint mGradientShadow;
private LinearGradient mShadowLinearGradient;
private Matrix mShadowGradientMatrix;
private float[] mSrc;
private float[] mDst;
private OnFoldListener mFoldListener;
private float mPreviousFoldFactor = 0;
private Bitmap mFullBitmap;
private Rect mDstRect;
public BaseFoldingLayout(Context context) {
super(context);
}
public BaseFoldingLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public BaseFoldingLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
}
public void init(Context context, AttributeSet attrs) {
// now style everything!
TypedArray ta = context.obtainStyledAttributes(attrs,
R.styleable.FoldingMenu);
int mFoldNumber = ta.getInt(R.styleable.FoldingMenu_foldNumber,
mNumberOfFolds);
if (mFoldNumber > 0 && mFoldNumber < 7) {
mNumberOfFolds = mFoldNumber;
} else {
mNumberOfFolds = 2;
}
ta.recycle();
}
@Override
protected boolean addViewInLayout(View child, int index,
LayoutParams params, boolean preventRequestLayout) {
throwCustomException(getChildCount());
boolean returnValue = super.addViewInLayout(child, index, params,
preventRequestLayout);
return returnValue;
}
@Override
public void addView(View child, int index, LayoutParams params) {
throwCustomException(getChildCount());
super.addView(child, index, params);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
View child = getChildAt(0);
measureChild(child, widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
View child = getChildAt(0);
child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
updateFold();
}
/**
* The custom exception to be thrown so as to limit the number of views in
* this layout to at most one.
*/
private class NumberOfFoldingLayoutChildrenException extends
RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
public NumberOfFoldingLayoutChildrenException(String message) {
super(message);
}
}
/**
* Throws an exception if the number of views added to this layout exceeds
* one.
*/
private void throwCustomException(int numOfChildViews) {
if (numOfChildViews == 1) {
throw new NumberOfFoldingLayoutChildrenException(
FOLDING_VIEW_EXCEPTION_MESSAGE);
}
}
public void setFoldListener(OnFoldListener foldListener) {
mFoldListener = foldListener;
}
/**
* Sets the fold factor of the folding view and updates all the
* corresponding matrices and values to account for the new fold factor.
* Once that is complete, it redraws itself with the new fold.
*/
public void setFoldFactor(float foldFactor) {
if (foldFactor != mFoldFactor) {
mFoldFactor = foldFactor;
calculateMatrices();
invalidate();
}
}
public void setOrientation(Orientation orientation) {
if (orientation != mOrientation) {
mOrientation = orientation;
updateFold();
}
}
public void setAnchorFactor(float anchorFactor) {
if (anchorFactor != mAnchorFactor) {
mAnchorFactor = anchorFactor;
updateFold();
}
}
public void setNumberOfFolds(int numberOfFolds) {
if (numberOfFolds != mNumberOfFolds) {
mNumberOfFolds = numberOfFolds;
updateFold();
}
}
public float getAnchorFactor() {
return mAnchorFactor;
}
public Orientation getOrientation() {
return mOrientation;
}
public float getFoldFactor() {
return mFoldFactor;
}
public int getNumberOfFolds() {
return mNumberOfFolds;
}
private void updateFold() {
prepareFold(mOrientation, mAnchorFactor, mNumberOfFolds);
calculateMatrices();
invalidate();
}
/**
* This method is called in order to update the fold's orientation, anchor
* point and number of folds. This creates the necessary setup in order to
* prepare the layout for a fold with the specified parameters. Some of the
* dimensions required for the folding transformation are also acquired
* here.
*
* After this method is called, it will be in a completely unfolded state by
* default.
*/
private void prepareFold(Orientation orientation, float anchorFactor,
int numberOfFolds) {
mSrc = new float[NUM_OF_POLY_POINTS];
mDst = new float[NUM_OF_POLY_POINTS];
mDstRect = new Rect();
mFoldFactor = 0;
mPreviousFoldFactor = 0;
mIsFoldPrepared = false;
mSolidShadow = new Paint();
mGradientShadow = new Paint();
mOrientation = orientation;
mIsHorizontal = (orientation == Orientation.HORIZONTAL);
if (mIsHorizontal) {
mShadowLinearGradient = new LinearGradient(0, 0, SHADING_FACTOR, 0,
Color.BLACK, Color.TRANSPARENT, TileMode.CLAMP);
} else {
mShadowLinearGradient = new LinearGradient(0, 0, 0, SHADING_FACTOR,
Color.BLACK, Color.TRANSPARENT, TileMode.CLAMP);
}
mGradientShadow.setStyle(Style.FILL);
mGradientShadow.setShader(mShadowLinearGradient);
mShadowGradientMatrix = new Matrix();
mAnchorFactor = anchorFactor;
mNumberOfFolds = numberOfFolds;
mOriginalWidth = getMeasuredWidth();
mOriginalHeight = getMeasuredHeight();
mFoldRectArray = new Rect[mNumberOfFolds];
mMatrix = new Matrix[mNumberOfFolds];
for (int x = 0; x < mNumberOfFolds; x++) {
mMatrix[x] = new Matrix();
}
int h = mOriginalHeight;
int w = mOriginalWidth;
if (Util.IS_JBMR2 && h != 0 && w != 0) {
mFullBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(mFullBitmap);
getChildAt(0).draw(canvas);
}
int delta = Math.round(mIsHorizontal ? ((float) w)
/ ((float) mNumberOfFolds) : ((float) h)
/ ((float) mNumberOfFolds));
/*
* Loops through the number of folds and segments the full layout into a
* number of smaller equal components. If the number of folds is odd,
* then one of the components will be smaller than all the rest. Note
* that deltap below handles the calculation for an odd number of folds.
*/
for (int x = 0; x < mNumberOfFolds; x++) {
if (mIsHorizontal) {
int deltap = (x + 1) * delta > w ? w - x * delta : delta;
mFoldRectArray[x] = new Rect(x * delta, 0, x * delta + deltap,
h);
} else {
int deltap = (x + 1) * delta > h ? h - x * delta : delta;
mFoldRectArray[x] = new Rect(0, x * delta, w, x * delta
+ deltap);
}
}
if (mIsHorizontal) {
mFoldMaxHeight = h;
mFoldMaxWidth = delta;
} else {
mFoldMaxHeight = delta;
mFoldMaxWidth = w;
}
mIsFoldPrepared = true;
}
/*
* Calculates the transformation matrices used to draw each of the separate
* folding segments from this view.
*/
private void calculateMatrices() {
mShouldDraw = true;
if (!mIsFoldPrepared) {
return;
}
/**
* If the fold factor is 1 than the folding view should not be seen and
* the canvas can be left completely empty.
*/
if (mFoldFactor == 1) {
mShouldDraw = false;
return;
}
// if (mFoldFactor == 0 && mPreviousFoldFactor > 0
// && mFoldListener != null) {
//
// mFoldListener.onEndFold(mFoldFactor);
// }else if (mPreviousFoldFactor == 0 && mFoldFactor > 0
// && mFoldListener != null) {
//
// mFoldListener.onStartFold(mFoldFactor);
// } else if(mFoldListener != null) {
// mFoldListener.onFoldingState(mFoldFactor);
// }
if (mFoldFactor > 0.9f && mFoldFactor > mPreviousFoldFactor
&& mFoldListener != null) {
mFoldListener.onEndFold(mFoldFactor);
} else if (mFoldFactor < 0.1f && mFoldFactor < mPreviousFoldFactor
&& mFoldListener != null) {
mFoldListener.onStartFold(mFoldFactor);
} else if (mFoldListener != null) {
mFoldListener.onFoldingState(mFoldFactor, mFoldDrawHeight);
}
// if(mFoldFactor == 0 && mFoldListener != null) {
// mFoldListener.onStartFold(mFoldFactor);
// } else if(mFoldFactor == 1 && mFoldListener != null) {
// mFoldListener.onEndFold(mFoldFactor);
// } else {
// mFoldListener.onFoldingState(mFoldFactor);
// }
mPreviousFoldFactor = mFoldFactor;
/*
* Reset all the transformation matrices back to identity before
* computing the new transformation
*/
for (int x = 0; x < mNumberOfFolds; x++) {
mMatrix[x].reset();
}
float cTranslationFactor = 1 - mFoldFactor;
float translatedDistance = mIsHorizontal ? mOriginalWidth
* cTranslationFactor : mOriginalHeight * cTranslationFactor;
float translatedDistancePerFold = Math.round(translatedDistance
/ mNumberOfFolds);
/*
* For an odd number of folds, the rounding error may cause the
* translatedDistancePerFold to be grater than the max fold width or
* height.
*/
mFoldDrawWidth = mFoldMaxWidth < translatedDistancePerFold ? translatedDistancePerFold
: mFoldMaxWidth;
mFoldDrawHeight = mFoldMaxHeight < translatedDistancePerFold ? translatedDistancePerFold
: mFoldMaxHeight;
float translatedDistanceFoldSquared = translatedDistancePerFold
* translatedDistancePerFold;
/*
* Calculate the depth of the fold into the screen using pythagorean
* theorem.
*/
float depth = mIsHorizontal ? (float) Math
.sqrt((double) (mFoldDrawWidth * mFoldDrawWidth - translatedDistanceFoldSquared))
: (float) Math
.sqrt((double) (mFoldDrawHeight * mFoldDrawHeight - translatedDistanceFoldSquared));
/*
* The size of some object is always inversely proportional to the
* distance it is away from the viewpoint. The constant can be varied to
* to affect the amount of perspective.
*/
float scaleFactor = DEPTH_CONSTANT / (DEPTH_CONSTANT + depth);
float scaledWidth, scaledHeight, bottomScaledPoint, topScaledPoint, rightScaledPoint, leftScaledPoint;
if (mIsHorizontal) {
scaledWidth = mFoldDrawWidth * cTranslationFactor;
scaledHeight = mFoldDrawHeight * scaleFactor;
} else {
scaledWidth = mFoldDrawWidth * scaleFactor;
scaledHeight = mFoldDrawHeight * cTranslationFactor;
}
topScaledPoint = (mFoldDrawHeight - scaledHeight) / 2.0f;
bottomScaledPoint = topScaledPoint + scaledHeight;
leftScaledPoint = (mFoldDrawWidth - scaledWidth) / 2.0f;
rightScaledPoint = leftScaledPoint + scaledWidth;
float anchorPoint = mIsHorizontal ? mAnchorFactor * mOriginalWidth
: mAnchorFactor * mOriginalHeight;
/* The fold along which the anchor point is located. */
float midFold = mIsHorizontal ? (anchorPoint / mFoldDrawWidth)
: anchorPoint / mFoldDrawHeight;
mSrc[0] = 0;
mSrc[1] = 0;
mSrc[2] = 0;
mSrc[3] = mFoldDrawHeight;
mSrc[4] = mFoldDrawWidth;
mSrc[5] = 0;
mSrc[6] = mFoldDrawWidth;
mSrc[7] = mFoldDrawHeight;
/*
* Computes the transformation matrix for each fold using the values
* calculated above.
*/
for (int x = 0; x < mNumberOfFolds; x++) {
boolean isEven = (x % 2 == 0);
if (mIsHorizontal) {
mDst[0] = (anchorPoint > x * mFoldDrawWidth) ? anchorPoint
+ (x - midFold) * scaledWidth : anchorPoint
- (midFold - x) * scaledWidth;
mDst[1] = isEven ? 0 : topScaledPoint;
mDst[2] = mDst[0];
mDst[3] = isEven ? mFoldDrawHeight : bottomScaledPoint;
mDst[4] = (anchorPoint > (x + 1) * mFoldDrawWidth) ? anchorPoint
+ (x + 1 - midFold) * scaledWidth
: anchorPoint - (midFold - x - 1) * scaledWidth;
mDst[5] = isEven ? topScaledPoint : 0;
mDst[6] = mDst[4];
mDst[7] = isEven ? bottomScaledPoint : mFoldDrawHeight;
} else {
mDst[0] = isEven ? 0 : leftScaledPoint;
mDst[1] = (anchorPoint > x * mFoldDrawHeight) ? anchorPoint
+ (x - midFold) * scaledHeight : anchorPoint
- (midFold - x) * scaledHeight;
mDst[2] = isEven ? leftScaledPoint : 0;
mDst[3] = (anchorPoint > (x + 1) * mFoldDrawHeight) ? anchorPoint
+ (x + 1 - midFold) * scaledHeight
: anchorPoint - (midFold - x - 1) * scaledHeight;
mDst[4] = isEven ? mFoldDrawWidth : rightScaledPoint;
mDst[5] = mDst[1];
mDst[6] = isEven ? rightScaledPoint : mFoldDrawWidth;
mDst[7] = mDst[3];
}
/*
* Pixel fractions are present for odd number of folds which need to
* be rounded off here.
*/
for (int y = 0; y < 8; y++) {
mDst[y] = Math.round(mDst[y]);
}
/*
* If it so happens that any of the folds have reached a point where
* the width or height of that fold is 0, then nothing needs to be
* drawn onto the canvas because the view is essentially completely
* folded.
*/
if (mIsHorizontal) {
if (mDst[4] <= mDst[0] || mDst[6] <= mDst[2]) {
mShouldDraw = false;
return;
}
} else {
if (mDst[3] <= mDst[1] || mDst[7] <= mDst[5]) {
mShouldDraw = false;
return;
}
}
/* Sets the shadow and bitmap transformation matrices. */
mMatrix[x].setPolyToPoly(mSrc, 0, mDst, 0, NUM_OF_POLY_POINTS / 2);
}
/*
* The shadows on the folds are split into two parts: Solid shadows and
* gradients. Every other fold has a solid shadow which overlays the
* whole fold. Similarly, the folds in between these alternating folds
* also have an overlaying shadow. However, it is a gradient that takes
* up part of the fold as opposed to a solid shadow overlaying the whole
* fold.
*/
/* Solid shadow paint object. */
int alpha = (int) (mFoldFactor * 255 * SHADING_ALPHA);
mSolidShadow.setColor(Color.argb(alpha, 0, 0, 0));
if (mIsHorizontal) {
mShadowGradientMatrix.setScale(mFoldDrawWidth, 1);
mShadowLinearGradient.setLocalMatrix(mShadowGradientMatrix);
} else {
mShadowGradientMatrix.setScale(1, mFoldDrawHeight);
mShadowLinearGradient.setLocalMatrix(mShadowGradientMatrix);
}
mGradientShadow.setAlpha(alpha);
}
@Override
protected void dispatchDraw(Canvas canvas) {
/**
* If prepareFold has not been called or if preparation has not
* completed yet, then no custom drawing will take place so only need to
* invoke super's onDraw and return.
*/
if (!mIsFoldPrepared || mFoldFactor == 0) {
super.dispatchDraw(canvas);
return;
}
if (!mShouldDraw) {
return;
}
Rect src;
/*
* Draws the bitmaps and shadows on the canvas with the appropriate
* transformations.
*/
for (int x = 0; x < mNumberOfFolds; x++) {
src = mFoldRectArray[x];
/* The canvas is saved and restored for every individual fold */
canvas.save();
/*
* Concatenates the canvas with the transformation matrix for the
* the segment of the view corresponding to the actual image being
* displayed.
*/
canvas.concat(mMatrix[x]);
if (Util.IS_JBMR2) {
mDstRect.set(0, 0, src.width(), src.height());
canvas.drawBitmap(mFullBitmap, src, mDstRect, null);
} else {
/*
* The same transformation matrix is used for both the shadow
* and the image segment. The canvas is clipped to account for
* the size of each fold and is translated so they are drawn in
* the right place. The shadow is then drawn on top of the
* different folds using the sametransformation matrix.
*/
canvas.clipRect(0, 0, src.right - src.left, src.bottom
- src.top);
if (mIsHorizontal) {
canvas.translate(-src.left, 0);
} else {
canvas.translate(0, -src.top);
}
super.dispatchDraw(canvas);
if (mIsHorizontal) {
canvas.translate(src.left, 0);
} else {
canvas.translate(0, src.top);
}
}
/* Draws the shadows corresponding to this specific fold. */
if (x % 2 == 0) {
canvas.drawRect(0, 0, mFoldDrawWidth, mFoldDrawHeight,
mSolidShadow);
} else {
canvas.drawRect(0, 0, mFoldDrawWidth, mFoldDrawHeight,
mGradientShadow);
}
canvas.restore();
}
}
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/ChartProp.java
================================================
package com.cwp.chart;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
public class ChartProp {
private int mId = 0;
private float mPercent = 1.0f;
private View mParent = null;
private int mColor = Color.WHITE;
private float mSweepAngle = 0f;
private String mName = "";
private String mName2 = "";
private float mStartAngle = 0f;
private float mEndAngle = 0f;
public ChartProp(View chartView) {
mParent = chartView;
}
public void setId(int id) {
mId = id;
}
public int getId() {
return mId;
}
/**
* the percent ,such as 0.5f,0.05f, NEIGHTER 50% NOR 50
*
* @param percent
*/
public void setPercent(float percent) {
// Log.e("caizh", "percent="+percent);
mPercent = percent;
mSweepAngle = percent * 360;
// invalidate();
}
public float getPercent() {
return mPercent;
}
public float getSweepAngle() {
return mSweepAngle;
}
public void setColor(int color) {
mColor = color;
// invalidate();
}
public int getColor() {
return mColor;
}
public String getName() {
return mName;
}
public void setName(String name) {
this.mName = name;
// invalidate();
}
public String getName2() {
return mName2;
}
public void setName2(String name) {
this.mName2 = name;
// invalidate();
}
private void invalidate() {
if (mParent != null) {
mParent.invalidate();
}
}
public float getStartAngle() {
return mStartAngle;
}
public void setStartAngle(float startAngle) {
this.mStartAngle = (startAngle);
}
public float getEndAngle() {
return mEndAngle;
}
public void setEndAngle(float endAngle) {
this.mEndAngle = (endAngle);
}
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/ChartPropChangeListener.java
================================================
package com.cwp.chart;
public interface ChartPropChangeListener {
public void getChartProp(ChartProp chartProp);
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/CheckAdapter.java
================================================
package com.cwp.chart;
import com.cwp.cmoneycharge.R;
import android.content.Context;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
public class CheckAdapter extends BaseAdapter {
private class ViewHolder {
public TextView name;
public CheckBox checkBox;
}
private String[] names;
private LayoutInflater mInflater;
private Context mContext;
private boolean[] checkedItem;
public CheckAdapter(Context context, String[] names, boolean[] checkedItem) {
this.names = names;
this.checkedItem = checkedItem;
this.mContext = context;
mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return names.length;
}
@Override
public Object getItem(int position) {
return names[position];
}
@Override
public long getItemId(int position) {
return position;
}
public View getItemView(int position) {
return lmap.get(position);
}
public boolean[] getCheckedItem() {
for (int i = 0; i < getCount(); i++) {
View view = this.getView(i, null, null);
CheckBox box = (CheckBox)view.findViewById(R.id.chk_selectone);
checkedItem[i] = box.isChecked();
}
return checkedItem;
}
SparseArray lmap = new SparseArray();
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
View view;
if (lmap.get(position) == null) {
view = mInflater.inflate(R.layout.dialog_multichoice_item, null);
holder = new ViewHolder();
holder.name = (TextView) view.findViewById(R.id.contact_name);
holder.checkBox = (CheckBox) view.findViewById(R.id.chk_selectone);
lmap.put(position, view);
if (names != null && names.length > 0) {
String name = (String) names[position];
holder.name.setText(name);
holder.checkBox.setChecked(checkedItem[position]);
}
view.setTag(holder);
} else {
view = lmap.get(position);
holder = (ViewHolder) view.getTag();
}
return view;
}
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/CustomMultiChoiceDialog.java
================================================
package com.cwp.chart;
import com.cwp.cmoneycharge.R;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
public class CustomMultiChoiceDialog extends Dialog {
public CustomMultiChoiceDialog(Context context) {
super(context);
}
public CustomMultiChoiceDialog(Context context, int theme) {
super(context, theme);
}
public static class Builder {
private Context context;
private String title;
private String message;
private String positiveButtonText;
private String negativeButtonText;
private View contentView;
private ListView listView;
private DialogInterface.OnClickListener positiveButtonClickListener;
private DialogInterface.OnClickListener negativeButtonClickListener;
private OnItemClickListener onItemClickListener;
private String[] items;
private boolean[] checkedItems;
private boolean showSelectAll;
private static boolean isMultiChoice = false;
public static String contact_name;
public Builder(Context context) {
this.context = context;
}
public Builder setMessage(String message) {
this.message = message;
return this;
}
public ListView getListView() {
return listView;
}
public boolean[] getCheckedItems() {
if (listView != null) {
CheckAdapter adapter = (CheckAdapter) listView.getAdapter();
checkedItems = adapter.getCheckedItem();
}
return checkedItems;
}
/**
* Set the Dialog message from resource
*
* @param title
* @return
*/
public Builder setMessage(int message) {
this.message = (String) context.getText(message);
return this;
}
/**
* Set the Dialog title from resource
*
* @param title
* @return
*/
public Builder setTitle(int title) {
this.title = (String) context.getText(title);
return this;
}
/**
* Set the Dialog title from String
*
* @param title
* @return
*/
public Builder setTitle(String title) {
this.title = title;
return this;
}
public Builder setContentView(View v) {
this.contentView = v;
return this;
}
/**
* Set the positive button resource and it's listener
*
* @param positiveButtonText
* @return
*/
public Builder setPositiveButton(int positiveButtonText,
DialogInterface.OnClickListener listener) {
this.positiveButtonText = (String) context
.getText(positiveButtonText);
this.positiveButtonClickListener = listener;
return this;
}
public Builder setPositiveButton(String positiveButtonText,
DialogInterface.OnClickListener listener) {
this.positiveButtonText = positiveButtonText;
this.positiveButtonClickListener = listener;
return this;
}
public Builder setNegativeButton(int negativeButtonText,
DialogInterface.OnClickListener listener) {
this.negativeButtonText = (String) context
.getText(negativeButtonText);
this.negativeButtonClickListener = listener;
return this;
}
public Builder setNegativeButton(String negativeButtonText,
DialogInterface.OnClickListener listener) {
this.negativeButtonText = negativeButtonText;
this.negativeButtonClickListener = listener;
return this;
}
/**
*
*
* @param items
* @param checkedItems
* @param onItemClickListener
* Listening the item click event.
* @param showSelectAll
* Whether to display the full checkbox.
* @return
*/
public Builder setMultiChoiceItems(boolean isMultiChoice,
String[] items, boolean[] checkedItems,
OnItemClickListener onItemClickListener, boolean showSelectAll) {
this.isMultiChoice = isMultiChoice;
this.items = items;
this.checkedItems = checkedItems;
this.onItemClickListener = onItemClickListener;
this.showSelectAll = showSelectAll;
return this;
}
public CustomMultiChoiceDialog create() {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// instantiate the dialog with the custom Theme
final CustomMultiChoiceDialog dialog = new CustomMultiChoiceDialog(
context, R.style.Dialog);
View layout = inflater.inflate(R.layout.dialog_multichoice_layout,
null);
// set the dialog title
TextView multichoicTitle = (TextView) layout
.findViewById(R.id.multichoic_title);
multichoicTitle.setText(title);
ImageView checkAll = (ImageView) layout
.findViewById(R.id.chk_selectall);
LinearLayout dialog_bottom = (LinearLayout) layout
.findViewById(R.id.dialog_bottom);
Button positiveButton = (Button) layout
.findViewById(R.id.positiveButton);
Button negativeButton = (Button) layout
.findViewById(R.id.negativeButton);
listView = (ListView) layout.findViewById(R.id.multichoiceList);
dialog.addContentView(layout, new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// set the confirm button
if (positiveButtonText != null) {
positiveButton.setText(positiveButtonText);
if (positiveButtonClickListener != null) {
positiveButton
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
positiveButtonClickListener.onClick(dialog,
DialogInterface.BUTTON_POSITIVE);
dialog.dismiss();
}
});
} else {
positiveButton
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
}
} else {
// if no confirm button just set the visibility to GONE
positiveButton.setVisibility(View.GONE);
dialog_bottom.setVisibility(View.GONE);
}
// set the cancel button
if (negativeButtonText != null) {
negativeButton.setText(negativeButtonText);
if (negativeButtonClickListener != null) {
negativeButton
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
negativeButtonClickListener.onClick(dialog,
DialogInterface.BUTTON_NEGATIVE);
dialog.dismiss();
}
});
} else {
negativeButton
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
}
} else {
// if no confirm button just set the visibility to GONE
negativeButton.setVisibility(View.GONE);
}
// is the Multichoice(澶氶?妗?
if (isMultiChoice == true) {
final CheckAdapter checkAdapter = new CheckAdapter(context,
items, checkedItems);
listView.setAdapter(checkAdapter);
listView.setItemsCanFocus(true);
if (onItemClickListener != null) {
listView.setOnItemClickListener(onItemClickListener);
} else {
listView.setOnItemClickListener(new OnMultiItemClick());
}
// show the all selectButton or not
if (showSelectAll) {
// checkAll.setVisibility( View.VISIBLE);
// checkAll.setOnCheckedChangeListener(new
// OnCheckedChangeListener() {
//
// @Override
// public void onCheckedChanged(CompoundButton buttonView,
// boolean isChecked) {
// int count = listView.getAdapter().getCount();
// if (isChecked) {
// // update the status of all checkbox to checked
// if (count > 0) {
// for (int i = 0; i < count; i++) {
// CheckBox itemCheckBox = (CheckBox) listView
// .getAdapter()
// .getView(i, null, null)
// .findViewById(
// R.id.chk_selectone);
// itemCheckBox.setChecked(true);
// }
// }
// } else {
// // update the status of checkbox to unchecked
// if (count > 0) {
// for (int i = 0; i < count; i++) {
// CheckBox itemCheckBox = (CheckBox) listView
// .getAdapter()
// .getView(i, null, null)
// .findViewById(
// R.id.chk_selectone);
// itemCheckBox.setChecked(false);
// }
// }
// }
// }
// });
checkAll.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
} else {
checkAll.setVisibility(View.GONE);
}
} else { // 如果是单选模式
final CheckAdapter checkAdapter = new CheckAdapter(context,
items, checkedItems);
listView.setAdapter(checkAdapter);
listView.setItemsCanFocus(true);
for (int i = 0; i < items.length; i++) { // 隐藏CheckBox
CheckBox itemCheckBox = (CheckBox) listView.getAdapter()
.getView(i, null, null)
.findViewById(R.id.chk_selectone);
itemCheckBox.setVisibility(View.GONE);
}
listView.setOnItemClickListener(onItemClickListener);
// show the all selectButton or not
if (showSelectAll) {
checkAll.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
} else {
checkAll.setVisibility(View.GONE);
}
}
// set the content message
if (message != null) {
// ((TextView)layout.findViewById(R.id.message)).setText(message);
} else if (contentView != null) {
// if no message set add the contentView to the dialog body
((LinearLayout) layout.findViewById(R.id.content))
.removeAllViews();
((LinearLayout) layout.findViewById(R.id.content)).addView(
contentView, new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
}
dialog.setContentView(layout);
return dialog;
}
class OnMultiItemClick implements OnItemClickListener {
@Override
public void onItemClick(AdapterView> parent, View view,
int positon, long arg3) {
CheckBox box = (CheckBox) view.findViewById(R.id.chk_selectone);
if (box.isChecked()) {
box.setChecked(false);
} else {
box.setChecked(true);
}
}
}
public static boolean getisMultiChoice() {
return isMultiChoice;
}
public static String getcontact_name() {
return contact_name;
}
}
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/FoldingLayout.java
================================================
/*
* Copyright (C) 2013 Priboi Tiberiu
* Copyright (C) 2013 The Android Open Source Project
*
* 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 com.cwp.chart;
import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
/**
* The folding layout where the number of folds, the anchor point and the
* orientation of the fold can be specified. Each of these parameters can be
* modified individually and updates and resets the fold to a default (unfolded)
* state. The fold factor varies between 0 (completely unfolded flat image) to
* 1.0 (completely folded, non-visible image).
*
* This layout throws an exception if there is more than one child added to the
* view. For more complicated view hierarchy's inside the folding layout, the
* views should all be nested inside 1 parent layout.
*
* This layout folds the contents of its child in real time. By applying matrix
* transformations when drawing to canvas, the contents of the child may change
* as the fold takes place. It is important to note that there are jagged edges
* about the perimeter of the layout as a result of applying transformations to
* a rectangle. This can be avoided by having the child of this layout wrap its
* content inside a 1 pixel transparent border. This will cause an anti-aliasing
* like effect and smoothen out the edges.
*
*/
public class FoldingLayout extends BaseFoldingLayout {
private final String FOLDING_VIEW_EXCEPTION_MESSAGE = "Folding Layout can only 1 child at "
+ "most";
private GestureDetector mScrollGestureDetector;
FoldingLayout that = null;
private int mTranslation = 0;
private int mParentPositionY = -1;
private int mTouchSlop = -1;
private boolean mDidNotStartScroll = true;
public FoldingLayout(Context context) {
super(context);
init(context, null);
that = this;
}
public FoldingLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
that = this;
}
public FoldingLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
that = this;
}
public void init(Context context, AttributeSet attrs) {
mScrollGestureDetector = new GestureDetector(context,
new ScrollGestureDetector());
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
setAnchorFactor(0);
super.init(context, attrs);
}
@Override
protected boolean addViewInLayout(View child, int index,
LayoutParams params, boolean preventRequestLayout) {
throwCustomException(getChildCount());
boolean returnValue = super.addViewInLayout(child, index, params,
preventRequestLayout);
return returnValue;
}
/**
* The custom exception to be thrown so as to limit the number of views in
* this layout to at most one.
*/
private class NumberOfFoldingLayoutChildrenException extends
RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
public NumberOfFoldingLayoutChildrenException(String message) {
super(message);
}
}
/**
* Throws an exception if the number of views added to this layout exceeds
* one.
*/
private void throwCustomException(int numOfChildViews) {
if (numOfChildViews == 1) {
throw new NumberOfFoldingLayoutChildrenException(
FOLDING_VIEW_EXCEPTION_MESSAGE);
}
}
/** This class uses user touch events to fold and unfold the folding view. */
private class ScrollGestureDetector extends
GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent e) {
mDidNotStartScroll = true;
return true;
}
/**
* All the logic here is used to determine by what factor the paper view
* should be folded in response to the user's touch events. The logic
* here uses vertical scrolling to fold a vertically oriented view and
* horizontal scrolling to fold a horizontally oriented fold. Depending
* on where the anchor point of the fold is, movements towards or away
* from the anchor point will either fold or unfold the paper
* respectively.
*
* The translation logic here also accounts for the touch slop when a
* new user touch begins, but before a scroll event is first invoked.
*/
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
int touchSlop = 0;
float factor;
if (mOrientation == Orientation.VERTICAL) {
factor = Math.abs((float) (mTranslation)
/ (float) (that.getHeight()));
if (e2.getY() - mParentPositionY <= that.getHeight()
&& e2.getY() - mParentPositionY >= 0) {
if ((e2.getY() - mParentPositionY) > that.getHeight()
* getAnchorFactor()) {
mTranslation -= (int) distanceY;
touchSlop = distanceY < 0 ? -mTouchSlop : mTouchSlop;
} else {
mTranslation += (int) distanceY;
touchSlop = distanceY < 0 ? mTouchSlop : -mTouchSlop;
}
mTranslation = mDidNotStartScroll ? mTranslation
+ touchSlop : mTranslation;
if (mTranslation < -that.getHeight()) {
mTranslation = -that.getHeight();
}
}
} else {
factor = Math.abs(((float) mTranslation)
/ ((float) that.getWidth()));
if (e2.getRawX() > that.getWidth() * getAnchorFactor()) {
mTranslation -= (int) distanceX;
touchSlop = distanceX < 0 ? -mTouchSlop : mTouchSlop;
} else {
mTranslation += (int) distanceX;
touchSlop = distanceX < 0 ? mTouchSlop : -mTouchSlop;
}
mTranslation = mDidNotStartScroll ? mTranslation + touchSlop
: mTranslation;
if (mTranslation < -that.getWidth()) {
mTranslation = -that.getWidth();
}
}
mDidNotStartScroll = false;
if (mTranslation > 0) {
mTranslation = 0;
}
that.setFoldFactor(factor);
return true;
}
}
@Override
public boolean onTouchEvent(MotionEvent me) {
return mScrollGestureDetector.onTouchEvent(me);
}
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/MenuFragment.java
================================================
package com.cwp.chart;
import com.cwp.cmoneycharge.PayChart;
import com.cwp.cmoneycharge.PayData;
import com.cwp.cmoneycharge.R;
import android.annotation.TargetApi;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
/**
* menu fragment ,主要是用于显示menu菜单
*
* @author Kris.lee
* @since Mar 12, 2013
* @version 1.0.0
*/
public class MenuFragment extends PreferenceFragment implements
OnPreferenceClickListener {
int index = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setRetainInstance(true);
// set the preference xml to the content view
addPreferencesFromResource(R.xml.menu);
// add listener
findPreference("mpaychart").setOnPreferenceClickListener(this);
findPreference("mincomechart").setOnPreferenceClickListener(this);
findPreference("dpaychart").setOnPreferenceClickListener(this);
findPreference("dincomehart").setOnPreferenceClickListener(this);
// findPreference("comparechart").setOnPreferenceClickListener(this);
// findPreference("mincomechart").setOnPreferenceClickListener(this);
SystemBarTintManager mTintManager;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setTranslucentStatus(true);
}
mTintManager = new SystemBarTintManager(getActivity());
mTintManager.setStatusBarTintEnabled(true);
mTintManager.setStatusBarTintResource(R.color.statusbar_bg);
}
@TargetApi(19)
protected void setTranslucentStatus(boolean on) {
Window win = getActivity().getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
}
@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if ("mpaychart".equals(key)) {
Intent intentl = new Intent(getActivity(), PayChart.class);
intentl.putExtra("datatype", "pay");
intentl.putExtra("type", 0);
startActivity(intentl);
} else if ("mincomechart".equals(key)) {
Intent intentl = new Intent(getActivity(), PayChart.class);
intentl.putExtra("datatype", "income");
intentl.putExtra("type", 0);
startActivity(intentl);
} else if ("dpaychart".equals(key)) {
Intent intentp = new Intent(getActivity(), PayChart.class);
intentp.putExtra("datatype", "pay");
intentp.putExtra("type", 1);
startActivity(intentp);
} else if ("dincomehart".equals(key)) {
Intent intentp = new Intent(getActivity(), PayChart.class);
intentp.putExtra("datatype", "income");
intentp.putExtra("type", 1);
startActivity(intentp);
} else if ("comparechart".equals(key)) {
// Intent intentp = new Intent(getActivity(), PIData.class);
// intent.putExtra("cwp.id", userid);
// intentp.putExtra("datatype", "income");
// intentp.putExtra("type", 1);
// startActivity(intentp);
}
// anyway , show the sliding menu
// ((MainActivity) getActivity()).getSlidingMenu().toggle();
return false;
}
}
================================================
FILE: MoneyCharge/app/src/main/java/com/cwp/chart/MyAdspter.java
================================================
package com.cwp.chart;
import java.util.List;
import java.util.Map;
import com.cwp.cmoneycharge.R;
import android.R.bool;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class MyAdspter extends BaseAdapter {
private List