Example usage for android.widget ListView setDivider

List of usage examples for android.widget ListView setDivider

Introduction

In this page you can find the example usage for android.widget ListView setDivider.

Prototype

public void setDivider(@Nullable Drawable divider) 

Source Link

Document

Sets the drawable that will be drawn between each item in the list.

Usage

From source file:com.gsma.rcs.ri.messaging.OneToOneTalkView.java

private void initialize() throws RcsGenericException, RcsServiceNotAvailableException {
    mCtx = this;/*from w  ww  .  ja va2s .c  om*/
    /* Set send button listener */
    Button sendBtn = (Button) findViewById(R.id.send_button);
    sendBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            sendText();
        }
    });
    mHandler = new Handler();
    mClearUndeliveredChat = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Set<String> msgIds = SingleChatIntentService.getUndelivered(mCtx, mContact);
            if (!msgIds.isEmpty()) {
                try {
                    if (LogUtils.isActive) {
                        Log.d(LOGTAG, "Clear delivery expiration for IDs=" + msgIds);
                    }
                    mChatService.clearMessageDeliveryExpiration(msgIds);

                } catch (RcsServiceException e) {
                    showException(e);
                } finally {
                    mClearUndeliveredAlertDialog = null;
                }
            }
        }
    };
    mUndeliveredCancelListener = new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mClearUndeliveredAlertDialog = null;
        }
    };
    mClearUndeliveredFt = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                Set<String> transferIds = FileTransferIntentService.getUndelivered(mCtx, mContact);
                if (!transferIds.isEmpty()) {
                    if (LogUtils.isActive) {
                        Log.d(LOGTAG, "Clear delivery expiration for IDs=" + transferIds);
                    }
                    mFileTransferService.clearFileTransferDeliveryExpiration(transferIds);
                    mClearUndeliveredAlertDialog = null;
                }
            } catch (RcsServiceException e) {
                showException(e);
            } finally {
                mClearUndeliveredAlertDialog = null;
            }
        }
    };

    mChatListener = new OneToOneChatListener() {

        /* Callback called when an Is-composing event has been received */
        @Override
        public void onComposingEvent(ContactId contact, boolean status) {
            /* Discard event if not for current contact */
            if (!contact.equals(mContact)) {
                return;
            }
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onComposingEvent contact=" + contact + " status=" + status);
            }
            displayComposingEvent(contact, status);
        }

        @Override
        public void onMessageStatusChanged(ContactId contact, String mimeType, String msgId,
                ChatLog.Message.Content.Status status, ChatLog.Message.Content.ReasonCode reasonCode) {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onMessageStatusChanged contact=" + contact + " mime-type=" + mimeType + " msgId="
                        + msgId + " status=" + status);
            }
        }

        @Override
        public void onMessagesDeleted(ContactId contact, Set<String> msgIds) {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onMessagesDeleted contact=" + contact + " for IDs=" + msgIds);
            }
        }

    };
    mFileTransferListener = new OneToOneFileTransferListener() {
        @Override
        public void onStateChanged(ContactId contact, String transferId, FileTransfer.State state,
                FileTransfer.ReasonCode reasonCode) {
            if (!contact.equals(mContact)) {
                return;
            }
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onStateChanged contact=" + contact + " transferId=" + transferId + " state="
                        + state + " reason=" + reasonCode);
            }
            if (FileTransfer.State.TRANSFERRED == state) {
                try {
                    FileTransfer fileTransfer = mFileTransferService.getFileTransfer(transferId);
                    if (fileTransfer == null) {
                        return;
                    }
                    if (Utils.isAudioType(fileTransfer.getMimeType())
                            && FileTransfer.Disposition.RENDER == fileTransfer.getDisposition()) {
                        Utils.playAudio(OneToOneTalkView.this, fileTransfer.getFile());
                        mFileTransferService.markFileTransferAsRead(transferId);
                    }
                } catch (RcsPersistentStorageException | RcsServiceNotAvailableException
                        | RcsGenericException e) {
                    showException(e);
                }
            }
        }

        @Override
        public void onProgressUpdate(ContactId contact, String transferId, long currentSize, long totalSize) {
        }

        @Override
        public void onDeleted(ContactId contact, Set<String> transferIds) {
        }
    };
    mChatService = getChatApi();
    mCapabilityService = getCapabilityApi();
    mFileTransferService = getFileTransferApi();

    HistoryUriBuilder uriBuilder = new HistoryUriBuilder(HistoryLog.CONTENT_URI);
    uriBuilder.appendProvider(ChatLog.Message.HISTORYLOG_MEMBER_ID);
    uriBuilder.appendProvider(FileTransferLog.HISTORYLOG_MEMBER_ID);
    mUriHistoryProvider = uriBuilder.build();

    mComposeText = (EditText) findViewById(R.id.userText);
    ChatServiceConfiguration configuration = mChatService.getConfiguration();
    // Set max label length
    int maxMsgLength = configuration.getOneToOneChatMessageMaxLength();
    if (maxMsgLength > 0) {
        /* Set the message composer max length */
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(maxMsgLength);
        mComposeText.setFilters(filterArray);
    }
    IsComposingManager.INotifyComposing iNotifyComposing = new IsComposingManager.INotifyComposing() {
        public void setTypingStatus(boolean isTyping) {
            try {
                if (mChat == null) {
                    return;
                }
                mChat.setComposingStatus(isTyping);
                if (LogUtils.isActive) {
                    Boolean _isTyping = isTyping;
                    Log.d(LOGTAG, "sendIsComposingEvent ".concat(_isTyping.toString()));
                }
            } catch (RcsGenericException e) {
                showException(e);
            }
        }
    };
    /* Instantiate the composing manager */
    mComposingManager = new IsComposingManager(configuration.getIsComposingTimeout(), iNotifyComposing);
    mComposeText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // Check if the text is not null.
            // we do not wish to consider putting the edit text back to null
            // (like when sending message), is having activity
            if (!TextUtils.isEmpty(s)) {
                // Warn the composing manager that we have some activity
                if (mComposingManager != null) {
                    mComposingManager.hasActivity();
                }
            }
        }

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

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

    /* Initialize the adapter. */
    mAdapter = new TalkCursorAdapter(this, true, mChatService, mFileTransferService);

    /* Associate the list adapter with the ListView. */
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setDivider(null);
    listView.setAdapter(mAdapter);
    registerForContextMenu(listView);
}

