/**
   * Fills the list with the available recordings. Only the recordings that are scheduled are added
   * to the list.
   */
  private void populateList() {
    // Clear the list and add the recordings
    adapter.clear();
    TVHClientApplication app = (TVHClientApplication) activity.getApplication();
    for (SeriesRecording srec : app.getSeriesRecordings()) {
      adapter.add(srec);
    }
    // Show the newest scheduled recordings first
    adapter.sort(Constants.RECORDING_SORT_DESCENDING);
    adapter.notifyDataSetChanged();

    if (toolbar != null) {
      onPrepareToolbarMenu(toolbar.getMenu());
      toolbar.setTitle(getString(R.string.series_recordings));
      if (adapter.getCount() > 0) {
        toolbar.setSubtitle(adapter.getCount() + " " + getString(R.string.items_available));
      } else {
        toolbar.setSubtitle(R.string.no_recordings_scheduled);
      }
    }
    // Inform the listeners that the channel list is populated.
    // They could then define the preselected list item.
    if (fragmentStatusInterface != null) {
      fragmentStatusInterface.onListPopulated(TAG);
    }
  }
 private void initToolBar() {
   toolbar = (Toolbar) findViewById(R.id.toolbar);
   setSupportActionBar(toolbar);
   toolbar.setTitle("关于驱动器");
   toolbar.setTitleTextColor(getResources().getColor(R.color.white));
   if (typeNum == AboutQudongActivity.PRODUCT_NOTEBOOK) {
     toolbar.setSubtitle("产品手册");
   } else if (typeNum == AboutQudongActivity.ORDER_NOTEBOOK) {
     toolbar.setSubtitle("指令手册");
   } else if (typeNum == AboutQudongActivity.TEST_NOTEBOOK) {
     toolbar.setSubtitle("调试软件手册");
   } else if (typeNum == AboutQudongActivity.QAA_NOTEBOOK) {
     toolbar.setSubtitle("常见问题");
   }
   toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_48dp);
   toolbar.setNavigationOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent = new Intent(NoteBookActivity.this, AboutQudongActivity.class); // 方法1
           startActivity(intent);
           finish();
         }
       });
   toolbar.setOnMenuItemClickListener(onMenuItemClick);
 }
  private void updateDialog() {
    Exercise chosenExercise = mExercise.getSection().getExercises().get(mChosenLevel);

    mToolbar.setTitle(chosenExercise.getTitle());
    mToolbar.setSubtitle(chosenExercise.getDescription());

    if (mExercise.getSection().getSectionMode() == SectionMode.LEVELS) {
      mLevelTextView.setText(chosenExercise.getLevel());
    } else {
      mLevelTextView.setText("Pick One");
    }

    if (mChosenLevel == 0) {
      mLevelPreviousButton.setVisibility(View.INVISIBLE);
    } else {
      mLevelPreviousButton.setVisibility(View.VISIBLE);
    }

    if (mChosenLevel >= (mAvailableLevels - 1)) {
      mLevelNextButton.setVisibility(View.INVISIBLE);
    } else {
      mLevelNextButton.setVisibility(View.VISIBLE);
    }

    updateProgressBar();
  }
 @Override
 public void setSubtitle(CharSequence subtitle) {
   mSubtitle = subtitle;
   if ((mDisplayOpts & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
     mToolbar.setSubtitle(subtitle);
   }
 }
Esempio n. 5
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.child_layout);
   init();
   setSupportActionBar(toolbar);
   JMessageClient.registerEventReceiver(this);
   JMessageClient.setNotificationMode(JMessageClient.NOTI_MODE_NO_NOTIFICATION);
   listener = new LocationListener();
   toolbar.setSubtitle("孩子");
   toolbar.setNavigationIcon(R.mipmap.ic_keyboard_backspace_white_24dp);
   toolbar.setNavigationOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           finish();
         }
       });
   location.setText("软件已开启,请按home键退出");
   client = new LocationClient(this);
   client.registerLocationListener(listener);
   LocationClientOption option = new LocationClientOption();
   option.setOpenGps(true); // 打开gps
   option.setCoorType("bd09ll"); // 设置坐标类型
   client.setLocOption(option);
   client.start();
 }
