detail posts activitydetail什么意思思

使用activity启动器的官方说明_白眼圈猫熊_新浪博客
使用activity启动器的官方说明
翻q去看了activity启动器的官方说明,放这儿以后慢慢看,也方便其他ai爱好者参考,省的翻q了。(ps:大致能看懂,但是看着费劲,英文不行头疼啊)
Using the Activity Starter Component
The activity starter component lets you combine applications by
having one application start up other applications. Activity
Starter is mostly for advanced developers, but it's a key way to
extend the App Inventor, because it means lets you take advantage
of applications written by others, and created with other
development frameworks.
The apps you start can be App Inventor apps created by you or
apps like Camera and Maps that are pre-installed on the
or any app at all, created using App Inventor or not, as
long as you have the necessary information to supply to the
activity starter.
For applications that are appropriately designed, you can pass
values to the applications when starting it. You can also start an
application and get back a result from it to use in further
processing, provided that the application is designed to return a
result. Presently, you can pass and receive text values only.
To start another application, you must supply certain control
information to the Android operating system. You do this by setting
various properties of Activity Starter before calling
the&StartActivity&method.
This section gives some examples.
Starting Another App Inventor Application from your App
Inventor App
You can start another app that was created with App Inventor if
you know its package name and class name. If you have the source
code of the app, you can find these names as follows:
Download the source code to your computer.
Using a file explorer or unzip utility, find the
youngandroidproject/project.properties&
The first line will start with
". Everything after that is the package and class name.
For example, here is a first line you might see for an App named
HelloPurr.:
main=appinventor.ai_HomerSimpson.HelloPurr
HomerSimpson&
part of the name comes from the App Inventor user account.
To start this app, you would use an activity starter component
with these properties:
ActivityPackage:
appinventor.ai_HomerSimpson.HelloPurr&
ActivityClass:
appinventor.ai_HomerSimpson.HelloPurr.Screen1
Invoking the activity
starter's&
StartActivity&
method will start HelloPurr. When HelloPurr finishes (if it
does), the original
app's&ActivityStarter.AfterActivity&method
will be invoked.
If you are going to start another App Inventor app, make sure
you use the correct package name. For example, if someone posts the
source code (zip file) for an app, and you repackage that app,
you'll end up with a different package name than he had. In cases
of doubt, or if you don't have the source code, start the activity
by hand on the phone and run "adb logcat" to view the Android
system log and see what was actually started, as explained below in
"Figuring out how to set the
properties".Note:&If you
will be starting a second App Inventor app that you yourself are
writing, it's generally easier and more convenient to design the
whole thing as a single multiple screen app, rather than creating
two separate apps. See the section below on "Activity Starter
versus Multiple Screen Apps".
Starting a Builtin Phone Application from your App Inventor
Apps that come with the phone can be invoked using package names
and class names, as above. Android apps can also launch responses
, which is the Android operating system's way of specifying
something to do without necessarily designating a particular app.
You can find information about intents (written for advanced
developers) in the&Android
system documentation&.
Some apps are designed to take extra information when they are
launched. For example, maps can take geographic information that
specifies which map to display. Another example is launching a Web
search with extra information that specifies the text to search
for. You must consult the documentation for the particular app to
learn what this extra information is and how to specify it.
Generally, you specify the information by setting the activity
starter's properties just before the other app is launched.
Here are some examples:
Start the Camera
To launch the Android Camera app, use an activity starter with
these properties:
android.intent.action.MAIN&
ActivityPackage:
com.google.android.camera&
ActivityClass: com.android.camera.Camera
This is pretty much what the App Inventor Camera component does,
although it is much more convenient to use the Camera
component.
Launch a Web search
To launch a Web search for a particular query, such as "Homer
Simpson", use an activity starter with these properties:
android.intent.action.WEB_SEARCH&
ExtraKey: query&
ExtraValue: Homer
ActivityPackage:
com.google.android.providers.enhancedgooglesearch&
ActivityClass:
com.google.android.providers.enhancedgooglesearch.Launcher
Open the browser to a Web page
Use these activity starter properties to open a specific web
android.intent.action.VIEW&
Start the mailer with pre-addressed message
To start the Android mailer application, use the
android.intent.action.VIEW&
. You can use Activity
starter's&DataUri&property
to specify the recipient, the subject, and the body of the message.
In each case, starting the activity will bring up the Android
mailer, and you can complete the message and then press "Send".
For example, if you specify:
android.intent.action.VIEW&
DataUri: mailto:
then starting the activity will bring up the mailer, with the
addressee filed in.
If you specify:
android.intent.action.VIEW&
DataUri: mailto:?subject=Please
Santa&=Bring me a pony
then starting the activity will bring up the mailer, with the
addressee, the subject, and the body filled in. You can use the
mailer to edit these before sending the message, if you prefer.
The DataURI here must be a URL encoded message designed to work
with the internet mailto service. Search the Web to find
appropriate documentation and tools for creating these, for
Elements of a Mailto: URL
Show a map for a location
If you know the latitude and a longitude of a location, you can
show a map using an activity starter with these properties to show
a map of the area:
android.intent.action.VIEW&
DataUri: geo:37.8,-122.23?z=23
The format of the DataURI is specific to the app. In this
example, the URI specifies a z (zoom) of 23, which is the largest
zoom value. Zoom value is optional and ranges from 1 (the entire
Earth) to 23.
If you know the zip code, you can set the activity starter
properties as follows:
android.intent.action.VIEW&
DataUri: geo:0,0&q=94043
If you have a street address, you can use a DataUri that encodes
the address with a scheme called&
URL encoding&
android.intent.action.VIEW&
DataUri: geo:0,0&q=5000% 20MacArthurBlvd
Oakland,CA
Generally in URI encoding the only characters you have to
replace are spaces (&
) and punctuation marks, such as comma
and period
Play a YouTube video
You'll need to know the URI of the YouTube video. Then set the
Activity Starter properties as
android.intent.action.VIEW&
ActivityPackage:
com.google.android.youtube&
ActivityClass:
com.google.android.youtube.PlayerActivity
and set the Data URI to the URI of the video to be played, for
DataUri: http:///watch?v=8ADwPLSFeY8
Figuring out how to set the properties
If you can't find documentation for the activities you want to
start, one way to figure out how to set the properties is to start
up the activity manually and look at what appears in the Android
System Log. For example, if you use YouTube to play a video, you'll
see in the log:
I/ActivityManager( 86): Starting activity: Intent {
act=android.intent.action.VIEW
cat=[android.intent.category.BROWSABLE]
dat=http:///watch?v=8ADwPLSFeY8 flg=0x3800000
cmp=com.google.android.youtube/.PlayerActivity }
If you can find the "cmp=" string, then the ActivityPackage is
the part before the slash, and the ActivityClass is is the entire
"cmp=" part, without the slash character. As in the YouTube
example, there may also be "dat=" information that can specify with
the DataUri property.
Starting arbitrary apps
You can use the Activity Starter to start any activity at all if
you know the package name and class name, or the appropriate
intent. Some developers document these intents for the benefit of
other Android developers. For hints on starting other apps using
intents, see the&
Android API
documentation&
or search the Android developer forums.
If you have an app on your phone and you don't have the source
code, you might still be able figure out the package name and class
name (and sometimes the intent) by launching the app and inspecting
the Android system log, as indicated above.
Receiving results from apps that you start
Some apps are constructed to return a result. You can see that
result as the&
argument of the activity
starter's&AfterActivity&event.
Currently, App Inventor can receive text results only.
Returning results from App Inventor apps, and getting the
You can create App Inventor apps that return a (text) result to
their callers, so they can be used as subroutines. To return a
result, invoke the command&
close screen with plain
(located in the Control drawer). Your subroutine app will
terminate, and the argument
of&close screen with plain
text&will become available to
the app that called it. If the calling app was itself an App
Inventor app that used an activity starter, it will see that text
as the argument to the activity
starter's&AfterActivity&event.
In more detail, suppose there are two App Inventor apps:
SubroutineApp&
designed to be started with an activity starter and return a
value, and
a&CallerApp&that
uses an ActivityStarter to
call&SubroutineApp&.
To return the
result,SubroutineApp&executes&close
screen with plain text&,
giving it as argument the result (text only) that should be
returned to the caller.
On the caller side,&
CallerApp&
sets up its Activity Starter with the correct package name and
class name for
starting&SubroutineApp&.
It must also set
the&ActivityStarter.ResultName&property
to the special text
string&APP_INVENTOR_RESULT&.
ThenCallerApp&starts
the&SubroutineApp&activity.
When the subroutine finishes, the Activity
Starter's&AfterActivity&event
triggers, and the result that was passed back
from&SubroutineApp&will
be available as
the&result&argument
to&AfterActivity&.
That same information is available as the
ActivityStarter's&Result&property.
Calling App Inventor Apps and passing values to them
If you are writing an App
CallerApp&
to call an App
Inventor&SubroutineApp&,
you can pass a text value
to&SubroutineApp&.
To do this, use an Activity Starter
in&CallerApp&with
the ExtraKey property to set to the special
tagAPP_INVENTOR_START&and
the ExtraValue property set to the text you want to pass.
The&SubroutineApp&can
retrieve that value by using
the&get start plain
text&block from the Control
By passing and returning results, you can combine several App
Inventor apps, both apps you write, as well as apps you share with
Returning results from arbitrary applications
Getting values back from other applications is like getting
values back from App Inventor apps. In general in Android, an
activity will return a result that is designated by a name, where
the result is designated by a name, where the name is specified
with the Activity Starter's&
ResultName&
property. The name to use for App Inventor apps
is&APP_INVENTOR_RESULT&,
as described above. Other applications, not created with App
Inventor, will use other names, and you'll need to know those names
in order get values back from those applications. In general,
you'll need to consult documentation about the app you want to use
as a subroutine. Some developers provide this information, or
sometimes you'll have access to the source code.
Not all Android apps use the&
and&ResultName&mechanism.
For example, some apps return information via the
properties&ResultType&and&ResultUri&.
Again, you'll need to have information from the app developer to
know which of these to use.
For advanced
developers:&
More specifically (with reference to the Android developer
documentation) an app can be designed to return
an&intent&.
The Activity starter uses the
specified&ResultName&to
access&intent.getStringExtra(resultName)&to
produce the result. The values
for&ResultType&and&ResultUri&come
from&intent.getType()&and&intent.getType()&.
Example: Picking files from the SD Card
Here's an example that illustrates using a third-party
application:
AndExplorer from
is an application that lets you pick files for your SD card. You
can call AndExplorer with an activity starter to add a file picking
capability to your application. You'll need to have AndExplorer
installed on your phone. You can get it from the Android
To start AndExplorer to pick a file, use an ActivityStarter
android.intent.action.PICK&
vnd.android.cursor.dir/lysesoft.andexplorer.file&
dataURI: file:///sdcard
When you start the activity and pick a file, the resulting file
name will be available as&
ResultUri&
Also,&ResultType&will
give the type of the file, for example, image/jpeg or . Using this,
you can write an app that lets you pick a file from the SD card and
either displays the image or plays the music track as
appropriate.
Is the application available?
If your app calls other apps as activities, you'll want to check
that those other apps are available on your user's phone before
trying to start them. You can check this using the Activity Starter
ResolveActivity&
, which returns the name of the Activity that would be started,
given the package or intent information you've provided. If this
name is blank, then the required application is not present, and
you can warn your user.
Using the Activity Starter versus using multiple screens
The sections above explain how you can create an App Inventor
app that calls another App Inventor app, perhaps with passing and
returning text values. If you will be writing both apps, it's
probably better to make a single multiscreen app rather than create
two apps and use the Activity Starter. This will simplify things
for your users, because they will need install only one app on
their device. Also, with multiple screen apps, you can pass and
return lists as values rather than just text, and you can share
values between the screens with TinyDB. See the documentation on
multiple screen apps for details.
Note on upgrading old apps
The activity starter commands described here have changed from
earlier releases, which used&
close screen with
and&get start
text&, rather than the
newer&close screen with plain
text&and&get
start plain text&. If you load
the source for an app from before 2012 and release 66, App Inventor
will flag the old blocks and require you to replace them with the
new versions.
Page last updated: 11/09/2015
白眼圈猫熊
博客等级:
博客积分:0
博客访问:46,676
关注人气:0
荣誉徽章:/ yueyanghudongcode
项目语言:None
权限:read-only(如需更高权限请先加入项目)
yueyanghudongcode/
Index: PostsDetailActivity.java
===================================================================
--- PostsDetailActivity.java (revision 1011)
+++ PostsDetailActivity.java (revision 1012)
@@ -85,7 +85,19 @@
* Created by qiqingbin on 16/4/28.
* 帖子详情
-public class PostsDetailActivity extends MyAutoLayoutActivity implements View.OnClickListener, View.OnTouchListener {
+public class PostsDetailActivity extends MyAutoLayoutActivity implements View.OnLayoutChangeListener, View.OnClickListener, View.OnTouchListener {
RelativeLayout rl_
//Activity最外层的Layout视图
private View activityRootV
//屏幕高度
private int screenHeight = 0;
//软件盘弹起后所占高度阀值
private int keyHeight = 0;
private int isThumbsup = 0;
private int isFirst = 0;
//用来标识是scenfragment进入的详情,还是抓你进去的详情(1是scenefragment,2是专题)
private String goS
//用来判断当前这次进来是否点赞
@@ -164,7 +176,7 @@
//帖子详情是否收藏checkbox
private CheckBox ck_posts_
//帖子详情是否点赞
private CheckBox ck_posts_
private ImageView ck_posts_
//帖子详情的是否收藏linearlayout
private LinearLayout ll_posts_detail_
//帖子详情的评论列表
@@ -258,7 +270,7 @@
if (msg.what == 3) {
getPostsDetailData(id);
if (msg.what ==401) {
if (msg.what == 401) {
getPostsDetailData(id);
String result = (String) msg.
@@ -378,7 +390,7 @@
JSONObject jsonObject1 = (JSONObject) jsonArray.get(i);
String replyCommentId = jsonObject1.getString(&replycommentid&);
String replyUserName =
String replyUserId=
String replyUserId =
JSONObject jsonObject3 = jsonObject1.getJSONObject(&replyUser&);
replyUserName = jsonObject3.getString(&nickname&);
@@ -388,7 +400,7 @@
String content = jsonObject1.getString(&content&);
String commentId = jsonObject1.getString(&id&);
String createtime = jsonObject1.getString(&createtime&);
String firstUserId=jsonObject1.getString(&userid&);
String firstUserId = jsonObject1.getString(&userid&);
JSONObject jsonObject2 = jsonObject1.getJSONObject(&user&);
String id = jsonObject2.getString(&id&);
String nickname = jsonObject2.getString(&nickname&);
@@ -437,7 +449,7 @@
if (list != null) {
fragment_scene_detail_dian.removeAllViews();
if(list.size()&=1){
if (list.size() &= 1) {
fragment_scene_detail_dian.setVisibility(View.GONE);
fragment_scene_detail_dian_gone.setVisibility(View.VISIBLE);
@@ -456,7 +468,7 @@
viewPoint.setImageResource(R.drawable.point_seletor_posts_detail);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DensityUtils.dp2px(PostsDetailActivity.this, 9), DensityUtils.dp2px(PostsDetailActivity.this, 9));
int size = DensityUtils.dp2px(PostsDetailActivity.this, 10);
params.setMargins(size / 8, size/2, size - 20, 0);
params.setMargins(size / 8, size / 2, size - 20, 0);
viewPoint.setLayoutParams(params);
// 将指示点添加到线性布局里
fragment_scene_detail_dian.addView(viewPoint);
@@ -632,66 +644,55 @@
ck_posts_isthumbsup.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
ck_posts_isthumbsup.setOnClickListener(new View.OnClickListener() {
public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
if (isChecked) {
if (islike != 1) {
if (!&1&.equals((String) SharePreferenceUtils.get(PostsDetailActivity.this, &logintype&, &-1&))) {
ck_posts_isthumbsup.setChecked(false);
showLoginDialog();
public void onClick(View v) {
if (islike != 1) {
if (!&1&.equals((String) SharePreferenceUtils.get(PostsDetailActivity.this, &logintype&, &-1&))) {
ck_posts_isthumbsup.setChecked(false);
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsup);
showLoginDialog();
((MainActivity)activity).jumpToLogin();
final RequestParams params = NetUtils.getRequestParams(PostsDetailActivity.this);
params.addBodyParameter(&id&, id);
String cancelThumbsupUrl = AppConfigureUtils.urlHead + &posts/& + id + &/like&;
LogUtils.d(&qqb&, &打印一个帖子id用& + id);
httpUtils.send(HttpRequest.HttpMethod.POST, cancelThumbsupUrl, params, new RequestCallBack&String&() {
public void onSuccess(ResponseInfo&String& responseInfo) {
singleOrDouble = singleOrDouble + 1;
isCurrentThumbsup = 1;
getThumbsUpUser(id);
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsuped);
ToastUtils.showShort(PostsDetailActivity.this, &点赞成功&);
islike = 1;
thumbsupNum = new Integer(thumbsupNum) + 1 + &&;
tv_posts_thumbsupnunm.setText(thumbsupNum);
currenthumbs = 1;
final RequestParams params = NetUtils.getRequestParams(PostsDetailActivity.this);
params.addBodyParameter(&id&, id);
String cancelThumbsupUrl = AppConfigureUtils.urlHead + &posts/& + id + &/like&;
LogUtils.d(&qqb&, &打印一个帖子id用& + id);
httpUtils.send(HttpRequest.HttpMethod.POST, cancelThumbsupUrl, params, new RequestCallBack&String&() {
public void onSuccess(ResponseInfo&String& responseInfo) {
listThumbsUpPersonAgain = listThumbsUpP
singleOrDouble = singleOrDouble + 1;
isCurrentThumbsup = 1;
LogUtils.d(&qqb&, &是否点赞islike& + &----
aaaaaaaaaaaaaaaaaa& + isCurrentThumbsup + &================& + islike);
getThumbsUpUser(id);
ll_thumbsup.setVisibility(View.VISIBLE);
LogUtils.d(&qqb&, &uuuuuuuuuuuuu uuuuuuu & + islike);
LogUtils.d(&qqb&, &帖子点赞成功& + responseInfo.statusCode + &
public void onFailure(HttpException e, String s) {
LogUtils.d(&qqb&, &帖子点赞失败& + e.getExceptionCode());
if (currenthumbs == -1) {
tv_posts_thumbsupnunm.setText(thumbsupNum);
tv_posts_thumbsupnunm.setText((new Integer(thumbsupNum) - 1) + &&);
if (islike == 0) {
ToastUtils.showShort(PostsDetailActivity.this, &点赞成功&);
tv_posts_thumbsupnunm.setText((new Integer(thumbsupNum) + 1) + &&);
currenthumbs = 1;
ToastUtils.showShort(PostsDetailActivity.this, &点赞失败&);
if (!NetUtils.isConnected(PostsDetailActivity.this)) {
ToastUtils.showShort(PostsDetailActivity.this, &当前网络不好&);
} else if (401 == e.getExceptionCode()) {
MainActivity.requestLogin(PostsDetailActivity.this, handler, 401);
public void onFailure(HttpException e, String s) {
LogUtils.d(&qqb&, &帖子点赞失败& + e.getExceptionCode());
ToastUtils.showShort(PostsDetailActivity.this, &点赞失败&);
if (!NetUtils.isConnected(PostsDetailActivity.this)) {
ToastUtils.showShort(PostsDetailActivity.this, &当前网络不好&);
} else if (401 == e.getExceptionCode()) {
MainActivity.requestLogin(PostsDetailActivity.this, handler, 401);
if (!&1&.equals((String) SharePreferenceUtils.get(PostsDetailActivity.this, &logintype&, &-1&))) {
showLoginDialog();
ck_posts_isthumbsup.setFocusable(true);
ck_posts_isthumbsup.setChecked(true);
ck_posts_isthumbsup.setChecked(true);
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsuped);
((MainActivity)activity).jumpToLogin();
RequestParams params = NetUtils.getRequestParams(PostsDetailActivity.this);
@@ -705,18 +706,12 @@
LogUtils.d(&qqb&, &是否点赞islike& + &----
bbbbbbbbbbbbbbbbb& + isCurrentThumbsup + &================& + islike);
getThumbsUpUser(id);
islike = 0;
LogUtils.d(&qqb&, &uuuuuuuuuuuuu
& + islike);
LogUtils.d(&qqb&, &帖子取消点赞成功& + responseInfo.statusCode + &
ToastUtils.showShort(PostsDetailActivity.this, &取消点赞成功&);
//如果当前进来还点赞了,那么就用点赞自后的点赞数来减去1
if (currenthumbs == 1) {
LogUtils.d(&qqb&, &点赞次数===》111&);
tv_posts_thumbsupnunm.setText(thumbsupNum);
} else if (currenthumbs == 0) {
LogUtils.d(&qqb&, &点赞次数===》222&);
tv_posts_thumbsupnunm.setText((new Integer(thumbsupNum) - 1) + &&);
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsup);
islike = -1;
thumbsupNum = new Integer(thumbsupNum) - 1 + &&;
tv_posts_thumbsupnunm.setText(thumbsupNum);
currenthumbs = -1;
@@ -734,7 +729,6 @@
scene_detail_content_allusers.setOnClickListener(this);
@@ -743,11 +737,11 @@
id = intent.getStringExtra(&id&);
goShow = intent.getStringExtra(&goshow&);
thumbsupNum = intent.getStringExtra(&thumbsupnum&);
String comNum=intent.getStringExtra(&commentnum&);
String comNum = intent.getStringExtra(&commentnum&);
tagName = intent.getStringExtra(&tagname&);
tagId= intent.getStringExtra(&tagid&);
tagId = intent.getStringExtra(&tagid&);
if(comNum!=null){
if (comNum != null) {
commentNum = new Integer(intent.getStringExtra(&commentnum&));
markId = intent.getStringExtra(&markid&);
@@ -761,7 +755,7 @@
tv_posts_thumbsupnunm = (TextView) findViewById(R.id.tv_posts_thumbsupnunm);
tv_posts_commentnum = (TextView) findViewById(R.id.tv_posts_commentnum);
ck_comment = (CheckBox) findViewById(R.id.ck_comment);
rl_over=(RelativeLayout)findViewById(R.id.rl_over);
iv_address_icon = (ImageView) findViewById(R.id.iv_address_icon);
rl_address = (RelativeLayout) findViewById(R.id.rl_address);
@@ -773,6 +767,12 @@
rl_back = (RelativeLayout) findViewById(R.id.rl_back);
rl_msg = (RelativeLayout) findViewById(R.id.rl_msg);
main = (RelativeLayout) findViewById(R.id.main);
activityRootView= (RelativeLayout) findViewById(R.id.main);
//获取屏幕高度
screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
//阀值设置为屏幕高度的1/3
keyHeight = screenHeight/3;
btn_send = (Button) findViewById(R.id.btn_send);
tv_isover_num = (TextView) findViewById(R.id.tv_isover_num);
iv_gender = (ImageView) findViewById(R.id.iv_gender);
@@ -787,7 +787,7 @@
pull = (PullToRefreshScrollView) findViewById(R.id.pull_posts_detail);
lv_comment = (MyListView) findViewById(R.id.lv_posts_comment);
ck_posts_isthumbsup = (CheckBox) findViewById(R.id.ck_posts_isthumbsup);
ck_posts_isthumbsup = (ImageView) findViewById(R.id.ck_posts_isthumbsup);
ck_posts_iscollect = (CheckBox) findViewById(R.id.ck_posts_iscollect);
httpUtils = new HttpUtils(10000);
httpUtils.configCurrentHttpCacheExpiry(500); // 设置缓存5秒,5秒内直接返回上次成功请求的结果。
@@ -804,11 +804,11 @@
android:focusableInTouchMode=&true&
scene_vp_detail = (ViewPager) findViewById(R.id.scene_vp_detail);
scene_detail_content = (RelativeLayout) findViewById(R.id.scene_detail_content);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(et_posts_comment.getWindowToken(), 0);
iv_share = (ImageView) findViewById(R.id.iv_share);
iv_share.setOnClickListener(this);
main.setOnClickListener(this);
pull.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
//设置置顶
pull.requestFocus();
@@ -830,7 +830,14 @@
isShowKeyBroad = 0;
protected void onResume() {
super.onResume();
//添加layout大小发生改变监听器
activityRootView.addOnLayoutChangeListener(PostsDetailActivity.this);
//展示铁西详情所有为帖子点赞的人
private void showThumbupPerson(List&String& listUserIcon) {
scene_detail_content_allusers.removeAllViews();
@@ -865,76 +872,10 @@
public boolean onTouch(View v, MotionEvent event) {
hideKeyboard();
class MyAttentionListener implements View.OnClickListener {
public void onClick(View v) {
switch (v.getId()) {
//设置帖子详情的是否点赞
private void setThumbsUp() {
if (ck_posts_isthumbsup.isChecked()) {
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsup);
ck_posts_isthumbsup.setChecked(false);
String id = &bbf8740005&;
RequestParams params = NetUtils.getRequestParams(PostsDetailActivity.this);
params.addBodyParameter(&id&, id);
//http://test./v1/posts/bbf8740005/like
http://test./v1/
String cancelThumbsupUrl = AppConfigureUtils.urlHead + &posts/& + id + &/like&;
LogUtils.d(&qqb&, &打印一个帖子id用&);
LogUtils.d(&qqb&, &打印一个帖子id用& + id);
httpUtils.send(HttpRequest.HttpMethod.POST, cancelThumbsupUrl, params, new RequestCallBack&String&() {
public void onSuccess(ResponseInfo&String& responseInfo) {
LogUtils.d(&qqb&, &帖子点赞成功& + responseInfo.statusCode + &
& + islike);
public void onFailure(HttpException e, String s) {
if (!NetUtils.isConnected(PostsDetailActivity.this)) {
ToastUtils.showShort(PostsDetailActivity.this, &当前网络不好&);
} else if (401 == e.getExceptionCode()) {
MainActivity.requestLogin(PostsDetailActivity.this, handler, 401);
LogUtils.d(&qqb&, &帖子点赞失败& + e.getExceptionCode());
RequestParams params = NetUtils.getRequestParams(PostsDetailActivity.this);
params.addBodyParameter(&id&, id);
String cancelThumbsupUrl = AppConfigureUtils.urlHead + &posts/& + id + &/like&;
httpUtils.send(HttpRequest.HttpMethod.DELETE, cancelThumbsupUrl, params, new RequestCallBack&String&() {
public void onSuccess(ResponseInfo&String& responseInfo) {
LogUtils.d(&qqb&, &帖子取消点赞成功& + responseInfo.statusCode + &
& + islike);
public void onFailure(HttpException e, String s) {
if (!NetUtils.isConnected(PostsDetailActivity.this)) {
ToastUtils.showShort(PostsDetailActivity.this, &当前网络不好&);
} else if (401 == e.getExceptionCode()) {
MainActivity.requestLogin(PostsDetailActivity.this, handler, 401);
LogUtils.d(&qqb&, &帖子取消点赞失败& + e.getExceptionCode());
ck_posts_isthumbsup.setBackgroundResource(R.drawable.scene_detail_thumbsup);
ck_posts_isthumbsup.setChecked(true);
protected void onDestroy() {
super.onDestroy();
@@ -985,14 +926,6 @@
class CommentContent {
public CommentContent(String content) {
this.content =
//用户评论
public void setCommment() {
JSONObject jsonObject = new JSONObject();
@@ -4,7 @@
jsonObject.put(&content&, et_posts_comment.getText().toString());
LogUtils.d(&qqb&, &打印commentid
--&1& + commentId);
LogUtils.d(&qqb&, &打印commentid
--&2& + id);
if(replyCommentId!=null){
jsonObject.put(&replycommentid&, commentId);
//18a2c1fde56e52eecf4d10010
09-01 22:47:05.353 /? D/qqb: 打印commentid
--&28a2c1fde56e52eece00005
LogUtils.d(&qqb&, &用户aaa& + jsonObject.toString());
RequestParams params = NetUtils.getRequestParams(PostsDetailActivity.this);
@@ -9,7 @@
currentPage = 1;
LogUtils.d(&qqb&, &用户评论成功& + responseInfo.statusCode);
commentNum = commentNum + 1;
tv_posts_commentnum.setText(commentNum + &&);
tv_posts_commentnum.setText(commentNum + &&);
hideKeyboard();
//评论成功一次就+1
@@ -14,10 @@
//解析点赞的人数据
private void parseUserData(String jsonString) {
LogUtils.d(&qqbd&, &jsonStringsss& + jsonString);
postsUserList = new ArrayList&&();
listId = new ArrayList&&();
LogUtils.d(&qqbd&, &jsonStringsss111&);
JSONObject jsonObject = new JSONObject(jsonString);
LogUtils.d(&qqbd&, &jsonStringsss222&);
JSONArray jsonArray = jsonObject.getJSONArray(&content&);
for (int i = 0; i & jsonArray.length(); i++) {
JSONObject jsonObject1 = (JSONObject) jsonArray.get(i);
@@ -82,8 @@
postsDatailBean = new PostsDatailBean(commentnum, content, createtime, headimg, postsImageList, postsUserList, iscollection, islike + &&, likenum, location, nickname, sex);
showDetail(postsDatailBean.getImagePosts());
if(postsDatailBean!=null){
if(postsDatailBean.getHeadimg().length()&0){
if (postsDatailBean != null) {
if (postsDatailBean.getHeadimg().length() & 0) {
iv_main_detail_content_icon.setVisibility(View.VISIBLE);
@@ -00,7 @@
subPlace = postsP
tv_address.setText(subPlace+&
tv_address.setText(subPlace + &
if (postsDatailBean.getLocation() != null) {
rl_address.setVisibility(View.VISIBLE);
@@ -22,10 @@
if (postsDatailBean.getContent().length() &= 50) {
subContent = postsDatailBean.getContent();
LogUtils.d(&qqb&,&帖子详情内容的长度1
&+subContent.length());
StringBuffer sb = new StringBuffer();
if (tagName != null) {
if (tagName.length() & 0) {
sb.append(&#& + tagName + &#&).append(& &+subContent);
sb.append(&#& + tagName + &#&).append(& & + subContent);
sb.append(subContent);
@@ -55,8 @@
ToastUtils.showShort(PostsDetailActivity.this, &点击啊--&打印tagid&+tagId);
}, 0, str.length() - subContent.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if(tagName!=null){
spannableString1.setSpan(new URLSpanNoUnderline(spannableString1.toString()), str.length() - subContent.length()+ 1, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
if (tagName != null) {
spannableString1.setSpan(new URLSpanNoUnderline(spannableString1.toString()), str.length() - subContent.length() + 1, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv_content.setText(spannableString1);
tv_content.setMovementMethod(LinkMovementMethod.getInstance());
@@ -64,7 @@
StringBuffer sb = new StringBuffer();
if (tagName != null) {
if (tagName.length() & 1) {
sb.append(&#& + tagName + &#&).append(& &+postsDatailBean.getContent());
sb.append(&#& + tagName + &#&).append(& & + postsDatailBean.getContent());
sb.append(postsDatailBean.getContent());
@@ -71,7 @@
sb.append(postsDatailBean.getContent());
LogUtils.d(&qqb&,&帖子详情内容的长度2
&+postsDatailBean.getContent());
LogUtils.d(&qqb&, &帖子详情内容的长度2
& + postsDatailBean.getContent());
CharSequence str = sb.toString();
LogUtils.d(&qqb&, &----&--&& + postsDatailBean.getContent());
@@ -05,16 @@
if(commentNum&0){
if (commentNum & 0) {
ck_comment.setVisibility(View.VISIBLE);
tv_posts_commentnum.setText(commentNum + &&);
ck_comment.setVisibility(View.VISIBLE);
tv_posts_commentnum.setText( &0&);
tv_posts_commentnum.setText(&0&);
} catch (Exception e) {
ck_comment.setVisibility(View.VISIBLE);
tv_posts_commentnum.setText( &0&);
tv_posts_commentnum.setText(&0&);
if (thumbsupNum != null) {
@@ -35,12 @@
if (islike == 1) {
isCurrentThumbsup =
ck_posts_isthumbsup.setChecked(true);
ck_posts_isthumbsup.setChecked(true);
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsuped);
isCurrentThumbsup =
ck_posts_isthumbsup.setChecked(false);
ck_posts_isthumbsup.setChecked(false);
ck_posts_isthumbsup.setBackgroundResource(R.drawable.thumbsup);
listThumbsUpPerson = postsDatailBean.getImageUser();
if (listThumbsUpPerson != null) {
@@ -47,6 @@
iv_dianzan.setVisibility(View.VISIBLE);
showThumbupPerson(listThumbsUpPerson);
if (postsDatailBean.getImageUser() != null) {
if (postsDatailBean.getImageUser().size() &= 8) {
tv_isover_num.setVisibility(View.VISIBLE);
tv_isover_num.setVisibility(View.GONE);
} catch (JSONException e) {
e.printStackTrace();
@@ -55,57 @@
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if (isShouldHideInput(v, ev)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
return super.dispatchTouchEvent(ev);
// 必不可少,否则所有的组件都不会有TouchEvent了
if (getWindow().superDispatchTouchEvent(ev)) {
return onTouchEvent(ev);
public boolean isShouldHideInput(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)&&(v instanceof ImageView)) {
int[] leftTop = {0, 0};
//获取输入框当前的location位置
v.getLocationInWindow(leftTop);
int left = leftTop[0];
int top = leftTop[1];
int bottom = top + v.getHeight();
int right = left + v.getWidth();
if (event.getX() & left && event.getX() & right
&& event.getY() & top && event.getY() & bottom) {
// 点击的是输入框区域,保留点击EditText的事件
public void onClick(View v) {
switch (v.getId()) {
case R.id.main:
ToastUtils.showShort(PostsDetailActivity.this,&&);
InputMethodManager imm2 = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm2.hideSoftInputFromWindow(v.getWindowToken(), 0);
case R.id.ck_comment:
InputMethodManager imm = (InputMethodManager) v.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -18,7 @@
case R.id.iv_add:
if (declarationPop == null) {
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
declarationPop = new DeclarationPop(PostsDetailActivity.this, itemsOnClick,wm);
declarationPop = new DeclarationPop(PostsDetailActivity.this, itemsOnClick, wm);
declarationPop.showAsDropDown(iv_add, 0, 0);
ll_popup.startAnimation(AnimationUtils.loadAnimation(PostsDetailActivity.this, R.anim.activity_translate_in));
@@ -28,7 @@
case R.id.rl_add:
if (declarationPop == null) {
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
declarationPop = new DeclarationPop(PostsDetailActivity.this, itemsOnClick,wm);
declarationPop = new DeclarationPop(PostsDetailActivity.this, itemsOnClick, wm);
declarationPop.showAsDropDown(iv_add, 0, 0);
ll_popup.startAnimation(AnimationUtils.loadAnimation(PostsDetailActivity.this, R.anim.activity_translate_in));
@@ -76,11 @@
if (threeComment != null && threeComment.length() & 0) {
intent.putExtra(&threecomment&, threeComment);
if(goShow!=null){
if(goShow.equals(&1&)){
if (goShow != null) {
if (goShow.equals(&1&)) {
//更新现场
intent.setAction(&updatecomment&);
//更新专题
intent.setAction(&updatecommentspecial&);
@@ -13,11 @@
if (threeComment != null && threeComment.length() & 0) {
intent.putExtra(&threecomment&, threeComment);
if(goShow!=null){
if(goShow.equals(&1&)){
if (goShow != null) {
if (goShow.equals(&1&)) {
//更新现场
intent.setAction(&updatecomment&);
//更新专题
intent.setAction(&updatecommentspecial&);
@@ -31,7 @@
case R.id.btn_send:
if (!&1&.equals((String) SharePreferenceUtils.get(PostsDetailActivity.this, &logintype&, &-1&))) {
showLoginDialog();
((MainActivity)activity).jumpToLogin();
setCommment();
@@ -49,8 @@
if (!&1&.equals(SharePreferenceUtils.get(PostsDetailActivity.this, &logintype&, &-1&))) {
showLoginDialog();
startShare();
final String url = AppConfigureUtils.shareHeader + &posts/& +
startShare(url);
//点赞的linearlayout
@@ -64,58 @@
private void startShare() {
final String url = AppConfigureUtils.shareHeader+&posts/&+
final UMImage image = new UMImage(PostsDetailActivity.this,url);
public void startShare(final
String url) {
final UMImage image = new UMImage(PostsDetailActivity.this,url);
final Dialog dialog_share = new Dialog(PostsDetailActivity.this, R.style.Dialog);
dialog_share.setCanceledOnTouchOutside(true);
dialog_share.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog_share.setContentView(R.layout.dialog_share);
Window window = dialog_share.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams lp = dialog_share.getWindow().getAttributes();
lp.width = ScreenUtils.getScreenWidth(PostsDetailActivity.this); //设置宽度
dialog_share.getWindow().setAttributes(lp);
dialog_share.findViewById(R.id.iv_wei_chat).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new ShareAction(PostsDetailActivity.this).setPlatform(SHARE_MEDIA.WEIXIN).setCallback(umShareListener)
.withText(&来自微籽android版app&)
.withMedia(image)
//.withMedia(new UMEmoji(ShareActivity.this,&http://img.newyx.net/news_img//_.gif&))
.withText(&hello umeng&)
.withTargetUrl(url)
final Dialog dialog_share = new Dialog(PostsDetailActivity.this, R.style.Dialog);
dialog_share.setCanceledOnTouchOutside(true);
dialog_share.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog_share.setContentView(R.layout.dialog_share);
Window window = dialog_share.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams lp = dialog_share.getWindow().getAttributes();
lp.width = ScreenUtils.getScreenWidth(PostsDetailActivity.this); //设置宽度
dialog_share.getWindow().setAttributes(lp);
dialog_share.findViewById(R.id.iv_wei_chat).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new ShareAction(PostsDetailActivity.this).setPlatform(SHARE_MEDIA.WEIXIN).setCallback(umShareListener)
.withText(&来自微籽android版app&)
.withMedia(image)
//.withMedia(new UMEmoji(ShareActivity.this,&http://img.newyx.net/news_img//_.gif&))
.withText(&hello umeng&)
.withTargetUrl(url)
dialog_share.findViewById(R.id.iv_friend).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new ShareAction(PostsDetailActivity.this).setPlatform(SHARE_MEDIA.WEIXIN_CIRCLE).setCallback(umShareListener)
.withText(&来自微籽android版app&)
.withMedia(image)
//.withMedia(new UMEmoji(ShareActivity.this,&http://img.newyx.net/news_img//_.gif&))
.withText(&hello umeng&)
.withTargetUrl(url)
dialog_share.findViewById(R.id.iv_friend).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new ShareAction(PostsDetailActivity.this).setPlatform(SHARE_MEDIA.WEIXIN_CIRCLE).setCallback(umShareListener)
.withText(&来自微籽android版app&)
.withMedia(image)
//.withMedia(new UMEmoji(ShareActivity.this,&http://img.newyx.net/news_img//_.gif&))
.withText(&hello umeng&)
.withTargetUrl(url)
dialog_share.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialog_share.dismiss();
dialog_share.show();
dialog_share.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialog_share.dismiss();
dialog_share.show();
* 弹出登录对话框
@@ -24,7 @@
final Dialog dialog = new Dialog(PostsDetailActivity.this, R.style.Dialog);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.appexitdailog);
TextView tv_notice= (TextView) dialog.findViewById(R.id.tv_notice);
TextView tv_notice = (TextView) dialog.findViewById(R.id.tv_notice);
tv_notice.setText(&需要先登录,是否立即登录?&);
dialog.findViewById(R.id.tv_confirm).setOnClickListener(new View.OnClickListener() {
@@ -66,15 @@
switch (v.getId()) {
//点击分享
case R.id.ll_popup:
ToastUtils.showShort(PostsDetailActivity.this, &点击分享&);
final String url = AppConfigureUtils.shareHeader + &posts/& +
startShare(url);
//点击投诉
case R.id.ll_complain:
ToastUtils.showShort(PostsDetailActivity.this, &点击投诉&);
Intent intent = new Intent(PostsDetailActivity.this, ReportActivity.class);
//postid = getIntent().getStringExtra(&postid&);
intent.putExtra(&postid&, id);
startActivity(intent);
@@ -07,14 @@
if (threeComment != null && threeComment.length() & 0) {
intent.putExtra(&threecomment&, threeComment);
if(goShow!=null){
if(goShow.equals(&1&)){
if (goShow != null) {
if (goShow.equals(&1&)) {
//更新现场
LogUtils.d(&qqb&,&打印goshow的值---&1
&+goShow);
LogUtils.d(&qqb&, &打印goshow的值---&1
& + goShow);
intent.setAction(&updatecomment&);
//更新专题
LogUtils.d(&qqb&,&打印goshow的值---&2
&+goShow);
LogUtils.d(&qqb&, &打印goshow的值---&2
& + goShow);
intent.setAction(&updatecommentspecial&);
@@ -46,7 @@
// ToastUtils.showShort(PostsDetailActivity.this,&分享失败啦&);
public void onCancel(SHARE_MEDIA platform) {
//ToastUtils.showShort(PostsDetailActivity.this,&分享取消了&);
@@ -55,30 @@
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/** attention to this below ,must add this**/
/** attention to this below ,must add this**/
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
public void onLayoutChange(View v, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
//old是改变前的左上右下坐标点值,没有old的是改变后的左上右下坐标点值
System.out.println(oldLeft + & & + oldTop +& & + oldRight + & & + oldBottom);
System.out.println(left + & & + top +& & + right + & & + bottom);
//现在认为只要控件将Activity向上推的高度超过了1/3屏幕高,就认为软键盘弹起
if(oldBottom != 0 && bottom != 0 &&(oldBottom - bottom & keyHeight)){
rl_over.setVisibility(View.VISIBLE);
Toast.makeText(PostsDetailActivity.this, &监听到软键盘弹起...&, Toast.LENGTH_SHORT).show();
}else if(oldBottom != 0 && bottom != 0 &&(bottom - oldBottom & keyHeight)){
rl_over.setVisibility(View.GONE);
Toast.makeText(PostsDetailActivity.this, &监听到软件盘关闭...&, Toast.LENGTH_SHORT).show();
(C)&&2013&&Alibaba&&Inc.&&All&&rights&&resvered.
Powered by

我要回帖

更多关于 activity什么意思 的文章

 

随机推荐