From source file:com.mobicage.rogerthat.plugins.messaging.FriendsThreadActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.message_thread);

    _1_DP_IN_PX = UIUtils.convertDipToPixels(this, 1);
    _4_DP_IN_PX = UIUtils.convertDipToPixels(this, 4);
    _20_DP_IN_PX = UIUtils.convertDipToPixels(this, 20);
    _42_DP_IN_PX = UIUtils.convertDipToPixels(this, 42);

    mRenderedMessages = new HashSet<>();
    final Intent intent = getIntent();
    mParentMessageKey = intent.getStringExtra(PARENT_MESSAGE_KEY);
    mFlags = intent.getLongExtra(MESSAGE_FLAGS, 0);
    ListView listView = (ListView) findViewById(R.id.thread_messages);
    setListView(listView);//from w ww.ja  v  a 2s  .c o m
    mScroller = Scroller.getInstance();
    listView.setDivider(null);
    listView.setVerticalScrollBarEnabled(false);
    mScroller.setListView(listView);

    final IntentFilter filter1 = new IntentFilter();
    for (String action : getAllReceivingIntents()) {
        filter1.addAction(action);
    }
    registerReceiver(getDefaultBroadcastReceiver(), filter1);

    IntentFilter filter2 = new IntentFilter(MessagingPlugin.NEW_MESSAGE_QUEUED_TO_BACKLOG_INTENT);
    filter2.addAction(MessagingPlugin.THREAD_DELETED_INTENT);
    filter2.addAction(BrandingMgr.ATTACHMENT_AVAILABLE_INTENT);
    filter2.addAction(MessagingPlugin.THREAD_MODIFIED_INTENT);
    filter2.addAction(FriendsPlugin.FRIEND_INFO_RECEIVED_INTENT);
    filter2.addAction(SystemPlugin.ASSET_AVAILABLE_INTENT);
    registerReceiver(mReceiver, filter2);
}

From source file:de.j4velin.mapsmeasure.Map.java

