Initial Project Creation
The goal of this project is to create an intuitive forum browsing application for the Ocean State Jeepsters (http://www.oceanstatejeepsters.com/forum/) Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
BIN
AndroidAutoIncrementVersionCode.exe
Executable file
BIN
AndroidAutoIncrementVersionCode.exe
Executable file
Binary file not shown.
8
OSJ Forum/.classpath
Normal file
8
OSJ Forum/.classpath
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
13
OSJ Forum/.externalToolBuilders/Build Incrementer.launch
Normal file
13
OSJ Forum/.externalToolBuilders/Build Incrementer.launch
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.debug.core.ATTR_REFRESH_RECURSIVE" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/OSJ Forum/AndroidManifest.xml" type="1"/> </resources>}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc}/osj-forum/AndroidAutoIncrementVersionCode.exe"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/OSJ Forum}"/>
|
||||
</launchConfiguration>
|
||||
2
OSJ Forum/.gitignore
vendored
Normal file
2
OSJ Forum/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/bin
|
||||
/gen
|
||||
47
OSJ Forum/.project
Normal file
47
OSJ Forum/.project
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OSJ Forum</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Build Incrementer.launch</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>incclean</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
32
OSJ Forum/AndroidManifest.xml
Normal file
32
OSJ Forum/AndroidManifest.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<manifest package="com.RickBarrette.osj.forum"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:targetSdkVersion="15" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".ItemListActivity"
|
||||
android:label="@string/title_topic_list" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ItemDetailActivity"
|
||||
android:label="@string/title_topic_detail" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ItemListActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
22
OSJ Forum/assets/exceptionhandler.properties
Normal file
22
OSJ Forum/assets/exceptionhandler.properties
Normal file
@@ -0,0 +1,22 @@
|
||||
# exceptionhandler.properties
|
||||
# @author ricky barrette <rickbarrette@gmail.com>
|
||||
# @author twenty codes <twentycodes@gmail.com>
|
||||
|
||||
# This file is used to tell the Exception Handler LIbrary how to file
|
||||
# new exception reports
|
||||
# HTTP ONLY
|
||||
#
|
||||
# Place this file in you project's assets folder and edit as needed
|
||||
#
|
||||
# server is the physical web address for your server
|
||||
# file is the path to your filing script
|
||||
# get is the path to your json retrieval script
|
||||
# app is the redmine project name
|
||||
# tracker is the redmine tracker
|
||||
server = http://rickbarrette.org/redmine/exceptionhandler
|
||||
app = OSJ Forum
|
||||
tracker = Development Bug
|
||||
|
||||
# uncomment the following if you want your application to use email to file reports.
|
||||
# if this is uncommented, email will always be used.
|
||||
#email = twentycodes@gmail.com
|
||||
BIN
OSJ Forum/ic_launcher-web.png
Normal file
BIN
OSJ Forum/ic_launcher-web.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 271 KiB |
BIN
OSJ Forum/libs/android-support-v4.jar
Normal file
BIN
OSJ Forum/libs/android-support-v4.jar
Normal file
Binary file not shown.
3
OSJ Forum/lint.xml
Normal file
3
OSJ Forum/lint.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
</lint>
|
||||
20
OSJ Forum/proguard-project.txt
Normal file
20
OSJ Forum/proguard-project.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
15
OSJ Forum/project.properties
Normal file
15
OSJ Forum/project.properties
Normal file
@@ -0,0 +1,15 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-16
|
||||
android.library.reference.1=../exception_handler_library/ExceptionHandlerLib
|
||||
BIN
OSJ Forum/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
OSJ Forum/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
BIN
OSJ Forum/res/drawable-ldpi/ic_launcher.png
Normal file
BIN
OSJ Forum/res/drawable-ldpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
OSJ Forum/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
OSJ Forum/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
OSJ Forum/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
OSJ Forum/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
6
OSJ Forum/res/layout/activity_topic_detail.xml
Normal file
6
OSJ Forum/res/layout/activity_topic_detail.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/topic_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".TopicDetailActivity" />
|
||||
9
OSJ Forum/res/layout/activity_topic_list.xml
Normal file
9
OSJ Forum/res/layout/activity_topic_list.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:name="com.RickBarrette.osj.forum.TopicListFragment"
|
||||
android:id="@+id/topic_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
tools:context=".TopicListActivity" />
|
||||
23
OSJ Forum/res/layout/activity_topic_twopane.xml
Normal file
23
OSJ Forum/res/layout/activity_topic_twopane.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:divider="?android:attr/dividerHorizontal"
|
||||
android:showDividers="middle"
|
||||
tools:context=".TopicListActivity">
|
||||
|
||||
<fragment android:name="com.RickBarrette.osj.forum.TopicListFragment"
|
||||
android:id="@+id/topic_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<FrameLayout android:id="@+id/topic_detail_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3" />
|
||||
|
||||
</LinearLayout>
|
||||
8
OSJ Forum/res/layout/fragment_topic_detail.xml
Normal file
8
OSJ Forum/res/layout/fragment_topic_detail.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="?android:attr/textAppearanceLarge"
|
||||
android:id="@+id/topic_detail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp"
|
||||
tools:context=".TopicDetailFragment" />
|
||||
3
OSJ Forum/res/values-large/refs.xml
Normal file
3
OSJ Forum/res/values-large/refs.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<item type="layout" name="activity_topic_list">@layout/activity_topic_twopane</item>
|
||||
</resources>
|
||||
3
OSJ Forum/res/values-sw600dp/refs.xml
Normal file
3
OSJ Forum/res/values-sw600dp/refs.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<item type="layout" name="activity_topic_list">@layout/activity_topic_twopane</item>
|
||||
</resources>
|
||||
5
OSJ Forum/res/values-v11/styles.xml
Normal file
5
OSJ Forum/res/values-v11/styles.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light" />
|
||||
|
||||
</resources>
|
||||
5
OSJ Forum/res/values-v14/styles.xml
Normal file
5
OSJ Forum/res/values-v14/styles.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
|
||||
|
||||
</resources>
|
||||
7
OSJ Forum/res/values/strings.xml
Normal file
7
OSJ Forum/res/values/strings.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">OSJ Forum</string>
|
||||
<string name="title_topic_detail">Topic Detail</string>
|
||||
<string name="title_topic_list">Topics</string>
|
||||
|
||||
</resources>
|
||||
5
OSJ Forum/res/values/styles.xml
Normal file
5
OSJ Forum/res/values/styles.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="android:Theme.Light" />
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.MenuItem;
|
||||
|
||||
public class TopicDetailActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_topic_detail);
|
||||
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(TopicDetailFragment.ARG_ITEM_ID,
|
||||
getIntent().getStringExtra(TopicDetailFragment.ARG_ITEM_ID));
|
||||
TopicDetailFragment fragment = new TopicDetailFragment();
|
||||
fragment.setArguments(arguments);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.topic_detail_container, fragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
NavUtils.navigateUpTo(this, new Intent(this, TopicListActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
import com.RickBarrette.osj.forum.dummy.DummyContent;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TopicDetailFragment extends Fragment {
|
||||
|
||||
public static final String ARG_ITEM_ID = "item_id";
|
||||
|
||||
DummyContent.DummyItem mItem;
|
||||
|
||||
public TopicDetailFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments().containsKey(ARG_ITEM_ID)) {
|
||||
mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_topic_detail, container, false);
|
||||
if (mItem != null) {
|
||||
((TextView) rootView.findViewById(R.id.topic_detail)).setText(mItem.content);
|
||||
}
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
|
||||
public class TopicListActivity extends FragmentActivity
|
||||
implements TopicListFragment.Callbacks {
|
||||
|
||||
private boolean mTwoPane;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
||||
|
||||
setContentView(R.layout.activity_topic_list);
|
||||
|
||||
if (findViewById(R.id.topic_detail_container) != null) {
|
||||
mTwoPane = true;
|
||||
((TopicListFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.topic_list))
|
||||
.setActivateOnItemClick(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(String id) {
|
||||
if (mTwoPane) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(TopicDetailFragment.ARG_ITEM_ID, id);
|
||||
TopicDetailFragment fragment = new TopicDetailFragment();
|
||||
fragment.setArguments(arguments);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.topic_detail_container, fragment)
|
||||
.commit();
|
||||
|
||||
} else {
|
||||
Intent detailIntent = new Intent(this, TopicDetailActivity.class);
|
||||
detailIntent.putExtra(TopicDetailFragment.ARG_ITEM_ID, id);
|
||||
startActivity(detailIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
import com.RickBarrette.osj.forum.dummy.DummyContent;
|
||||
|
||||
import android.R;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class TopicListFragment extends ListFragment {
|
||||
|
||||
private static final String STATE_ACTIVATED_POSITION = "activated_position";
|
||||
|
||||
private Callbacks mCallbacks = sDummyCallbacks;
|
||||
private int mActivatedPosition = ListView.INVALID_POSITION;
|
||||
|
||||
public interface Callbacks {
|
||||
|
||||
public void onItemSelected(String id);
|
||||
}
|
||||
|
||||
private static Callbacks sDummyCallbacks = new Callbacks() {
|
||||
@Override
|
||||
public void onItemSelected(String id) {
|
||||
}
|
||||
};
|
||||
|
||||
public TopicListFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(),
|
||||
R.layout.simple_list_item_activated_1,
|
||||
R.id.text1,
|
||||
DummyContent.ITEMS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (savedInstanceState != null && savedInstanceState
|
||||
.containsKey(STATE_ACTIVATED_POSITION)) {
|
||||
setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
if (!(activity instanceof Callbacks)) {
|
||||
throw new IllegalStateException("Activity must implement fragment's callbacks.");
|
||||
}
|
||||
|
||||
mCallbacks = (Callbacks) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mCallbacks = sDummyCallbacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView listView, View view, int position, long id) {
|
||||
super.onListItemClick(listView, view, position, id);
|
||||
mCallbacks.onItemSelected(DummyContent.ITEMS.get(position).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (mActivatedPosition != ListView.INVALID_POSITION) {
|
||||
outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
|
||||
}
|
||||
}
|
||||
|
||||
public void setActivateOnItemClick(boolean activateOnItemClick) {
|
||||
getListView().setChoiceMode(activateOnItemClick
|
||||
? ListView.CHOICE_MODE_SINGLE
|
||||
: ListView.CHOICE_MODE_NONE);
|
||||
}
|
||||
|
||||
public void setActivatedPosition(int position) {
|
||||
if (position == ListView.INVALID_POSITION) {
|
||||
getListView().setItemChecked(mActivatedPosition, false);
|
||||
} else {
|
||||
getListView().setItemChecked(position, true);
|
||||
}
|
||||
|
||||
mActivatedPosition = position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.RickBarrette.osj.forum.dummy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DummyContent {
|
||||
|
||||
public static class DummyItem {
|
||||
|
||||
public String id;
|
||||
public String content;
|
||||
|
||||
public DummyItem(String id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
|
||||
public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
|
||||
|
||||
static {
|
||||
addItem(new DummyItem("1", "Item 1"));
|
||||
addItem(new DummyItem("2", "Item 2"));
|
||||
addItem(new DummyItem("3", "Item 3"));
|
||||
}
|
||||
|
||||
private static void addItem(DummyItem item) {
|
||||
ITEMS.add(item);
|
||||
ITEM_MAP.put(item.id, item);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user