Search in sources :

Example 66 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project Taskzilla by CMPUT301W18T05.

the class ViewTaskActivity method thePinkButton.

/**
 *@param view pretty much the page it's on
 * @author myapplestory
 * thePinkButton
 * upon pressing place button on task page
 * prompts user to enter in a bid amount
 * if valid input, will add bid to task
 *
 * notes
 * can probably add more stuff to dialog
 */
public void thePinkButton(android.view.View view) {
    final AlertDialog mBuilder = new AlertDialog.Builder(ViewTaskActivity.this).create();
    final View mView = getLayoutInflater().inflate(R.layout.dialog_place_bid, null);
    final EditText incomingBidText = mView.findViewById(R.id.place_bid_edittext);
    // Taken from https://gist.github.com/gaara87/3607765
    // 2018-03-19
    // Limits the number of decimals allowed in input
    incomingBidText.setFilters(new InputFilter[] { new DigitsKeyListener(Boolean.FALSE, Boolean.TRUE) {

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            StringBuilder builder = new StringBuilder(dest);
            builder.insert(dstart, source);
            String temp = builder.toString();
            if (temp.contains(".")) {
                temp = temp.substring(temp.indexOf(".") + 1);
                if (temp.length() > 2) {
                    return "";
                }
            }
            return super.filter(source, start, end, dest, dstart, dend);
        }
    } });
    // bring up keyboard when user taps place bid
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    final Button submitBidButton = mView.findViewById(R.id.submit_bid_button);
    submitBidButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Float incomingBidFloat;
            try {
                incomingBidFloat = Float.parseFloat(incomingBidText.getText().toString());
                incomingBidFloat = (float) (Math.round(incomingBidFloat * 100.0) / 100.0);
            } catch (Exception exception) {
                Toast.makeText(ViewTaskActivity.this, "Please enter in a valid bid amount", Toast.LENGTH_SHORT).show();
                return;
            }
            // do stuff here to actually add bid
            task.addBid(new Bid(currentUserId, taskID, incomingBidFloat));
            task.setStatus("bidded");
            TaskStatus.setText("bidded");
            Toast.makeText(ViewTaskActivity.this, "Bid placed", Toast.LENGTH_SHORT).show();
            // hide keyboard upon pressing button
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(submitBidButton.getWindowToken(), 0);
            mBuilder.dismiss();
        }
    });
    mBuilder.setView(mView);
    mBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DigitsKeyListener(android.text.method.DigitsKeyListener) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) TextView(android.widget.TextView) ExpandableListView(android.widget.ExpandableListView) Spanned(android.text.Spanned) ImageButton(android.widget.ImageButton) Button(android.widget.Button) Bid(com.cmput301w18t05.taskzilla.Bid)

Example 67 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project TamTime by flyingrub.

the class SearchView method getView.

public View getView(ViewGroup parent) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header_home, parent, false);
    RecyclerView.LayoutManager layoutManager = new org.solovyev.android.views.llm.LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
    researchRecyclerView = (RecyclerView) view.findViewById(R.id.result);
    researchRecyclerView.setLayoutManager(layoutManager);
    researchRecyclerView.setItemAnimator(new DefaultItemAnimator());
    researchRecyclerView.setHasFixedSize(false);
    researchRecyclerView.swapAdapter(null, true);
    search = (EditText) view.findViewById(R.id.search_text);
    search.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                new SearchAsync().execute(search.getText().toString());
                return true;
            }
            return false;
        }
    });
    search.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean b) {
            search.setCursorVisible(b);
        }
    });
    search.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().length() == 0) {
                researchRecyclerView.swapAdapter(null, true);
            } else {
                new SearchAsync().execute(s.toString());
            }
        }
    });
    return view;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 68 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project xDrip by NightscoutFoundation.