@SuppressLint("NewApi")
@Override/* ww  w . j a  v  a2 s .co m*/
public void onCreate(final Bundle savedInstanceState) {
    try {
        super.onCreate(savedInstanceState);
    } catch (final BadParcelableException bpe) {
        bpe.printStackTrace();
    }
    setContentView(R.layout.activity_map);

    formatter_no_dec.setMaximumFractionDigits(0);
    formatter_two_dec.setMaximumFractionDigits(2);

    final SharedPreferences prefs = getSharedPreferences("settings", Context.MODE_PRIVATE);

    // use metric a the default everywhere, except in the US
    metric = prefs.getBoolean("metric", !Locale.getDefault().equals(Locale.US));

    final View topCenterOverlay = findViewById(R.id.topCenterOverlay);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    final View menuButton = findViewById(R.id.menu);
    if (menuButton != null) {
        menuButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {
                mDrawerLayout.openDrawer(GravityCompat.START);
            }
        });
    }

    if (mDrawerLayout != null) {
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

        mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {

            private boolean menuButtonVisible = true;

            @Override
            public void onDrawerStateChanged(int newState) {

            }

            @TargetApi(Build.VERSION_CODES.HONEYCOMB)
            @Override
            public void onDrawerSlide(final View drawerView, final float slideOffset) {
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
                    topCenterOverlay.setAlpha(1 - slideOffset);
                if (menuButtonVisible && menuButton != null && slideOffset > 0) {
                    menuButton.setVisibility(View.INVISIBLE);
                    menuButtonVisible = false;
                }
            }

            @Override
            public void onDrawerOpened(final View drawerView) {
                if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
                    topCenterOverlay.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onDrawerClosed(final View drawerView) {
                if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
                    topCenterOverlay.setVisibility(View.VISIBLE);
                if (menuButton != null) {
                    menuButton.setVisibility(View.VISIBLE);
                    menuButtonVisible = true;
                }
            }
        });
    }

    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    if (mMap == null) {
        Dialog d = GooglePlayServicesUtil
                .getErrorDialog(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this), this, 0);
        d.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                finish();
            }
        });
        d.show();
        return;
    }

    marker = BitmapDescriptorFactory.fromResource(R.drawable.marker);
    mMap.setOnMarkerClickListener(new OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(final Marker click) {
            addPoint(click.getPosition());
            return true;
        }
    });

    mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
        @Override
        public boolean onMyLocationButtonClick() {
            if (mMap.getMyLocation() != null) {
                LatLng myLocation = new LatLng(mMap.getMyLocation().getLatitude(),
                        mMap.getMyLocation().getLongitude());
                double distance = SphericalUtil.computeDistanceBetween(myLocation,
                        mMap.getCameraPosition().target);

                // Only if the distance is less than 50cm we are on our location, add the marker
                if (distance < 0.5) {
                    Toast.makeText(Map.this, R.string.marker_on_current_location, Toast.LENGTH_SHORT).show();
                    addPoint(myLocation);
                }
            }
            return false;
        }
    });

    // check if open with csv file
    if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
        try {
            Util.loadFromFile(getIntent().getData(), this);
            if (!trace.isEmpty())
                mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(trace.peek(), 16));
        } catch (IOException e) {
            Toast.makeText(this,
                    getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                    Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(final Bundle bundle) {
                    Location l = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
                    if (l != null && mMap.getCameraPosition().zoom <= 2) {
                        mMap.moveCamera(CameraUpdateFactory
                                .newLatLngZoom(new LatLng(l.getLatitude(), l.getLongitude()), 16));
                    }
                    mGoogleApiClient.disconnect();
                }

                @Override
                public void onConnectionSuspended(int cause) {

                }
            }).build();
    mGoogleApiClient.connect();

    valueTv = (TextView) findViewById(R.id.distance);
    updateValueText();
    valueTv.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (type == MeasureType.DISTANCE)
                changeType(MeasureType.AREA);
            // only switch to elevation mode is an internet connection is
            // available and user has access to this feature
            else if (type == MeasureType.AREA && Util.checkInternetConnection(Map.this) && PRO_VERSION)
                changeType(MeasureType.ELEVATION);
            else
                changeType(MeasureType.DISTANCE);
        }
    });

    View delete = findViewById(R.id.delete);
    delete.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            removeLast();
        }
    });
    delete.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(final View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(Map.this);
            builder.setMessage(getString(R.string.delete_all, trace.size()));
            builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    clear();
                    dialog.dismiss();
                }
            });
            builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder.create().show();
            return true;
        }
    });

    mMap.setOnMapClickListener(new OnMapClickListener() {
        @Override
        public void onMapClick(final LatLng center) {
            addPoint(center);
        }
    });

    // Drawer stuff
    ListView drawerList = (ListView) findViewById(R.id.left_drawer);
    drawerListAdapert = new DrawerListAdapter(this);
    drawerList.setAdapter(drawerListAdapert);
    drawerList.setDivider(null);
    drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, int position, long id) {
            switch (position) {
            case 0: // Search before Android 5.0
                Dialogs.getSearchDialog(Map.this).show();
                closeDrawer();
                break;
            case 2: // Units
                Dialogs.getUnits(Map.this, distance, SphericalUtil.computeArea(trace)).show();
                closeDrawer();
                break;
            case 3: // distance
                changeType(MeasureType.DISTANCE);
                break;
            case 4: // area
                changeType(MeasureType.AREA);
                break;
            case 5: // elevation
                if (PRO_VERSION) {
                    changeType(MeasureType.ELEVATION);
                } else {
                    Dialogs.getElevationAccessDialog(Map.this, mService).show();
                }
                break;
            case 7: // map
                changeView(GoogleMap.MAP_TYPE_NORMAL);
                break;
            case 8: // satellite
                changeView(GoogleMap.MAP_TYPE_HYBRID);
                break;
            case 9: // terrain
                changeView(GoogleMap.MAP_TYPE_TERRAIN);
                break;
            case 11: // save
                Dialogs.getSaveNShare(Map.this, trace).show();
                closeDrawer();
                break;
            case 12: // more apps
                try {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:j4velin"))
                            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (ActivityNotFoundException anf) {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://play.google.com/store/apps/developer?id=j4velin"))
                                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;
            case 13: // about
                Dialogs.getAbout(Map.this).show();
                closeDrawer();
                break;
            default:
                break;
            }
        }
    });

    changeView(prefs.getInt("mapView", GoogleMap.MAP_TYPE_NORMAL));
    changeType(MeasureType.DISTANCE);

    // KitKat translucent decor enabled? -> Add some margin/padding to the
    // drawer and the map
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {

        int statusbar = Util.getStatusBarHeight(this);

        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) topCenterOverlay.getLayoutParams();
        lp.setMargins(0, statusbar + 10, 0, 0);
        topCenterOverlay.setLayoutParams(lp);

        // on most devices and in most orientations, the navigation bar
        // should be at the bottom and therefore reduces the available
        // display height
        int navBarHeight = Util.getNavigationBarHeight(this);

        DisplayMetrics total, available;
        total = new DisplayMetrics();
        available = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(available);
        API17Wrapper.getRealMetrics(getWindowManager().getDefaultDisplay(), total);

        boolean navBarOnRight = getResources()
                .getConfiguration().orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE
                && (total.widthPixels - available.widthPixels > 0);

        if (navBarOnRight) {
            // in landscape on phones, the navigation bar might be at the
            // right side, reducing the available display width
            mMap.setPadding(mDrawerLayout == null ? Util.dpToPx(this, 200) : 0, statusbar, navBarHeight, 0);
            drawerList.setPadding(0, statusbar + 10, 0, 0);
            if (menuButton != null)
                menuButton.setPadding(0, 0, 0, 0);
        } else {
            mMap.setPadding(0, statusbar, 0, navBarHeight);
            drawerList.setPadding(0, statusbar + 10, 0, 0);
            drawerListAdapert.setMarginBottom(navBarHeight);
            if (menuButton != null)
                menuButton.setPadding(0, 0, 0, navBarHeight);
        }
    }

    mMap.setMyLocationEnabled(true);

    PRO_VERSION |= prefs.getBoolean("pro", false);
    if (!PRO_VERSION) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND")
                .setPackage("com.android.vending"), mServiceConn, Context.BIND_AUTO_CREATE);
    }
}

