Search in sources :

Example 91 with RelativeLayout

use of android.widget.RelativeLayout in project Android-NotesApp by HelloPraveen.

the class BinActivity method onCreate.

@TargetApi(Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bin);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(BinActivity.this);
    premium = preferences.getInt("premium", 0);
    interstitialAd = new InterstitialAd(BinActivity.this);
    interstitialAd.setAdUnitId("ca-app-pub-8429477298745270/2004640333");
    interstitialAd.loadAd(new AdRequest.Builder().build());
    i = new Intent(BinActivity.this, MainActivity.class);
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
    Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
    SpannableStringBuilder SS = new SpannableStringBuilder("Trash");
    SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(SS);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    final BinDatabaseHandler db = new BinDatabaseHandler(this);
    l = db.getAllNotes();
    final RecyclerView recyclerView = findViewById(R.id.binRecyclerView);
    final RelativeLayout rl = findViewById(R.id.binPlaceholder);
    if (l.isEmpty()) {
        recyclerView.setVisibility(View.GONE);
        rl.setVisibility(View.VISIBLE);
    }
    NoteAdapter mAdapter = new NoteAdapter(l);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
    recyclerView.setAdapter(mAdapter);
    recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), new ClickListener() {

        @Override
        public void onClick(View view, final int position) {
            final Note note = l.get(position);
            final String mNote = note.getNote();
            final int mStar = note.getStar();
            final String mDate = note.getDate();
            final String mTitle = note.getTitle();
            new MaterialStyledDialog.Builder(BinActivity.this).setIcon(R.drawable.ic_settings_backup_restore).setDescription("You may choose to restore your note or delete it permanently!").setPositiveText("DELETE").onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    BinDatabaseHandler db = new BinDatabaseHandler(BinActivity.this);
                    List<Note> l2 = db.getAllNotes();
                    final Note note2 = l2.get(position);
                    db.deleteNote(note2);
                    i.putExtra("note", true);
                    i.putExtra("delete", true);
                    if (interstitialAd.isLoaded() && premium != 1) {
                        interstitialAd.show();
                        interstitialAd.setAdListener(new AdListener() {

                            @Override
                            public void onAdClosed() {
                                startActivity(i);
                                finish();
                            }
                        });
                    } else {
                        startActivity(i);
                        finish();
                    }
                }
            }).setNegativeText("RESTORE").onNegative(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    BinDatabaseHandler db = new BinDatabaseHandler(BinActivity.this);
                    DatabaseHandler db2 = new DatabaseHandler(BinActivity.this);
                    db2.addNote(new Note(mNote, mDate, mStar, mTitle));
                    List<Note> l2 = db.getAllNotes();
                    final Note note2 = l2.get(position);
                    db.deleteNote(note2);
                    i.putExtra("note", true);
                    i.putExtra("restore", true);
                    if (interstitialAd.isLoaded() && premium != 1) {
                        interstitialAd.show();
                        interstitialAd.setAdListener(new AdListener() {

                            @Override
                            public void onAdClosed() {
                                startActivity(i);
                                finish();
                            }
                        });
                    } else {
                        startActivity(i);
                        finish();
                    }
                }
            }).setNeutralText("DISMISS").onNeutral(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                }
            }).setHeaderColor(R.color.colorPrimary).withIconAnimation(false).withDivider(true).show();
        }
    }));
}
Also used : BinDatabaseHandler(io.praveen.typenote.SQLite.BinDatabaseHandler) SpannableStringBuilder(android.text.SpannableStringBuilder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) BinDatabaseHandler(io.praveen.typenote.SQLite.BinDatabaseHandler) DatabaseHandler(io.praveen.typenote.SQLite.DatabaseHandler) NoteAdapter(io.praveen.typenote.SQLite.NoteAdapter) InterstitialAd(com.google.android.gms.ads.InterstitialAd) List(java.util.List) ClickListener(io.praveen.typenote.SQLite.ClickListener) RecyclerTouchListener(io.praveen.typenote.SQLite.RecyclerTouchListener) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SharedPreferences(android.content.SharedPreferences) Typeface(android.graphics.Typeface) Intent(android.content.Intent) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) AdListener(com.google.android.gms.ads.AdListener) DialogAction(com.afollestad.materialdialogs.DialogAction) Note(io.praveen.typenote.SQLite.Note) RelativeLayout(android.widget.RelativeLayout) RecyclerView(android.support.v7.widget.RecyclerView) SpannableStringBuilder(android.text.SpannableStringBuilder) TargetApi(android.annotation.TargetApi)