Esempio n. 6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat);

    Bundle b = getIntent().getExtras();
    conv = new Conversation(b.getString("convId"), "", "");

    rvChat = (RecyclerView) findViewById(R.id.rvChat);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    rvChat.setLayoutManager(layoutManager);
    chatAdapter = new ChatAdapter();
    rvChat.setAdapter(chatAdapter);

    toolbar = (Toolbar) findViewById(R.id.chatToolbar);
    setSupportActionBar(toolbar);
    // if group set title and sub, else only title
    toolbar.setTitle("paul,john");
    toolbar.setSubtitle("");
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    etMsg = (EditText) findViewById(R.id.etMsg);
    etMsg.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            rvChat.smoothScrollToPosition(
                chatAdapter.messages.size() - 1 <= 0 ? 0 : chatAdapter.messages.size() - 1);
          }
        });
    bSend = (Button) findViewById(R.id.bSend);
    bSend.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            DarkChat.executor.submit(
                new Runnable() {
                  @Override
                  public void run() {
                    String m = etMsg.getText().toString();
                    if (m.trim().equals("")) return;
                    mService
                        .getChat()
                        .sendMessage(new Message(conv.getId(), mService.getChat().getAuthor(), m));
                  }
                });
            etMsg.setText("");
            rvChat.smoothScrollToPosition(
                chatAdapter.messages.size() - 1 <= 0 ? 0 : chatAdapter.messages.size() - 1);
          }
        });
  }
