Exemplo n.º 1
0
 @Override
 public void onClick(View v) {
   if (super.getActivity() instanceof HomeActivity) {
     HomeActivity a = (HomeActivity) super.getActivity();
     a.loadData(null);
   }
 }
Exemplo n.º 2
0
  private void onMigrationFinished() {
    if (TraktoidPrefs.INSTANCE.isUserLoggedIn() && TraktoidPrefs.INSTANCE.getUsername() != null)
      HomeActivity.launch(this);
    else LoginActivity.launch(this);

    finish();
  }
 private void startApp(ApplicationIcon ai, Context context) {
   try {
     Intent appLaunch = new Intent();
     appLaunch.setClassName(ai.getPackageName(), ai.getActivityName());
     appLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     context.startActivity(appLaunch);
     if (ctx instanceof HomeActivity) {
       ((HomeActivity) ctx).resetState(); // Self explanatory
     }
   } catch (Exception e) {
     Toast.makeText(context, "Couldn't start this app!", Toast.LENGTH_SHORT).show();
   }
 }
  public void testLogout() {
    Instrumentation.ActivityMonitor activityMonitor =
        getInstrumentation().addMonitor(Login.class.getName(), null, false);

    // open current activity.
    HomeActivity myActivity = getActivity();
    final Button button = (Button) myActivity.findViewById(R.id.logout_button);
    myActivity.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            // click button and open next activity.
            button.performClick();
          }
        });

    // Watch for the timeout
    // example values 5000 if in ms, or 5 if it's in seconds.
    Login nextActivity =
        (Login) getInstrumentation().waitForMonitorWithTimeout(activityMonitor, 5000);
    // next activity is opened and captured.
    assertNotNull(nextActivity);
    nextActivity.finish();
  }
Exemplo n.º 5
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.other);

    ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
    // You can assign the title programmatically by passing a
    // CharSequence or resource id.
    actionBar.setTitle("Second activity");
    actionBar.setSubTitle("Subtitle 2");
    actionBar.setHomeAction(
        new IntentAction(this, HomeActivity.createIntent(this), R.drawable.ic_title_home_default));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.addAction(new IntentAction(this, createShareIntent(), R.drawable.ic_share));
    actionBar.addAction(new ExampleAction());
  }
 @Override
 public void onClick(View arg0) {
   HomeActivity sct = (HomeActivity) activity;
   sct.onItemClick(mPosition);
 }