From source file:com.conferenceengineer.android.iosched.ui.SocialStreamFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView lv = getListView();
    /*if (!UIUtils.isTablet(getActivity())) {
    view.setBackgroundColor(getResources().getColor(R.color.stream_spacer_color));
    }*///from w w w .  j  a  va2 s .  co m

    // Add some padding if the parent layout is too wide to avoid stretching the items too much
    // emulating the activity_letterboxed_when_large layout behaviour
    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {

        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.social_stream_padding_vertical);
        if (verticalMargin > 0) {
            lv.setClipToPadding(false);
            lv.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    lv.setOnScrollListener(this);
    lv.setDrawSelectorOnTop(true);
    lv.setDivider(getResources().getDrawable(R.drawable.stream_list_divider));
    lv.setDividerHeight(getResources().getDimensionPixelSize(R.dimen.stream_divider_height));
    //view.setBackgroundColor(getResources().getColor(R.color.stream_list_bg_color));

    setListAdapter(mStreamAdapter);
}

From source file:org.solovyev.android.messenger.BaseListFragment.java

protected void fillListView(@Nonnull ListView lv, @Nonnull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        lv.setScrollbarFadingEnabled(true);
    }//from   www  . j  a v  a 2s .co m
    lv.setBackgroundDrawable(null);
    lv.setCacheColorHint(Color.TRANSPARENT);
    ListViewScroller.createAndAttach(lv, this);
    lv.setFastScrollEnabled(true);

    lv.setTextFilterEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverscrollFooter(null);
    }

    lv.setVerticalFadingEdgeEnabled(false);
    lv.setFocusable(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    }
    lv.setDivider(new ColorDrawable(Color.LTGRAY));
    lv.setDividerHeight(1);
}