Esempio n. 7
0
  @AfterViews
  void afterViews() {
    toolbar_main.setTitle(R.string.steps_cloud_cn);
    toolbar_main.setSubtitle("修改昵称");
    setSupportActionBar(toolbar_main);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    et_change_nick.setText(nick);

    aCache = ACache.get(this);
  }
 private void initToolbar() {
   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   toolbar.setTitle(R.string.app_name);
   toolbar.setSubtitle("Добавить новый цветок");
   toolbar.setOnMenuItemClickListener(
       new Toolbar.OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           return false;
         }
       });
   toolbar.inflateMenu(R.menu.menu_main);
 }
  @Override
  public void setDisplayOptions(int newOpts) {
    final int oldOpts = mDisplayOpts;
    final int changed = oldOpts ^ newOpts;
    mDisplayOpts = newOpts;
    if (changed != 0) {
      if ((changed & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        if ((newOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
          updateNavigationIcon();
          updateHomeAccessibility();
        } else {
          mToolbar.setNavigationIcon(null);
        }
      }

      if ((changed & AFFECTS_LOGO_MASK) != 0) {
        updateToolbarLogo();
      }

      if ((changed & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        if ((newOpts & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
          mToolbar.setTitle(mTitle);
          mToolbar.setSubtitle(mSubtitle);
        } else {
          mToolbar.setTitle(null);
          mToolbar.setSubtitle(null);
        }
      }

      if ((changed & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomView != null) {
        if ((newOpts & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
          mToolbar.addView(mCustomView);
        } else {
          mToolbar.removeView(mCustomView);
        }
      }
    }
  }
 private void updateTitle() {
   switch (mCurrentViewType) {
     case CalendarController.ViewType.DAY:
       mToolbar.setSubtitle(buildDayOfWeek());
       mToolbar.setTitle(buildFullDate());
       break;
     case CalendarController.ViewType.WEEK:
       if (Utils.getShowWeekNumber(mContext)) {
         mToolbar.setSubtitle(buildWeekNum());
       } else {
         mToolbar.setSubtitle("");
       }
       mToolbar.setTitle(buildMonthYearDate());
       break;
     case CalendarController.ViewType.MONTH:
       mToolbar.setSubtitle("");
       mToolbar.setTitle(buildMonthYearDate());
       break;
     case CalendarController.ViewType.AGENDA:
       mToolbar.setSubtitle(buildDayOfWeek());
       mToolbar.setTitle(buildFullDate());
       break;
   }
 }
  @Override
  public void manageAppBar(
      ActionBar actionBar, Toolbar toolbar, ActionBarDrawerToggle actionBarDrawerToggle) {
    actionBar.setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            handleBackPress();
          }
        });
    toolbar.setTitle(getString(R.string.nav_audio_title));
    SpannableString spannableString = new SpannableString(getString(R.string.app_subtitle));
    spannableString.setSpan(new StyleSpan(Typeface.ITALIC), 0, spannableString.length(), 0);
    toolbar.setSubtitle(spannableString);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bio);
    Resources res = getResources();
    Biography = res.getStringArray(R.array.biographyc20);
    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);
    myToolbar.setSubtitle(R.string.c20);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ListAdapter theAdapter = new bioadapter(this, Biography);
    final ListView wirdlist = (ListView) findViewById(R.id.biolist);
    wirdlist.setAdapter(theAdapter);
    registerForContextMenu(wirdlist);
    ListAdapter listAdapter = wirdlist.getAdapter();
    ImageView a = new ImageView(this);
    a.setImageResource(R.drawable.bio1);
    wirdlist.addHeaderView(a, null, false);
    a.setScaleType(ImageView.ScaleType.FIT_START);
    a.setAdjustViewBounds(true);
    ImageView b = new ImageView(this);
    b.setImageResource(R.drawable.gmsbtn);
    wirdlist.addFooterView(b);
    b.setScaleType(ImageView.ScaleType.FIT_START);
    b.setAdjustViewBounds(true);
    b.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            Uri uri =
                Uri.parse(
                    "http://www.greenmountainschool.org"); // missing 'http://' will cause crashed
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_top_apps);
    toolbar = (Toolbar) findViewById(R.id.toolbarList);
    setSupportActionBar(toolbar);

    // Get a reference to the AppsListFragment
    appsListFragment =
        (AppsListFragment) getFragmentManager().findFragmentById(R.id.apps_list_fragment);

    // Get a reference to the appsDetailFragment
    appsDetailFragment =
        (AppsDetailFragment)
            getSupportFragmentManager().findFragmentById(R.id.apps_detail_fragment);

    preferences =
        this.getSharedPreferences(PreferencesManager.PREFERENCES_FILE, Context.MODE_PRIVATE);
    mngrPreferences = new PreferencesManager(preferences);

    // ToolBar Config
    toolbar.setLogo(R.mipmap.ic_launcher);
    toolbar.setTitle("iTunes - Top Apps");
    toolbar.setSubtitle("Last Update: " + mngrPreferences.getRssUpdate().substring(0, 10));

    if (appsDetailFragment != null) {

      if (appsDetailFragment.getLastSelectedIndex() != -1) {

        appsDetailFragment.showAppDetail(appsDetailFragment.getLastSelectedIndex());

      } else {

        appsDetailFragment.showAppDetail(0);
      }
    }
  }
  /**
   * Metoda, u osnovi, inicira GUI u modu za azuriranje postojećeg cilja. To se koknretnije odnosi
   * na popunjavanje odgovarajucih polja za input sa trenutnim atributima cilja koji se azurira.
   * Takodjer se postavljaju vrijednosti teksta podnaslova Activity - a i Button - a za potvru, na
   * odgovarajucu vrijednost.
   */
  private void initUpdateForm() {
    toolbar.setSubtitle(getString(R.string.updateExistingGoal));
    Intent intent = getIntent();
    int goalId = intent.getIntExtra(getResources().getString(R.string.extraGoalIdTag), -1);

    if (goalId == -1) {
      Toast.makeText(ctx, getResources().getString(R.string.errorMessage), Toast.LENGTH_SHORT)
          .show();
      onBackPressed();
      return;
    }
    ArrayList<Goal> goals = dbc.getGoals();
    updatingGoal = new Goal();
    int i = 0;
    for (; i < goals.size(); i++) {
      if (goals.get(i).getId() == goalId) {
        updatingGoal = goals.get(i);
        break;
      }
    }
    txtName.setText(updatingGoal.getName());
    txtComment.setText(updatingGoal.getComment());

    int temp = -1;
    if (updatingGoal.getHigherGoal() == null) temp = -1;
    else {
      Goal higherGoal = HigherGoalGenerator.getHigherGoal(updatingGoal);

      for (int j = 0; j < goals.size(); j++) {
        try {
          if (goals.get(j).getId() == higherGoal.getId()) {
            temp = j;
            break;
          }
        } catch (Exception e) {

        }
      }
    }
    final int higherGoalIndex = temp + 1;
    spnHigherGoal.post(
        new Runnable() {
          @Override
          public void run() {
            spnHigherGoal.setSelection(higherGoalIndex);
          }
        });

    btnChooseDate.setText(DataParser.dateToString(updatingGoal.getDeadline()));
    rbPriority.setRating(updatingGoal.getPriority());

    ArrayList<Category> categories = dbc.getCategories();
    i = 0;
    for (; i < categories.size(); i++) {
      if (categories.get(i).getId() == updatingGoal.getCategory().getId()) {
        final int categoryIndex = i;

        spnCategory.post(
            new Runnable() {
              @Override
              public void run() {
                spnCategory.setSelection(categoryIndex);
              }
            });
        break;
      }
    }
  }
