├── libs ├── core.jar ├── volley.jar ├── eventbus.jar ├── gson-2.2.1.jar ├── pagerindicator.jar ├── picasso-2.3.1.jar ├── xUtils-2.6.14.jar ├── android-support-v4.jar ├── butterknife-4.0.1.jar ├── commons-codec-1.3.jar ├── nineoldandroids-2.4.0.jar ├── android-async-http-1.4.6.jar ├── fastjson-1.1.43.android.jar ├── androidannotations-api-3.1.jar ├── viewpagertransformslibrary.jar ├── universal-image-loader-1.9.3.jar └── com.haarman.listviewanimations-2.6.0.jar ├── res ├── raw │ └── qrcode_found.wav ├── drawable-hdpi │ ├── ic_launcher.png │ ├── s_search_bg.png │ ├── slip_ball.png │ ├── slip_left.png │ ├── slip_right.png │ ├── scan_icon_nor.png │ ├── scan_top_bg2.png │ ├── home_img_ratio.png │ ├── menu_btn_normal.png │ ├── menu_btn_pressed.png │ ├── v1_7_back_hover.png │ ├── xsearch_loading.png │ ├── topbar_right_press.png │ ├── v1_7_back_blue_nor.png │ ├── me_share_return_press.png │ ├── topbar_right_normal.png │ ├── home_img_ratio_selected.png │ ├── news_tab_item_bg_select.9.png │ ├── xsearch_msg_pull_arrow_down.png │ └── emotionstore_progresscancelbtn.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── drawable │ ├── me_share_return_normal.png │ ├── text_blue.xml │ ├── toast_bg.xml │ ├── share_return.xml │ ├── top_right_selector.xml │ ├── back_seletor.xml │ ├── progress_style.xml │ ├── progress_bar_states.xml │ ├── btn_bind_cancel_.xml │ ├── btn_bind_cancel.xml │ └── tab_indicator.xml ├── values │ ├── dimen.xml │ ├── drawables.xml │ ├── strings.xml │ ├── colors.xml │ ├── attrs.xml │ ├── ids.xml │ ├── pull_picture_dimens.xml │ ├── styles.xml │ ├── pull_refresh_strings.xml │ └── vpi__styles.xml ├── anim │ ├── in_from_bottom.xml │ ├── in_from_left.xml │ ├── in_from_right.xml │ ├── in_from_top.xml │ ├── out_to_bottom.xml │ ├── out_to_left.xml │ ├── out_to_right.xml │ ├── out_to_top.xml │ ├── update_loading_progressbar_anim.xml │ ├── pop_enter.xml │ └── pop_exit.xml ├── layout │ ├── progressdialog.xml │ ├── viewpager_item.xml │ ├── activity_baseweb.xml │ ├── view_custom_toast.xml │ ├── ad_cycle_view.xml │ ├── pull_to_load_footer.xml │ ├── view_top_bar.xml │ ├── popu_get_photo.xml │ ├── pull_to_refresh_header.xml │ └── camera.xml └── color │ └── tab_theme.xml ├── .gitignore ├── src └── com │ ├── finddreams │ └── baselib │ │ ├── activity │ │ └── DemoActivity.java │ │ ├── utils │ │ ├── ConstantsValue.java │ │ ├── MD5Util.java │ │ ├── BroadcastHelper.java │ │ ├── GsonUtil.java │ │ ├── PlaySoundUtil.java │ │ ├── Screenshot.java │ │ ├── InstallManager.java │ │ ├── ToastManager.java │ │ ├── DateUtil.java │ │ ├── FileUtil.java │ │ ├── AppHelper.java │ │ ├── InputMethodUtil.java │ │ ├── AppManager.java │ │ ├── DisplayUtil.java │ │ ├── CacheUtil.java │ │ ├── LogManager.java │ │ └── ActivityUtil.java │ │ ├── view │ │ ├── NoScrollGridView.java │ │ ├── CustomToast.java │ │ ├── CustomProgressDialog.java │ │ ├── CustomViewPager.java │ │ ├── NoScrollListView.java │ │ ├── ScrollListView.java │ │ ├── RotateAnimation.java │ │ ├── ImageTextView.java │ │ ├── ProgressWebView.java │ │ ├── TopBarView.java │ │ ├── FlippingImageView.java │ │ ├── ModelPopup.java │ │ ├── BounceScrollView.java │ │ ├── ClearEditText.java │ │ ├── SendValidateButton.java │ │ └── ScaleImageView.java │ │ ├── base │ │ ├── BaseViewHolder.java │ │ ├── BaseActivity.java │ │ ├── MyBaseAdapter.java │ │ ├── BaseWebActivity.java │ │ ├── BasePage.java │ │ └── BaseFragment.java │ │ ├── http │ │ ├── MyHttpClient.java │ │ ├── URLUtils.java │ │ ├── MyHttpUtils.java │ │ └── NetStateUtil.java │ │ ├── app │ │ ├── MyApplication.java │ │ └── CrashHandler.java │ │ └── service │ │ └── ServiceManager.java │ ├── zxing │ └── barcode │ │ ├── ViewfinderResultPointCallback.java │ │ ├── FinishListener.java │ │ ├── AutoFocusCallback.java │ │ ├── PreviewCallback.java │ │ ├── InactivityTimer.java │ │ ├── DecodeThread.java │ │ ├── EncodingHandler.java │ │ ├── DecodeHandler.java │ │ ├── DecodeFormatManager.java │ │ ├── PlanarYUVLuminanceSource.java │ │ ├── CaptureActivityHandler.java │ │ └── FlashlightManager.java │ └── android │ └── pulltorefreshview │ ├── ILoadingLayout.java │ ├── IPullToRefresh.java │ └── FooterLoadingLayout.java ├── AndroidManifest.xml ├── .project └── README.md /libs/core.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/core.jar -------------------------------------------------------------------------------- /libs/volley.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/volley.jar -------------------------------------------------------------------------------- /libs/eventbus.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/eventbus.jar -------------------------------------------------------------------------------- /libs/gson-2.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/gson-2.2.1.jar -------------------------------------------------------------------------------- /libs/pagerindicator.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/pagerindicator.jar -------------------------------------------------------------------------------- /libs/picasso-2.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/picasso-2.3.1.jar -------------------------------------------------------------------------------- /libs/xUtils-2.6.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/xUtils-2.6.14.jar -------------------------------------------------------------------------------- /res/raw/qrcode_found.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/raw/qrcode_found.wav -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/butterknife-4.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/butterknife-4.0.1.jar -------------------------------------------------------------------------------- /libs/commons-codec-1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/commons-codec-1.3.jar -------------------------------------------------------------------------------- /libs/nineoldandroids-2.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/nineoldandroids-2.4.0.jar -------------------------------------------------------------------------------- /libs/android-async-http-1.4.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/android-async-http-1.4.6.jar -------------------------------------------------------------------------------- /libs/fastjson-1.1.43.android.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/fastjson-1.1.43.android.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/s_search_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/s_search_bg.png -------------------------------------------------------------------------------- /res/drawable-hdpi/slip_ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/slip_ball.png -------------------------------------------------------------------------------- /res/drawable-hdpi/slip_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/slip_left.png -------------------------------------------------------------------------------- /res/drawable-hdpi/slip_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/slip_right.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /libs/androidannotations-api-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/androidannotations-api-3.1.jar -------------------------------------------------------------------------------- /libs/viewpagertransformslibrary.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/viewpagertransformslibrary.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/scan_icon_nor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/scan_icon_nor.png -------------------------------------------------------------------------------- /res/drawable-hdpi/scan_top_bg2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/scan_top_bg2.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /libs/universal-image-loader-1.9.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/universal-image-loader-1.9.3.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/home_img_ratio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/home_img_ratio.png -------------------------------------------------------------------------------- /res/drawable-hdpi/menu_btn_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/menu_btn_normal.png -------------------------------------------------------------------------------- /res/drawable-hdpi/menu_btn_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/menu_btn_pressed.png -------------------------------------------------------------------------------- /res/drawable-hdpi/v1_7_back_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/v1_7_back_hover.png -------------------------------------------------------------------------------- /res/drawable-hdpi/xsearch_loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/xsearch_loading.png -------------------------------------------------------------------------------- /res/drawable-hdpi/topbar_right_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/topbar_right_press.png -------------------------------------------------------------------------------- /res/drawable-hdpi/v1_7_back_blue_nor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/v1_7_back_blue_nor.png -------------------------------------------------------------------------------- /res/drawable/me_share_return_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable/me_share_return_normal.png -------------------------------------------------------------------------------- /res/values/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16sp 4 | 5 | -------------------------------------------------------------------------------- /res/drawable-hdpi/me_share_return_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/me_share_return_press.png -------------------------------------------------------------------------------- /res/drawable-hdpi/topbar_right_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/topbar_right_normal.png -------------------------------------------------------------------------------- /libs/com.haarman.listviewanimations-2.6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/libs/com.haarman.listviewanimations-2.6.0.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/home_img_ratio_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/home_img_ratio_selected.png -------------------------------------------------------------------------------- /res/drawable-hdpi/news_tab_item_bg_select.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/news_tab_item_bg_select.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/xsearch_msg_pull_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/xsearch_msg_pull_arrow_down.png -------------------------------------------------------------------------------- /res/drawable-hdpi/emotionstore_progresscancelbtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finddreams/Android_BaseLib/HEAD/res/drawable-hdpi/emotionstore_progresscancelbtn.png -------------------------------------------------------------------------------- /res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00000000 4 | 5 | -------------------------------------------------------------------------------- /res/anim/in_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/in_from_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/in_from_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/in_from_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/out_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/out_to_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/out_to_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/anim/out_to_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /res/layout/progressdialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /res/drawable/text_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /gen 3 | # Local configuration file (sdk path, etc) 4 | local.properties 5 | 6 | # Eclipse project files 7 | .classpath 8 | .project 9 | 10 | # Proguard folder generated by Eclipse 11 | proguard/ 12 | /ic_launcher-web.png 13 | /.classpath 14 | /.settings 15 | /.classpath 16 | /proguard-project.txt 17 | /project.properties 18 | -------------------------------------------------------------------------------- /res/anim/update_loading_progressbar_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /res/drawable/toast_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /res/anim/pop_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /res/anim/pop_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /res/drawable/share_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/drawable/top_right_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/layout/viewpager_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/activity/DemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.activity; 2 | 3 | import com.finddreams.baselib.base.BaseActivity; 4 | /** 5 | * @Description: 例子,如何使用的实例 6 | * @author finddreams 7 | * @address https://github.com/finddreams 8 | */ 9 | public class DemoActivity extends BaseActivity { 10 | 11 | @Override 12 | protected void initView() { 13 | 14 | } 15 | 16 | @Override 17 | protected void initData() { 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /res/drawable/back_seletor.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BaseLib 4 | 返回 5 | 拍照 6 | 从手机相册选取 7 | 取消 8 | 模特 9 | 将二维码放入框内, 即可自动扫描 10 | 更多 11 | 扫描二维码 12 | 沒有网络 13 | 14 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /res/drawable/progress_style.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/layout/activity_baseweb.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /res/layout/view_custom_toast.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffffff 4 | 5 | #ffd65284 6 | #ff7a7979 7 | #ff999999 8 | #ffef71a1 9 | #000000 10 | #60000000 11 | #b0000000 12 | #c0ffff00 13 | #aeff39 14 | #E60200 15 | 16 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/ConstantsValue.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import android.os.Environment; 4 | 5 | public class ConstantsValue { 6 | 7 | public static final String COMMON_ACTION = "finddreams"; 8 | private static final String IMAGE_PATH_DIR = "/.finddreams/img/"; 9 | private static final String IMAGE_APP_PATH_DIR = "/.finddreams/app_img/"; 10 | private static final String APP_LOG_PATH_DIR = "/.finddreams/log/"; 11 | public static final String IMAGE_APP_PATH = Environment.getExternalStorageDirectory() + IMAGE_APP_PATH_DIR; 12 | 13 | public static final boolean DEBUG = true; 14 | public static final String INTENT_URL = "url"; 15 | public static final String INTENT_TITLE = "title"; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/NoScrollGridView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.GridView; 6 | /** 7 | * @Description:没有滚动条的gridview 8 | * @author http://blog.csdn.net/finddreams 9 | */ 10 | public class NoScrollGridView extends GridView { 11 | public NoScrollGridView(Context context) { 12 | super(context); 13 | } 14 | 15 | public NoScrollGridView(Context context, AttributeSet attrs) { 16 | super(context, attrs); 17 | } 18 | 19 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 20 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, 21 | MeasureSpec.AT_MOST); 22 | super.onMeasure(widthMeasureSpec, expandSpec); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /res/layout/ad_cycle_view.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/base/BaseViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.base; 2 | 3 | import android.util.SparseArray; 4 | import android.view.View; 5 | /** 6 | * @Description:万能的viewHolder 7 | * @author http://blog.csdn.net/finddreams 8 | */ 9 | public class BaseViewHolder { 10 | @SuppressWarnings("unchecked") 11 | public static T get(View view, int id) { 12 | SparseArray viewHolder = (SparseArray) view.getTag(); 13 | if (viewHolder == null) { 14 | viewHolder = new SparseArray(); 15 | view.setTag(viewHolder); 16 | } 17 | View childView = viewHolder.get(id); 18 | if (childView == null) { 19 | childView = view.findViewById(id); 20 | viewHolder.put(id, childView); 21 | } 22 | return (T) childView; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import java.security.MessageDigest; 4 | 5 | /** 6 | * @Description:md5的加密 7 | * @author http://blog.csdn.net/finddreams 8 | */ 9 | public class MD5Util { 10 | 11 | public static String getMD5(String content) { 12 | try { 13 | MessageDigest digest = MessageDigest.getInstance("MD5"); 14 | digest.update(content.getBytes()); 15 | return getHashString(digest); 16 | 17 | } catch (Exception e) { 18 | e.printStackTrace(); 19 | } 20 | return null; 21 | } 22 | 23 | private static String getHashString(MessageDigest digest) { 24 | StringBuilder builder = new StringBuilder(); 25 | for (byte b : digest.digest()) { 26 | builder.append(Integer.toHexString((b >> 4) & 0xf)); 27 | builder.append(Integer.toHexString(b & 0xf)); 28 | } 29 | return builder.toString(); 30 | } 31 | } -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BaseLib 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /res/drawable/progress_bar_states.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /res/drawable/btn_bind_cancel_.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /res/drawable/btn_bind_cancel.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/CustomToast.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | 4 | 5 | 6 | 7 | import com.finddreams.baselib.R; 8 | 9 | import android.content.Context; 10 | import android.view.Gravity; 11 | import android.view.View; 12 | import android.widget.TextView; 13 | import android.widget.Toast; 14 | 15 | public class CustomToast extends Toast { 16 | 17 | private TextView textView; 18 | private String text; 19 | private View view; 20 | private int time; 21 | private Context context; 22 | 23 | public CustomToast(Context context,String text,int time) { 24 | super(context); 25 | this.context = context; 26 | this.text = text; 27 | this.time = time; 28 | init(); 29 | } 30 | 31 | private void init() { 32 | view = View.inflate(context, R.layout.view_custom_toast, null); 33 | setView(view); 34 | textView = (TextView) view.findViewById(R.id.textView); 35 | textView.setText(text); 36 | setGravity(Gravity.CENTER_HORIZONTAL, 0, 0); 37 | setDuration(time); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/CustomProgressDialog.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.view.Gravity; 6 | 7 | import com.finddreams.baselib.R; 8 | 9 | public class CustomProgressDialog extends Dialog { 10 | 11 | public CustomProgressDialog(Context context, String strMessage) { 12 | this(context, R.style.CustomProgressDialog, strMessage); 13 | } 14 | 15 | public CustomProgressDialog(Context context, int theme, String strMessage) { 16 | super(context, theme); 17 | this.setContentView(R.layout.progressdialog); 18 | this.getWindow().getAttributes().gravity = Gravity.CENTER; 19 | // TextView tvMsg = (TextView) this.findViewById(R.id.id_tv_loadingmsg); 20 | // if (tvMsg != null) { 21 | // tvMsg.setText(strMessage); 22 | // } 23 | } 24 | 25 | @Override 26 | public void onWindowFocusChanged(boolean hasFocus) { 27 | 28 | if (!hasFocus) { 29 | dismiss(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/CustomViewPager.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | 4 | 5 | import android.content.Context; 6 | import android.util.AttributeSet; 7 | import android.view.MotionEvent; 8 | 9 | public class CustomViewPager extends LazyViewPager { 10 | private boolean isScrollable; 11 | 12 | public CustomViewPager(Context context) { 13 | super(context); 14 | } 15 | 16 | public CustomViewPager(Context context, AttributeSet attrs) { 17 | super(context, attrs); 18 | } 19 | 20 | @Override 21 | public boolean onTouchEvent(MotionEvent ev) { 22 | if (isScrollable == false) { 23 | return false; 24 | } else { 25 | return super.onTouchEvent(ev); 26 | } 27 | 28 | } 29 | 30 | @Override 31 | public boolean onInterceptTouchEvent(MotionEvent ev) { 32 | if (isScrollable == false) { 33 | return false; 34 | } else { 35 | return super.onInterceptTouchEvent(ev); 36 | } 37 | 38 | } 39 | 40 | public boolean isScrollable() { 41 | return isScrollable; 42 | } 43 | 44 | public void setScrollable(boolean isScrollable) { 45 | this.isScrollable = isScrollable; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/NoScrollListView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.ListView; 6 | 7 | /** 8 | * @Description:自定义无滚动条的ListView 9 | * @author http://blog.csdn.net/finddreams 10 | */ 11 | public class NoScrollListView extends ListView { 12 | 13 | public NoScrollListView(Context context) 14 | { 15 | super(context); 16 | } 17 | 18 | public NoScrollListView(Context context, AttributeSet attrs) 19 | { 20 | super(context, attrs); 21 | } 22 | 23 | public NoScrollListView(Context context, AttributeSet attrs, int defStyle) 24 | { 25 | super(context, attrs, defStyle); 26 | } 27 | @Override 28 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 29 | 30 | int expandSpec = MeasureSpec.makeMeasureSpec( 31 | Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 32 | super.onMeasure(widthMeasureSpec, expandSpec); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/BroadcastHelper.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | public class BroadcastHelper { 7 | 8 | public static void sendCommonBroadCast(Context context,String content) { 9 | Intent intent = new Intent(); 10 | intent.setAction(ConstantsValue.COMMON_ACTION); 11 | intent.addCategory(Intent.CATEGORY_DEFAULT); 12 | intent.putExtra(ConstantsValue.COMMON_ACTION, content); 13 | context.sendBroadcast(intent); 14 | } 15 | 16 | public static void sendBroadCast(Context context,String action,String key,String value) { 17 | Intent intent = new Intent(); 18 | intent.setAction(action); 19 | intent.addCategory(Intent.CATEGORY_DEFAULT); 20 | intent.putExtra(key, value); 21 | context.sendBroadcast(intent); 22 | } 23 | 24 | public static void sendBroadCast(Context context,String action,String key,int value) { 25 | Intent intent = new Intent(); 26 | intent.setAction(action); 27 | intent.addCategory(Intent.CATEGORY_DEFAULT); 28 | intent.putExtra(key, value); 29 | context.sendBroadcast(intent); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /res/color/tab_theme.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/com/zxing/barcode/ViewfinderResultPointCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zxing.barcode; 18 | 19 | import com.google.zxing.ResultPoint; 20 | import com.google.zxing.ResultPointCallback; 21 | 22 | public final class ViewfinderResultPointCallback implements ResultPointCallback { 23 | 24 | private final ViewfinderView viewfinderView; 25 | 26 | public ViewfinderResultPointCallback(ViewfinderView viewfinderView) { 27 | this.viewfinderView = viewfinderView; 28 | } 29 | 30 | public void foundPossibleResultPoint(ResultPoint point) { 31 | viewfinderView.addPossibleResultPoint(point); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.base; 2 | 3 | 4 | import com.finddreams.baselib.http.MyHttpClient; 5 | import com.finddreams.baselib.utils.AppManager; 6 | import com.loopj.android.http.AsyncHttpClient; 7 | 8 | import android.content.Context; 9 | import android.os.Bundle; 10 | import android.support.v4.app.FragmentActivity; 11 | import android.view.Window; 12 | /** 13 | * @Description:所有Activity的基类,是个抽象类,把整个项目中都需要用到的东西封装起来 14 | * @author http://blog.csdn.net/finddreams 15 | */ 16 | public abstract class BaseActivity extends FragmentActivity { 17 | 18 | protected Context context; 19 | protected AsyncHttpClient httpClient; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | this.requestWindowFeature(Window.FEATURE_NO_TITLE); 25 | AppManager.getAppManager().addActivity(this); 26 | context = this; 27 | httpClient = MyHttpClient.getHttpClient(); 28 | initView(); 29 | initData(); 30 | } 31 | /** 32 | * 抽象方法子类必须实现 33 | */ 34 | protected abstract void initView(); 35 | 36 | protected abstract void initData(); 37 | 38 | @Override 39 | protected void onDestroy() { 40 | super.onDestroy(); 41 | AppManager.getAppManager().finishActivity(this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/ScrollListView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.ListView; 6 | 7 | /** 8 | * @Description:ScrollView中嵌套ListView的解决方案, 9 | * 解决在scrollview中只显示Listview中一行的问题 10 | * @author http://blog.csdn.net/finddreams 11 | */ 12 | 13 | public class ScrollListView extends ListView { 14 | private boolean haveScrollbar = false; 15 | 16 | public ScrollListView(Context context) { 17 | super(context); 18 | } 19 | 20 | public ScrollListView(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | } 23 | 24 | public ScrollListView(Context context, AttributeSet attrs, int defStyle) { 25 | super(context, attrs, defStyle); 26 | } 27 | 28 | 29 | public void setHaveScrollbar(boolean haveScrollbar) { 30 | this.haveScrollbar = haveScrollbar; 31 | } 32 | 33 | @Override 34 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 35 | if(haveScrollbar){ 36 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 37 | }else{ 38 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 39 | super.onMeasure(widthMeasureSpec, expandSpec); 40 | } 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/base/MyBaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.base; 2 | 3 | import java.util.List; 4 | 5 | 6 | import android.content.Context; 7 | import android.os.Bundle; 8 | import android.widget.BaseAdapter; 9 | 10 | /** 11 | * @Description:自定义的BaseAdapter,所有adapter的父类。 12 | * @author http://blog.csdn.net/finddreams 13 | */ 14 | public abstract class MyBaseAdapter extends BaseAdapter { 15 | 16 | public Context context; 17 | public List list;// 18 | public Q view; // 这里不一定是ListView,比如GridView,CustomListView 19 | 20 | 21 | public MyBaseAdapter(Context context, List list, Q view) { 22 | this.context = context; 23 | this.list = list; 24 | this.view = view; 25 | } 26 | 27 | public MyBaseAdapter(Context context, List list) { 28 | this.context = context; 29 | this.list = list; 30 | 31 | } 32 | /** 33 | * update 34 | * @param list 35 | */ 36 | public void updateListView(List list){ 37 | this.list = list; 38 | notifyDataSetChanged(); 39 | } 40 | 41 | @Override 42 | public int getCount() { 43 | return list.size(); 44 | } 45 | 46 | @Override 47 | public Object getItem(int position) { 48 | return list.get(position); 49 | } 50 | 51 | @Override 52 | public long getItemId(int position) { 53 | return position; 54 | } 55 | 56 | 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /res/layout/pull_to_load_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 22 | 23 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/http/MyHttpClient.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.http; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.loopj.android.http.AsyncHttpClient; 6 | import com.loopj.android.http.AsyncHttpResponseHandler; 7 | import com.loopj.android.http.RequestParams; 8 | 9 | /** 10 | * @Description:使用了android-async-http的网络帮助类 11 | * @author http://blog.csdn.net/finddreams 12 | */ 13 | public class MyHttpClient { 14 | 15 | private static int CONNECTTIMEOUT = 15 * 1000; // 连接超时 16 | private static AsyncHttpClient client; 17 | private MyHttpClient(){ 18 | } 19 | public static AsyncHttpClient getHttpClient(){ 20 | if(client==null){ 21 | client=new AsyncHttpClient(); 22 | client.setTimeout(CONNECTTIMEOUT); 23 | } 24 | return client; 25 | } 26 | /** 27 | * 带参数的get请求 28 | * @param urlString 29 | * @param params 30 | * @param res 31 | */ 32 | public void sendGet(String urlString, RequestParams params, 33 | AsyncHttpResponseHandler res){ 34 | 35 | client.get(urlString, params, res); 36 | 37 | } 38 | public void sendGet(String url,AsyncHttpResponseHandler responseHandler){ 39 | client.get(url, responseHandler); 40 | } 41 | 42 | public void sendPost(String url,RequestParams params,HashMap vaules,AsyncHttpResponseHandler responseHandler){ 43 | 44 | client.post(url, params, responseHandler); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/RotateAnimation.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import android.graphics.Camera; 4 | import android.graphics.Matrix; 5 | import android.view.animation.Animation; 6 | import android.view.animation.Transformation; 7 | 8 | public class RotateAnimation extends Animation { 9 | 10 | private Camera mCamera; 11 | private float mCenterX; 12 | private float mCenterY; 13 | private Mode mMode; 14 | 15 | public RotateAnimation(float centerX, float centerY, Mode mode) { 16 | mCenterX = centerX; 17 | mCenterY = centerY; 18 | mMode = mode; 19 | } 20 | 21 | @Override 22 | public void initialize(int width, int height, int parentWidth, 23 | int parentHeight) { 24 | super.initialize(width, height, parentWidth, parentHeight); 25 | mCamera = new Camera(); 26 | } 27 | 28 | @Override 29 | protected void applyTransformation(float interpolatedTime, Transformation t) { 30 | float deg = 0.0F + 360.0F * interpolatedTime; 31 | Matrix matrix = t.getMatrix(); 32 | mCamera.save(); 33 | if (mMode == Mode.X) 34 | mCamera.rotateX(deg); 35 | if (mMode == Mode.Y) 36 | mCamera.rotateY(deg); 37 | if (mMode == Mode.Z) 38 | mCamera.rotateZ(deg); 39 | 40 | mCamera.getMatrix(matrix); 41 | mCamera.restore(); 42 | matrix.preTranslate(-mCenterX, -mCenterY); 43 | matrix.postTranslate(mCenterX, mCenterY); 44 | 45 | } 46 | 47 | public enum Mode { 48 | X, Y, Z; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/com/zxing/barcode/FinishListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zxing.barcode; 18 | 19 | import android.app.Activity; 20 | import android.content.DialogInterface; 21 | 22 | /** 23 | * Simple listener used to exit the app in a few cases. 24 | * 25 | */ 26 | public final class FinishListener 27 | implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable { 28 | 29 | private final Activity activityToFinish; 30 | 31 | public FinishListener(Activity activityToFinish) { 32 | this.activityToFinish = activityToFinish; 33 | } 34 | 35 | public void onCancel(DialogInterface dialogInterface) { 36 | run(); 37 | } 38 | 39 | public void onClick(DialogInterface dialogInterface, int i) { 40 | run(); 41 | } 42 | 43 | public void run() { 44 | activityToFinish.finish(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/base/BaseWebActivity.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.base; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.widget.ProgressBar; 6 | 7 | import com.finddreams.baselib.R; 8 | import com.finddreams.baselib.utils.ConstantsValue; 9 | import com.finddreams.baselib.view.ProgressWebView; 10 | /** 11 | * WebView 12 | * @author liuxiang 13 | * @date 2015-1-30 下午6:07:05 14 | * @version V1.0 15 | */ 16 | public class BaseWebActivity extends BaseActivity { 17 | 18 | // private View mLoadingView; 19 | protected ProgressWebView mWebView; 20 | private ProgressBar web_progressbar; 21 | @Override 22 | protected void initView() { 23 | setContentView(R.layout.activity_baseweb); 24 | // mLoadingView = findViewById(R.id.baseweb_loading_indicator); 25 | mWebView = (ProgressWebView) findViewById(R.id.baseweb_webview); 26 | mWebView.getSettings().setJavaScriptEnabled(true); 27 | } 28 | 29 | @Override 30 | protected void initData() { 31 | Intent intent = getIntent(); 32 | Bundle bundle = intent.getExtras(); 33 | String url = bundle.getString(ConstantsValue.INTENT_URL); 34 | String title = bundle.getString(ConstantsValue.INTENT_TITLE); 35 | // if(!TextUtils.isEmpty(url)&&TextUtils.isEmpty(title)){ 36 | mWebView.loadUrl(url); 37 | 38 | // } 39 | 40 | } 41 | @Override 42 | protected void onDestroy() { 43 | // TODO Auto-generated method stub 44 | super.onDestroy(); 45 | mWebView=null; 46 | 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/ImageTextView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import com.finddreams.baselib.utils.BitmapUtil; 4 | 5 | import android.content.Context; 6 | import android.graphics.Bitmap; 7 | import android.graphics.drawable.Drawable; 8 | import android.util.AttributeSet; 9 | import android.widget.TextView; 10 | /** 11 | * @Description: 文字图片,这个相信大家都知道,比如QQ底部导航上的未读消息数 12 | * 13 | * @author http://blog.csdn.net/finddreams 14 | */ 15 | public class ImageTextView extends TextView { 16 | private Bitmap bitmap; 17 | private String text; 18 | Drawable d; 19 | 20 | public ImageTextView(Context context) { 21 | super(context); 22 | text = this.getText().toString().substring(0, 1); 23 | bitmap = BitmapUtil.getIndustry(context, text); 24 | d = BitmapUtil.bitmapTodrawable(bitmap); 25 | this.setCompoundDrawables(d, null, null, null); 26 | } 27 | 28 | public ImageTextView(Context context, AttributeSet attrs, int defStyle) { 29 | super(context, attrs, defStyle); 30 | text = this.getText().toString().substring(0, 1); 31 | bitmap = BitmapUtil.getIndustry(context, text); 32 | d = BitmapUtil.bitmapTodrawable(bitmap); 33 | this.setCompoundDrawables(d, null, null, null); 34 | } 35 | 36 | public ImageTextView(Context context, AttributeSet attrs) { 37 | super(context, attrs); 38 | text = this.getText().toString().substring(0, 1); 39 | bitmap = BitmapUtil.getIndustry(context, text); 40 | d = BitmapUtil.bitmapTodrawable(bitmap); 41 | this.setCompoundDrawables(d, null, null, null); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/base/BasePage.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.base; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.View.OnClickListener; 9 | 10 | import com.finddreams.baselib.http.MyHttpClient; 11 | import com.lidroid.xutils.ViewUtils; 12 | import com.loopj.android.http.AsyncHttpClient; 13 | 14 | /** 15 | * @Description:所有页面view的基类。 16 | * @author http://blog.csdn.net/finddreams 17 | */ 18 | public abstract class BasePage implements OnClickListener { 19 | 20 | protected Context context; 21 | protected View contentView; 22 | protected AsyncHttpClient httpClient; 23 | 24 | public boolean isLoadSuccess=false; 25 | 26 | public BasePage(Context context) { 27 | this.context = context; 28 | contentView = initView((LayoutInflater) context 29 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE)); 30 | ViewUtils.inject(contentView); 31 | httpClient = MyHttpClient.getHttpClient(); 32 | 33 | } 34 | protected abstract View initView(LayoutInflater inflater); 35 | 36 | public abstract void initData(); 37 | 38 | public View getContentView() { 39 | return contentView; 40 | } 41 | @Override 42 | public void onClick(View v) { 43 | } 44 | 45 | protected void startActivity(Activity activity) { 46 | Intent intent = new Intent(context, activity.getClass()); 47 | context.startActivity(intent); 48 | 49 | // AppManager.getAppManager().finishActivity(); 50 | 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /res/values/pull_picture_dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 80dp 4 | 5 | 0dp 6 | 48dp 7 | 8 | 16dp 9 | 10 | 12dp 11 | 12 | 12dp 13 | 14 | 8dp 15 | 9dp 16 | 6dp 17 | 5dp 18 | 10dp 19 | 30dp 20 | 21 | 18dp 22 | 23 | 8dp 24 | 25 | 12dp 26 | 27 | 14dp 28 | 10dp 29 | 6dp 30 | 40dp 31 | 32 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/GsonUtil.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.google.gson.Gson; 7 | import com.google.gson.reflect.TypeToken; 8 | /** 9 | * @Description:谷歌的Gson解析工具类,官方推荐 10 | * @author http://blog.csdn.net/finddreams 11 | */ 12 | public class GsonUtil { 13 | 14 | public GsonUtil() { 15 | // TODO Auto-generated constructor stub 16 | } 17 | 18 | public static String createGsonString(Object object) { 19 | Gson gson = new Gson(); 20 | String gsonString = gson.toJson(object); 21 | return gsonString; 22 | } 23 | 24 | public static T changeGsonToBean(String gsonString, Class cls) { 25 | Gson gson = new Gson(); 26 | T t = gson.fromJson(gsonString, cls); 27 | return t; 28 | } 29 | 30 | public static List changeGsonToList(String gsonString, Class cls) { 31 | Gson gson = new Gson(); 32 | List list = gson.fromJson(gsonString, new TypeToken>() {}.getType()); 33 | return list; 34 | } 35 | 36 | 37 | 38 | public static List> changeGsonToListMaps( 39 | String gsonString) { 40 | List> list = null; 41 | Gson gson = new Gson(); 42 | list = gson.fromJson(gsonString, new TypeToken>>() { 43 | }.getType()); 44 | return list; 45 | } 46 | 47 | public static Map changeGsonToMaps(String gsonString) { 48 | Map map = null; 49 | Gson gson = new Gson(); 50 | map = gson.fromJson(gsonString, new TypeToken>() { 51 | }.getType()); 52 | return map; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 24 | 31 | 32 | 36 | 37 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/PlaySoundUtil.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import android.content.Context; 4 | import android.media.AudioManager; 5 | import android.media.MediaPlayer; 6 | import android.media.SoundPool; 7 | 8 | /** 9 | * @Description:声音播放的工具类,可以使用meidaplayer,也可以使用SoundPool播放池来播放更有效率 10 | * @author http://blog.csdn.net/finddreams 11 | */ 12 | public class PlaySoundUtil { 13 | private MediaPlayer mMediaPlayer; 14 | private Context context; 15 | private static SoundPool sp; 16 | public static SoundPool getSoundPool() { 17 | if (sp == null) { 18 | synchronized (PlaySoundUtil.class) { 19 | if (sp == null) { 20 | sp = new SoundPool(10, AudioManager.STREAM_MUSIC, 5); 21 | // notifySoundId = sp.load(context, R.raw.notify, 0); 22 | // waitSoundId = sp.load(context, R.raw.tone_wait, 0); 23 | } 24 | } 25 | } 26 | return sp; 27 | } 28 | 29 | public PlaySoundUtil(Context context){ 30 | mMediaPlayer=new MediaPlayer(); 31 | this.context =context; 32 | sp = getSoundPool(); 33 | } 34 | 35 | public void playSoundsByPool(int sid){ 36 | int soundid=sp.load(context, sid, 0); 37 | sp.play(soundid, 1, 1, 0, 0, 1); 38 | } 39 | 40 | public void playSounds(int sid) { 41 | 42 | if (mMediaPlayer != null) { 43 | if (mMediaPlayer.isPlaying()) { 44 | mMediaPlayer.stop(); 45 | } 46 | mMediaPlayer.release(); 47 | mMediaPlayer = null; 48 | } 49 | 50 | mMediaPlayer = MediaPlayer.create(context, sid); 51 | /* 准备播放 */ 52 | try { 53 | mMediaPlayer.prepare(); 54 | } catch (Exception e) { 55 | // TODO Auto-generated catch block 56 | e.printStackTrace(); 57 | } 58 | /* 开始播放 */ 59 | mMediaPlayer.start(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/com/zxing/barcode/AutoFocusCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zxing.barcode; 18 | 19 | import android.hardware.Camera; 20 | import android.os.Handler; 21 | import android.os.Message; 22 | import android.util.Log; 23 | 24 | final class AutoFocusCallback implements Camera.AutoFocusCallback { 25 | 26 | private static final String TAG = AutoFocusCallback.class.getSimpleName(); 27 | 28 | private static final long AUTOFOCUS_INTERVAL_MS = 1500L; 29 | 30 | private Handler autoFocusHandler; 31 | private int autoFocusMessage; 32 | 33 | void setHandler(Handler autoFocusHandler, int autoFocusMessage) { 34 | this.autoFocusHandler = autoFocusHandler; 35 | this.autoFocusMessage = autoFocusMessage; 36 | } 37 | 38 | public void onAutoFocus(boolean success, Camera camera) { 39 | if (autoFocusHandler != null) { 40 | Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success); 41 | autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS); 42 | autoFocusHandler = null; 43 | } else { 44 | Log.d(TAG, "Got auto-focus callback, but no handler for it"); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.base; 2 | 3 | import com.finddreams.baselib.app.MyApplication; 4 | import com.finddreams.baselib.http.MyHttpClient; 5 | import com.loopj.android.http.AsyncHttpClient; 6 | 7 | import android.app.Activity; 8 | import android.content.Context; 9 | import android.os.Bundle; 10 | import android.support.v4.app.Fragment; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.View.OnClickListener; 14 | import android.view.ViewGroup; 15 | /** 16 | * @Description:所有fragment的基类 17 | * @author http://blog.csdn.net/finddreams 18 | */ 19 | public abstract class BaseFragment extends Fragment implements OnClickListener { 20 | protected Context context; 21 | public View rootView; 22 | protected MyApplication myApp; 23 | protected AsyncHttpClient httpClient; 24 | @Override 25 | public void onActivityCreated(Bundle savedInstanceState) { 26 | 27 | super.onActivityCreated(savedInstanceState); 28 | initData(); 29 | } 30 | 31 | @Override 32 | public void onCreate(Bundle savedInstanceState) { 33 | 34 | super.onCreate(savedInstanceState); 35 | context = getActivity(); 36 | myApp = (MyApplication) getActivity().getApplication(); 37 | httpClient = MyHttpClient.getHttpClient(); 38 | } 39 | 40 | 41 | @Override 42 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 43 | Bundle savedInstanceState) { 44 | rootView = initView(inflater); 45 | return rootView; 46 | } 47 | public View getRootView(){ 48 | return rootView; 49 | } 50 | @Override 51 | public void onClick(View arg0) { 52 | 53 | 54 | } 55 | protected abstract View initView(LayoutInflater inflater); 56 | 57 | protected abstract void initData(); 58 | 59 | protected abstract void processClick(View v); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/Screenshot.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.FileOutputStream; 6 | 7 | import android.content.Context; 8 | import android.graphics.Bitmap; 9 | import android.graphics.Bitmap.Config; 10 | import android.graphics.Canvas; 11 | import android.view.View; 12 | 13 | public class Screenshot { 14 | 15 | private static final String TAG = "Screenshot"; 16 | /** 17 | * Screenshot and save image to the sdcard 18 | * 19 | * @param context 20 | * @return image file 21 | * @throws FileNotFoundException 22 | */ 23 | public static File getScreenshot(Context context,View view) throws FileNotFoundException { 24 | File file = null; 25 | try { 26 | if (view == null) { 27 | return null; 28 | } 29 | // View view = ((Activity)context).getWindow().getDecorView(); 30 | // View mainScreen = ((Activity)context).findViewById(layoutResId); 31 | int height = DisplayUtil.getMobileHeight(context); 32 | int width = DisplayUtil.getMobileWidth(context); 33 | Bitmap bitmap = Bitmap.createBitmap( width, height, Config.ARGB_8888 ); 34 | Canvas canvas = new Canvas(bitmap); 35 | 36 | view.draw(canvas); 37 | long time = System.currentTimeMillis(); 38 | 39 | file = new File(ConstantsValue.IMAGE_APP_PATH+ "/" + time + ".png"); 40 | 41 | FileOutputStream f = null; 42 | f = new FileOutputStream(file); 43 | boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, f); 44 | if(b){ 45 | LogManager.d(TAG, "screentshot success"); 46 | } 47 | if (file.exists()) { 48 | LogManager.d(TAG, "image file exists"); 49 | } else { 50 | LogManager.d(TAG, "image file not exists"); 51 | } 52 | } catch (Exception e) { 53 | LogManager.e(TAG, "getScreenshot", e); 54 | } 55 | return file; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /res/values/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 已经到底啦 5 | 松开加载更多 6 | 下拉可以刷新 7 | 松开获取更多 8 | 上次刷新时间 : 9 | 正在加载中 10 | 正在刷新… 11 | 12 | 13 | 点击屏幕,重新加载 14 | 15 | 正在加载… 16 | 17 | 18 | @string/pushmsg_center_pull_down_text 19 | 上拉可以刷新 20 | 松开后刷新 21 | @string/pushmsg_center_load_more_ongoing_text 22 | @string/pushmsg_center_pull_down_update_time 23 | 松开载入更多 24 | @string/pull_to_refresh_header_hint_loading 25 | @string/pushmsg_center_no_more_msg 26 | 网络不给力,请检查网络 27 | 28 | 29 | 图片已保存到相册 30 | 保存图片失败 31 | 下一组: 32 | 上一组: 33 | 34 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/ProgressWebView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.util.AttributeSet; 6 | import android.webkit.WebView; 7 | import android.widget.ProgressBar; 8 | 9 | import com.finddreams.baselib.R; 10 | 11 | /** 12 | * 带进度条的WebView 13 | */ 14 | @SuppressWarnings("deprecation") 15 | public class ProgressWebView extends WebView { 16 | 17 | private ProgressBar progressbar; 18 | 19 | public ProgressWebView(Context context, AttributeSet attrs) { 20 | super(context, attrs); 21 | progressbar = new ProgressBar(context, null, 22 | android.R.attr.progressBarStyleHorizontal); 23 | progressbar.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 24 | 10, 0, 0)); 25 | 26 | Drawable drawable = context.getResources().getDrawable(R.drawable.progress_bar_states); 27 | progressbar.setProgressDrawable(drawable); 28 | addView(progressbar); 29 | // setWebViewClient(new WebViewClient(){}); 30 | setWebChromeClient(new WebChromeClient()); 31 | //是否支持缩放 32 | getSettings().setSupportZoom(true); 33 | getSettings().setBuiltInZoomControls(true); 34 | } 35 | 36 | public class WebChromeClient extends android.webkit.WebChromeClient { 37 | @Override 38 | public void onProgressChanged(WebView view, int newProgress) { 39 | if (newProgress == 100) { 40 | progressbar.setVisibility(GONE); 41 | } else { 42 | if (progressbar.getVisibility() == GONE) 43 | progressbar.setVisibility(VISIBLE); 44 | progressbar.setProgress(newProgress); 45 | } 46 | super.onProgressChanged(view, newProgress); 47 | } 48 | 49 | } 50 | 51 | @Override 52 | protected void onScrollChanged(int l, int t, int oldl, int oldt) { 53 | LayoutParams lp = (LayoutParams) progressbar.getLayoutParams(); 54 | lp.x = l; 55 | lp.y = t; 56 | progressbar.setLayoutParams(lp); 57 | super.onScrollChanged(l, t, oldl, oldt); 58 | } 59 | } -------------------------------------------------------------------------------- /src/com/finddreams/baselib/app/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.app; 2 | 3 | import java.util.LinkedList; 4 | 5 | import android.app.Activity; 6 | import android.app.Application; 7 | 8 | import com.finddreams.baselib.utils.ConstantsValue; 9 | 10 | public class MyApplication extends Application { 11 | private static final String TAG = "InitApplication"; 12 | private static boolean isLogged = false; 13 | private static MyApplication instance; 14 | private static LinkedList activityList; 15 | private Activity activity; 16 | @Override 17 | public void onCreate() 18 | { 19 | instance = this; 20 | super.onCreate(); 21 | if (!ConstantsValue.DEBUG) { 22 | /* 全局异常崩溃处理 */ 23 | CrashHandler catchExcep = new CrashHandler(this); 24 | Thread.setDefaultUncaughtExceptionHandler(catchExcep); 25 | } 26 | activityList = new LinkedList(); 27 | super.onCreate(); 28 | } 29 | 30 | public Activity getActivity() { 31 | return activity; 32 | } 33 | public void setActivity(Activity activity) { 34 | this.activity = activity; 35 | } 36 | public static MyApplication getInstance() 37 | { 38 | return instance; 39 | } 40 | /** 41 | * Activity关闭时,删除Activity列表中的Activity对象*/ 42 | public void removeActivity(Activity a){ 43 | activityList.remove(a); 44 | } 45 | 46 | /** 47 | * 向Activity列表中添加Activity对象*/ 48 | public void addActivity(Activity a){ 49 | activityList.add(a); 50 | } 51 | 52 | /** 53 | * 关闭Activity列表中的所有Activity*/ 54 | public void finishActivity(){ 55 | for (Activity activity : activityList) { 56 | if (null != activity) { 57 | activity.finish(); 58 | } 59 | } 60 | activityList.clear(); 61 | //杀死该应用进程 62 | android.os.Process.killProcess(android.os.Process.myPid()); 63 | } 64 | 65 | public static boolean isLogged() { 66 | return isLogged; 67 | } 68 | public static void setLogged(boolean isLogged) { 69 | MyApplication.isLogged = isLogged; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/InstallManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * **************************************************************** 3 | * 4 | * Copyright (C) SNDA Corporation. All rights reserved. 5 | * 6 | * FileName : InstallManager.java 7 | * Description : APK Package related functions. 8 | * 9 | ****************************************************************** 10 | */ 11 | package com.finddreams.baselib.utils; 12 | 13 | import java.util.List; 14 | 15 | import android.app.ActivityManager; 16 | import android.content.Context; 17 | import android.content.pm.PackageInfo; 18 | 19 | /** 20 | * A class that extracts data and install apk. 21 | */ 22 | public class InstallManager { 23 | private Context mContext = null; 24 | 25 | public InstallManager(Context context) 26 | { 27 | mContext = context; 28 | } 29 | 30 | public int getInstalledVersion(String packageName, boolean getSysPackages) { 31 | List packs = mContext.getPackageManager().getInstalledPackages(0); 32 | int curVersion = -1; 33 | for (int i = 0; i < packs.size(); i++) { 34 | PackageInfo p = packs.get(i); 35 | 36 | if (p.packageName.equals(packageName)) { 37 | curVersion = p.versionCode; 38 | break; 39 | } 40 | } 41 | 42 | return curVersion; 43 | } 44 | 45 | public boolean appIsStart(String packageName) { 46 | boolean ret = false; 47 | ActivityManager mActivityManager = (ActivityManager) mContext 48 | .getSystemService(Context.ACTIVITY_SERVICE); 49 | List mServiceList = mActivityManager 50 | .getRunningServices(1000); 51 | for (int i = 0; i < mServiceList.size(); i++) { 52 | if (packageName.equals(mServiceList.get(i).service.getPackageName())) { 53 | ret = true; 54 | break; 55 | } 56 | } 57 | 58 | return ret; 59 | } 60 | } -------------------------------------------------------------------------------- /src/com/android/pulltorefreshview/ILoadingLayout.java: -------------------------------------------------------------------------------- 1 | package com.android.pulltorefreshview; 2 | 3 | /** 4 | * 下拉刷新和上拉加载更多的界面接口 5 | * 6 | * @author Li Hong 7 | * @since 2013-7-29 8 | */ 9 | public interface ILoadingLayout { 10 | /** 11 | * 当前的状态 12 | */ 13 | public enum State { 14 | 15 | /** 16 | * Initial state 17 | */ 18 | NONE, 19 | 20 | /** 21 | * When the UI is in a state which means that user is not interacting 22 | * with the Pull-to-Refresh function. 23 | */ 24 | RESET, 25 | 26 | /** 27 | * When the UI is being pulled by the user, but has not been pulled far 28 | * enough so that it refreshes when released. 29 | */ 30 | PULL_TO_REFRESH, 31 | 32 | /** 33 | * When the UI is being pulled by the user, and has 34 | * been pulled far enough so that it will refresh when released. 35 | */ 36 | RELEASE_TO_REFRESH, 37 | 38 | /** 39 | * When the UI is currently refreshing, caused by a pull gesture. 40 | */ 41 | REFRESHING, 42 | 43 | /** 44 | * When the UI is currently refreshing, caused by a pull gesture. 45 | */ 46 | @Deprecated 47 | LOADING, 48 | 49 | /** 50 | * No more data 51 | */ 52 | NO_MORE_DATA, 53 | } 54 | 55 | /** 56 | * 设置当前状态,派生类应该根据这个状态的变化来改变View的变化 57 | * 58 | * @param state 状态 59 | */ 60 | public void setState(State state); 61 | 62 | /** 63 | * 得到当前的状态 64 | * 65 | * @return 状态 66 | */ 67 | public State getState(); 68 | 69 | /** 70 | * 得到当前Layout的内容大小,它将作为一个刷新的临界点 71 | * 72 | * @return 高度 73 | */ 74 | public int getContentSize(); 75 | 76 | /** 77 | * 在拉动时调用 78 | * 79 | * @param scale 拉动的比例 80 | */ 81 | public void onPull(float scale); 82 | } 83 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/ToastManager.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import android.content.Context; 4 | import android.widget.Toast; 5 | 6 | import com.finddreams.baselib.view.CustomToast; 7 | 8 | /** 9 | * @Description: 管理toast的类 10 | * @author http://blog.csdn.net/finddreams 11 | */ 12 | public class ToastManager { 13 | 14 | protected static final String TAG = "AppToast"; 15 | public static CustomToast toast; 16 | /** 17 | * 信息提示 18 | * @param context 19 | * @param content 20 | */ 21 | public static void makeToast(Context context, String content) { 22 | if(context==null)return; 23 | if(toast != null) 24 | toast.cancel(); 25 | toast = new CustomToast(context, content, Toast.LENGTH_LONG); 26 | toast.show(); 27 | } 28 | 29 | public static void showShortText(Context context, int resId) { 30 | try { 31 | if(context==null)return; 32 | if(toast != null) 33 | toast.cancel(); 34 | toast = new CustomToast(context, context.getString(resId),Toast.LENGTH_SHORT); 35 | toast.show(); 36 | } catch (Exception e) { 37 | LogManager.e(TAG,e.getMessage()); 38 | } 39 | } 40 | public static void showShortText(Context context, CharSequence text) { 41 | if(context==null)return; 42 | if(toast != null) 43 | toast.cancel(); 44 | toast = new CustomToast(context, text.toString(),Toast.LENGTH_SHORT); 45 | toast.show(); 46 | } 47 | 48 | public static void showLongText(Context context, int resId) { 49 | try { 50 | if(context==null)return; 51 | if(toast != null) 52 | toast.cancel(); 53 | toast = new CustomToast(context, context.getString(resId),Toast.LENGTH_LONG); 54 | toast.show(); 55 | 56 | } catch (Exception e) { 57 | LogManager.e(TAG,e.getMessage()); 58 | } 59 | } 60 | 61 | public static void showLongText(Context context, CharSequence text) { 62 | if(context==null)return; 63 | if(toast != null) 64 | toast.cancel(); 65 | toast = new CustomToast(context, text.toString(),Toast.LENGTH_LONG); 66 | toast.show(); 67 | } 68 | 69 | 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /res/values/vpi__styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 38 | 39 | 40 | 43 | 44 | 48 | 49 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | import android.util.Log; 9 | 10 | public class DateUtil { 11 | 12 | private static final String TAG = "DateUtil"; 13 | 14 | private static final String FORMAT1= "yyyy-MM-dd HH:mm:ss"; 15 | private static final String FORMAT2 = "yyyyMMddHHmmss"; 16 | private static SimpleDateFormat sdfNormal; 17 | private static SimpleDateFormat sdfStr; 18 | 19 | static { 20 | sdfNormal = new SimpleDateFormat(FORMAT1); 21 | sdfStr = new SimpleDateFormat(FORMAT2); 22 | } 23 | 24 | public static String formatDate(String date){ 25 | String format = null; 26 | try { 27 | if (date == null || "".equals(date)) { 28 | return ""; 29 | } 30 | format = sdfNormal.format(sdfNormal.parse(date)); 31 | } catch (ParseException e) { 32 | LogManager.e(TAG, "formatDate", e); 33 | return date; 34 | } 35 | return format; 36 | } 37 | /** 38 | * get current date,date pattern : yyyy-MM-dd HH:mm:ss 39 | * @return 40 | */ 41 | public static String getCurrentDate(){ 42 | String format = null; 43 | format = sdfNormal.format(new Date()); 44 | return format; 45 | } 46 | 47 | public static String formatDateStr(String date) { 48 | String format = null; 49 | try { 50 | Date parseDate = sdfStr.parse(date); 51 | format = sdfNormal.format(parseDate); 52 | } catch (ParseException e) { 53 | LogManager.e(TAG, "formatDateStr", e); 54 | return date; 55 | } 56 | return format; 57 | } 58 | 59 | /** 60 | * 获取当前时间的字符串 61 | */ 62 | public static String getCurrentDateStr() { 63 | Date date = new Date(); 64 | Calendar c = Calendar.getInstance(); 65 | c.setTime(date); 66 | String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; 67 | int w = c.get(Calendar.DAY_OF_WEEK) - 1; 68 | if (w < 0) { 69 | w = 0; 70 | } 71 | String mDate = c.get(Calendar.YEAR) + "年" + (c.get(Calendar.MONTH) + 1) 72 | + "月" + c.get(Calendar.DATE) + "日 " + weekDays[w]; 73 | return mDate; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | 8 | import android.os.Environment; 9 | 10 | public class FileUtil { 11 | 12 | public static final String ROOT = Environment.getExternalStorageDirectory().getPath() + "/nicehair/"; 13 | public static final String CAMERA = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/"; 14 | public static final String CACHE_IMG ="/cache/images/"; 15 | /** 16 | * 应用日志目录文件 17 | */ 18 | public static String APP_LOG_PATH = ROOT + "log/"; 19 | 20 | /** 21 | * 日志文件路径 22 | */ 23 | public static String LOGFILE = APP_LOG_PATH + "log.txt"; 24 | 25 | /** 26 | * 读取输入流数据 27 | * 28 | * @param inStream 29 | * @return 30 | */ 31 | public static byte[] read(InputStream inStream) throws Exception { 32 | ByteArrayOutputStream outStream = new ByteArrayOutputStream(); 33 | byte[] buffer = new byte[1024]; 34 | int len = 0; 35 | while ((len = inStream.read(buffer)) != -1) { 36 | outStream.write(buffer, 0, len); 37 | } 38 | inStream.close(); 39 | return outStream.toByteArray(); 40 | } 41 | /** 42 | * 判断SD是否可以 43 | * 44 | * @return 45 | */ 46 | public static boolean isSdcardExist() { 47 | if (Environment.getExternalStorageState().equals( 48 | Environment.MEDIA_MOUNTED)) { 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | /** 55 | * 创建根目录 56 | * 57 | * @param path 58 | * 目录路径 59 | */ 60 | public static void createDirFile(String path) { 61 | File dir = new File(path); 62 | if (!dir.exists()) { 63 | dir.mkdirs(); 64 | } 65 | } 66 | 67 | /** 68 | * 创建文件 69 | * 70 | * @param path 71 | * 文件路径 72 | * @return 创建的文件 73 | */ 74 | public static File createNewFile(String path) { 75 | File file = new File(path); 76 | if (!file.exists()) { 77 | try { 78 | file.createNewFile(); 79 | } catch (IOException e) { 80 | return null; 81 | } 82 | } 83 | return file; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/TopBarView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | import com.finddreams.baselib.R; 4 | 5 | import android.app.Activity; 6 | import android.content.Context; 7 | import android.util.AttributeSet; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | import android.widget.LinearLayout; 12 | import android.widget.TextView; 13 | 14 | /** 15 | * @Description:每个应用都需要用到的顶部导航条自定义,包含有返回,标题等五个控件 16 | * @author http://blog.csdn.net/finddreams 17 | */ 18 | public class TopBarView extends LinearLayout{ 19 | 20 | private LinearLayout mTopBack; 21 | public TextView mTvBack; 22 | public TextView mTvTitle; 23 | public ImageView mIvRight; 24 | public TextView mTvRight; 25 | private Activity mActivity; 26 | public TopBarView(Context context) { 27 | super(context); 28 | } 29 | public TopBarView(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | LayoutInflater.from(context).inflate(R.layout.view_top_bar, this, true); 32 | mTopBack=(LinearLayout)this.findViewById(R.id.top_back_btn); 33 | mTvBack=(TextView)this.findViewById(R.id.top_back_tv); 34 | mTvTitle=(TextView)this.findViewById(R.id.top_title); 35 | mTvRight=(TextView)this.findViewById(R.id.top_right_tv); 36 | mIvRight=(ImageView)this.findViewById(R.id.top_right_btn); 37 | mTopBack.setOnClickListener(onClickListener); 38 | mTvRight.setOnClickListener(onClickListener); 39 | mIvRight.setOnClickListener(onClickListener); 40 | } 41 | private OnClickListener onClickListener = new OnClickListener() { 42 | 43 | @Override 44 | public void onClick(View v) { 45 | // TODO Auto-generated method stub 46 | switch(v.getId()) { 47 | case R.id.top_back_btn: 48 | if(mActivity!=null) 49 | mActivity.finish(); 50 | break; 51 | case R.id.top_right_tv: 52 | 53 | break; 54 | case R.id.top_right_btn: 55 | 56 | break; 57 | } 58 | } 59 | }; 60 | public void setActivity(Activity activity) { 61 | this.mActivity=activity; 62 | } 63 | public void setTitle(String title) { 64 | mTvTitle.setText(title); 65 | } 66 | public void setRightText(String text) { 67 | mTvRight.setText(text); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/AppHelper.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.PackageInfo; 7 | import android.content.pm.PackageManager; 8 | import android.content.pm.PackageManager.NameNotFoundException; 9 | import android.net.Uri; 10 | /** 11 | * @Description: app的帮助类 12 | * @author http://blog.csdn.net/finddreams 13 | */ 14 | public class AppHelper { 15 | 16 | private static final String TAG = "AppHelper"; 17 | /** 18 | * @param context 19 | * @return 20 | */ 21 | public static String getAppVersion(Context context) { 22 | try { 23 | // 获取packagemanager的实例 24 | PackageManager packageManager = context.getPackageManager(); 25 | // getPackageName()是你当前类的包名,0代表是获取版本信息 26 | PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(),0); 27 | String version = packInfo.versionName; 28 | return version; 29 | } catch (NameNotFoundException e) { 30 | e.printStackTrace(); 31 | } 32 | return null; 33 | } 34 | 35 | /** 36 | * get android os version no 37 | * @return 38 | */ 39 | public static float getAndroidVersion() { 40 | return Float.valueOf(android.os.Build.VERSION.RELEASE); 41 | } 42 | 43 | /** 44 | * get device model 45 | * @return 46 | */ 47 | public String getDeviceModel () { 48 | return android.os.Build.MODEL; 49 | } 50 | 51 | /** 52 | * get android os sdk version 2.2 = 8,2.3 = 9,4.2.1 = 17 53 | * @return sdk version 54 | */ 55 | public static int getSDKVersion(){ 56 | return android.os.Build.VERSION.SDK_INT; 57 | } 58 | /** 59 | * 根据Uri安装apk 60 | * @param context 61 | * @param uri 62 | */ 63 | public void installApk(Context context,Uri uri) { 64 | if (uri.toString().endsWith(".apk")) { 65 | Intent intent = new Intent(); 66 | intent.setAction(Intent.ACTION_VIEW); 67 | // intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive"); 68 | intent.setDataAndType(uri,"application/vnd.android.package-archive"); 69 | context.startActivity(intent); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /res/drawable/tab_indicator.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/com/zxing/barcode/PreviewCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zxing.barcode; 18 | 19 | import android.graphics.Point; 20 | import android.hardware.Camera; 21 | import android.os.Handler; 22 | import android.os.Message; 23 | import android.util.Log; 24 | 25 | final class PreviewCallback implements Camera.PreviewCallback { 26 | 27 | private static final String TAG = PreviewCallback.class.getSimpleName(); 28 | 29 | private final CameraConfigurationManager configManager; 30 | private final boolean useOneShotPreviewCallback; 31 | private Handler previewHandler; 32 | private int previewMessage; 33 | 34 | PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) { 35 | this.configManager = configManager; 36 | this.useOneShotPreviewCallback = useOneShotPreviewCallback; 37 | } 38 | 39 | void setHandler(Handler previewHandler, int previewMessage) { 40 | this.previewHandler = previewHandler; 41 | this.previewMessage = previewMessage; 42 | } 43 | 44 | public void onPreviewFrame(byte[] data, Camera camera) { 45 | Point cameraResolution = configManager.getCameraResolution(); 46 | if (!useOneShotPreviewCallback) { 47 | camera.setPreviewCallback(null); 48 | } 49 | if (previewHandler != null) { 50 | Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x, 51 | cameraResolution.y, data); 52 | message.sendToTarget(); 53 | previewHandler = null; 54 | } else { 55 | Log.d(TAG, "Got preview callback, but no handler for it"); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /res/layout/view_top_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 25 | 26 | 27 | 35 | 36 | 46 | 47 | 57 | 58 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/InputMethodUtil.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | import java.util.Timer; 4 | import java.util.TimerTask; 5 | 6 | import android.app.Activity; 7 | import android.content.Context; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.view.inputmethod.InputMethodManager; 11 | 12 | import com.finddreams.baselib.service.ServiceManager; 13 | /** 14 | * @Description:对于软键盘的管理 15 | * @author http://blog.csdn.net/finddreams 16 | */ 17 | public class InputMethodUtil { 18 | 19 | /** 20 | * 延迟打开软键盘,默认延迟500ms 21 | * @param context 22 | */ 23 | public static void showInputMethodDelay(final Context context) { 24 | Timer timer = new Timer(); 25 | timer.schedule(new TimerTask() { 26 | @Override 27 | public void run() { 28 | InputMethodManager imm = ServiceManager.getInputMethodManager(context); 29 | imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 30 | } 31 | }, 500); 32 | } 33 | /** 34 | * 延迟打开软键盘 35 | * @param context 36 | * @param delay 延迟时间 37 | */ 38 | public static void showInputMethodDelay(final Context context,long delay) { 39 | Timer timer = new Timer(); 40 | timer.schedule(new TimerTask() { 41 | @Override 42 | public void run() { 43 | InputMethodManager imm = ServiceManager.getInputMethodManager(context); 44 | imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 45 | } 46 | }, delay); 47 | } 48 | /** 49 | * 直接打开软键盘 50 | * @param context 51 | */ 52 | public static void showInputMethod(final Context context) { 53 | InputMethodManager imm = ServiceManager.getInputMethodManager(context); 54 | imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 55 | } 56 | /** 57 | * 关闭软键盘 58 | * @param context 59 | * @param view 60 | */ 61 | public static void hiddenInputMethod(final Context context,View view) { 62 | InputMethodManager imm = ServiceManager.getInputMethodManager(context); 63 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 64 | } 65 | 66 | public static void hideBottomSoftInputMethod(Context context) { 67 | ((Activity)context).getWindow().setSoftInputMode( 68 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/zxing/barcode/InactivityTimer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zxing.barcode; 18 | 19 | import java.util.concurrent.Executors; 20 | import java.util.concurrent.ScheduledExecutorService; 21 | import java.util.concurrent.ScheduledFuture; 22 | import java.util.concurrent.ThreadFactory; 23 | import java.util.concurrent.TimeUnit; 24 | 25 | import android.app.Activity; 26 | 27 | /** 28 | * Finishes an activity after a period of inactivity. 29 | */ 30 | public final class InactivityTimer { 31 | 32 | private static final int INACTIVITY_DELAY_SECONDS = 5 * 60; 33 | 34 | private final ScheduledExecutorService inactivityTimer = 35 | Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory()); 36 | private final Activity activity; 37 | private ScheduledFuture inactivityFuture = null; 38 | 39 | public InactivityTimer(Activity activity) { 40 | this.activity = activity; 41 | onActivity(); 42 | } 43 | 44 | public void onActivity() { 45 | cancel(); 46 | inactivityFuture = inactivityTimer.schedule(new FinishListener(activity), 47 | INACTIVITY_DELAY_SECONDS, 48 | TimeUnit.SECONDS); 49 | } 50 | 51 | private void cancel() { 52 | if (inactivityFuture != null) { 53 | inactivityFuture.cancel(true); 54 | inactivityFuture = null; 55 | } 56 | } 57 | 58 | public void shutdown() { 59 | cancel(); 60 | inactivityTimer.shutdown(); 61 | } 62 | 63 | private static final class DaemonThreadFactory implements ThreadFactory { 64 | public Thread newThread(Runnable runnable) { 65 | Thread thread = new Thread(runnable); 66 | thread.setDaemon(true); 67 | return thread; 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/http/URLUtils.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.http; 2 | 3 | import java.net.URISyntaxException; 4 | import java.util.ArrayList; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.apache.http.client.utils.URIUtils; 10 | import org.apache.http.client.utils.URLEncodedUtils; 11 | import org.apache.http.message.BasicNameValuePair; 12 | 13 | import com.lidroid.xutils.HttpUtils; 14 | import com.lidroid.xutils.util.LogUtils; 15 | 16 | /** 17 | * @Description:url的帮助类 18 | * @author http://blog.csdn.net/finddreams 19 | */ 20 | public class URLUtils { 21 | 22 | public final static String HOST = "blog.csdn.net"; 23 | public static final String PATH = "finddreams"; 24 | public static final String SCHEME = "http"; 25 | public static final String defaultEncoding = "UTF-8"; 26 | 27 | public static String getUrl(String baseurl) { 28 | if (baseurl != null) { 29 | String url = SCHEME + "://" + HOST + "/" + PATH + baseurl; 30 | return url; 31 | } 32 | return null; 33 | } 34 | /** 35 | * 创建Url 36 | * @param resource 37 | * @return 38 | */ 39 | public static String createURL(String resource) { 40 | try { 41 | String url = URIUtils.createURI(SCHEME, HOST, -1, PATH + resource, 42 | "", null).toString(); 43 | LogUtils.d(url); 44 | return url; 45 | } catch (URISyntaxException e) { 46 | e.printStackTrace(); 47 | } 48 | return null; 49 | } 50 | 51 | public static String createURL(String resource, Map params) { 52 | return createURL(resource, params, defaultEncoding); 53 | } 54 | 55 | public static String createURL(String resource, Map params, 56 | String encoding) { 57 | List parameters = new ArrayList(); 58 | for (Iterator> it = params.entrySet() 59 | .iterator(); it.hasNext();) { 60 | Map.Entry entry = (Map.Entry) it 61 | .next(); 62 | parameters.add(new BasicNameValuePair(entry.getKey(), entry 63 | .getValue())); 64 | } 65 | 66 | try { 67 | String url = URIUtils.createURI(SCHEME, HOST, -1, PATH + resource, 68 | URLEncodedUtils.format(parameters, encoding), null) 69 | .toString(); 70 | 71 | LogUtils.d(url); 72 | return url; 73 | } catch (URISyntaxException e) { 74 | e.printStackTrace(); 75 | } 76 | return null; 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/utils/AppManager.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.utils; 2 | 3 | 4 | import java.util.Stack; 5 | 6 | import android.app.Activity; 7 | import android.app.ActivityManager; 8 | import android.content.Context; 9 | /** 10 | **************************************** 11 | * @author 刘祥 12 | * @Description: 这是一个管理Activity的类,可以对项目中Activity的生命周期进行管理, 13 | * 达到安全退出的目的; 14 | * @date 2014-7-7 下午3:30:52 15 | ***************************************** 16 | */ 17 | public class AppManager { 18 | 19 | private static Stack activityStack; 20 | private static AppManager instance; 21 | 22 | private AppManager(){} 23 | /** 24 | * 单一实例 25 | */ 26 | public static AppManager getAppManager(){ 27 | if(instance==null){ 28 | instance=new AppManager(); 29 | } 30 | return instance; 31 | } 32 | /** 33 | * 添加Activity到堆栈中 34 | */ 35 | public void addActivity(Activity activity){ 36 | if(activityStack==null){ 37 | activityStack=new Stack(); 38 | } 39 | activityStack.add(activity); 40 | } 41 | /** 42 | * 获取当前Activity(堆栈中最后压入的) 43 | */ 44 | public Activity currentActivity(){ 45 | Activity activity=activityStack.lastElement(); 46 | return activity; 47 | } 48 | /** 49 | * 结束当前Activity(堆栈中最后压入的) 50 | */ 51 | public void finishActivity(){ 52 | Activity activity=activityStack.lastElement(); 53 | finishActivity(activity); 54 | } 55 | /** 56 | * 结束指定的Activity 57 | */ 58 | public void finishActivity(Activity activity){ 59 | if(activity!=null){ 60 | activityStack.remove(activity); 61 | activity.finish(); 62 | activity=null; 63 | } 64 | } 65 | /** 66 | * 结束指定类名的Activity 67 | */ 68 | public void finishActivity(Class cls){ 69 | for (Activity activity : activityStack) { 70 | if(activity.getClass().equals(cls) ){ 71 | finishActivity(activity); 72 | } 73 | } 74 | } 75 | /** 76 | * 结束所有Activity 77 | */ 78 | public void finishAllActivity(){ 79 | for (int i = 0, size = activityStack.size(); i < size; i++){ 80 | if (null != activityStack.get(i)){ 81 | activityStack.get(i).finish(); 82 | } 83 | } 84 | activityStack.clear(); 85 | } 86 | /** 87 | * 彻底退出应用程序,安全退出 88 | */ 89 | public void AppExit(Context context) { 90 | try { 91 | finishAllActivity(); 92 | ActivityManager activityMgr= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); 93 | activityMgr.restartPackage(context.getPackageName()); 94 | System.exit(0); 95 | android.os.Process.killProcess(android.os.Process.myPid()); 96 | } catch (Exception e) { } 97 | } 98 | } -------------------------------------------------------------------------------- /src/com/finddreams/baselib/http/MyHttpUtils.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.http; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.http.HttpEntity; 6 | 7 | import android.content.Context; 8 | 9 | import com.finddreams.baselib.R; 10 | import com.finddreams.baselib.utils.StringUtil; 11 | import com.finddreams.baselib.utils.ToastManager; 12 | import com.lidroid.xutils.HttpUtils; 13 | import com.lidroid.xutils.http.RequestParams; 14 | import com.lidroid.xutils.http.callback.RequestCallBack; 15 | import com.lidroid.xutils.http.client.HttpRequest; 16 | import com.lidroid.xutils.http.client.HttpRequest.HttpMethod; 17 | import com.lidroid.xutils.util.LogUtils; 18 | 19 | /** 20 | * 自定义的HttpUtils 21 | * 22 | * @author liuxiang 23 | * @date 2015-2-5 下午3:46:48 24 | * @version V1.0 25 | */ 26 | public class MyHttpUtils { 27 | 28 | private static final int CONNTIMEOUT = 1000 * 15; 29 | private static final int CACHE_TIME = 1000 * 20; 30 | private static HttpUtils http; 31 | private Context context; 32 | 33 | public MyHttpUtils(Context context) { 34 | this.context = context; 35 | http = new HttpUtils(CONNTIMEOUT); 36 | 37 | } 38 | 39 | public void setCache() { 40 | http.configCurrentHttpCacheExpiry(CACHE_TIME); 41 | } 42 | 43 | public void httpGet(String url, RequestCallBack callback) { 44 | http(HttpMethod.GET, url, null, callback); 45 | } 46 | 47 | public void httpPost(String url, RequestParams params, 48 | RequestCallBack callback) { 49 | http(HttpMethod.POST, url, params, callback); 50 | } 51 | 52 | protected void http(HttpRequest.HttpMethod method, String url, 53 | RequestParams params, RequestCallBack callback) { 54 | http.configCurrentHttpCacheExpiry(CACHE_TIME); 55 | LogUtils.allowD = true; 56 | if (params != null) { 57 | if (params.getQueryStringParams() != null) 58 | LogUtils.d(url + params.getQueryStringParams().toString()); 59 | HttpEntity entity = params.getEntity(); 60 | if (entity != null) { 61 | 62 | try { 63 | LogUtils.d(url + StringUtil.convertStreamToString(entity.getContent())); 64 | } catch (IOException e) { 65 | 66 | e.printStackTrace(); 67 | } 68 | } 69 | } else { 70 | params = new RequestParams(); 71 | } 72 | 73 | if (0 == NetStateUtil.isNetworkAvailable(context)) { 74 | showCustomToast(context.getString(R.string.no_net)); 75 | http.send(method, url, params, callback); 76 | } else { 77 | http.send(method, url, params, callback); 78 | } 79 | } 80 | 81 | protected void showCustomToast(String str) { 82 | ToastManager.showShortText(context, str); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/finddreams/baselib/view/FlippingImageView.java: -------------------------------------------------------------------------------- 1 | package com.finddreams.baselib.view; 2 | 3 | 4 | 5 | import android.content.Context; 6 | import android.util.AttributeSet; 7 | import android.view.View; 8 | import android.view.animation.Animation; 9 | import android.view.animation.LinearInterpolator; 10 | import android.widget.ImageView; 11 | 12 | import com.finddreams.baselib.view.RotateAnimation.Mode; 13 | /** 14 | * 左右翻转旋转图片 15 | * @author liuxiang 16 | * @date 2015-1-30 下午5:27:02 17 | * @version V1.0 18 | */ 19 | public class FlippingImageView extends ImageView { 20 | 21 | private RotateAnimation mAnimation; 22 | private boolean mIsHasAnimation; 23 | 24 | public FlippingImageView(Context context) { 25 | super(context); 26 | } 27 | 28 | public FlippingImageView(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | } 31 | 32 | public FlippingImageView(Context context, AttributeSet attrs, int defStyle) { 33 | super(context, attrs, defStyle); 34 | } 35 | 36 | private void setRotateAnimation() { 37 | if (mIsHasAnimation == false && getWidth() > 0 38 | && getVisibility() == View.VISIBLE) { 39 | mIsHasAnimation = true; 40 | mAnimation = new RotateAnimation(getWidth() / 2.0F, 41 | getHeight() / 2.0F, Mode.Y); 42 | mAnimation.setDuration(1000L); 43 | mAnimation.setInterpolator(new LinearInterpolator()); 44 | mAnimation.setRepeatCount(-1); 45 | mAnimation.setRepeatMode(Animation.RESTART); 46 | setAnimation(mAnimation); 47 | } 48 | } 49 | 50 | private void clearRotateAnimation() { 51 | if (mIsHasAnimation) { 52 | mIsHasAnimation = false; 53 | setAnimation(null); 54 | mAnimation = null; 55 | } 56 | } 57 | 58 | @Override 59 | protected void onAttachedToWindow() { 60 | super.onAttachedToWindow(); 61 | setRotateAnimation(); 62 | 63 | } 64 | 65 | @Override 66 | protected void onDetachedFromWindow() { 67 | super.onDetachedFromWindow(); 68 | clearRotateAnimation(); 69 | } 70 | 71 | @Override 72 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 73 | super.onSizeChanged(w, h, oldw, oldh); 74 | if (w > 0) { 75 | setRotateAnimation(); 76 | } 77 | } 78 | 79 | public void startAnimation() { 80 | if (mIsHasAnimation) { 81 | super.startAnimation(mAnimation); 82 | } 83 | } 84 | 85 | @Override 86 | protected void onVisibilityChanged(View changedView, int visibility) { 87 | super.onVisibilityChanged(changedView, visibility); 88 | if (visibility == View.INVISIBLE || visibility == View.GONE) { 89 | clearRotateAnimation(); 90 | } else { 91 | setRotateAnimation(); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /res/layout/popu_get_photo.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 |