Skip to content

Commit 43b31dc

Browse files
committed
Dynamic RSSfeed reader
1 parent 9a61a58 commit 43b31dc

File tree

20 files changed

+159
-36
lines changed

20 files changed

+159
-36
lines changed

com.vogella.android.fragment.dialog/res/layout/activity_main.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,4 @@
44
android:layout_height="match_parent"
55
tools:context=".MainActivity" >
66

7-
<TextView
8-
android:layout_width="wrap_content"
9-
android:layout_height="wrap_content"
10-
android:layout_centerHorizontal="true"
11-
android:layout_centerVertical="true"
12-
android:text="@string/hello_world" />
13-
147
</RelativeLayout>
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
22

33
<item
4-
android:id="@+id/menu_settings"
4+
android:id="@+id/actionitem_userdialog"
55
android:orderInCategory="100"
6-
android:showAsAction="never"
7-
android:title="@string/menu_settings"/>
6+
android:showAsAction="ifRoom"
7+
android:title="Enter user"/>
8+
<item
9+
android:id="@+id/actionitem_alertdialog"
10+
android:orderInCategory="80"
11+
android:showAsAction="ifRoom"
12+
android:title="Alert">
13+
</item>
814

915
</menu>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.example.com.vogella.android.fragment.dialog;
2+
3+
import android.app.AlertDialog;
4+
import android.app.AlertDialog.Builder;
5+
import android.app.Dialog;
6+
import android.app.DialogFragment;
7+
import android.os.Bundle;
8+
import android.view.LayoutInflater;
9+
import android.view.View;
10+
import android.view.ViewGroup;
11+
import android.widget.EditText;
12+
13+
public class AlertDialogFragment extends DialogFragment {
14+
15+
16+
public AlertDialogFragment() {
17+
// Empty constructor required for DialogFragment
18+
}
19+
20+
@Override
21+
public Dialog onCreateDialog(Bundle savedInstanceState) {
22+
Builder alertDialog = new AlertDialog.Builder(getActivity());
23+
alertDialog.setTitle("Alert!");
24+
alertDialog.setMessage("This is a notication dialog");
25+
return alertDialog.create();
26+
}
27+
}

com.vogella.android.fragment.dialog/src/com/example/com/vogella/android/fragment/dialog/EditNameDialog.java renamed to com.vogella.android.fragment.dialog/src/com/example/com/vogella/android/fragment/dialog/EditNameDialogFragment.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import android.view.ViewGroup;
88
import android.widget.EditText;
99

10-
public class EditNameDialog extends DialogFragment {
10+
public class EditNameDialogFragment extends DialogFragment {
1111

1212
private EditText mEditText;
1313

14-
public EditNameDialog() {
14+
public EditNameDialogFragment() {
1515
// Empty constructor required for DialogFragment
1616
}
1717

@@ -21,7 +21,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
2121
View view = inflater.inflate(R.layout.fragment_editnamedialog,
2222
container);
2323
mEditText = (EditText) view.findViewById(R.id.txt_your_name);
24-
getDialog().setTitle("Hello");
24+
getDialog().setTitle("Please enter your name");
2525

2626
return view;
2727
}

com.vogella.android.fragment.dialog/src/com/example/com/vogella/android/fragment/dialog/MainActivity.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,30 @@ protected void onCreate(Bundle savedInstanceState) {
1717

1818
@Override
1919
public boolean onCreateOptionsMenu(Menu menu) {
20-
// Inflate the menu; this adds items to the action bar if it is present.
2120
getMenuInflater().inflate(R.menu.activity_main, menu);
2221
return true;
2322
}
2423

2524
@Override
2625
public boolean onOptionsItemSelected(MenuItem item) {
2726
FragmentManager fm = getFragmentManager();
28-
EditNameDialog editNameDialog = new EditNameDialog();
29-
editNameDialog.setRetainInstance(true);
30-
editNameDialog.show(fm, "fragment_edit_name");
27+
switch (item.getItemId()) {
28+
29+
case R.id.actionitem_alertdialog:
30+
AlertDialogFragment alertDialog = new AlertDialogFragment();
31+
alertDialog.setRetainInstance(true);
32+
alertDialog.show(fm, "alertfragment");
33+
break;
34+
case R.id.actionitem_userdialog:
35+
EditNameDialogFragment editNameDialog = new EditNameDialogFragment();
36+
editNameDialog.setRetainInstance(true);
37+
editNameDialog.show(fm, "userfragemnt");
38+
break;
39+
40+
default:
41+
break;
42+
}
43+
3144
return true;
3245
}
3346
}

com.vogella.android.lifecycle.activity/src/com/vogella/android/lifecycle/activity/TracerActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ private void notify(String methodName) {
5353
String name = this.getClass().getName();
5454
String[] strings = name.split("\\.");
5555
Notification noti = new Notification.Builder(this)
56-
.setContentTitle(methodName + " " + strings[strings.length - 1]).setAutoCancel(true)
57-
.setSmallIcon(R.drawable.ic_launcher)
56+
.setContentTitle(methodName + " " + strings[strings.length - 1])
57+
.setAutoCancel(true).setSmallIcon(R.drawable.ic_launcher)
5858
.setContentText(name).build();
5959
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
6060
notificationManager.notify((int) System.currentTimeMillis(), noti);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.vogella.android.listview.animations</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>

com.vogella.android.multitouch/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
android:allowBackup="true"
1313
android:icon="@drawable/ic_launcher"
1414
android:label="@string/app_name"
15+
1516
android:theme="@style/AppTheme" >
1617
<activity
1718
android:name="com.vogella.android.multitouch.MainActivity"
18-
android:label="@string/app_name" >
19+
android:label="@string/app_name"
20+
android:screenOrientation="landscape" >
1921
<intent-filter>
2022
<action android:name="android.intent.action.MAIN" />
2123

com.vogella.android.multitouch/src/com/vogella/android/multitouch/MultitouchView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class MultitouchView extends View {
2020
Color.BLACK, Color.CYAN, Color.GRAY, Color.RED, Color.DKGRAY,
2121
Color.LTGRAY, Color.YELLOW };
2222

23+
private Paint textPaint;
24+
25+
2326
public MultitouchView(Context context, AttributeSet attrs) {
2427
super(context, attrs);
2528
initView();
@@ -31,19 +34,21 @@ private void initView() {
3134
// set painter color to a color you like
3235
mPaint.setColor(Color.BLUE);
3336
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
37+
textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
38+
textPaint.setTextSize(20);
3439
}
3540

3641
@Override
3742
public boolean onTouchEvent(MotionEvent event) {
3843

3944
// get pointer index from the event object
40-
int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
45+
int pointerIndex = event.getActionIndex();
4146

4247
// get pointer ID
4348
int pointerId = event.getPointerId(pointerIndex);
4449

4550
// get masked (not specific to a pointer) action
46-
int maskedAction = event.getAction() & MotionEvent.ACTION_MASK;
51+
int maskedAction = event.getActionMasked();
4752

4853
switch (maskedAction) {
4954

@@ -90,6 +95,7 @@ protected void onDraw(Canvas canvas) {
9095
mPaint.setColor(colors[i % 9]);
9196
canvas.drawCircle(point.x, point.y, SIZE, mPaint);
9297
}
98+
canvas.drawText("Total pointers: " + mActivePointers.size(), 10, 40 , textPaint);
9399
}
94100

95101
}

de.vogella.android.activitiystack/.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>de.vogella.android.activitiystack</name>
3+
<name>de.vogella.android.activitystack</name>
44
<comment></comment>
55
<projects>
66
</projects>

0 commit comments

Comments
 (0)