Esempio n. 15
0
 public void setSubtitle(int i) {
     setSubtitle(getContext().getText(i));
 }
Esempio n. 16
0
 public Toolbar(Context context, AttributeSet attributeSet, int i) {
     super(a(context, attributeSet, i), attributeSet, i);
     this.t = new qu();
     this.u = 8388627;
     this.A = new ArrayList();
     this.B = new int[2];
     this.D = new uv(this);
     this.L = new uw(this);
     rn a = rn.a(getContext(), attributeSet, nv.Toolbar, i, 0);
     this.l = a.f(nv.Toolbar_titleTextAppearance, 0);
     this.m = a.f(nv.Toolbar_subtitleTextAppearance, 0);
     this.u = a.b(nv.Toolbar_android_gravity, this.u);
     this.n = 48;
     int c = a.c(nv.Toolbar_titleMargins, 0);
     this.s = c;
     this.r = c;
     this.q = c;
     this.p = c;
     c = a.c(nv.Toolbar_titleMarginStart, -1);
     if (c >= 0) {
         this.p = c;
     }
     c = a.c(nv.Toolbar_titleMarginEnd, -1);
     if (c >= 0) {
         this.q = c;
     }
     c = a.c(nv.Toolbar_titleMarginTop, -1);
     if (c >= 0) {
         this.r = c;
     }
     c = a.c(nv.Toolbar_titleMarginBottom, -1);
     if (c >= 0) {
         this.s = c;
     }
     this.o = a.d(nv.Toolbar_maxButtonHeight, -1);
     c = a.c(nv.Toolbar_contentInsetStart, Integer.MIN_VALUE);
     int c2 = a.c(nv.Toolbar_contentInsetEnd, Integer.MIN_VALUE);
     this.t.b(a.d(nv.Toolbar_contentInsetLeft, 0), a.d(nv.Toolbar_contentInsetRight, 0));
     if (!(c == Integer.MIN_VALUE && c2 == Integer.MIN_VALUE)) {
         this.t.a(c, c2);
     }
     this.g = a.a(nv.Toolbar_collapseIcon);
     this.h = a.b(nv.Toolbar_collapseContentDescription);
     CharSequence b = a.b(nv.Toolbar_title);
     if (!TextUtils.isEmpty(b)) {
         setTitle(b);
     }
     b = a.b(nv.Toolbar_subtitle);
     if (!TextUtils.isEmpty(b)) {
         setSubtitle(b);
     }
     this.j = getContext();
     setPopupTheme(a.f(nv.Toolbar_popupTheme, 0));
     Drawable a2 = a.a(nv.Toolbar_navigationIcon);
     if (a2 != null) {
         setNavigationIcon(a2);
     }
     b = a.b(nv.Toolbar_navigationContentDescription);
     if (!TextUtils.isEmpty(b)) {
         setNavigationContentDescription(b);
     }
     this.K = a.d(nv.Toolbar_android_minHeight, 0);
     a.b();
     this.M = a.c();
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bio);
    Resources res = getResources();
    Biography = res.getStringArray(R.array.chapters);

    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);

    myToolbar.setSubtitle("The Founder of the Shadhili Way");

    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ListAdapter theAdapter = new bioadapter2(this, Biography);
    final ListView wirdlist = (ListView) findViewById(R.id.biolist);
    wirdlist.setAdapter(theAdapter);
    registerForContextMenu(wirdlist);
    ListAdapter listAdapter = wirdlist.getAdapter();

    ImageView a = new ImageView(this);
    a.setImageResource(R.drawable.bio1);
    wirdlist.addHeaderView(a, null, false);
    a.setScaleType(ImageView.ScaleType.FIT_START);
    a.setAdjustViewBounds(true);

    ImageView b = new ImageView(this);
    b.setImageResource(R.drawable.gmsbtn);
    wirdlist.addFooterView(b);
    b.setScaleType(ImageView.ScaleType.FIT_START);
    b.setAdjustViewBounds(true);
    b.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            Uri uri =
                Uri.parse(
                    "http://www.greenmountainschool.org"); // missing 'http://' will cause crashed
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
          }
        });

    wirdlist.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> AdapterView, View view, int position, long id) {

            if (position == 1) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc1.class);
              startActivity(myIntent);
            }
            if (position == 2) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc2.class);
              startActivity(myIntent);
            }
            if (position == 3) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc3.class);
              startActivity(myIntent);
            }
            if (position == 4) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc4.class);
              startActivity(myIntent);
            }
            if (position == 5) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc5.class);
              startActivity(myIntent);
            }
            if (position == 6) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc6.class);
              startActivity(myIntent);
            }
            if (position == 7) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc7.class);
              startActivity(myIntent);
            }
            if (position == 8) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc8.class);
              startActivity(myIntent);
            }
            if (position == 9) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc9.class);
              startActivity(myIntent);
            }
            if (position == 10) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc10.class);
              startActivity(myIntent);
            }
            if (position == 11) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc11.class);
              startActivity(myIntent);
            }
            if (position == 12) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc12.class);
              startActivity(myIntent);
            }
            if (position == 13) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc13.class);
              startActivity(myIntent);
            }
            if (position == 14) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc14.class);
              startActivity(myIntent);
            }
            if (position == 15) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc15.class);
              startActivity(myIntent);
            }
            if (position == 16) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc16.class);
              startActivity(myIntent);
            }
            if (position == 17) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc17.class);
              startActivity(myIntent);
            }
            if (position == 18) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc18.class);
              startActivity(myIntent);
            }
            if (position == 19) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc19.class);
              startActivity(myIntent);
            }
            if (position == 20) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc20.class);
              startActivity(myIntent);
            }
            if (position == 21) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc21.class);
              startActivity(myIntent);
            }
            if (position == 22) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc22.class);
              startActivity(myIntent);
            }
            if (position == 23) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc23.class);
              startActivity(myIntent);
            }
            if (position == 24) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc24.class);
              startActivity(myIntent);
            }
            if (position == 25) {
              Intent myIntent = new Intent(getApplicationContext(), bioactivityc25.class);
              startActivity(myIntent);
            }
          }
        });
  }
  /**
   * Initializes the activity.
   *
   * @param savedInstanceState saved data of previous state.
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_result);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ImageButton fav = (ImageButton) findViewById(R.id.imageButton);
    fav.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (favorites == 1) {
              forget();
              fav.setImageDrawable(
                  ContextCompat.getDrawable(ResultActivity.this, R.mipmap.ic_unfavorite_star));
              favorites = 0;
              Snackbar.make(v, R.string.resact_sb_remove, Snackbar.LENGTH_LONG)
                  .setAction("Action", null)
                  .show();
            } else {
              remember();
              fav.setImageDrawable(
                  ContextCompat.getDrawable(ResultActivity.this, R.mipmap.ic_favorite_star));
              favorites = 1;
              Snackbar.make(v, R.string.resact_sb_add, Snackbar.LENGTH_LONG)
                  .setAction("Action", null)
                  .show();
            }
          }
        });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // giving filter spinner select listener
    filterSpinner = (Spinner) findViewById(R.id.filter_spinner);
    filterSpinner.setOnItemSelectedListener(this);

    // getting the passed bus number
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      busStopNumber = extras.getString("busStopNumber");
      busStopName = extras.getString("busStopName");
      busNumber = busStopNumber;

      // text field where the searched stop number is displayed
      // TextView stopNumberText = (TextView) findViewById(R.id.stop_number_text);
      // stopNumberText.setText(busStopNumber+": "+busStopName);
      toolbar.setSubtitle(busStopNumber + ": " + busStopName);
    }
  }
Esempio n. 19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sleep_time_set);

    Toolbar toolbar = (Toolbar) findViewById(R.id.set_toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("ReSleep");
    toolbar.setSubtitle("睡眠時間設定");

    toolbar.setNavigationIcon(R.drawable.back_icon);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), SettingActivity.class);
            startActivity(intent);
          }
        });

    final TimePicker timePicker = (TimePicker) findViewById(R.id.sleepTimePicker);
    timePicker.setIs24HourView(true);
    timePicker.setCurrentHour(loadUserInfo(7L));
    timePicker.setCurrentMinute(loadUserInfo(8L));

    Button button = (Button) findViewById(R.id.changeButton);
    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            int hour = timePicker.getCurrentHour();
            int min = timePicker.getCurrentMinute();

            User userWakeHour = getUserDao(getApplicationContext()).loadByRowId(3L);
            int wakeHour = Integer.valueOf(userWakeHour.getText());

            User userWakeMin = getUserDao(getApplicationContext()).loadByRowId(4L);
            int wakeMin = Integer.valueOf(userWakeMin.getText());

            int sleepHour, sleepMin;

            if (min == 0) {
              sleepMin = wakeMin;
              sleepHour = wakeHour - hour;
            } else if (min > wakeMin) {
              sleepMin = 60 - (min - wakeMin);
              sleepHour = wakeHour - hour - 1;
            } else {
              sleepMin = wakeMin - min;
              sleepHour = wakeHour - hour;
            }

            if (sleepHour < wakeHour) {
              sleepHour += 24;
            }

            insertUserInfo(String.valueOf(sleepHour), System.currentTimeMillis(), "SLEEP_HOUR", 5L);
            outputUserInfo(String.valueOf(sleepHour) + ", sleep_hour");
            insertUserInfo(String.valueOf(sleepMin), System.currentTimeMillis(), "SLEEP_MIN", 6L);
            outputUserInfo(String.valueOf(sleepMin) + ", sleep_min");
            insertUserInfo(String.valueOf(hour), System.currentTimeMillis(), "SLEEPTIME_HOUR", 7L);
            outputUserInfo(String.valueOf(hour) + ", sleeptime_hour");
            insertUserInfo(String.valueOf(min), System.currentTimeMillis(), "SLEEPTIME_MIN", 8L);
            outputUserInfo(String.valueOf(min) + ", sleeptime_min");

            setRange();

            Toast.makeText(
                    getApplicationContext(),
                    "睡眠時間を" + hour + "時間" + min + "分に設定しました",
                    Toast.LENGTH_LONG)
                .show();
          }
        });
  }
Esempio n. 20
0
 public void setToolbarSubtitle(Toolbar toolbar, CharSequence subtitle) {
   toolbar.setSubtitle(subtitle);
 }
Esempio n. 21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    // Registrando CHAT no observer
    this.mMessageSubject = MessageSubject.getInstance();
    this.mMessageSubject.attach(this);

    // Instancias
    this.mBD = new BD(this);
    this.mFirebase = new Firebase(Util.FIREBASE_URL);
    this.mListMessage = new ArrayList<Message>();
    this.messageDAO = new MessageDAO(this);

    // Referências
    mNewMessage = (EditText) findViewById(R.id.et_newMessage);
    mRecyclerView = (RecyclerView) findViewById(R.id.rv_listMsg);

    // Pegando o nome
    String nomeChatAtivo = getIntent().getStringExtra("nome").toString();
    // Pegando o numero
    mNumeroChatAtivo = getIntent().getStringExtra("numero").toString();

    // Mudando o status da mensagem para lida
    messageDAO.novasMensagensLidas(mNumeroChatAtivo);
    // Buscando o log
    this.mListMessage = messageDAO.getLog(mNumeroChatAtivo);

    Toolbar toolbar = (Toolbar) findViewById(R.id.tbChat);
    // Setando como titulo e subtitulo
    toolbar.setTitle(nomeChatAtivo);
    toolbar.setSubtitle("online");
    setSupportActionBar(toolbar);

    // Ativando o botao voltar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Ativando a foto que fica ao lado do botao voltar
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    // Criando um LayoutManager
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setReverseLayout(false);
    llm.setOrientation(LinearLayoutManager.VERTICAL);

    // Setando os atributos do RecyclerView
    // mRecyclerView.setScrollContainer(true);
    mRecyclerView.setHasFixedSize(
        true); // Informa que o tamanho do recyclerView não vai mudar, ajuda na otimização.
    mRecyclerView.setLayoutManager(llm); // Setando o layoutmanager no recyclerview

    // Criando e passando a lista de mensagens para o adapter
    chatAdapter = new ChatAdapter(mListMessage, this, this);

    // Setando o Adapter no RecyclerView
    mRecyclerView.setAdapter(chatAdapter);

    // Caso a lista de mensagem esteja vazia, esconde o textview com a frase
    if (this.mListMessage.size() > 0) {
      findViewById(R.id.empty).setVisibility(View.INVISIBLE);
      mRecyclerView.getLayoutManager().scrollToPosition(mListMessage.size() - 1);
    }
  }