Skip to content

Commit a12fddb

Browse files
committed
Check in start of new techstacks Android App
1 parent 76b2409 commit a12fddb

File tree

42 files changed

+2468
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2468
-86
lines changed

src/AndroidClient/.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AndroidClient/.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AndroidClient/android/android.iml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
6363
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
6464
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
65-
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
6665
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
6766
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
6867
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
@@ -82,11 +81,7 @@
8281
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
8382
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
8483
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
85-
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
8684
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
87-
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
88-
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
89-
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
9085
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
9186
</content>
9287
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />

src/AndroidClient/app/app.iml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@
8181
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
8282
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
8383
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
84-
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
85-
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
8684
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8785
</content>
8886
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />

src/AndroidClient/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
<application
66
android:allowBackup="true"
7-
android:icon="@mipmap/ic_launcher"
8-
android:label="@string/app_name"
9-
android:theme="@style/AppTheme">
7+
android:icon="@drawable/ic_launcher"
8+
android:label="@string/app_name">
109
<activity
1110
android:name=".MainActivity"
1211
android:label="@string/app_name">
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
* Copyright 2012 The Android Open Source Project
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 servicestack.net.androidclient;
18+
19+
import android.app.ActionBar;
20+
import android.content.Intent;
21+
import android.os.Bundle;
22+
import android.support.v4.app.Fragment;
23+
import android.support.v4.app.FragmentActivity;
24+
import android.support.v4.app.FragmentManager;
25+
import android.support.v4.app.FragmentStatePagerAdapter;
26+
import android.support.v4.app.NavUtils;
27+
import android.support.v4.app.TaskStackBuilder;
28+
import android.support.v4.view.ViewPager;
29+
import android.view.LayoutInflater;
30+
import android.view.MenuItem;
31+
import android.view.View;
32+
import android.view.ViewGroup;
33+
import android.widget.TextView;
34+
35+
public class CollectionDemoActivity extends FragmentActivity {
36+
37+
/**
38+
* The {@link android.support.v4.view.PagerAdapter} that will provide fragments representing
39+
* each object in a collection. We use a {@link android.support.v4.app.FragmentStatePagerAdapter}
40+
* derivative, which will destroy and re-create fragments as needed, saving and restoring their
41+
* state in the process. This is important to conserve memory and is a best practice when
42+
* allowing navigation between objects in a potentially large collection.
43+
*/
44+
DemoCollectionPagerAdapter mDemoCollectionPagerAdapter;
45+
46+
/**
47+
* The {@link android.support.v4.view.ViewPager} that will display the object collection.
48+
*/
49+
ViewPager mViewPager;
50+
51+
public void onCreate(Bundle savedInstanceState) {
52+
super.onCreate(savedInstanceState);
53+
setContentView(R.layout.activity_collection_demo);
54+
55+
// Create an adapter that when requested, will return a fragment representing an object in
56+
// the collection.
57+
//
58+
// ViewPager and its adapters use support library fragments, so we must use
59+
// getSupportFragmentManager.
60+
mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());
61+
62+
// Set up action bar.
63+
final ActionBar actionBar = getActionBar();
64+
65+
// Specify that the Home button should show an "Up" caret, indicating that touching the
66+
// button will take the user one step up in the application's hierarchy.
67+
actionBar.setDisplayHomeAsUpEnabled(true);
68+
69+
// Set up the ViewPager, attaching the adapter.
70+
mViewPager = (ViewPager) findViewById(R.id.pager);
71+
mViewPager.setAdapter(mDemoCollectionPagerAdapter);
72+
}
73+
74+
@Override
75+
public boolean onOptionsItemSelected(MenuItem item) {
76+
switch (item.getItemId()) {
77+
case android.R.id.home:
78+
// This is called when the Home (Up) button is pressed in the action bar.
79+
// Create a simple intent that starts the hierarchical parent activity and
80+
// use NavUtils in the Support Package to ensure proper handling of Up.
81+
Intent upIntent = new Intent(this, MainActivity.class);
82+
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
83+
// This activity is not part of the application's task, so create a new task
84+
// with a synthesized back stack.
85+
TaskStackBuilder.from(this)
86+
// If there are ancestor activities, they should be added here.
87+
.addNextIntent(upIntent)
88+
.startActivities();
89+
finish();
90+
} else {
91+
// This activity is part of the application's task, so simply
92+
// navigate up to the hierarchical parent activity.
93+
NavUtils.navigateUpTo(this, upIntent);
94+
}
95+
return true;
96+
}
97+
return super.onOptionsItemSelected(item);
98+
}
99+
100+
/**
101+
* A {@link android.support.v4.app.FragmentStatePagerAdapter} that returns a fragment
102+
* representing an object in the collection.
103+
*/
104+
public static class DemoCollectionPagerAdapter extends FragmentStatePagerAdapter {
105+
106+
public DemoCollectionPagerAdapter(FragmentManager fm) {
107+
super(fm);
108+
}
109+
110+
@Override
111+
public Fragment getItem(int i) {
112+
Fragment fragment = new DemoObjectFragment();
113+
Bundle args = new Bundle();
114+
args.putInt(DemoObjectFragment.ARG_OBJECT, i + 1); // Our object is just an integer :-P
115+
fragment.setArguments(args);
116+
return fragment;
117+
}
118+
119+
@Override
120+
public int getCount() {
121+
// For this contrived example, we have a 100-object collection.
122+
return 100;
123+
}
124+
125+
@Override
126+
public CharSequence getPageTitle(int position) {
127+
return "OBJECT " + (position + 1);
128+
}
129+
}
130+
131+
/**
132+
* A dummy fragment representing a section of the app, but that simply displays dummy text.
133+
*/
134+
public static class DemoObjectFragment extends Fragment {
135+
136+
public static final String ARG_OBJECT = "object";
137+
138+
@Override
139+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
140+
Bundle savedInstanceState) {
141+
View rootView = inflater.inflate(R.layout.fragment_collection_object, container, false);
142+
Bundle args = getArguments();
143+
((TextView) rootView.findViewById(android.R.id.text1)).setText(
144+
Integer.toString(args.getInt(ARG_OBJECT)));
145+
return rootView;
146+
}
147+
}
148+
}

0 commit comments

Comments
 (0)