仿拉手團購App4--我的模塊

来源:http://www.cnblogs.com/ganchuanpu/archive/2017/05/16/6864088.html
-Advertisement-
Play Games

fragment_me.xml MeFragment.java ...


          

fragment_me.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:orientation="vertical"
              android:background="@color/app_bg"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/app_bg">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            
            <RelativeLayout
                android:id="@+id/me_login_layout"
                android:layout_width="match_parent"
                android:layout_height="@dimen/me_login_layout_height"
                android:paddingLeft="@dimen/me_login_layout_paddingLeft"
                android:background="@mipmap/my_login_bg"
                android:visibility="gone">
                <com.facebook.drawee.view.SimpleDraweeView
                    android:id="@+id/me_login_iv_head"
                    android:layout_width="@dimen/me_login_head_width"
                    android:layout_height="@dimen/me_login_head_height"
                    android:layout_marginEnd="@dimen/me_login_head_marginEnd"
                    android:layout_centerVertical="true"
                    android:scaleType="fitXY"
                    app:placeholderImage="@mipmap/user_head"/>
                <LinearLayout
                    android:id="@+id/me_login_profile_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/me_login_iv_head"
                    android:orientation="vertical">
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="@dimen/me_login_profile_layout_marginStart">
                        <TextView
                            android:id="@+id/me_login_tv_username"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            tools:text="布拉拉"
                            android:singleLine="true"
                            android:ellipsize="end"
                            android:textColor="@color/grad"
                            android:textSize="@dimen/me_login_username_size"/>
                        <ImageView
                            android:id="@+id/me_login_iv_level"
                            android:layout_width="@dimen/me_login_level_width"
                            android:layout_height="@dimen/me_login_level_height"
                            android:layout_marginStart="@dimen/me_login_level_marginStart"
                            android:layout_toRightOf="@+id/me_login_tv_username"
                            android:src="@mipmap/level_0"/>
                    </RelativeLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/me_login_balance_layout_marginTop"
                        android:layout_marginStart="@dimen/me_login_profile_layout_marginStart">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/me_login_balance"
                            android:textSize="@dimen/me_login_balance_size"/>
                        <TextView
                            android:id="@+id/me_login_tv_balance"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="00.00"
                            android:textSize="@dimen/textSize_16"/>
                    </LinearLayout>
                </LinearLayout>
                <ImageView
                    android:id="@+id/me_login_iv_arrow_right"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginEnd="@dimen/me_login_head_marginEnd"
                    android:src="@mipmap/icon_user_arrow_more"/>
            </RelativeLayout>

            <LinearLayout
                android:id="@+id/me_nologin_layout"
                android:layout_width="match_parent"
                android:layout_height="@dimen/me_login_layout_height"
                android:orientation="vertical"
                android:gravity="center"
                android:background="@mipmap/my_login_bg">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/me_nologin_not_login"
                    android:textSize="@dimen/me_nologin_textSize"
                    android:textColor="@color/grad"/>
                <Button
                    android:id="@+id/me_nologin_btn_login"
                    android:layout_width="80dp"
                    android:layout_height="30dp"
                    android:layout_marginTop="10dp"
                    android:text="@string/me_nologin_login"
                    android:textSize="@dimen/me_nologin_textSize"
                    android:textColor="@color/grad"
                    android:background="@drawable/login_btn_bg_selector"/>
            </LinearLayout>
            
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:background="@drawable/white_quai_bg"
                android:orientation="horizontal">
                <TextView
                    android:id="@+id/me_user_tv_cart"
                    style="@style/me_userLayout_textView_style"
                    android:drawableTop="@mipmap/user_icon_lashouquan"
                    android:text="@string/me_user_cart"/>
                <View
                    style="@style/me_vertical_view_style"/>
                <TextView
                    android:id="@+id/me_user_tv_favorite"
                    style="@style/me_userLayout_textView_style"
                    android:drawableTop="@mipmap/user_icon_favorite"
                    android:text="@string/me_user_favorite"/>
                <View
                    style="@style/me_vertical_view_style"/>
                <TextView
                    android:id="@+id/me_user_tv_history"
                    style="@style/me_userLayout_textView_style"
                    android:drawableTop="@mipmap/user_icon_history"
                    android:text="@string/me_user_history"/>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/me_user_order_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="@drawable/white_quai_bg">
                <RelativeLayout
                    android:id="@+id/me_item_unpaid_layout"
                    style="@style/me_common_item_relativeLayout_style">
                    <ImageView
                        android:id="@+id/me_item_unpaid_iv_icon"
                        style="@style/me_common_item_icon_imageView_style"
                        android:src="@mipmap/user_listicon_daifukuan"/>
                    <TextView
                        style="@style/me_common_item_title_textView_style"
                        android:layout_toRightOf="@+id/me_item_unpaid_iv_icon"
                        android:text="@string/me_item_unpaid_order"/>
                    <ImageView
                        android:id="@+id/me_item_unpaid_iv_arrow_right"
                        style="@style/me_common_item_arrow_right_imageView_style"/>
                    <TextView
                        android:id="@+id/me_item_unpaid_tv_count"
                        android:layout_toLeftOf="@+id/me_item_unpaid_iv_arrow_right"
                        android:textColor="@color/white"
                        android:background="@mipmap/num_red_bg"
                        style="@style/me_common_item_count_textView_style"
                        android:text="1"/>
                </RelativeLayout>
                <View
                    style="@style/me_horizontal_view_style"/>
                <RelativeLayout
                    android:id="@+id/me_item_paid_order_layout"
                    style="@style/me_common_item_relativeLayout_style">
                    <ImageView
                        android:id="@+id/me_item_paid_iv_icon"
                        style="@style/me_common_item_icon_imageView_style"
                        android:src="@mipmap/user_listicon_yifukuan"/>
                    <TextView
                        style="@style/me_common_item_title_textView_style"
                        android:layout_toRightOf="@+id/me_item_paid_iv_icon"
                        android:text="@string/me_item_paid_order"/>
                    <ImageView
                        android:id="@+id/me_item_paid_iv_arrow_right"
                        style="@style/me_common_item_arrow_right_imageView_style"/>
                    <TextView
                        android:id="@+id/me_item_paid_tv_count"
                        android:layout_toLeftOf="@+id/me_item_paid_iv_arrow_right"
                        style="@style/me_common_item_count_textView_style"
                        tools:text="1"/>
                    <TextView
                        android:id="@+id/me_item_paid_tv_uncomment_count"
                        style="@style/me_common_item_count_textView_style"
                        android:layout_toLeftOf="@+id/me_item_paid_iv_arrow_right"
                        android:background="@drawable/movie_group_good_buy_d"
                        android:paddingLeft="5.0dip"
                        android:paddingRight="5.0dip"
                        android:text="@string/me_item_unpaid_uncomment"
                        android:textColor="@color/white"
                        android:visibility="gone"/>
                </RelativeLayout>
                <View
                    style="@style/me_horizontal_view_style"/>
                <RelativeLayout
                    android:id="@+id/me_item_lottery_layout"
                    style="@style/me_common_item_relativeLayout_style">
                    <ImageView
                        android:id="@+id/me_item_lottery_iv_icon"
                        style="@style/me_common_item_icon_imageView_style"
                        android:src="@mipmap/user_listicon_choujiang"/>
                    <TextView
                        style="@style/me_common_item_title_textView_style"
                        android:layout_toRightOf="@+id/me_item_lottery_iv_icon"
                        android:text="@string/me_item_lottery_order"/>
                    <ImageView
                        android:id="@+id/me_item_lottery_iv_arrow_right"
                        style="@style/me_common_item_arrow_right_imageView_style"/>
                    <TextView
                        android:id="@+id/me_item_lottery_tv_count"
                        android:layout_toLeftOf="@+id/me_item_lottery_iv_arrow_right"
                        style="@style/me_common_item_count_textView_style"
                        tools:text="1"/>
                </RelativeLayout>
                <View
                    style="@style/me_horizontal_view_style"/>
                <RelativeLayout
                    android:id="@+id/me_item_treasure_layout"
                    style="@style/me_common_item_relativeLayout_style">
                    <ImageView
                        android:id="@+id/me_item_treasure_iv_icon"
                        style="@style/me_common_item_icon_imageView_style"
                        android:src="@mipmap/user_generdisplay_img"/>
                    <TextView
                        style="@style/me_common_item_title_textView_style"
                        android:layout_toRightOf="@+id/me_item_treasure_iv_icon"
                        android:text="@string/me_item_treasure_order"/>
                    <ImageView
                        android:id="@+id/me_item_treasure_iv_arrow_right"
                        style="@style/me_common_item_arrow_right_imageView_style"/>
                    <TextView
                        android:id="@+id/me_item_treasure_tv_count"
                        android:layout_toLeftOf="@+id/me_item_treasure_iv_arrow_right"
                        style="@style/me_common_item_count_textView_style"
                        tools:text="1"/>
                </RelativeLayout>
            </LinearLayout>

            <RelativeLayout
                android:id="@+id/me_item_bankcard_layout"
                style="@style/me_common_item_relativeLayout_style"
                android:layout_marginTop="@dimen/me_item_common_layout_marginTop"
                android:visibility="gone">
                <ImageView
                    android:id="@+id/me_item_bankcard_iv_icon"
                    style="@style/me_common_item_icon_imageView_style"
                    android:src="@mipmap/user_icon_yinhangka"/>
                <TextView
                    style="@style/me_common_item_title_textView_style"
                    android:layout_toRightOf="@+id/me_item_bankcard_iv_icon"
                    android:text="@string/me_item_bankcard"/>
                <ImageView
                    android:id="@+id/me_item_bankcard_iv_arrow_right"
                    style="@style/me_common_item_arrow_right_imageView_style"/>
                <TextView
                    android:id="@+id/me_item_bankcard_tv_complete"
                    android:layout_toLeftOf="@+id/me_item_bankcard_iv_arrow_right"
                    style="@style/me_common_item_count_textView_style"
                    android:text="@string/me_item_bankcard_go_complete"/>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/me_item_coupons_layout"
                style="@style/me_common_item_relativeLayout_style"
                android:layout_marginTop="@dimen/me_item_common_layout_marginTop"
                android:visibility="gone">
                <ImageView
                    android:id="@+id/me_item_coupons_iv_icon"
                    style="@style/me_common_item_icon_imageView_style"
                    android:src="@mipmap/user_listicon_diyongquan"/>
                <TextView
                    style="@style/me_common_item_title_textView_style"
                    android:layout_toRightOf="@+id/me_item_coupons_iv_icon"
                    android:text="@string/me_item_coupons"/>
                <ImageView
                    android:id="@+id/me_item_coupons_iv_arrow_right"
                    style="@style/me_common_item_arrow_right_imageView_style"/>
                <TextView
                    android:id="@+id/me_item_coupons_tv_count"
                    android:layout_toLeftOf="@+id/me_item_coupons_iv_arrow_right"
                    style="@style/me_common_item_count_textView_style"
                    tools:text="1"/>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/me_item_recommend_layout"
                style="@style/me_common_item_relativeLayout_style"
                android:layout_marginTop="@dimen/me_item_common_layout_marginTop">
                <ImageView
                    android:id="@+id/me_item_recommend_iv_icon"
                    style="@style/me_common_item_icon_imageView_style"
                    android:src="@mipmap/user_listicon_tuijian"/>
                <TextView
                    style="@style/me_common_item_title_textView_style"
                    android:layout_toRightOf="@+id/me_item_recommend_iv_icon"
                    android:text="@string/me_item_recommend"/>
                <ImageView
                    android:id="@+id/me_item_recommend_iv_arrow_right"
                    style="@style/me_common_item_arrow_right_imageView_style"/>
                <TextView
                    android:id="@+id/me_item_recommend_tv_new"
                    style="@style/me_common_item_count_textView_style"
                    android:layout_toLeftOf="@+id/me_item_recommend_iv_arrow_right"
                    android:background="@drawable/orange_bg"
                    android:text="new"
                    android:textColor="@color/white"
                    android:textSize="@dimen/textSize_12"/>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/me_item_qr_layout"
                style="@style/me_common_item_relativeLayout_style"
                android:layout_marginTop="@dimen/me_item_common_layout_marginTop">
                <ImageView
                    android:id="@+id/me_item_qr_iv_icon"
                    style="@style/me_common_item_icon_imageView_style"
                    android:src="@mipmap/nav_icon_scan_sel"/>
                <TextView
                    style="@style/me_common_item_title_textView_style"
                    android:layout_toRightOf="@+id/me_item_qr_iv_icon"
                    android:text="@string/me_item_qr"/>
                <ImageView
                    android:id="@+id/me_item_qr_iv_arrow_right"
                    style="@style/me_common_item_arrow_right_imageView_style"/>
            </RelativeLayout>
        </LinearLayout>

    </ScrollView>

