|
|
|
@ -3,7 +3,7 @@ package com.orangesale.cn.activity;
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
|
|
import android.app.FragmentTransaction;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
|
@ -14,6 +14,7 @@ import com.orangesale.cn.fragment.IndexFragment;
|
|
|
|
|
import com.orangesale.cn.fragment.PersonFragment;
|
|
|
|
|
import com.orangesale.cn.fragment.ProductFragment;
|
|
|
|
|
import com.orangesale.cn.fragment.ShoppingFragment;
|
|
|
|
|
import com.orangesale.cn.fragment.TimeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
@ -21,7 +22,6 @@ public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
private ProductFragment productFragment;
|
|
|
|
|
private ShoppingFragment shoppingFragment;
|
|
|
|
|
private IndexFragment indexFragment;
|
|
|
|
|
|
|
|
|
|
private PersonFragment personFragment;
|
|
|
|
|
|
|
|
|
|
private LinearLayout indexLine;
|
|
|
|
@ -29,12 +29,9 @@ public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
private LinearLayout shoppingLine;
|
|
|
|
|
private LinearLayout personLine;
|
|
|
|
|
|
|
|
|
|
public IndexActivity(LinearLayout indexLine,LinearLayout productLine, LinearLayout shoppingLine, LinearLayout personLine) {
|
|
|
|
|
this.productLine = productLine;
|
|
|
|
|
this.personLine = personLine;
|
|
|
|
|
this.indexLine = indexLine;
|
|
|
|
|
this.shoppingLine = shoppingLine;
|
|
|
|
|
}
|
|
|
|
|
Intent timeServiceIntent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
@ -42,6 +39,8 @@ public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
init();
|
|
|
|
|
initIndexFragment();
|
|
|
|
|
Thread thread = new Thread(runnable);
|
|
|
|
|
thread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void init() {
|
|
|
|
@ -74,7 +73,7 @@ public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
initshoppingFragment();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case R.id.content_pearson:
|
|
|
|
|
case R.id.content_person:
|
|
|
|
|
//注册验证方法
|
|
|
|
|
initpersonFragment();
|
|
|
|
|
break;
|
|
|
|
@ -96,7 +95,7 @@ public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initshoppingFragment() {
|
|
|
|
|
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
|
|
|
|
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
|
|
|
|
if (shoppingFragment == null) {
|
|
|
|
|
shoppingFragment = new ShoppingFragment();
|
|
|
|
|
}
|
|
|
|
@ -114,13 +113,22 @@ public class IndexActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initIndexFragment() {
|
|
|
|
|
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
|
|
|
|
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
|
|
|
|
if (indexFragment == null) {
|
|
|
|
|
indexFragment = new IndexFragment();
|
|
|
|
|
}
|
|
|
|
|
transaction.replace(R.id.main_content,productFragment);
|
|
|
|
|
transaction.replace(R.id.main_content,indexFragment);
|
|
|
|
|
transaction.commit();
|
|
|
|
|
}
|
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
|
timeServiceIntent = new Intent(IndexActivity.this, TimeService.class);
|
|
|
|
|
startService(timeServiceIntent);
|
|
|
|
|
};
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
stopService(timeServiceIntent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|