From source file:com.kncwallet.wallet.ui.SendCoinsFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.send_coins_fragment, container, false);
    contactsListView = (ListView) view.findViewById(R.id.send_coins_contacts_list);

    viewBalanceBtc = (CurrencyTextView) view.findViewById(R.id.wallet_balance_btc);

    txText = (EditText) view.findViewById(R.id.send_coins_text);

    viewBalanceLocal = (CurrencyTextView) view.findViewById(R.id.wallet_balance_local);

    viewBalanceLocal.setPrecision(Constants.LOCAL_PRECISION, 0);
    viewBalanceLocal.setStrikeThru(Constants.TEST);

    viewBalanceBtc.setOnClickListener(new OnClickListener() {
        @Override/* w  w  w.  j  a  va2  s . c om*/
        public void onClick(final View v) {
            SendCoinsFragment.this.switchBalance();
        }
    });

    viewBalanceLocal.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            SendCoinsFragment.this.switchBalance();
        }
    });

    receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address);
    receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null));
    receivingAddressView.setOnFocusChangeListener(receivingAddressListener);
    receivingAddressView.addTextChangedListener(receivingAddressListener);

    receivingStaticView = view.findViewById(R.id.send_coins_receiving_static);
    receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address);
    receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label);

    receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {

            if (hasFocus) {
                startReceivingAddressActionMode();
            } else {
                clearActionMode();
            }
        }
    });

    btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc);
    btcAmountView.setCurrencySymbol(DenominationUtil.getCurrencyCode(btcShift));
    btcAmountView.setInputPrecision(DenominationUtil.getMaxPrecision(btcShift));
    btcAmountView.setHintPrecision(btcPrecision);
    btcAmountView.setShift(btcShift);

    final CurrencyAmountView localAmountView = (CurrencyAmountView) view
            .findViewById(R.id.send_coins_amount_local);
    localAmountView.setInputPrecision(Constants.LOCAL_PRECISION);
    localAmountView.setHintPrecision(Constants.LOCAL_PRECISION);
    amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView);

    bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable);
    bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled());
    bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            if (isChecked && !bluetoothAdapter.isEnabled()) {
                // try to enable bluetooth
                startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE),
                        REQUEST_CODE_ENABLE_BLUETOOTH);
            }
        }
    });

    bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message);

    sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction);
    sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(),
            false);
    sentTransactionView.setAdapter(sentTransactionListAdapter);

    viewGo = (Button) view.findViewById(R.id.send_coins_go);
    viewGo.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            validateReceivingAddress(true);
            validateAmounts(true);

            if (everythingValid())
                handleGo();
        }
    });

    if (savedInstanceState != null) {
        restoreInstanceState(savedInstanceState);
    } else {
        final Intent intent = activity.getIntent();
        final String action = intent.getAction();
        final Uri intentUri = intent.getData();
        final String scheme = intentUri != null ? intentUri.getScheme() : null;

        if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
                && intentUri != null && "bitcoin".equals(scheme))
            initStateFromBitcoinUri(intentUri);
        else if (intent.hasExtra(SendCoinsFragment.INTENT_EXTRA_ADDRESS))
            initStateFromIntentExtras(intent.getExtras());
    }

    TextView header = ((TextView) view.findViewById(R.id.header_text));

    header.setText(R.string.send_heading);

    contactListAdapter = new SimpleCursorAdapter(activity, R.layout.address_book_row_small, null,
            new String[] { AddressBookProvider.KEY_ADDRESS, AddressBookProvider.KEY_LABEL,
                    AddressBookProvider.KEY_ADDRESS, AddressBookProvider.KEY_ADDRESS },
            new int[] { R.id.address_book_contact_image, R.id.address_book_row_label,
                    R.id.address_book_row_address, R.id.address_book_row_source_image });

    contactListAdapter.setViewBinder(new ViewBinder() {
        @Override
        public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
            if (view.getId() == R.id.address_book_contact_image) {
                //...
                SmartImageView img = (SmartImageView) view;
                //img.setImageBitmap(bm);
                String address = cursor.getString(columnIndex);
                Bitmap contactImage = AddressBookProvider.bitmapForAddress(SendCoinsFragment.this.getActivity(),
                        address);
                if (contactImage != null) {
                    img.setImageBitmap(contactImage);
                } else {

                    String imageUrl = ContactImage.getImageUrl(activity,
                            AddressBookProvider.resolveRowId(activity, address));
                    if (imageUrl != null) {
                        img.setImageUrl(imageUrl, R.drawable.contact_placeholder);
                    } else {
                        img.setImageResource(R.drawable.contact_placeholder);
                    }

                }

                return true; //true because the data was bound to the view
            } else if (view.getId() == R.id.address_book_row_source_image) {
                ((ImageView) view).setImageResource(cachedSourceImageResource(cursor.getString(columnIndex)));
                return true;
            }

            //Constants.ADDRESS_FORMAT_LINE_SIZE));

            return false;
        }
    });

    boolean smallScreen = getResources().getBoolean(R.bool.values_small);

    if (!smallScreen) {
        ListView list = (ListView) contactsListView;
        Drawable divider = getResources().getDrawable(R.drawable.transaction_list_divider);
        list.setDivider(divider);
        list.setDividerHeight(1);
        list.setAdapter(contactListAdapter);

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

                //to save a lookup
                TextView addr = (TextView) view.findViewById(R.id.address_book_row_address);
                TextView label = (TextView) view.findViewById(R.id.address_book_row_label);

                if (setSendAddress(addr.getText().toString(), label.getText().toString())) {
                    startReceivingAddressActionMode();
                } else {
                    informInvalidAddress(addr.getText().toString(), label.getText().toString());
                }

            }
        });
    } else {
        contactsListView.setVisibility(View.GONE);
    }

    return view;
}

