@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_complete_info);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    if (bundle == null) {
      finish();
      return;
    } else {
      ORG_ID = bundle.getInt("id");
    }
    Log.i(TAG, String.valueOf(ORG_ID));
    setVars();
    nextUrl = nextUrl + ORG_ID;
    if (nextUrl.contains(" ")) {
      nextUrl = nextUrl.replaceAll(" ", "%20");
    }
    //        ***************** LOG.i *****************
    Log.i(TAG, nextUrl);
    new CompleteData().execute();

    floatingActionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            startActivity(new Intent(getApplicationContext(), NeedsList.class));
          }
        });
  }
  private void createMenuButton() {
    mMenuButton = new FloatingActionButton(getContext());

    mMenuButton.mShowShadow = mMenuShowShadow;
    if (mMenuShowShadow) {
      mMenuButton.mShadowRadius = Util.dpToPx(getContext(), mMenuShadowRadius);
      mMenuButton.mShadowXOffset = Util.dpToPx(getContext(), mMenuShadowXOffset);
      mMenuButton.mShadowYOffset = Util.dpToPx(getContext(), mMenuShadowYOffset);
    }
    mMenuButton.setColors(mMenuColorNormal, mMenuColorPressed, mMenuColorRipple);
    mMenuButton.mShadowColor = mMenuShadowColor;
    mMenuButton.mFabSize = mMenuFabSize;
    mMenuButton.updateBackground();

    mMenuButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            toggle(mIsAnimated);
          }
        });

    mImageToggle = new ImageView(getContext());
    mImageToggle.setImageDrawable(mIcon);

    addView(mMenuButton, super.generateDefaultLayoutParams());
    addView(mImageToggle);

    createDefaultIconAnimation();
  }
Exemplo n.º 3
0
  @Override
  public void setFloatActionButton() {
    // 今天按钮的操作
    today.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            //                Toast.makeText(MainActivity.this , "今天" , Toast.LENGTH_SHORT).show();
            mPresenter.startNewActivity(0);
            closeFloatActionButton();
          }
        });
    // 明天按钮的操作
    tomorrow.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPresenter.startNewActivity(1);
            closeFloatActionButton();
            //                Toast.makeText(MainActivity.this , "tomorrow" ,
            // Toast.LENGTH_SHORT).show();
          }
        });

    // 收集
    collection.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPresenter.startNewActivity(2);
            closeFloatActionButton();
            //                Toast.makeText(MainActivity.this, "collection",
            // Toast.LENGTH_SHORT).show();
          }
        });

    // 定制
    book.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPresenter.startNewActivity(3);
            closeFloatActionButton();
            //                Toast.makeText(MainActivity.this, "book", Toast.LENGTH_SHORT).show();
          }
        });
  }
Exemplo n.º 4
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View rootView = inflater.inflate(R.layout.blog_fragment_main, container, false);
   ButterKnife.inject(this, rootView);
   vpDate.setAdapter(new BlogFragmentListAdapter(getChildFragmentManager()));
   tabs.setViewPager(vpDate);
   tabs.setTextColor(Color.WHITE);
   tabs.setBackgroundColor(getResources().getColor(R.color.blue));
   write.setOnClickListener(v -> startActivity(new Intent(getActivity(), WriteActivity.class)));
   return rootView;
 }