the class ProfileEditor method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mContext = this;
    doMgdl = (Pref.getString("units", "mgdl").equals("mgdl"));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile_editor);
    undoBtn = (Button) findViewById(R.id.profileUndoBtn);
    saveBtn = (Button) findViewById(R.id.profileSaveBtn);
    adjustallSeekBar = (SeekBar) findViewById(R.id.profileAdjustAllseekBar);
    adjustPercentage = (TextView) findViewById(R.id.profileAdjustAllPercentage);
    profileItemList.addAll(loadData(true));
    // Toolbar toolbar = (Toolbar) findViewById(R.id.profile_toolbar);
    // setSupportActionBar(toolbar);
    JoH.fixActionBar(this);
    // TODO add menu in xml
    adjustallSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            adjustmentFactor = 1 + ((progress - 25) * 0.02);
            adjustPercentage.setText(JoH.qs(adjustmentFactor * 100, 0) + "%");
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            profileItemList.clear();
            // we must preserve the existing object reference used by the adapter
            profileItemList.addAll(loadData(false));
            // allow autosliding scales downwards
            mAdapter.resetTopMax();
            // does temporary save
            forceRefresh(true);
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.profile_recycler_view);
    mAdapter = new ProfileAdapter(this, profileItemList, doMgdl);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    if (profileItemList.size() == 0) {
        profileItemList.add(new ProfileItem(0, END_OF_DAY, JoH.tolerantParseDouble(Pref.getString("profile_carb_ratio_default", "10")), JoH.tolerantParseDouble(Pref.getString("profile_insulin_sensitivity_default", "0.1"))));
    }
    updateAdjustmentFactor(1.0);
    shuffleFit();
    mAdapter.registerAdapterDataObserver(// handle incoming messages from the adapater
    new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            super.onChanged();
        // Log.d(TAG, "onChanged");
        }

        @Override
        public void onItemRangeChanged(final int positionStart, int itemCount, Object payload) {
            super.onItemRangeChanged(positionStart, itemCount, payload);
            Log.d(TAG, "onItemRangeChanged: pos:" + positionStart + " cnt:" + itemCount + " p: " + payload.toString());
            if (payload.toString().equals("time start updated")) {
                if (positionStart > 0) {
                    // did we encroach on previous item end or open up a gap??
                    if ((profileItemList.get(positionStart - 1).end_min != profileItemList.get(positionStart).start_min - 1)) {
                        profileItemList.get(positionStart - 1).end_min = profileItemList.get(positionStart).start_min - 1;
                    }
                } else {
                    // if setting the first start time also mirror this to the last end time
                    // 
                    profileItemList.get(profileItemList.size() - 1).end_min = profileItemList.get(positionStart).start_min - 1;
                }
                forceRefresh();
            } else if (payload.toString().equals("time end updated")) {
                // don't apply gap calcualtion to last item when end changes
                if (positionStart < profileItemList.size() - 1) {
                    // for all blocks other than the final one
                    if ((profileItemList.get(positionStart + 1).start_min != profileItemList.get(positionStart).end_min + 1)) {
                        profileItemList.get(positionStart + 1).start_min = profileItemList.get(positionStart).end_min + 1;
                    }
                } else {
                    // if setting the last end time also mirror this to the first start time
                    // 
                    profileItemList.get(0).start_min = profileItemList.get(positionStart).end_min + 1;
                }
                forceRefresh();
            // split or delete
            } else if (payload.toString().equals("long-split")) {
                final DisplayMetrics dm = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(dm);
                final int screen_width = dm.widthPixels;
                final int screen_height = dm.heightPixels;
                boolean small_screen = false;
                // smaller screens or lower version don't seem to play well with long dialog button names
                if ((screen_width < 720) || (screen_height < 720) || ((Build.VERSION.SDK_INT < Build.VERSION_CODES.M)))
                    small_screen = true;
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
                alertDialogBuilder.setMessage(R.string.split_delete_or_do_nothing);
                alertDialogBuilder.setPositiveButton(small_screen ? getString(R.string.split) : getString(R.string.split_this_block_in_two), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        ProfileItem old_item = profileItemList.get(positionStart);
                        ProfileItem new_item;
                        if (old_item.start_min < old_item.end_min) {
                            // no wrapping time
                            new_item = new ProfileItem(old_item.end_min - (old_item.end_min - old_item.start_min) / 2, old_item.end_min, old_item.carb_ratio, old_item.sensitivity);
                        } else {
                            // wraps around
                            new_item = new ProfileItem(old_item.end_min - ((old_item.end_min - MINS_PER_DAY) - old_item.start_min) / 2, old_item.end_min, old_item.carb_ratio, old_item.sensitivity);
                        }
                        old_item.end_min = new_item.start_min - 1;
                        profileItemList.add(positionStart + 1, new_item);
                        forceRefresh();
                    }
                });
                if (profileItemList.size() > 1) {
                    alertDialogBuilder.setNeutralButton(small_screen ? getString(R.string.delete) : getString(R.string.delete_this_time_block), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            profileItemList.remove(positionStart);
                            forceRefresh();
                        }
                    });
                }
                alertDialogBuilder.setNegativeButton(small_screen ? getString(R.string.cancel) : getString(R.string.cancel_do_nothing), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
                AlertDialog alertDialog = alertDialogBuilder.create();
                alertDialog.show();
            } else {
                // for other non special changes
                forceRefresh();
            }
        }
    });
    DefaultItemAnimator animator = new DefaultItemAnimator() {

        @Override
        public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) {
            return true;
        }
    };
    recyclerView.setItemAnimator(animator);
    recyclerView.setAdapter(mAdapter);
    mAdapter.notifyDataSetChanged();
    showcasemenu(SHOWCASE_PROFILE_SPLIT);
}
Also used : AlertDialog(android.app.AlertDialog) SeekBar(android.widget.SeekBar) DialogInterface(android.content.DialogInterface) GsonBuilder(com.google.gson.GsonBuilder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DisplayMetrics(android.util.DisplayMetrics) Point(android.graphics.Point) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView)