Example 92 with RelativeLayout

use of android.widget.RelativeLayout in project androidApp by InspectorIncognito.

the class BusIconsBuilder method setupEventIconImage.

private void setupEventIconImage(View view, int id, ServerSentEvent event) {
    RelativeLayout layout = view.findViewById(id);
    layout.setVisibility(View.VISIBLE);
    ((ImageView) layout.findViewById(R.id.report_image)).setImageDrawable(ContextCompat.getDrawable(view.getContext(), event.getResDrawableId()));
    ((TextView) layout.findViewById(R.id.report_number)).setText(String.format(Locale.getDefault(), "%d", event.getConfirms()));
}
Also used : RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 93 with RelativeLayout

use of android.widget.RelativeLayout in project Custom-Navigation-Drawer by shrikanth7698.

the class SNavigationDrawer method initMenu.

protected void initMenu() {
    for (int i = 0; i < menuItemList.size(); i++) {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.menu_row_item, null);
        TextView titleTV = view.findViewById(R.id.titleTV);
        TextView titleTV1 = view.findViewById(R.id.titleTV1);
        ImageView backgroundIV = view.findViewById(R.id.backgroundIV);
        CardView backgroundCV = view.findViewById(R.id.backgroundCV);
        View tintView = (View) view.findViewById(R.id.tintView);
        tintView.setBackgroundColor(menuItemSemiTransparentColor);
        titleTV.setTextColor(secondaryMenuItemTextColor);
        titleTV1.setTextColor(primaryMenuItemTextColor);
        titleTV.setTextSize(secondaryMenuItemTextSize);
        titleTV1.setTextSize(primaryMenuItemTextSize);
        final RelativeLayout rootRL = view.findViewById(R.id.rootRL);
        backgroundCV.setTag("cv" + i);
        System.out.println("Testing " + backgroundCV.getTag());
        titleTV.setTag("tv" + i);
        if (i >= 1) {
            backgroundCV.setVisibility(View.GONE);
            backgroundCV.animate().translationX(rootRL.getX() - backgroundCV.getWidth()).setDuration(1).start();
            titleTV.setVisibility(View.VISIBLE);
        }
        rootRL.setTag(i);
        rootRL.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (currentPos != Integer.valueOf(view.getTag().toString())) {
                    final CardView backCV1 = (CardView) menuLL.findViewWithTag("cv" + currentPos);
                    final TextView title1 = (TextView) menuLL.findViewWithTag("tv" + currentPos);
                    backCV1.animate().translationX(rootRL.getX() - backCV1.getWidth()).setDuration(300).start();
                    currentPos = Integer.valueOf(view.getTag().toString());
                    menuItemClicked(currentPos);
                    appbarTitleTV.setText(menuItemList.get(currentPos).getTitle());
                    final CardView backCV = (CardView) menuLL.findViewWithTag("cv" + currentPos);
                    final TextView title = (TextView) menuLL.findViewWithTag("tv" + currentPos);
                    backCV.setVisibility(View.INVISIBLE);
                    System.out.println("Drawer Testing " + backCV.getTag());
                    backCV.animate().translationX(rootRL.getX() - backCV.getWidth()).setDuration(1).start();
                    backCV.animate().translationX(rootRL.getX()).setDuration(300).start();
                    backCV.setVisibility(View.VISIBLE);
                    title.setVisibility(View.GONE);
                    final Handler handler1 = new Handler();
                    handler1.postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            backCV1.setVisibility(View.GONE);
                            title1.setVisibility(View.VISIBLE);
                        }
                    }, 300);
                    // Close Navigation Drawer
                    closeDrawer();
                } else {
                    menuItemClicked(currentPos);
                    closeDrawer();
                }
            }
        });
        backgroundIV.setImageDrawable(getContext().getDrawable(menuItemList.get(i).getImageId()));
        titleTV.setText(menuItemList.get(i).getTitle());
        titleTV1.setText(menuItemList.get(i).getTitle());
        menuLL.addView(view);
    }
}
Also used : CardView(android.support.v7.widget.CardView) RelativeLayout(android.widget.RelativeLayout) Handler(android.os.Handler) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CardView(android.support.v7.widget.CardView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 94 with RelativeLayout

use of android.widget.RelativeLayout in project iNaturalistAndroid by inaturalist.

the class CommentsIdsAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final Resources res = mContext.getResources();
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View view = inflater.inflate(mIsNewLayout ? R.layout.comment_id_item_obs_viewer : R.layout.comment_id_item, parent, false);
    final BetterJSONObject item = mItems.get(position);
    try {
        final TextView comment = (TextView) view.findViewById(R.id.comment);
        RelativeLayout idLayout = (RelativeLayout) view.findViewById(R.id.id_layout);
        final RelativeLayout idAgreeLayout = (RelativeLayout) view.findViewById(R.id.id_agree_container);
        TextView postedOn = (TextView) view.findViewById(R.id.posted_on);
        final String username = item.getJSONObject("user").getString("login");
        Timestamp postDate = item.getTimestamp("updated_at");
        if (postDate == null)
            postDate = item.getTimestamp("created_at");
        if (mIsNewLayout) {
            postedOn.setText(String.format(res.getString(item.getString("type").equals("comment") ? R.string.comment_title : R.string.id_title), username, formatIdDate(mContext, postDate)));
        } else {
            SimpleDateFormat format = new SimpleDateFormat("LLL d, yyyy");
            postedOn.setText(String.format(res.getString(R.string.posted_by), (mLogin != null) && username.equalsIgnoreCase(mLogin) ? res.getString(R.string.you) : username, format.format(postDate)));
        }
        OnClickListener showUser = new OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, UserProfile.class);
                intent.putExtra("user", new BetterJSONObject(item.getJSONObject("user")));
                mContext.startActivity(intent);
            }
        };
        final ImageView userPic = (ImageView) view.findViewById(R.id.user_pic);
        JSONObject user = item.getJSONObject("user");
        String userIconUrl = user.optString("user_icon_url", user.optString("icon"));
        boolean hasUserIcon = userIconUrl != null;
        userPic.setOnClickListener(showUser);
        postedOn.setOnClickListener(showUser);
        if (hasUserIcon) {
            Picasso.with(mContext).load(userIconUrl).fit().centerCrop().placeholder(R.drawable.ic_account_circle_black_24dp).transform(new UserActivitiesAdapter.CircleTransform()).into(userPic, new Callback() {

                @Override
                public void onSuccess() {
                // Nothing to do here
                }

                @Override
                public void onError() {
                }
            });
        } else {
            if (mIsNewLayout) {
                userPic.setAlpha(100);
            }
        }
        final ImageView moreMenu = (ImageView) view.findViewById(R.id.more_menu);
        final boolean isComment = item.getString("type").equals("comment");
        final View loading = view.findViewById(R.id.loading);
        final DialogInterface.OnClickListener onClick = new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int which) {
                switch(which) {
                    case R.id.restore:
                        loading.setVisibility(View.VISIBLE);
                        mOnIDAddedCb.onIdentificationRestored(item);
                        break;
                    case R.id.delete:
                        // Display deletion confirmation dialog
                        mHelper.confirm(mContext.getString(isComment ? R.string.delete_comment : R.string.delete_id), isComment ? R.string.delete_comment_message : R.string.delete_id_message, new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                loading.setVisibility(View.VISIBLE);
                                if (isComment) {
                                    mOnIDAddedCb.onCommentRemoved(item);
                                } else {
                                    mOnIDAddedCb.onIdentificationRemoved(item);
                                }
                            }
                        }, new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                            }
                        }, R.string.yes, R.string.no);
                        break;
                    case R.id.edit:
                        if (isComment) {
                            mOnIDAddedCb.onCommentUpdated(item);
                        } else {
                            mOnIDAddedCb.onIdentificationUpdated(item);
                        }
                }
            }
        };
        if (moreMenu != null) {
            moreMenu.setVisibility(View.GONE);
            moreMenu.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (loading.getVisibility() == View.VISIBLE) {
                        return;
                    }
                    int menuResource = isComment && username.equalsIgnoreCase(mLogin) ? R.menu.comment_menu : R.menu.id_menu;
                    boolean restoreId = false;
                    if (menuResource == R.menu.id_menu) {
                        Boolean isCurrent = item.getBoolean("current");
                        if (((isCurrent == null) || (!isCurrent)) && (username.equalsIgnoreCase(mLogin))) {
                            restoreId = true;
                        }
                    }
                    Menu popupMenu;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                        PopupMenu popup = new PopupMenu(getContext(), moreMenu);
                        popup.getMenuInflater().inflate(menuResource, popup.getMenu());
                        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                            @Override
                            public boolean onMenuItemClick(android.view.MenuItem menuItem) {
                                onClick.onClick(null, menuItem.getItemId());
                                return true;
                            }
                        });
                        popupMenu = popup.getMenu();
                        popup.show();
                    } else {
                        BottomSheet sheet = new BottomSheet.Builder((Activity) mContext).sheet(menuResource).listener(onClick).show();
                        popupMenu = sheet.getMenu();
                    }
                    if (restoreId) {
                        // Show restore ID menu option
                        popupMenu.getItem(0).setVisible(false);
                        popupMenu.getItem(1).setVisible(true);
                    } else {
                        // Show withdraw ID menu option
                        popupMenu.getItem(0).setVisible(true);
                        popupMenu.getItem(1).setVisible(false);
                    }
                }
            });
        }
        if (item.getString("type").equals("comment")) {
            // Comment
            comment.setVisibility(View.VISIBLE);
            idLayout.setVisibility(View.GONE);
            loading.setVisibility(View.GONE);
            if (moreMenu != null)
                moreMenu.setVisibility(View.VISIBLE);
            if (mIsNewLayout)
                idAgreeLayout.setVisibility(View.GONE);
            comment.setText(Html.fromHtml(item.getString("body")));
            Linkify.addLinks(comment, Linkify.ALL);
            comment.setMovementMethod(LinkMovementMethod.getInstance());
            if (mIsNewLayout) {
                postedOn.setTextColor(postedOn.getTextColors().withAlpha(255));
                if (hasUserIcon)
                    userPic.setAlpha(255);
            }
        } else {
            // Identification
            idLayout.setVisibility(View.VISIBLE);
            String body = item.getString("body");
            if (body != null && body.length() > 0) {
                comment.setText(Html.fromHtml(body));
                Linkify.addLinks(comment, Linkify.ALL);
                comment.setMovementMethod(LinkMovementMethod.getInstance());
                comment.setVisibility(View.VISIBLE);
                if (!mIsNewLayout) {
                    ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) comment.getLayoutParams();
                    layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + 25, layoutParams.rightMargin, layoutParams.bottomMargin);
                    comment.setLayoutParams(layoutParams);
                }
            } else {
                comment.setVisibility(View.GONE);
            }
            ImageView idPic = (ImageView) view.findViewById(R.id.id_pic);
            JSONObject taxonObject = item.getJSONObject("taxon");
            JSONObject defaultPhoto = taxonObject.optJSONObject("default_photo");
            if (defaultPhoto != null) {
                UrlImageViewHelper.setUrlDrawable(idPic, taxonObject.optString("image_url", defaultPhoto.optString("square_url")), R.drawable.iconic_taxon_unknown);
            } else {
                idPic.setImageResource(R.drawable.iconic_taxon_unknown);
            }
            TextView idName = (TextView) view.findViewById(R.id.id_name);
            idName.setText(TaxonUtils.getTaxonName(mContext, item.getJSONObject("taxon")));
            TextView idTaxonName = (TextView) view.findViewById(R.id.id_taxon_name);
            idTaxonName.setText(TaxonUtils.getTaxonScientificName(item.getJSONObject("taxon")));
            int rankLevel = item.getJSONObject("taxon").optInt("rank_level");
            idTaxonName.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
            if (rankLevel <= 20) {
                idTaxonName.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC));
            }
            Boolean isCurrent = item.getBoolean("current");
            if ((isCurrent == null) || (!isCurrent)) {
                // An outdated identification - show as faded-out
                idName.setTextColor(idName.getTextColors().withAlpha(100));
                idTaxonName.setTextColor(idTaxonName.getTextColors().withAlpha(100));
                if (!mIsNewLayout)
                    postedOn.setTextColor(postedOn.getTextColors().withAlpha(100));
                idPic.setAlpha(100);
                userPic.setAlpha(100);
            } else {
                idName.setTextColor(idName.getTextColors().withAlpha(255));
                idTaxonName.setTextColor(idTaxonName.getTextColors().withAlpha(255));
                if (!mIsNewLayout)
                    postedOn.setTextColor(postedOn.getTextColors().withAlpha(255));
                idPic.setAlpha(255);
                if (hasUserIcon)
                    userPic.setAlpha(255);
            }
            final View agree = view.findViewById(R.id.id_agree);
            agree.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if ((mLogin != null) && (username.equalsIgnoreCase(mLogin))) {
                        mOnIDAddedCb.onIdentificationRemoved(item);
                    } else {
                        mOnIDAddedCb.onIdentificationAdded(item);
                        mTaxonId = item.getInt("taxon_id");
                    }
                    loading.setVisibility(View.VISIBLE);
                    if (!mIsNewLayout) {
                        agree.setVisibility(View.GONE);
                    }
                    mAgreeing.set(position, true);
                }
            });
            loading.setVisibility(View.GONE);
            // See if there's ID of the same taxon before this one
            int currentTaxonId = item.getInt("taxon_id");
            boolean foundPreviousSameTaxon = false;
            for (int i = 0; i < position; i++) {
                BetterJSONObject taxon = mItems.get(i);
                Integer taxonId = taxon.getInt("taxon_id");
                if ((taxonId != null) && (taxonId == currentTaxonId)) {
                    foundPreviousSameTaxon = true;
                    break;
                }
            }
            boolean didNotIdThisBefore = true;
            for (int i = 0; i < mItems.size(); i++) {
                if (mLogin == null)
                    break;
                if (i == position)
                    continue;
                BetterJSONObject taxon = mItems.get(i);
                if ((taxon.getJSONObject("user").getString("login").equalsIgnoreCase(mLogin))) {
                    Integer taxonId = taxon.getInt("taxon_id");
                    if ((taxonId != null) && (taxonId == currentTaxonId) && (taxon.getBoolean("current"))) {
                        // Agreed on the current taxon type before
                        didNotIdThisBefore = false;
                        break;
                    }
                }
            }
            if (!foundPreviousSameTaxon && didNotIdThisBefore) {
                // show agree button
                if (mIsNewLayout) {
                    idAgreeLayout.setVisibility(View.VISIBLE);
                } else {
                    agree.setVisibility(View.VISIBLE);
                }
            } else {
                // Second (or more) taxon id of its kind - don't show agree button
                if (mIsNewLayout) {
                    idAgreeLayout.setVisibility(View.GONE);
                } else {
                    agree.setVisibility(View.GONE);
                }
            }
            if (moreMenu != null)
                moreMenu.setVisibility(View.GONE);
            if ((mLogin != null) && (username.equalsIgnoreCase(mLogin))) {
                if (!mIsNewLayout) {
                    ((Button) agree).setText(R.string.remove);
                    agree.setVisibility(View.VISIBLE);
                } else {
                    idAgreeLayout.setVisibility(View.GONE);
                    if (moreMenu != null)
                        moreMenu.setVisibility(View.VISIBLE);
                }
                if ((isCurrent == null) || (!isCurrent)) {
                    // Faded IDs should not have a "Remove" button
                    if (mIsNewLayout) {
                        idAgreeLayout.setVisibility(View.GONE);
                    } else {
                        agree.setVisibility(View.GONE);
                    }
                }
            } else {
                if (!mIsNewLayout)
                    ((Button) agree).setText(R.string.agree);
            }
            if ((mAgreeing.get(position) != null) && (mAgreeing.get(position) == true)) {
                loading.setVisibility(View.VISIBLE);
                if (!mIsNewLayout) {
                    agree.setVisibility(View.GONE);
                } else {
                    idAgreeLayout.setVisibility(View.GONE);
                }
            }
            if (mLogin == null) {
                // Can't agree if not logged in
                if (!mIsNewLayout) {
                    agree.setVisibility(View.GONE);
                } else {
                    idAgreeLayout.setVisibility(View.GONE);
                }
            }
            if (mIsNewLayout) {
                OnClickListener listener = new OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        Intent intent = new Intent(mContext, TaxonActivity.class);
                        JSONObject taxon = mItems.get(position).getJSONObject("taxon");
                        intent.putExtra(TaxonActivity.TAXON, new BetterJSONObject(taxon));
                        intent.putExtra(TaxonActivity.OBSERVATION, mObservation);
                        intent.putExtra(TaxonActivity.DOWNLOAD_TAXON, true);
                        mContext.startActivity(intent);
                    }
                };
                idLayout.setOnClickListener(listener);
                idName.setOnClickListener(listener);
                idTaxonName.setOnClickListener(listener);
            }
            boolean isActive = item.getJSONObject("taxon").optBoolean("is_active", true);
            ViewGroup taxonInactive = (ViewGroup) view.findViewById(R.id.taxon_inactive);
            taxonInactive.setVisibility(isActive ? View.GONE : View.VISIBLE);
            if (!isActive) {
                idTaxonName.setPaintFlags(idTaxonName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
                idName.setPaintFlags(idTaxonName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            }
            taxonInactive.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    INaturalistApp app = (INaturalistApp) mContext.getApplicationContext();
                    String inatNetwork = app.getInaturalistNetworkMember();
                    String inatHost = app.getStringResourceByName("inat_host_" + inatNetwork);
                    Locale deviceLocale = mContext.getResources().getConfiguration().locale;
                    String deviceLanguage = deviceLocale.getLanguage();
                    String taxonUrl = String.format("%s/taxon_changes?taxon_id=%d&locale=%s", inatHost, item.getInt("taxon_id"), deviceLanguage);
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(taxonUrl));
                    mContext.startActivity(i);
                }
            });
        }
        if (moreMenu != null) {
            if ((mLogin == null) || ((mLogin != null) && (!username.equalsIgnoreCase(mLogin)))) {
                moreMenu.setVisibility(View.GONE);
            }
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    view.setTag(item);
    if (!mIsNewLayout)
        view.setOnClickListener(this);
    return view;
}
Also used : Locale(java.util.Locale) DialogInterface(android.content.DialogInterface) Timestamp(java.sql.Timestamp) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) ViewGroup(android.view.ViewGroup) JSONException(org.json.JSONException) Intent(android.content.Intent) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint) UrlImageViewCallback(com.koushikdutta.urlimageviewhelper.UrlImageViewCallback) Callback(com.squareup.picasso.Callback) JSONObject(org.json.JSONObject) LayoutInflater(android.view.LayoutInflater) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) Resources(android.content.res.Resources) BottomSheet(com.cocosw.bottomsheet.BottomSheet) SimpleDateFormat(java.text.SimpleDateFormat) PopupMenu(android.widget.PopupMenu)