Exemplo n.º 5
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Activity a = getActivity();

    questionList = (RecyclerView) a.findViewById(R.id.fragment_my_questions_list);
    text = (FloatingActionButton) a.findViewById(R.id.menu_item_text);
    image = (FloatingActionButton) a.findViewById(R.id.menu_item_image);
    video = (FloatingActionButton) a.findViewById(R.id.menu_item_video);

    final LinearLayoutManager layoutManager =
        new LinearLayoutManager(getActivity().getApplicationContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    questionList.setLayoutManager(layoutManager);

    questionList.setAdapter(new MyQuestionsListAdapter(getContext()));

    text.setOnClickListener(this);
    image.setOnClickListener(this);
    video.setOnClickListener(this);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    try {
      android.support.v7.app.ActionBar actionBar = getSupportActionBar();
      if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(false);
      }
    } catch (NullPointerException e) {
      e.printStackTrace();
    }

    Intent intent = getIntent();
    gagTitle = intent.getStringExtra(GAG_TITLE);
    gagURL = intent.getStringExtra(GAG_URL);
    file_ext = getIntent().getStringExtra(FILE_EXT);

    setContentView(R.layout.activity_display_recieved_image);
    bp = new BitmapProcessor(this, DisplayReceivedImage.this);

    final FloatingActionMenu fam = (FloatingActionMenu) findViewById(R.id.fam);
    FloatingActionButton save = (FloatingActionButton) findViewById(R.id.save);
    FloatingActionButton share = (FloatingActionButton) findViewById(R.id.share);
    FloatingActionButton changeTitle = (FloatingActionButton) findViewById(R.id.changeTitle);
    final FloatingActionButton changeSize = (FloatingActionButton) findViewById(R.id.changeSize);
    final TouchImageView mImageView = (TouchImageView) findViewById(R.id.imageViewPhoto);

    DiscreteSeekBar seekbar = (DiscreteSeekBar) findViewById(R.id.seekBar);
    final RelativeLayout sbc = (RelativeLayout) findViewById(R.id.seekBarContainer);
    sbc.setVisibility(View.INVISIBLE);

    changeSize.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            sbc.setVisibility(View.VISIBLE);
            changeSize.setEnabled(false);
          }
        });

    seekbar.setOnProgressChangeListener(
        new DiscreteSeekBar.OnProgressChangeListener() {
          @Override
          public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
            customPercent = value;
          }

          @Override
          public void onStartTrackingTouch(DiscreteSeekBar seekBar) {
            Toast.makeText(
                    context,
                    "Changes will take effect after releasing seek bar.",
                    Toast.LENGTH_SHORT)
                .show();
          }

          @Override
          public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
            fam.close(true);
            bp.cache(file_ext, mImageView, true, true);
          }
        });

    changeTitle.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            new MaterialDialog.Builder(context)
                .title("Change Title Text")
                .theme(Theme.DARK)
                .cancelable(false)
                .inputType(InputType.TYPE_CLASS_TEXT)
                .alwaysCallInputCallback()
                .negativeText("Cancel")
                .input(
                    "Title",
                    gagTitle,
                    new MaterialDialog.InputCallback() {
                      @Override
                      public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                        if (input.length() == 0) {
                          dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                          newGagTitle = "";
                        } else {
                          dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
                          newGagTitle = input.toString();
                        }
                      }
                    })
                .onPositive(
                    new MaterialDialog.SingleButtonCallback() {
                      @Override
                      public void onClick(
                          @NonNull MaterialDialog materialDialog,
                          @NonNull DialogAction dialogAction) {
                        if (!newGagTitle.equals("")) gagTitle = newGagTitle;
                        bp.cache(
                            file_ext, mImageView, !(customPercent == 5), !newGagTitle.equals(""));
                      }
                    })
                .show();
          }
        });

    save.setOnClickListener(this);
    share.setOnClickListener(this);

    photoURI =
        Uri.parse(
            getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + "/downloads/GAG" + file_ext);

    bp.cache(file_ext, mImageView, false, true);
  }