Example 69 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project xDrip-plus by jamorham.

the class LanguageAdapter method onCreateViewHolder.

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.language_list_row, parent, false);
    final MyViewHolder holder = new MyViewHolder(itemView);
    // allow ime-done on multiline
    holder.local_text.setHorizontallyScrolling(false);
    holder.local_text.setMaxLines(100);
    holder.elementUndo.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            LanguageAdapter.this.notifyItemChanged(holder.position, "undo");
            return true;
        }
    });
    holder.local_text.setOnEditorActionListener(new EditText.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                informThisRowChanged(holder, v);
            }
            return handled;
        }
    });
    holder.local_text.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus == false) {
            informThisRowChanged(holder, (TextView) v);
        }
    });
    /*   holder.local_text.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) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                final int pos = holder.getAdapterPosition();
                // has it actually changed or was this recycle element just reused?
                if (!languageList.get(pos).local_text.equals(s.toString()))
                {
                    Log.d(TAG,"afterTextChanged: "+pos+" :"+s+":"+languageList.get(pos).local_text);
                    LanguageAdapter.this.notifyItemChanged(pos, new LanguageItem(languageList.get(pos).item_name, languageList.get(pos).english_text, s.toString()));

                }
             }
        });
*/
    return holder;
}
Also used : EditText(android.widget.EditText) KeyEvent(android.view.KeyEvent) TextView(android.widget.TextView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 70 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project xDrip-plus by jamorham.

the class Home method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mActivity = this;
    if (!xdrip.checkAppContext(getApplicationContext())) {
        toast("Unusual internal context problem - please report");
        Log.wtf(TAG, "xdrip.checkAppContext FAILED!");
        try {
            xdrip.initCrashlytics(getApplicationContext());
            Crashlytics.log("xdrip.checkAppContext FAILED!");
        } catch (Exception e) {
        // nothing we can do really
        }
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
        // not much to do
        }
        if (!xdrip.checkAppContext(getApplicationContext())) {
            toast("Cannot start - please report context problem");
            finish();
        }
    }
    if (Build.VERSION.SDK_INT < 17) {
        JoH.static_toast_long("xDrip+ will not work below Android version 4.2");
        finish();
    }
    xdrip.checkForcedEnglish(Home.this);
    super.onCreate(savedInstanceState);
    // for toolbar mode
    setTheme(R.style.AppThemeToolBarLite);
    Injectors.getHomeShelfComponent().inject(this);
    if (!Experience.gotData()) {
        homeShelf.set("source_wizard", true);
        homeShelf.set("source_wizard_auto", true);
    }
    set_is_follower();
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    final boolean checkedeula = checkEula();
    binding = ActivityHomeBinding.inflate(getLayoutInflater());
    binding.setVs(homeShelf);
    binding.setHome(this);
    binding.setUi(ui);
    setContentView(binding.getRoot());
    Toolbar mToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(mToolbar);
    mToolbar.setLongClickable(true);
    mToolbar.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // show configurator
            final ActivityHomeShelfSettingsBinding binding = ActivityHomeShelfSettingsBinding.inflate(getLayoutInflater());
            final Dialog dialog = new Dialog(v.getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            binding.setVs(homeShelf);
            dialog.setContentView(binding.getRoot());
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.show();
            return false;
        }
    });
    // findViewById(R.id.home_layout_holder).setBackgroundColor(getCol(X.color_home_chart_background));
    this.dexbridgeBattery = (TextView) findViewById(R.id.textBridgeBattery);
    this.parakeetBattery = (TextView) findViewById(R.id.parakeetbattery);
    this.sensorAge = (TextView) findViewById(R.id.libstatus);
    this.extraStatusLineText = (TextView) findViewById(R.id.extraStatusLine);
    this.currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
    this.bpmButton = (Button) findViewById(R.id.bpmButton);
    this.stepsButton = (Button) findViewById(R.id.walkButton);
    extraStatusLineText.setText("");
    dexbridgeBattery.setText("");
    parakeetBattery.setText("");
    sensorAge.setText("");
    if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        this.currentBgValueText.setTextSize(100);
    }
    this.notificationText = (TextView) findViewById(R.id.notices);
    if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        this.notificationText.setTextSize(40);
    }
    is_newbie = Experience.isNewbie();
    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) && checkedeula) {
        if (Experience.installedForAtLeast(5 * Constants.MINUTE_IN_MS)) {
            checkBatteryOptimization();
        }
    }
    // jamorham voice input et al
    this.voiceRecognitionText = (TextView) findViewById(R.id.treatmentTextView);
    this.textBloodGlucose = (TextView) findViewById(R.id.textBloodGlucose);
    this.textCarbohydrates = (TextView) findViewById(R.id.textCarbohydrate);
    this.textInsulinDose = (TextView) findViewById(R.id.textInsulinUnits);
    this.textTime = (TextView) findViewById(R.id.textTimeButton);
    this.btnBloodGlucose = (ImageButton) findViewById(R.id.bloodTestButton);
    this.btnCarbohydrates = (ImageButton) findViewById(R.id.buttonCarbs);
    this.btnInsulinDose = (ImageButton) findViewById(R.id.buttonInsulin);
    this.btnCancel = (ImageButton) findViewById(R.id.cancelTreatment);
    this.btnApprove = (ImageButton) findViewById(R.id.approveTreatment);
    this.btnTime = (ImageButton) findViewById(R.id.timeButton);
    this.btnUndo = (ImageButton) findViewById(R.id.btnUndo);
    this.btnRedo = (ImageButton) findViewById(R.id.btnRedo);
    this.btnVehicleMode = (ImageButton) findViewById(R.id.vehicleModeButton);
    hideAllTreatmentButtons();
    if (searchWords == null) {
        initializeSearchWords("");
    }
    this.btnSpeak = (ImageButton) findViewById(R.id.btnTreatment);
    btnSpeak.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            promptTextInput();
        }
    });
    btnSpeak.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            promptSpeechInput();
            return true;
        }
    });
    this.btnNote = (ImageButton) findViewById(R.id.btnNote);
    btnNote.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
                showNoteTextInputDialog(v, 0);
            } else {
                promptSpeechNoteInput(v);
            }
            return false;
        }
    });
    btnNote.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
                showNoteTextInputDialog(v, 0);
            } else {
                promptSpeechNoteInput(v);
            }
        }
    });
    btnCancel.setOnClickListener(new View.OnClickListener() {

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

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

        @Override
        public void onClick(View v) {
            // proccess and approve treatment
            textInsulinDose.setVisibility(View.INVISIBLE);
            btnInsulinDose.setVisibility(View.INVISIBLE);
            Treatments.create(0, thisinsulinnumber, Treatments.getTimeStampWithOffset(thistimeoffset));
            thisinsulinnumber = 0;
            reset_viewport = true;
            if (hideTreatmentButtonsIfAllDone()) {
                updateCurrentBgInfo("insulin button");
            }
        }
    });
    btnCarbohydrates.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // proccess and approve treatment
            textCarbohydrates.setVisibility(View.INVISIBLE);
            btnCarbohydrates.setVisibility(View.INVISIBLE);
            reset_viewport = true;
            Treatments.create(thiscarbsnumber, 0, Treatments.getTimeStampWithOffset(thistimeoffset));
            thiscarbsnumber = 0;
            if (hideTreatmentButtonsIfAllDone()) {
                updateCurrentBgInfo("carbs button");
            }
        }
    });
    btnBloodGlucose.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            reset_viewport = true;
            processCalibration();
        }
    });
    btnTime.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // clears time if clicked
            textTime.setVisibility(View.INVISIBLE);
            btnTime.setVisibility(View.INVISIBLE);
            if (hideTreatmentButtonsIfAllDone()) {
                updateCurrentBgInfo("time button");
            }
        }
    });
    final DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int screen_width = dm.widthPixels;
    int screen_height = dm.heightPixels;
    if (screen_width <= 320) {
        small_width = true;
        small_screen = true;
    }
    if (screen_height <= 320) {
        small_height = true;
        small_screen = true;
    }
    // final int refdpi = 320;
    Log.d(TAG, "Width height: " + screen_width + " " + screen_height + " DPI:" + dm.densityDpi);
    JoH.fixActionBar(this);
    try {
        getSupportActionBar().setTitle(R.string.app_name);
    } catch (NullPointerException e) {
        Log.e(TAG, "Couldn't set title due to null pointer");
    }
    activityVisible = true;
    statusReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            final String bwp = intent.getStringExtra("bwp");
            if (bwp != null) {
                statusBWP = bwp;
                refreshStatusLine();
            } else {
                final String iob = intent.getStringExtra("iob");
                if (iob != null) {
                    statusIOB = iob;
                    refreshStatusLine();
                }
            }
        }
    };
    // handle incoming extras
    final Bundle bundle = getIntent().getExtras();
    processIncomingBundle(bundle);
    checkBadSettings();
    // lower priority
    PlusSyncService.startSyncService(getApplicationContext(), "HomeOnCreate");
    ParakeetHelper.notifyOnNextCheckin(false);
    if (checkedeula && (!getString(R.string.app_name).equals("xDrip+"))) {
        showcasemenu(SHOWCASE_VARIANT);
    }
    if (checkedeula && is_newbie && ((dialog == null) || !dialog.isShowing())) {
        if (!SdcardImportExport.handleBackup(this)) {
            if (!Pref.getString("units", "mgdl").equals("mmol")) {
                Log.d(TAG, "Newbie mmol prompt");
                if (Experience.defaultUnitsAreMmol()) {
                    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.setTitle(R.string.glucose_units_mmol_or_mgdl);
                    builder.setMessage(R.string.is_your_typical_glucose_value);
                    builder.setNegativeButton("5.5", new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            Pref.setString("units", "mmol");
                            Preferences.handleUnitsChange(null, "mmol", null);
                            Home.staticRefreshBGCharts();
                            toast(getString(R.string.settings_updated_to_mmol));
                        }
                    });
                    builder.setPositiveButton("100", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Home.staticRefreshBGCharts();
                            dialog.dismiss();
                        }
                    });
                    dialog = builder.create();
                    dialog.show();
                }
            }
        }
    }
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) ActivityHomeShelfSettingsBinding(com.eveningoutpost.dexdrip.databinding.ActivityHomeShelfSettingsBinding) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) BgGraphBuilder(com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) BroadcastReceiver(android.content.BroadcastReceiver) LineChartView(lecho.lib.hellocharts.view.LineChartView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) PreviewLineChartView(lecho.lib.hellocharts.view.PreviewLineChartView) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics) IOException(java.io.IOException) ParseException(java.text.ParseException) ActivityNotFoundException(android.content.ActivityNotFoundException) Paint(android.graphics.Paint) Point(android.graphics.Point) ColorDrawable(android.graphics.drawable.ColorDrawable) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

View (android.view.View)367 RecyclerView (android.support.v7.widget.RecyclerView)271 TextView (android.widget.TextView)175 Intent (android.content.Intent)109 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)84 Toolbar (android.support.v7.widget.Toolbar)77 TextWatcher (android.text.TextWatcher)77 Editable (android.text.Editable)76 ImageView (android.widget.ImageView)76 ArrayList (java.util.ArrayList)68 Bundle (android.os.Bundle)48 DialogInterface (android.content.DialogInterface)47 AlertDialog (android.support.v7.app.AlertDialog)47 AdapterView (android.widget.AdapterView)46 EditText (android.widget.EditText)42 SuppressLint (android.annotation.SuppressLint)39 Button (android.widget.Button)39 ActionBar (android.support.v7.app.ActionBar)34 List (java.util.List)34 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)33