Exemplo n.º 7
0
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

      int i = getArguments().getInt(ARG_MENU_NUMBER);
      String Menu = menuItems[i];
      View rootView = null;
      // Animation anim = AnimationUtils.loadAnimation(this.getActivity().getBaseContext(),
      //  R.anim.showin);
      ListView lv;
      ListItem.USERID = "90999900";
      switch (i) {
        case 0:
          HomeActivity objhome = new HomeActivity();
          rootView = inflater.inflate(R.layout.activity_home, container, false);
          objhome.setInstance(this.getActivity(), this.getActivity(), rootView, session);
          // rootView.setAnimation(anim);
          break;
        case 1:
          myfeedActivity objfeedact = new myfeedActivity();
          rootView = inflater.inflate(R.layout.mylistview, container, false);
          lv = (ListView) rootView.findViewById(R.id.myfeed_listView);
          objfeedact.create_feed(this.getActivity(), this.getActivity(), lv, rootView, session);
          // rootView.setAnimation(anim);
          break;
        case 2:
          mymessageActivity objmsgact = new mymessageActivity();
          rootView = inflater.inflate(R.layout.mylistview, container, false);
          lv = (ListView) rootView.findViewById(R.id.myfeed_listView);
          objmsgact.create_feed(this.getActivity(), this.getActivity(), lv, rootView);
          // rootView.setAnimation(anim);
          break;
        case 3:
          rootView = inflater.inflate(R.layout.fragment_planet, container, false);
          // rootView.setAnimation(anim);
          break;
        case 4:
          rootView = inflater.inflate(R.layout.fragment_planet, container, false);
          // rootView.setAnimation(anim);
          break;
        case 5:
          /*Intent myIntent = new Intent(this.getActivity(), loginActivity.class);
          this.getActivity().startActivityForResult(myIntent, PICK_CONTACT_REQUEST);*/
          session.logoutUser();
          break;
        case 6:
          rootView = inflater.inflate(R.layout.fragment_planet, container, false);
          // rootView.setAnimation(anim);
          break;
        default:
          rootView = inflater.inflate(R.layout.fragment_planet, container, false);
          // rootView.setAnimation(anim);
          break;
      }

      /*int imageId = getResources().getIdentifier(Menu.toLowerCase(Locale.getDefault()),
              "drawable", getActivity().getPackageName());
      ((ImageView) rootView.findViewById(R.id.image)).setImageResource(imageId);*/
      CurentMenu = Menu;
      getActivity().setTitle(Menu);
      return rootView;
    }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.add_shift_fragment, parent, false);

    if (((AppCompatActivity) getActivity()).getSupportActionBar() != null) {
      ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Add Shift");
    }

    mCurrencyCashTextView = (TextView) v.findViewById(R.id.cashCurrencyTextView);
    mCurrencyCashTextView.setTextColor(Color.parseColor("#80FFFFFF"));

    // Get Cash Tips.
    cashTips = "0";
    mCashTipsEditText = (EditText) v.findViewById(R.id.cash_tips_editText);
    mCashTipsEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() == 0) {
              mCurrencyCashTextView.setTextColor(Color.parseColor("#80FFFFFF"));
            } else {
              mCurrencyCashTextView.setTextColor(Color.parseColor("#FFFFFFFF"));
            }
            cashTips = s.toString();
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    mCurrencyCreditTextView = (TextView) v.findViewById(R.id.creditCurrencyTextView);
    mCurrencyCreditTextView.setTextColor(Color.parseColor("#80FFFFFF"));

    // Get Credit Tips.
    creditTips = "0";
    mCreditTipsEditText = (EditText) v.findViewById(R.id.credit_tips_editText);
    mCreditTipsEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() == 0) {
              mCurrencyCreditTextView.setTextColor(Color.parseColor("#80FFFFFF"));
            } else {
              mCurrencyCreditTextView.setTextColor(Color.parseColor("#FFFFFFFF"));
            }
            creditTips = s.toString();
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    mCurrencyTipOutTextView = (TextView) v.findViewById(R.id.tipOutTextView);
    mCurrencyTipOutTextView.setTextColor(Color.parseColor("#80FFFFFF"));

    // Get Tip Out.
    tipOut = "0";
    mTipOutEditText = (EditText) v.findViewById(R.id.tip_out_editText);
    mTipOutEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() == 0) {
              mCurrencyTipOutTextView.setTextColor(Color.parseColor("#80FFFFFF"));
            } else {
              mCurrencyTipOutTextView.setTextColor(Color.parseColor("#FFFFFFFF"));
            }
            tipOut = s.toString();
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    // Get Hours Worked.
    mHoursWorkedNumberPicker =
        (com.jcgibson.customwidgets.NumberPicker) v.findViewById(R.id.hoursWorkedPicker);
    mMinutesWorkedNumberPicker =
        (com.jcgibson.customwidgets.NumberPicker) v.findViewById(R.id.minutesWorkedPicker);

    // Get Date.
    mDateButton = (Button) v.findViewById(R.id.tipDateButton);
    mDateButton.setText(HomeActivity.getDateAsString());
    mDate = HomeActivity.getDate();
    mDateButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Launch DatePickerFragment
            FragmentManager fm = getActivity().getSupportFragmentManager();
            DatePickerFragment dialog = DatePickerFragment.newInstance(mShift.getDate());
            dialog.setTargetFragment(AddShiftFragment.this, REQUEST_DATE);
            dialog.show(fm, DIALOG_DATE);
          }
        });

    mCurrencySalesTextView = (TextView) v.findViewById(R.id.totalSalesCurrencyTextView);
    mCurrencySalesTextView.setTextColor(Color.parseColor("#80FFFFFF"));

    // Get Total Sales.
    totalSales = "0";
    mSalesEditText = (EditText) v.findViewById(R.id.totalSalesData);
    mSalesEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() == 0) {
              mCurrencySalesTextView.setTextColor(Color.parseColor("#80FFFFFF"));
            } else {
              mCurrencySalesTextView.setTextColor(Color.parseColor("#FFFFFFFF"));
            }
            totalSales = s.toString();
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    return v;
  }