Exemplo n.º 7
0
  private void setupListeners() {

    // on Enter press on keyboard
    searchField.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0);
            genreSpinner.requestFocus();
            searchButton.callOnClick();
            return true;
          }
        });

    searchField.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) clear.setVisibility(View.VISIBLE);
            else clear.setVisibility(View.GONE);
          }

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

    clear.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            searchField.setText("");
          }
        });

    searchButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent result = new Intent(SearchActivity.this, ResultActivity.class);
            result.putExtra("query", searchField.getText().toString());
            result.putExtra(
                "quality",
                qualityRG.getCheckedRadioButtonId() == R.id.q_720p
                    ? "720p"
                    : qualityRG.getCheckedRadioButtonId() == R.id.q_1080p ? "1080p" : "3D");
            result.putExtra(
                "genre",
                getResources()
                    .getStringArray(R.array.genre_value)[genreSpinner.getSelectedItemPosition()]);
            result.putExtra(
                "sort",
                getResources()
                    .getStringArray(R.array.sort_value)[sortSpinner.getSelectedItemPosition()]);
            result.putExtra(
                "order", orderRG.getCheckedRadioButtonId() == R.id.asc ? "asc" : "desc");
            result.putExtra(
                "rating",
                getResources()
                    .getStringArray(R.array.rating_value)[ratingSpinner.getSelectedItemPosition()]);
            startActivity(result);
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    UserGuideDialog userGuideDialog = new UserGuideDialog(MainActivity.this, "homePage");

    initViews();

    // set OnClickListener for Floating Action Button
    mFabCamera.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addFromCamera();
          }
        });

    mFabGallery.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addFromGallery();
          }
        });

    // set OnItemClickListener for grid items
    mGridView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            BeaconMap beaconMap = (BeaconMap) parent.getItemAtPosition(position);
            onMapSelected(beaconMap);
          }
        });

    mGridView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(
              AdapterView<?> parent, View view, final int arg2, long arg3) {

            AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);

            alertDialog.setTitle("Confirm Delete...");

            // Setting Dialog Message
            alertDialog.setMessage("Are you sure you want delete this?");

            // Setting Icon to Dialog
            alertDialog.setIcon(R.drawable.delete);

            // Setting Positive "Yes" Button
            alertDialog.setPositiveButton(
                "YES",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {

                    deleteMap(arg2);
                    updateGridContent();
                  }
                });

            // Setting Negative "NO" Button
            alertDialog.setNegativeButton(
                "NO",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    // Write your code here to invoke NO event
                    dialog.cancel();
                  }
                });

            // Showing Alert Message
            alertDialog.show();

            return false;
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    activity = this;
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    ins = this;
    PreferenceManager.setDefaultValues(
        this, R.xml.pref_openaps, false); // Sets default OpenAPS Preferences if the user has not

    // xdrip start
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    checkEula();

    startService(new Intent(getApplicationContext(), DataCollectionService.class));
    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
    PreferenceManager.setDefaultValues(this, R.xml.pref_bg_notification, false);
    // xdrip end

    setContentView(R.layout.activity_main);

    // Setup menu
    menu1 = (FloatingActionMenu) findViewById(R.id.menu);
    FloatingActionButton menu_add_treatment =
        (FloatingActionButton) findViewById(R.id.menu_add_treatment);
    menu_add_treatment.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), EnterTreatment.class);
            startActivity(intent);
            menu1.close(true);
          }
        });
    FloatingActionButton menu_settings = (FloatingActionButton) findViewById(R.id.menu_settings);
    menu_settings.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
            menu1.close(true);
          }
        });
    FloatingActionButton menu_cancel_temp =
        (FloatingActionButton) findViewById(R.id.menu_cancel_temp);
    menu_cancel_temp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            pumpAction.cancelTempBasal(MainActivity.activity);
            menu1.close(true);
          }
        });

    // Create the adapter that will return a fragment for each of the 4 primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) this.findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    // mViewPager.setOffscreenPageLimit(4);
    // //Do not destroy any Fragments, // TODO: 14/09/2015 casues an issue with bvb chart rendering,
    // not sure why
    // Build Fragments
    openAPSFragmentObject = new openAPSFragment();
    iobcobActiveFragmentObject = new iobcobActiveFragment();
    iobcobFragmentObject = new iobcobFragment();
    basalvsTempBasalObject = new basalvsTempBasalFragment();

    // starts OpenAPS and Treatments loops
    startLoops();

    // RunsOpenAPS
    runOpenAPS(findViewById(android.R.id.content));

    // Get Recent Stats
    updateStats();
  }