From source file:org.cafemember.ui.LaunchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Date now = new Date();
    /*int year = now.getYear();
    int month = now.getMonth();//from  w  w  w .  jav a 2s  .  c  o  m
    int day = now.getDay();
    now.getDate();
    long curr = 147083220000l;
    if(System.currentTimeMillis() > curr ){
    Toast.makeText(this,"    . ?      ",Toast.LENGTH_LONG).show();
    finish();
    }*/

    ApplicationLoader.postInitApplication();
    NativeCrashManager.handleDumpFiles(this);

    if (!UserConfig.isClientActivated()) {
        Intent intent = getIntent();
        if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction())
                || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
            super.onCreate(savedInstanceState);
            finish();
            return;
        }
        if (intent != null && !intent.getBooleanExtra("fromIntro", false)) {
            SharedPreferences preferences = ApplicationLoader.applicationContext
                    .getSharedPreferences("logininfo2", MODE_PRIVATE);
            Map<String, ?> state = preferences.getAll();
            if (state.isEmpty()) {
                Intent intent2 = new Intent(this, IntroActivity.class);
                startActivity(intent2);
                super.onCreate(savedInstanceState);
                finish();
                return;
            }
        }
    }

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages);
    getWindow().setBackgroundDrawableResource(R.drawable.transparent);

    super.onCreate(savedInstanceState);
    Theme.loadRecources(this);

    if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) {
        UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime();
    }

    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    }

    actionBarLayout = new ActionBarLayout(this);

    drawerLayoutContainer = new DrawerLayoutContainer(this);
    setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (AndroidUtilities.isTablet()) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

        RelativeLayout launchLayout = new RelativeLayout(this);
        drawerLayoutContainer.addView(launchLayout);
        FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams();
        layoutParams1.width = LayoutHelper.MATCH_PARENT;
        layoutParams1.height = LayoutHelper.MATCH_PARENT;
        launchLayout.setLayoutParams(layoutParams1);

        backgroundTablet = new ImageView(this);
        backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP);
        backgroundTablet.setImageResource(R.drawable.cats);
        launchLayout.addView(backgroundTablet);
        RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet
                .getLayoutParams();
        relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        backgroundTablet.setLayoutParams(relativeLayoutParams);

        launchLayout.addView(actionBarLayout);
        relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
        relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        actionBarLayout.setLayoutParams(relativeLayoutParams);

        rightActionBarLayout = new ActionBarLayout(this);
        launchLayout.addView(rightActionBarLayout);
        relativeLayoutParams = (RelativeLayout.LayoutParams) rightActionBarLayout.getLayoutParams();
        relativeLayoutParams.width = AndroidUtilities.dp(320);
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        rightActionBarLayout.setLayoutParams(relativeLayoutParams);
        rightActionBarLayout.init(rightFragmentsStack);
        rightActionBarLayout.setDelegate(this);

        shadowTabletSide = new FrameLayout(this);
        shadowTabletSide.setBackgroundColor(0x40295274);
        launchLayout.addView(shadowTabletSide);
        relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams();
        relativeLayoutParams.width = AndroidUtilities.dp(1);
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        shadowTabletSide.setLayoutParams(relativeLayoutParams);

        shadowTablet = new FrameLayout(this);
        shadowTablet.setVisibility(View.GONE);
        shadowTablet.setBackgroundColor(0x7F000000);
        launchLayout.addView(shadowTablet);
        relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams();
        relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        shadowTablet.setLayoutParams(relativeLayoutParams);
        shadowTablet.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
                    float x = event.getX();
                    float y = event.getY();
                    int location[] = new int[2];
                    layersActionBarLayout.getLocationOnScreen(location);
                    int viewX = location[0];
                    int viewY = location[1];

                    if (layersActionBarLayout.checkTransitionAnimation()
                            || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY
                                    && y < viewY + layersActionBarLayout.getHeight()) {
                        return false;
                    } else {
                        if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
                            for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
                                layersActionBarLayout
                                        .removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
                                a--;
                            }
                            layersActionBarLayout.closeLastFragment(true);
                        }
                        return true;
                    }
                }
                return false;
            }
        });

        shadowTablet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        layersActionBarLayout = new ActionBarLayout(this);
        layersActionBarLayout.setRemoveActionBarExtraHeight(true);
        layersActionBarLayout.setBackgroundView(shadowTablet);
        layersActionBarLayout.setUseAlphaAnimations(true);
        layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
        launchLayout.addView(layersActionBarLayout);
        relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams();
        relativeLayoutParams.width = AndroidUtilities.dp(530);
        relativeLayoutParams.height = AndroidUtilities.dp(528);
        layersActionBarLayout.setLayoutParams(relativeLayoutParams);
        layersActionBarLayout.init(layerFragmentsStack);
        layersActionBarLayout.setDelegate(this);
        layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
        layersActionBarLayout.setVisibility(View.GONE);
    } else {
        drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }

    ListView listView = new ListView(this) {
        @Override
        public boolean hasOverlappingRendering() {
            return false;
        }
    };
    listView.setBackgroundColor(0xffffffff);
    listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this));
    listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    drawerLayoutContainer.setDrawerLayout(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    Point screenSize = AndroidUtilities.getRealScreenSize();
    layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320)
            : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56);
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    listView.setLayoutParams(layoutParams);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //
            if (position == 12) {
                presentFragment(new SettingsActivity());
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 11) {

                try {
                    RulesActivity his = new RulesActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 2) {

                Defaults def = Defaults.getInstance();
                boolean open = def.openOnJoin();
                def.setOpenOnJoin(!open);
                if (view instanceof TextCheckCell) {
                    ((TextCheckCell) view).setChecked(!open);
                }
            } else if (position == 4) {
                try {
                    HistoryActivity his = new HistoryActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            }

            else if (position == 3) {
                Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/cafemember"));
                startActivity(telegram);

                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 5) {
                try {
                    FAQActivity his = new FAQActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 6) {
                Intent telegram = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https://telegram.me/" + Defaults.getInstance().getSupport()));
                startActivity(telegram);

                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 7) {
                try {
                    HelpActivity his = new HelpActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 8) {
                try {
                    AddRefActivity his = new AddRefActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 9) {

                try {
                    Log.d("TAB", "Triggering");
                    ShareActivity his = new ShareActivity();
                    Log.d("TAB", "Triggered");
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 10) {
                try {
                    //                        TransfareActivity his = new TransfareActivity();
                    //                        presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            }
        }
    });

    drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
    actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
    actionBarLayout.init(mainFragmentsStack);
    actionBarLayout.setDelegate(this);

    ApplicationLoader.loadWallpaper();

    passcodeView = new PasscodeView(this);
    drawerLayoutContainer.addView(passcodeView);
    FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams();
    layoutParams1.width = LayoutHelper.MATCH_PARENT;
    layoutParams1.height = LayoutHelper.MATCH_PARENT;
    passcodeView.setLayoutParams(layoutParams1);

    NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
    currentConnectionState = ConnectionsManager.getInstance().getConnectionState();

    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.needShowAlert);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
    if (Build.VERSION.SDK_INT < 14) {
        NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged);
    }

    if (actionBarLayout.fragmentsStack.isEmpty()) {
        if (!UserConfig.isClientActivated()) {
            actionBarLayout.addFragmentToStack(new LoginActivity());
            drawerLayoutContainer.setAllowOpenDrawer(false, false);
        } else {
            dialogsFragment = new DialogsActivity(null);
            actionBarLayout.addFragmentToStack(dialogsFragment);
            drawerLayoutContainer.setAllowOpenDrawer(true, false);
        }

        try {
            if (savedInstanceState != null) {
                String fragmentName = savedInstanceState.getString("fragment");
                if (fragmentName != null) {
                    Bundle args = savedInstanceState.getBundle("args");
                    switch (fragmentName) {
                    case "chat":
                        if (args != null) {
                            ChatActivity chat = new ChatActivity(args);
                            if (actionBarLayout.addFragmentToStack(chat)) {
                                chat.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "settings": {
                        SettingsActivity settings = new SettingsActivity();
                        actionBarLayout.addFragmentToStack(settings);
                        settings.restoreSelfArgs(savedInstanceState);
                        break;
                    }
                    case "group":
                        if (args != null) {
                            GroupCreateFinalActivity group = new GroupCreateFinalActivity(args);
                            if (actionBarLayout.addFragmentToStack(group)) {
                                group.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "channel":
                        if (args != null) {
                            ChannelCreateActivity channel = new ChannelCreateActivity(args);
                            if (actionBarLayout.addFragmentToStack(channel)) {
                                channel.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "edit":
                        if (args != null) {
                            ChannelEditActivity channel = new ChannelEditActivity(args);
                            if (actionBarLayout.addFragmentToStack(channel)) {
                                channel.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "chat_profile":
                        if (args != null) {
                            ProfileActivity profile = new ProfileActivity(args);
                            if (actionBarLayout.addFragmentToStack(profile)) {
                                profile.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "wallpapers": {
                        WallpapersActivity settings = new WallpapersActivity();
                        actionBarLayout.addFragmentToStack(settings);
                        settings.restoreSelfArgs(savedInstanceState);
                        break;
                    }
                    }
                }
            }
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    } else {
        boolean allowOpen = true;
        if (AndroidUtilities.isTablet()) {
            allowOpen = actionBarLayout.fragmentsStack.size() <= 1
                    && layersActionBarLayout.fragmentsStack.isEmpty();
            if (layersActionBarLayout.fragmentsStack.size() == 1
                    && layersActionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
                allowOpen = false;
            }
        }
        if (actionBarLayout.fragmentsStack.size() == 1
                && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
            allowOpen = false;
        }
        drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
    }

    handleIntent(getIntent(), false, savedInstanceState != null, false);
    needLayout();

    final View view = getWindow().getDecorView().getRootView();
    view.getViewTreeObserver()
            .addOnGlobalLayoutListener(onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    int height = view.getMeasuredHeight();
                    if (height > AndroidUtilities.dp(100) && height < AndroidUtilities.displaySize.y
                            && height + AndroidUtilities.dp(100) > AndroidUtilities.displaySize.y) {
                        AndroidUtilities.displaySize.y = height;
                        FileLog.e("tmessages", "fix display size y to " + AndroidUtilities.displaySize.y);
                    }
                }
            });
}

From source file:com.esprit.droidcon.corruption.AutreListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;//from w  ww . j a  v a 2s  .co  m
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Autre");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

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

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(AutreListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(AutreListActivity.this, AutreListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:com.esprit.droidcon.corruption.SiteWebListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;/*from   www .ja  va2 s .  c o m*/
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Site Web");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(SiteWebListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(SiteWebListActivity.this, SiteWebListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:com.esprit.droidcon.corruption.EtatCivileListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;//w  w w . j  a  v  a2s.c  o  m
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Etat Civil");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

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

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(EtatCivileListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(EtatCivileListActivity.this, EtatCivileListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}