</LinearLayout>

MeFragment.java

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_me, null);
    initView(view);
    initUserLayout();
    return view;
}

private void initUserLayout() {
    User user = User.getCurrentUser(User.class);
    if (user != null) {
        mLoginLayout.setVisibility(View.VISIBLE);
        mNologinLayout.setVisibility(View.GONE);
        mItemBankcardLayout.setVisibility(View.VISIBLE);
        mItemCouponsLayout.setVisibility(View.VISIBLE);

        mLoginTvUsername.setText(user.getUsername());
        mLoginTvBalance.setText(user.getBalance() + "");
        if (user.getHeadIcon() == null) {
            mLoginIvHead.setImageResource(R.mipmap.user_head);
        } else {
            mLoginIvHead.setImageURI(Uri.parse(user.getHeadIcon().getFileUrl()));
        }
    } else {
        mLoginLayout.setVisibility(View.GONE);
        mNologinLayout.setVisibility(View.VISIBLE);
        mItemBankcardLayout.setVisibility(View.GONE);
        mItemCouponsLayout.setVisibility(View.GONE);
    }
}

  

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.me_login_profile_layout:
            Intent profileIntent = new Intent(getActivity(), UserProfileActivity.class);
            startActivityForResult(profileIntent, PROFILE_REQUEST_CODE);
            break;
        case R.id.me_nologin_btn_login:
            Intent intent = new Intent(getActivity(), LoginActivity.class);
            startActivityForResult(intent, LOGIN_REQUEST_CODE);
            break;
        case R.id.me_item_qr_layout:
            Intent qrIntent = new Intent(getActivity(), CaptureActivity.class);
            getActivity().startActivityForResult(qrIntent,SCAN_QR_REQUEST);
            break;
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == LOGIN_REQUEST_CODE && resultCode == LoginActivity.LOGIN_RESULT_CODE) {
        initUserLayout();
    } else if (requestCode == PROFILE_REQUEST_CODE && resultCode == UserProfileActivity.PROFILE_RESULT_CODE) {
        initUserLayout();
    } else if (requestCode == SCAN_QR_REQUEST) {

    }
    super.onActivityResult(requestCode, resultCode, data);
}

  

  

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...