Exemplo n.º 10
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Logger.v("onCreateView");
    View view = inflater.inflate(R.layout.fragment_thread_detail, container, false);

    mDetailListView = (XListView) view.findViewById(R.id.lv_thread_details);
    mDetailListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mTipBar = (TextView) view.findViewById(R.id.thread_detail_tipbar);
    mTipBar.bringToFront();

    mFam = (FloatingActionMenu) view.findViewById(R.id.multiple_actions);
    mFam.setVisibility(View.INVISIBLE);

    FloatingActionButton fabRefresh =
        (FloatingActionButton) view.findViewById(R.id.action_fab_refresh);
    fabRefresh.setImageDrawable(
        new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_refresh).color(Color.WHITE));
    fabRefresh.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mFam.close(true);
            mFloorOfPage = LAST_FLOOR;
            refresh();
          }
        });

    FloatingActionButton fabQuickReply =
        (FloatingActionButton) view.findViewById(R.id.action_fab_quick_reply);
    fabQuickReply.setImageDrawable(
        new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_reply).color(Color.WHITE));
    fabQuickReply.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mFam.close(false);
            mFam.setVisibility(View.INVISIBLE);
            quickReply.setVisibility(View.VISIBLE);
            quickReply.bringToFront();
            (new Handler())
                .postDelayed(
                    new Runnable() {
                      public void run() {
                        mReplyTextTv.requestFocus();
                        mReplyTextTv.dispatchTouchEvent(
                            MotionEvent.obtain(
                                SystemClock.uptimeMillis(),
                                SystemClock.uptimeMillis(),
                                MotionEvent.ACTION_DOWN,
                                0,
                                0,
                                0));
                        mReplyTextTv.dispatchTouchEvent(
                            MotionEvent.obtain(
                                SystemClock.uptimeMillis(),
                                SystemClock.uptimeMillis(),
                                MotionEvent.ACTION_UP,
                                0,
                                0,
                                0));
                      }
                    },
                    200);
          }
        });

    FloatingActionButton fabGotoPage =
        (FloatingActionButton) view.findViewById(R.id.action_fab_goto_page);
    fabGotoPage.setImageDrawable(
        new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_swap_horiz).color(Color.WHITE));
    fabGotoPage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mFam.close(true);
            showGotoPageDialog();
          }
        });

    if (!HiSettingsHelper.getInstance().getIsLandscape()) {
      mDetailListView.addHeaderView(inflater.inflate(R.layout.head_thread_detail, null));
      mTitleView = (TextView) view.findViewById(R.id.thread_detail_title);
      mTitleView.setTextSize(HiSettingsHelper.getTitleTextSize());
      mTitleView.setText(mTitle);
    }
    mDetailListView.setPullLoadEnable(false);
    mDetailListView.setPullRefreshEnable(false);
    mDetailListView.setXListViewListener(
        new XListView.IXListViewListener() {
          @Override
          public void onRefresh() {
            // Previous Page
            if (mCurrentPage > 1) {
              mCurrentPage--;
            }
            mDetailListView.stopRefresh();
            mFloorOfPage = LAST_FLOOR;
            showOrLoadPage();
            quickReply.setVisibility(View.INVISIBLE);
          }

          @Override
          public void onLoadMore() {
            // Next Page
            if (mCurrentPage < mMaxPage) {
              mCurrentPage++;
            }
            mDetailListView.stopLoadMore();
            showOrLoadPage();
          }
        });

    final GestureDetector.SimpleOnGestureListener listener =
        new GestureDetector.SimpleOnGestureListener() {
          @Override
          public boolean onDoubleTap(MotionEvent e) {
            if (mDetailListView.isFastScrollEnabled()) {
              mDetailListView.setFastScrollEnabled(false);
              mDetailListView.setFastScrollAlwaysVisible(false);
            } else {
              mDetailListView.setFastScrollEnabled(true);
              mDetailListView.setFastScrollAlwaysVisible(true);
            }
            return true;
          }
        };

    final GestureDetector detector = new GestureDetector(mCtx, listener);
    detector.setOnDoubleTapListener(listener);

    mDetailListView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (mFam.isOpened()) {
              mFam.close(false);
            }
            return detector.onTouchEvent(event);
          }
        });

    quickReply = view.findViewById(R.id.quick_reply);
    mReplyTextTv = (TextView) quickReply.findViewById(R.id.tv_reply_text);
    mReplyTextTv.setTextSize(HiSettingsHelper.getPostTextSize());
    mPostReplyIb = (ImageButton) quickReply.findViewById(R.id.ib_reply_post);
    mPostReplyIb.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String replyText = mReplyTextTv.getText().toString();
            if (replyText.length() < 5) {
              Toast.makeText(getActivity(), "字数必须大于5", Toast.LENGTH_LONG).show();
            } else {
              mReplyTextTv.setText("");
              quickReply.setVisibility(View.INVISIBLE);
              PostBean postBean = new PostBean();
              postBean.setContent(replyText);
              postBean.setTid(mTid);
              new PostAsyncTask(
                      getActivity(),
                      PostAsyncTask.MODE_QUICK_REPLY,
                      null,
                      ThreadDetailFragment.this)
                  .execute(postBean);
              // Close SoftKeyboard
              InputMethodManager imm =
                  (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(mReplyTextTv.getWindowToken(), 0);
              mFam.setVisibility(View.VISIBLE);
            }
          }
        });

    return view;
  }
Exemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_feed);

    gps = new GPSTracker(this);

    toolbar = (Toolbar) findViewById(R.id.toolBarFeed);
    setSupportActionBar(toolbar);

    Display mdisp = getWindowManager().getDefaultDisplay();
    Point mdispSize = new Point();
    mdisp.getSize(mdispSize);
    int maxX = mdispSize.x;
    int maxY = mdispSize.y;

    float dpPadding = convertDpToPixel(20, MainFeedActivity.this);

    pivotX = maxX - (int) dpPadding;
    pivotY = maxY - (int) dpPadding;

    mPager = (ViewPager) findViewById(R.id.loginPagerMain);
    mPager.setAdapter(new MainPagerAdapter(getFragmentManager()));
    mPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            // TODO: scale Floating Action Button size
            Log.d("POSITION_OFFSET", positionOffset + "");
            Log.d("POS_OFFSET_VIEW", whichView + "");
            Log.d("JUST_POS", position + "");

            if (positionOffset < 0.5) {
              if (whichView) {
                //
                // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryColorDark)));

              } else {
                //
                // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor)));
              }
              //                    fabMainFeed.setScaleX((1 - 2 * positionOffset));
              //                    fabMainFeed.setScaleY((1 - 2 * positionOffset));

            } else {

              //
              // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryColorDark)));
              //                    fabMainFeed.setScaleX((2 * positionOffset - 1));
              //                    fabMainFeed.setScaleY((2 * positionOffset - 1));
            }
          }

          @Override
          public void onPageSelected(int position) {
            whichView = !whichView;
          }

          @Override
          public void onPageScrollStateChanged(int state) {
            if (state == ViewPager.SCROLL_STATE_IDLE) {
              // Hide the keyboard.
              ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                  .hideSoftInputFromWindow(mPager.getWindowToken(), 0);
            }
          }
        });

    mTabs = (SlidingTabLayout) findViewById(R.id.loginTabsMain);
    mTabs.setCustomTabView(R.layout.custom_tab_view_main, R.id.mainTabsText);
    mTabs.setDistributeEvenly(true);
    mTabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.primaryColorLight);
          }
        });
    mTabs.setViewPager(mPager);

    navigationView = (NavigationView) findViewById(R.id.navigationView);
    navigationView.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {

            menuItem.setChecked(false);

            mNavItemId = menuItem.getItemId();
            drawerLayout.closeDrawers();

            switch (mNavItemId) {
              case R.id.navProfile:
                Intent profIntent = new Intent(MainFeedActivity.this, ProfileActivity.class);
                startActivity(profIntent);
                return true;
              case R.id.navSettings:
                Intent settingsIntent = new Intent(MainFeedActivity.this, SettingsActivity.class);
                startActivity(settingsIntent);
                return true;
            }
            return false;
          }
        });

    fabMenu = (FloatingActionMenu) findViewById(R.id.fabMenu);
    fabCurrentLocation =
        (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabCurrentLocation);
    fabPickLocation =
        (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabPickLocation);
    fabAirport = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabAirport);

    fabCurrentLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });

    fabPickLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainFeedActivity.this, FSPickLocActivity.class);
            startActivity(intent);
          }
        });

    fabAirport.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });

    //        fabMainFeed = (FloatingActionButton) findViewById(R.id.fabMainFeed);
    //        fabMainFeed.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //
    //                // TODO: expand the FAB to give three options, each launching a different
    // intent
    //                // Can use whichView boolean value to launch the right intent by assigning
    //                // OnClickListener to the 3 options and check the whichView boolean in each
    //
    //                if (whichView) {
    //                    Toast.makeText(MainFeedActivity.this, "SECOND INTENT",
    // Toast.LENGTH_LONG).show();
    //                    Intent intent = new Intent(MainFeedActivity.this,
    // AddForSalePostActivity.class);
    //                    startActivity(intent);
    //
    //                } else {
    //                    Toast.makeText(MainFeedActivity.this, "FIRST INTENT",
    // Toast.LENGTH_LONG).show();
    //                    Intent intent = new Intent(MainFeedActivity.this,
    // AddForSalePostActivity.class);
    //                    startActivity(intent);
    //                }
    //            }
    //        });

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, drawerLayout, toolbar, R.string.openDrawer, R.string.closeDrawer);
    drawerLayout.setDrawerListener(mDrawerToggle);

    toolbar.setTitle("Browse");
    toolbar.setTitleTextColor(getResources().getColor(R.color.whiteColor));
    mPager.setCurrentItem(0);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    Intent data = getIntent();
    earthWallpaper = (EarthWallpaper) data.getExtras().getSerializable(WALLPAPER_OBJECT);
    // setTheme(R.style.AppTheme_NoActionBar);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
      setTheme(R.style.AppTheme_NoActionBar);
    }
    setContentView(R.layout.activity_wallpaper);

    downloadDialog = new BaseDialog(this).getDownloadDialog();

    if (!downloadDir.exists()) {
      boolean created = downloadDir.mkdir();
      Log.d("WallpaperActivity", "Download directory didn't exist : creation -> " + created);
    }

    if (!Preferences.exists()) Preferences.init(this);

    downloadDir = new File(Preferences.getInstance().getWallpaperDownloadDirectory());

    rootLayout = (CoordinatorLayout) findViewById(R.id.wallpaper_coordinator_root);
    collapsingToolbarLayout =
        (CollapsingToolbarLayout) findViewById(R.id.wallpaper_collapsing_toolbar);
    // collapsingToolbarLayout.setExpandedTitleTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
    collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.FullscreenTextPreview);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_details_view);
    toolbar.setTitle(earthWallpaper.getFormattedWallpaperTitle());
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // set and load the appbar image
    appBarImage = (ImageView) findViewById(R.id.wall_preview);
    Picasso.with(this).load(earthWallpaper.getWallThumbUrl()).into(appBarImage);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      appBarImage.setTransitionName(data.getExtras().getString(IMAGE_TRANSITION_NAME));
      // toolbar.setTransitionName(data.getExtras().getString(TEXT_TRANSITION_NAME));
    }

    // assigning the information to the views
    cityTextView = (TextView) findViewById(R.id.details_location_text);
    if (earthWallpaper.getWallpaperRegion() == null) {
      cityTextView.setText(R.string.details_unknown);
    } else {
      cityTextView.setText(earthWallpaper.getWallpaperRegion());
    }
    countryTextView = (TextView) findViewById(R.id.details_country_text);
    if (earthWallpaper.getWallpaperCountry() == null) {
      countryTextView.setText(R.string.details_unknown);
    } else {
      countryTextView.setText(earthWallpaper.getWallpaperCountry());
    }
    coordinatesTextView = (TextView) findViewById(R.id.details_coords_text);
    coordinatesTextView.setText(getFormattedCoordinates());

    // setting the google maps layout stuff
    googleMapsLayout = (RelativeLayout) findViewById(R.id.gmaps_nav_layout);
    googleMapsLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent googleMaps =
                new Intent(Intent.ACTION_VIEW, Uri.parse(earthWallpaper.getGoogleMapsUrl()));
            startActivity(googleMaps);
          }
        });
    googleMapsHintTextView = (TextView) findViewById(R.id.details_gmaps_link_icon_text);
    googleMapsHintTextView.setText(earthWallpaper.getGoogleMapsTitle());

    final int[] c = {0};
    attributionLayout = (RelativeLayout) findViewById(R.id.details_attribution_layout);
    attributionLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            c[0]++;
            if (c[0] >= 20) unlock = true;
          }
        });

    attributionTextView = (TextView) findViewById(R.id.details_attribution_text);
    if (earthWallpaper.getWallpaperAttribution() == null) {
      attributionTextView.setText(R.string.details_unknown);
    } else {
      attributionTextView.setText(earthWallpaper.getWallpaperAttribution());
    }

    shareLinkLayout = (RelativeLayout) findViewById(R.id.share_link_layout);
    shareLinkLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShow();
          }
        });

    shareLinkTextView = (TextView) findViewById(R.id.details_share_link_text);
    shareLinkTextView.setText(earthWallpaper.getShareUrl());

    // inflating the fab menu and it's entries
    floatingActionMenu = (FloatingActionMenu) findViewById(R.id.details_fab_menu);
    floatingActionMenu.setClosedOnTouchOutside(true);

    floatingActionShare = (FloatingActionButton) findViewById(R.id.fab_item_share);
    floatingActionShare.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_share_variant)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionShare.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShare();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionApply = (FloatingActionButton) findViewById(R.id.fab_item_apply);
    floatingActionApply.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_check)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionApply.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Snackbar.make(rootLayout, "Applying is coming soon!", Snackbar.LENGTH_SHORT).show();
            onSetAsWallpaper();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionArchive = (FloatingActionButton) findViewById(R.id.fab_item_archive);
    if (Preferences.getInstance().isFavorite(earthWallpaper)) {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart_outline)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(
          getResources().getString(R.string.fab_menu_item_remove_archive));
    } else {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(getResources().getString(R.string.fab_menu_item_archive));
    }
    floatingActionArchive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(false);

            if (Preferences.getInstance().isFavorite(earthWallpaper)) {
              Preferences.getInstance().removeFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_removed, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            } else {
              Preferences.getInstance().addFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart_outline)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_remove_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_added, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            }
          }
        });

    floatingActionDownload = (FloatingActionButton) findViewById(R.id.fab_item_download);
    floatingActionDownload.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_download)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionDownload.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
            if (Preferences.getInstance().canWriteExternalStorage()) {
              new DownloadWallpaperTask(
                      WallpaperActivityPre.this,
                      Preferences.getInstance().getWallpaperDownloadDir(),
                      earthWallpaper)
                  .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, unlock);
            } else {
              Preferences.getInstance()
                  .requestExternalStoragePermission(
                      WallpaperActivityPre.this, WallpaperActivityPre.this, false);
            }
          }
        });

    // EarthView.withGoogle().getEarthWallpaper(earthWallpaper.getWallpaperId(), this);
    new DownloadHighResImage(this, earthWallpaper, this)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    setTypefaces();
  }