Example 95 with RelativeLayout

use of android.widget.RelativeLayout in project GeometricWeather by WangDaYeeeeee.

the class MainActivity method initWidget.

private void initWidget() {
    this.handler = new SafeHandler<>(this);
    this.statusBar = findViewById(R.id.activity_main_statusBar);
    this.weatherView = findViewById(R.id.activity_main_weatherView);
    if (weatherView instanceof MaterialWeatherView) {
        int kind;
        if (locationNow.weather == null) {
            kind = WeatherView.WEATHER_KIND_CLEAR_DAY;
        } else {
            kind = WeatherViewController.getWeatherViewWeatherKind(locationNow.weather.realTime.weatherKind, TimeManager.getInstance(this).isDayTime());
        }
        weatherView.setWeather(kind);
        ((MaterialWeatherView) weatherView).setOpenGravitySensor(PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.key_gravity_sensor_switch), true));
    }
    this.appBar = findViewById(R.id.activity_main_appBar);
    this.toolbar = findViewById(R.id.activity_main_toolbar);
    toolbar.inflateMenu(R.menu.activity_main);
    toolbar.setNavigationOnClickListener(this);
    toolbar.setOnClickListener(this);
    toolbar.setOnMenuItemClickListener(this);
    this.switchLayout = findViewById(R.id.activity_main_switchView);
    switchLayout.setData(locationList, locationNow);
    switchLayout.setOnSwitchListener(this);
    switchLayout.setOnTouchListener(indicatorStateListener);
    this.refreshLayout = findViewById(R.id.activity_main_refreshView);
    int startPosition = (int) (DisplayUtils.getStatusBarHeight(getResources()) + DisplayUtils.dpToPx(this, 16));
    refreshLayout.setProgressViewOffset(false, startPosition, startPosition + refreshLayout.getProgressViewEndOffset());
    refreshLayout.setOnRefreshListener(this);
    if (weatherView instanceof MaterialWeatherView) {
        refreshLayout.setColorSchemeColors(weatherView.getThemeColors()[0]);
    }
    this.scrollView = findViewById(R.id.activity_main_scrollView);
    scrollView.setOnScrollChangeListener(new OnScrollListener(weatherView.getFirstCardMarginTop()));
    scrollView.setOnTouchListener(indicatorStateListener);
    this.cardContainer = findViewById(R.id.activity_main_cardContainer);
    RelativeLayout baseView = findViewById(R.id.container_main_base_view);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) baseView.getLayoutParams();
    params.height = weatherView.getFirstCardMarginTop();
    baseView.setLayoutParams(params);
    baseView.setOnClickListener(this);
    this.realtimeTemp = findViewById(R.id.container_main_base_view_tempTxt);
    this.realtimeWeather = findViewById(R.id.container_main_base_view_weatherTxt);
    this.realtimeSendibleTemp = findViewById(R.id.container_main_base_view_sendibleTempTxt);
    this.aqiOrWind = findViewById(R.id.container_main_base_view_aqiOrWindTxt);
    findViewById(R.id.container_main_trend_first_card_timeContainer).setOnClickListener(this);
    this.timeIcon = findViewById(R.id.container_main_trend_first_card_timeIcon);
    timeIcon.setOnClickListener(this);
    this.refreshTime = findViewById(R.id.container_main_trend_first_card_timeText);
    this.firstTitle = findViewById(R.id.container_main_trend_first_card_title);
    this.firstTrendRecyclerView = findViewById(R.id.container_main_trend_first_card_trendRecyclerView);
    this.secondTitle = findViewById(R.id.container_main_trend_second_card_title);
    this.secondTrendRecyclerView = findViewById(R.id.container_main_trend_second_card_trendRecyclerView);
    this.detailsTitle = findViewById(R.id.container_main_details_card_title);
    this.detailRecyclerView = findViewById(R.id.container_main_details_card_recyclerView);
    this.indicator = findViewById(R.id.activity_main_indicator);
}
Also used : RelativeLayout(android.widget.RelativeLayout) MaterialWeatherView(wangdaye.com.geometricweather.ui.widget.weatherView.materialWeatherView.MaterialWeatherView) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout)

Aggregations

RelativeLayout (android.widget.RelativeLayout)396 TextView (android.widget.TextView)180 View (android.view.View)164 ImageView (android.widget.ImageView)109 LinearLayout (android.widget.LinearLayout)67 ViewGroup (android.view.ViewGroup)61 Intent (android.content.Intent)31 AdapterView (android.widget.AdapterView)29 Button (android.widget.Button)29 FrameLayout (android.widget.FrameLayout)28 SuppressLint (android.annotation.SuppressLint)26 LayoutInflater (android.view.LayoutInflater)22 OnClickListener (android.view.View.OnClickListener)22 ScrollView (android.widget.ScrollView)22 Paint (android.graphics.Paint)20 CardView (android.support.v7.widget.CardView)19 Context (android.content.Context)18 Point (android.graphics.Point)18 ListView (android.widget.ListView)18 RadioButton (android.widget.RadioButton)17