Skip to content

Commit

Permalink
fix bug nullpointerexception
Browse files Browse the repository at this point in the history
  • Loading branch information
wujingchao committed Apr 18, 2015
1 parent 165e55c commit b9908cf
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MainActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mc = (MultiCardMenu) findViewById(R.id.mc);
mc = (MultiCardMenu) findViewById(R.id.multi_card_menu);
mc.setOnDisplayOrHideListener(new MultiCardMenu.OnDisplayOrHideListener() {
@Override
public void onDisplay(int which) {
Expand All @@ -42,6 +42,7 @@ public void go(View view) {

public void show(View view) {
i ++;
if(mc.getChildCount() <= i) i = 0;
Log.d(TAG,"index:" + i);
mc.show(i);
}
Expand Down
Binary file removed app/src/main/res/drawable-hdpi/card_image.png
Binary file not shown.
Binary file added app/src/main/res/drawable-hdpi/ent.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/title_bar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http:https://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#2B2B2B" />

<corners android:topLeftRadius="8dip"
android:topRightRadius="8dp"/>

<stroke android:color="#3C3F41" android:width="0.5dp"/>

</shape>
166 changes: 94 additions & 72 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,111 @@
android:layout_height="match_parent"
android:orientation="vertical">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="show"
android:onClick="show"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hide"
android:onClick="hide"/>

<net.wujingchao.android.view.MultiCardMenu
xmlns:simple="http:https://schemas.android.com/apk/res-auto"
simple:background_layout="@layout/main2"
simple:margin_top="80dp"
simple:fade="true"
android:id="@+id/mc"
simple:title_bar_height_display="20dp"
simple:title_bar_height_no_display="60dp"
android:id="@+id/multi_card_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dip"
android:layout_marginTop="30dip"
android:background="@color/holo_blue_dark">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GO"
android:onClick="go"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="清理加速"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dip"
android:background="@color/holo_green_dark">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GO"
android:onClick="go"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="防护监控"/>
</LinearLayout>
<LinearLayout
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dip"
android:background="@color/holo_red_dark">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GO"
android:onClick="go"/>
android:layout_height="400dip"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="软件管理"/>
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@drawable/title_bar"
android:textColor="@color/title_bar_text"
android:gravity="center_vertical"
android:text="Destiny"
android:textStyle="bold"
android:textSize="20sp"
android:paddingLeft="10dp"/>

<TableLayout
android:background="#3C3F41"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TableRow
android:layout_weight="1">
<Button
android:textColor="#BABABA"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="Blue"/>
<Button
android:textColor="#BABABA"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Fail"/>
</TableRow>
<TableRow
android:layout_weight="1">
<Button
android:textColor="#BABABA"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Hope"/>
<Button
android:textColor="#BABABA"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Nice"/>
</TableRow>
</TableLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dip"
android:background="@color/ripple_material_light">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GO"
android:onClick="go"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:text=" 通话管理"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dip"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@drawable/title_bar"
android:textColor="@color/title_bar_text"
android:gravity="center_vertical"
android:text="Rainbow"
android:textStyle="bold"
android:textSize="20sp"
android:paddingLeft="10dp"/>

<SeekBar
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dip"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@drawable/title_bar"
android:textColor="@color/title_bar_text"
android:gravity="center_vertical"
android:text="Eternity"
android:textStyle="bold"
android:textSize="20sp"
android:paddingLeft="10dp"/>

<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/ent"/>
</LinearLayout>

</net.wujingchao.android.view.MultiCardMenu>
</net.wujingchao.android.view.MultiCardMenu>


</LinearLayout>
6 changes: 4 additions & 2 deletions app/src/main/res/layout/main2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<LinearLayout xmlns:android="http:https://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:layout_margin="20dp">

<TextView
android:layout_width="wrap_content"
Expand Down Expand Up @@ -81,7 +83,7 @@
android:layout_height="wrap_content"
android:text="New CheckBox"
android:layout_gravity="center_horizontal" />
<RadioButton
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New RadioButton" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<resources>
<color name="holo_green_dark">#ff669900</color>
<color name="holo_red_dark">#ffcc0000</color>
<color name="title_bar_text">#A4A488</color>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

/**
Expand All @@ -19,6 +20,10 @@ class DarkFrameLayout extends FrameLayout {

private int alpha = 0x00;

public boolean isDispatch = false;

private MultiCardMenu multiMenu;

public DarkFrameLayout(Context context) {
this(context, null);
}
Expand All @@ -33,6 +38,11 @@ public DarkFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
mFadePaint = new Paint();
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return multiMenu.isDisplaying();
}

@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
super.dispatchDraw(canvas);
Expand All @@ -54,4 +64,8 @@ public void fade(int alpha) {
invalidate();
}

public void setMultiMenu(MultiCardMenu multiMenu) {
this.multiMenu = multiMenu;
}

}
Loading

0 comments on commit b9908cf

Please sign in to comment.