Exemplo n.º 13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_journalcreate);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Parse API codes
    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    Parse.initialize(
        this,
        "GDqpaudUzxIubXTzJTXko0i062wWxqLK1AJSzD2K",
        "KHiJQsUdQYQcZVtxTCuFM6MmbQGKcIGEW1idXmC0");

    // Parse test
    // ParseObject testObject = new ParseObject("TestObject");
    // testObject.put("foo", "bar");
    // testObject.saveInBackground();

    final EditText jTitle = (EditText) findViewById(R.id.journal_title);
    final EditText jCompose = (EditText) findViewById(R.id.journal_compose);
    final Button btnSave = (Button) findViewById(R.id.btn_save_journal);
    menu1 = (FloatingActionMenu) findViewById(R.id.menu1);
    fab1 = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fab1);
    fab2 = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fab2);
    fab3 = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fab3);

    // Text to string
    journalTitle = jTitle.getText().toString();
    journalCompose = jCompose.getText().toString();

    // Click listeners

    fab1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Snackbar.make(v, "Reminder dialog pop up", Snackbar.LENGTH_SHORT)
                .setAction("Setup", null)
                .show();
          }
        });
    fab2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent view = new Intent(Journalcreate.this, Journal.class);
            startActivity(view);
          }
        });
    fab3.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent create = new Intent(Journalcreate.this, Natahome.class);
            startActivity(create);
          }
        });

    // journal save button
    btnSave.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            ParseObject journalObject = new ParseObject("journal");
            journalObject.put("JournalTitle", journalTitle);
            journalObject.put("JournalBody", journalCompose);
            journalObject.saveInBackground();

            Snackbar.make(v, "Journal saved to Parse", Snackbar.LENGTH_LONG).show();
          }
        });
  }