In my project I have an Activity that loads a list of news. When the list is loaded, this Activity is populated with the information of the first item on the list:

enter image description here

But since this loads all the news from the server, I want the user to be able to swap the news with his finger. For example: we start with news[0] and user swipe left, the content change to news[1]. The user swipe left again and the content changes to news[2] and so on... if the user swipes right, then it return to the previous news (news[1]). The header should not have a swipe movement, only the main frame (image and body should change):

enter image description here

What would be the best aproach for this behavior? I was thinking about using a TabLayout with ViewPager but I'm not sure if this is the correct way to do this. If I have something like 100 news this could be a overkill to load 100 fragments in the ViewPager right?

Does android have a better way to do this? How should I do this?

The first picture is how the preview looks; however, when I run the emulator, it looks like the second picture. I am not sure why it is happening. By the way, I am making a simple drumbox application.

Preview img

Emulator

img

The code for activity_main.xml is

<Button
android:id="@+id/bass"
android:layout_width="150dp"
android:layout_height="250dp"
android:text="1"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="10dp" />

<Button
android:id="@+id/snare"
android:layout_width="150dp"
android:layout_height="250dp"
android:text="2"
tools:layout_editor_absoluteX="200dp"
tools:layout_editor_absoluteY="10dp" />

<Button
android:id="@+id/closedhihat"
android:layout_width="150dp"
android:layout_height="250dp"
android:text="3"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="250dp" />

<Button
android:id="@+id/hitom"
android:layout_width="150dp"
android:layout_height="250dp"
android:text="4"
tools:layout_editor_absoluteX="200dp"
tools:layout_editor_absoluteY="250dp" />

</android.support.constraint.ConstraintLayout>

Can anyone help?

I can't make Android load a web resource into an ArrayList - whatever I do, the list is empty. If I don't run it in a thread, logcat shows a StrictMode$AndroidBlockGuardPolicy.onNetwork error. In java VM this is working perfectly; the site is loaded into the list and I can get the data I want.

Here is the code:

public class WeatherData {
public static String data() {
    String[] tempsArr = new String[9];
    String[] minArr = new String[9];
    Calendar calendar = Calendar.getInstance();
    String[] weekDay = new String[1];
    SimpleDateFormat[] dayFormat = new SimpleDateFormat[1];
    dayFormat[0] = new SimpleDateFormat("E");
    weekDay[0] = dayFormat[0].format(calendar.getTime());
    final ArrayList<String> list = new ArrayList<String>();
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {

            try {
                System.setProperty("http.proxyHost", "cache.mrt.ac.lk");
                System.setProperty("http.proxyPort", "3128");

                //Document doc = Jsoup.connect(url).timeout(10000).get();

                URL link = new URL("https://www.sinoptik.bg/shumen-bulgaria-100727233/10-days");
                BufferedReader in = new BufferedReader(new InputStreamReader(link.openStream()));
                String inputLine;
                String[] arr;
                int count = 0;

                while ((inputLine = in.readLine()) != null) {
                    list.add(inputLine);
                    count++;
                }
                in.close();
            } catch (MalformedURLException me) {
                System.out.println(me);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            } catch (Exception e) {
                Log.e(TAG, e.getMessage());
            }
        }
    });
    thread.start();

    dayFormat[0] = new SimpleDateFormat("E");

    weekDay[0] = dayFormat[0].format(calendar.getTime());
    int idx = 0;
    for (
            int j = 0; j < list.size() - 550; j++)

    {
        if (list.get(j).contains(weekDay[0].toString())) {
            tempsArr[idx] = getNum(list.get(j + 3));
            minArr[idx] = getNum(list.get(j + 5));
            idx++;
            calendar.add(Calendar.DAY_OF_WEEK, 1);
            weekDay[0] = dayFormat[0].format(calendar.getTime());
        }
    }

    return tempsArr[1];
}

I know it needs optimization, but I want first to make it work and give me at least one value (that's why I used only one of the arrays with one index for return). I see it on debug it is connecting to the site but the ArrayList is empty and it is doing nothing.

Idk if i should ask here (nobody on xda cares my problem and wont help me. The users using my app but dont help me). Ive ported Samsung Music from SDK 24 to SDK 23 and now when the player plays a few minutes, it will crash and give a fatal error. Only Fatal. no Errors or warnings only fatal. And i need to know how i can read logs and find out whats the bug/problem in smali code. (helping with logs nobody cares too)

I get this error:

10-08 00:16:17.642   439   439 F DEBUG:
pid: 2794, tid: 3144, name: RenderThread
>>> com.sec.android.app.music <<<

Can you help mr with finding the issue and correct it? Thank you♡

Do we need any other special permission other than INTERNET, for running TCP server in android app ?

I'm trying to remove those specific items based off their location in the values list. The below code, throws an error as the copy list shrinks too much

private ArrayList<String> removeGen(int addLines, int labLines, int venLines, ArrayList<String> values){
        ArrayList<String> copy = new ArrayList<>();
        copy = (ArrayList<String>) values.clone();
        for(int i = 0; i < values.size(); i++) {
            if (i > 100 && i < (100 + (addLines * 5) + 1)) {
                copy.remove(i);
            }

            if (i > (100 + (addLines * 5)) + 9 && i < 100 + (addLines * 5) + (labLines * 4) + 10) {
                copy.remove(i);
            }

            if (i > 100 + (addLines * 5) + (labLines * 4) + 21 && i < 100 + (addLines * 5) + (labLines * 4) + (venLines * 4) + 22) {
                copy.remove(i);
            }
        }

        return copy;

The problem is some values are indistinguishable from one another so I can't use remover(obj) either.

How can I return a list with the values removed at the above locations?

I did many searches on the web, and only partially I understood what I have to do.

When my IDE (Android Studio) reminded me that are available recent update for android SDK, I provided to install them. Now I notice that the Android-SDK directory occupies 87Gb of HDD memory. This because are installed all the Android API from older version to the latest new.

Today I decided to delete all the SDK directory and perform a clean installaton of the SDK tool. What I ask is which are the minimum things that I've to install from the SDK manager to be up and running for Android Development. Consider that my apps must run from Android API 14 (4.0 IceCream) to the least available API version (currently on October 2017 is API 25). In addiction I use an Android Emulator with Lollipop 5.1 (API 22).

The last thing I ask is when there is a new available and I would to install it, should I unistall all the older API version to prevent SDK grow up?

This is the screenshot of my Android Studio SKD manager. As you can see the only checked API is 7.1.1 Nougat API 25. enter image description here

This is a series of screenshot of package details of SDK Manager enter image description here enter image description here

enter image description here

The others are all unchecked. I have to say that for Android 5.1 Lollipop API 22, check marks appear after I create the Android Emulator with Lollipop Installed.

NB: I need only things for mobile programming, not TV or Wearable.

I am new with Android development, so this is probably a rookie mistake but, I am stuck.

I want to start an activity when clicking on the menu, but the following exception shows up:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mygymroutine.mygymroutine/com.mygymroutine.mygymroutine.activities.ActivitySchedule}: java.lang.IllegalArgumentException: No view found for id 0x7f0d008b (com.mygymroutine.mygymroutine:id/fragment_schedule) for fragment ScheduleFragment{39f1839 #0 id=0x7f0d008b ...

This is the code related:

public class basic extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_basic);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

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

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

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.basic, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
public boolean onNavigationItemSelected(MenuItem item) {
        displaySelectedScreen(item.getItemId());
        return true;
    }
    private void displaySelectedScreen(int itemId) {
        Intent intent=null;
        switch (itemId) {
            case R.id.nav_schedule:
                intent=new Intent(this, ActivitySchedule.class);
                startActivity(intent);
                break;
        }

Activity code

package com.mygymroutine.mygymroutine.activities;


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;


import com.mygymroutine.mygymroutine.Fragments.ScheduleFragment;
import com.mygymroutine.mygymroutine.R;


public class ActivitySchedule extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.acivity_schedule);
        if(savedInstanceState==null){
            ScheduleFragment fg = new ScheduleFragment();
            getSupportFragmentManager().beginTransaction().add(R.id.fragment_schedule, fg)
                    .commit();
        }
    }
}

Fragment

package com.mygymroutine.mygymroutine.Fragments;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.mygymroutine.mygymroutine.R;

public class ScheduleFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //returning our layout file
        //change R.layout.yourlayoutfilename for each of your fragments
        View rootView=inflater.inflate(R.layout.fragment_schedule, container, false);
        FloatingActionButton fab=(FloatingActionButton)rootView.findViewById(R.id.fab_schedule);
        return inflater.inflate(R.layout.fragment_schedule, container, false);
    }


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

        getActivity().setTitle("Schedule");
    }
}

Fragment Schedule xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fragment_schedule"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="17dp"
        android:text="Schedule"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_schedule"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="41dp"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:clickable="true"
        android:tint="@android:color/background_light"
        app:backgroundTint="@android:color/holo_red_light"
        app:fabSize="mini"
        app:rippleColor="@android:color/transparent"
        app:srcCompat="@android:drawable/ic_menu_add" />

</RelativeLayout>

Activity schedule xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.mygymroutine.mygymroutine.activities.ActivitySchedule">

</android.support.constraint.ConstraintLayout>

is there a cable that allows the following: connect the audio-out (normally to a speaker) of phone1 to the audio-in of a phone2 (mic) and the audio-out of phone2 to the audio-in of phone1?

I am pretty sure that the signals levels are different (mic audio is lower than audio from speakers) and also the impedance of the mic and speakers do not match either so I can not just take an aux cable and invert the internal wires.

Also, is it possible to do the same thing using the USB ports with an OTG cable instead of the audio ports ?

I am making sure both phones are from the same manufacturer so there is no incompatibility issues on the audio connections.

I've got this code it works to drag and drop one image, how would i then make this into being able to drag two separate images or possibly even more? Still very new at this and i am so lost right now.

package com.acclaimdriving.onthemove;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.FrameLayout.LayoutParams;
public class ApproachingRight extends Activity {
private CanvasView customCanvas;
int windowwidth;
int windowheight;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_approaching_right);
    customCanvas = (CanvasView) findViewById(R.id.signature_canvas);


    windowwidth = getWindowManager().getDefaultDisplay().getWidth();
    windowheight = getWindowManager().getDefaultDisplay().getHeight();
    final ImageView balls = (ImageView)findViewById(R.id.car1);

    balls.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            LayoutParams layoutParams = (LayoutParams) balls.getLayoutParams();
            switch(event.getAction())
            {
                case MotionEvent.ACTION_DOWN:
                    break;
                case MotionEvent.ACTION_MOVE:
                    int x_cord = (int)event.getRawX();
                    int y_cord = (int)event.getRawY();
                    if(x_cord>windowwidth){x_cord=windowwidth;}
                    if(y_cord>windowheight){y_cord=windowheight;}

                    layoutParams.leftMargin = x_cord -25;
                    layoutParams.topMargin = y_cord - 75;

                    balls.setLayoutParams(layoutParams);
                    break;
                default:
                    break;
            }
            return true;
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_start_screen, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_menu) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
public void clearCanvas(View v) {
    customCanvas.clearCanvas();
}

}

If this codes needs to be changed entirely let me know as this was more hacked together from other tutorials ive watched.

I made a Class named SessionManager and I want to use its SharedPeference for SettingActivity. How Can I do that?

I have a lListView that displays some items of a single type through SimpleCursorAdapter.

What I need is the first column to display a list item of a second type (a single textview would do, in order to give a sense of a title) and then all the other items from the cursor.

How can I achieve this using SimpleCursorAdapter.ViewBinder?

I guess it would be something like...

public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
                if (columnIndex==1){
                  // how to get a reference of the second item type here?
                    return true;
                }
                return false;
            }

I am trying to add the text view to the right end of the parent with the below code. But it is not working.

Can Anyone help?Pls

    ConstraintSet constraintSet = new ConstraintSet();
    TextView mValue1 = new TextView(getContext());
    mValue1.setText("Value 1");
    mValue1.setId(R.id.rightLabel1);
    addView(mValue1);
    constraintSet.clone(this);
    constraintSet.connect(mValue1.getId(), ConstraintSet.TOP, this.getId(), ConstraintSet.TOP);
    constraintSet.connect(mValue1.getId(), ConstraintSet.END, this.getId(), ConstraintSet.END);
    constraintSet.applyTo(this);

Im trying to do a chat. MainActivity has a ToolBar and BottomNavigationVIew.

The chat fragment has a recyclerView, an editText and ImageButton, but when I load the fragment the BottomNavigationVIew overlaps the EditText and the ImageButton

I dont know if this is important but in Android Studio the item of BottomNavigationVIew looks smaller than it is, not for example like the ToolBar Also I use android:layout_above="@+id/navigation" and it doesn't work enter image description here

enter image description here

I have tried many ways but I cant do it

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_parent_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:text="@string/parent_name"
                android:textSize="20sp" />


            <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/student_photo"
                android:layout_width="55dp"
                android:layout_height="55dp"
                android:layout_alignParentEnd="true"

                android:layout_alignParentRight="true"
                android:layout_gravity="right|center"
                android:onClick="onClick"
                android:padding="4dp"
                android:src="@drawable/foto"
                app:civ_border_color="@color/iron"
                app:civ_border_width="1dp" />

        </LinearLayout>

    </android.support.v7.widget.Toolbar>


    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/navigation">

        <ProgressBar
            android:id="@+id/pb_loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="invisible" />
    </FrameLayout>

</LinearLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@color/primary_dark"
    app:itemIconTint="@color/nav_item_state_list"
    app:itemTextColor="@color/nav_item_state_list"
    app:menu="@menu/menu_navigation" />
</RelativeLayout>

chat_fragment.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:id="@+id/messages"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:scrollbars="vertical"
    android:scrollbarStyle="outsideOverlay"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:orientation="horizontal"
    android:gravity="center_vertical">

    <EditText
        android:id="@+id/message_input"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="@string/prompt_message"
        android:imeActionId="@+id/send"
        android:imeActionLabel="@string/action_send"
        android:imeOptions="actionSend"
        android:inputType="text"
        android:maxLines="1"/>
    <ImageButton
        android:id="@+id/send_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_send"
        android:contentDescription="@string/action_send"/>

</LinearLayout>

</LinearLayout>

fragment.java

                FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentManager.popBackStackImmediate();
            fragmentTransaction.replace(R.id.frame_layout, chat);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();

i want to send 1 small message from one android device to another and again receiving small message from that android device by connecting through hot spot or any other way? similar like (hike direct,mini militia(offline),share it chatting)

I'm trying to develop a small solution with the possibility of user authentication. Because this will be later hand over to other developers, i want the first iteration of the solution secure as possible for user data.

After reading some stuff about security and hashing, i'm decided to store hash + salt in a single field in the database. Most of the time salt's in the examples are 16 byte's long. But technical they could have had any size.

That leads to my question:

  • If it isn't public how long my salt and my hash are and i set them to a 'random' value, is this an extra step for protecting user data?

If somehow the database gets in wrong hands, the attacker wouldn't know at which point the salt ends and the hash starts.


Given example in .net Core 2.0 which allows me to set the length of salt and hash:

static Dictionary<string,string> _memDict = new Dictionary<string,string>() {{"username","password"}};

static int _amountOfHashBytes = 32;
static int _amountOfSaltBytes = 16;
static int _amountOfIterations = 10000;

static void Main(string[] args) 
{
    string passphrase = "passphrase"; 
    string usrName = "dotnetcoreuser";

    // 1) Create the salt value with a cryptographic 
    byte[] salt; 
    RandomNumberGenerator.Create().GetBytes(salt = new byte[_amountOfSaltBytes]); 
    Console.WriteLine("Salt: " + Convert.ToBase64String(salt)); 

    // 2) Create the Rfc2898DeriveBytes and get the hash value
    var pbkdf2 = new Rfc2898DeriveBytes(passphrase, salt, _amountOfIterations); 
    byte[] hash = pbkdf2.GetBytes(_amountOfHashBytes); 
    Console.WriteLine("Hash: " + Convert.ToBase64String(hash)); 

    // 3) Combine the salt and password bytes for later use
    byte[] hashBytes = new byte[_amountOfSaltBytes + _amountOfHashBytes]; 
    Array.Copy(salt, 0, hashBytes, 0, _amountOfSaltBytes); 
    Array.Copy(hash, 0, hashBytes, _amountOfSaltBytes, _amountOfHashBytes); 

    // 4) Turn the combined salt + hash into a string for storage
    string savedPasswordHash = Convert.ToBase64String(hashBytes); 
    Console.WriteLine("Combine: " + savedPasswordHash); 
    _memDict.Add(usrName, savedPasswordHash);

    // 5) Verify the user-entered password against a stored password.
    string tryInput = "1234";
    Console.WriteLine("Try: {0} Result: {1}", tryInput, IsValidPassword(tryInput, usrName));
    tryInput = "password";
    Console.WriteLine("Try: {0} Result: {1}", tryInput, IsValidPassword(tryInput, usrName));
    tryInput = "passphrase";
    Console.WriteLine("Try: {0} Result: {1}", tryInput, IsValidPassword(tryInput, usrName));
}

static bool IsValidPassword(string userInput, string userName)
{
    string savedPasswordHash = _memDict[userName];
    byte[] hashBytes = Convert.FromBase64String(savedPasswordHash);
    byte[] salt = new byte[_amountOfSaltBytes];
    Array.Copy(hashBytes, 0, salt, 0, _amountOfSaltBytes);
    var pbkdf2 = new Rfc2898DeriveBytes(userInput, salt, _amountOfIterations);
    byte[] hash = pbkdf2.GetBytes(_amountOfHashBytes);
    for (int i=0; i < _amountOfHashBytes; i++)
    {
        if (hashBytes[i+_amountOfSaltBytes] != hash[i]) { return false; }
    }
    return true;
}

I already have few pages with pagination working properly.

class ObjectToSearch
{
    $id;           //Id from mysql
    $name;         //Name of the object from mysql
    $description;  //Description in base64_encode() from mysql
    $date;         //Date of the object from musql
}

Now, I need to do a searching form and the pagination with it. My problem is that some data are not only fetch from the database, also but need to be rework after as $description needs to be decrypted from base64 to be read. So when I'm searching a part of the description, I need to fetch all the table before filtering the description. On big data, it just can't work as their is too many data.

How could I optimise a search like:

name = "*" //filter from mysql

description = "test"

date = "*" //filter from mysql

I am currently building an Android app which polls an api on an interval (using rxJava and retrofit). When there is a change in the data, the app is meant to present the user with a notification. I had a realization that it would be better to have this polling logic on a server as apposed to the device itself to dramatically decrease api server load. However, I have no idea where to begin. I took at look at Firebase's Cloud Messaging, but cannot find any documentation in regards to setting up a server.

How should I go about doing this, in the easiest way possible? I've only ever worked with Android and OOP.

In the life of a developer it often happens that you get assigned to an already existing software project, programmed by other developers. It can happen that this project is not maintained anymore by other developers.

I find it particularly difficult to get started on an existing project which has no active developers anymore because I don't know where to "dive in". We have for example a project which is not documented and there are no developers maintaining it. I got assigned to implement some features into this software. I got only the git repository link along my tasks. (The application is terminal-based and written in Python, but that doesn't matter)

What are the common practices to do when getting an existing project if nobody can help you? I can't ask the former developers anymore because they don't work at the company anymore.

How should I find out how the application works? I tried finding out what it actually does by installing it and trying out different commands (trial and error) but that takes a really long time. I search for a more straightforward solution for this case.

I am developing a web based vehicle tracking application. Clients buy GPS devices and the company i work for mount it on their vehicles. Then the client gets a user name and a password for the software and this is how he is able to monitoring his fleet.

However when the company started to grow some clients want to mount GPS devices on static plarforms which are not VEHICLES! Other clients want to be able to list all their fleet units inside the software EVEN if they didnt buy GPS device for them but they simply want to be able input some data which is not tracking related.

So i have to improve the software in order to be able to handle the dummy units and the platforms which locations do not change.

So here comes my question:

Should i have few classes like:

Vehicle(id, maxSpeed, Canbus, FuelTankCalibration, AnalogSonda, GpsDevice.....)

StaticPlatform(id, Location, AnalogSonda, GpsDevice....)

DummyVehicle(id, MetaData,.....)

or one big class

FleetUnit(Type, id, maxSpeed, canBus, FuelCalibration, AnalogSonda, GpsDevice, Location, MetaData,.....)

and based on the Type(VEHICLE, STATIC_PLATFORM, DUMMY_VEHICLE) varibale to handle the various situation?

10x in advance.

I'm having some trouble with conforming 2 protocols together using the Codable protocol.

My understanding is that even if I used a custom object, as long as that object successfully conforms to Codable, then any object referencing that can also conform.

I have the following code and cannot see why I am getting the errors:

import UIKit
import Foundation

protocol PromotionProtocol: Codable {
    var promotionType: Int? { get }
    var promotionCode: String? { get }
    var fileName: String? { get }
    var facetDescription: String? { get }
    var promoDescription: String? { get }
}

class Promotion: PromotionProtocol {
    var promotionType: Int?
    var promotionCode: String?
    var fileName: String?
    var facetDescription: String?
    var promoDescription: String?
}

protocol PromotionInfoProtocol: Codable {
    var cornerPromotion: PromotionProtocol? { get }
    var mainPromotion: PromotionProtocol? { get }
    var isTopFive: Bool? { get }
}

class PromoInfo: PromotionInfoProtocol {
    var cornerPromotion: PromotionProtocol?
    var mainPromotion: PromotionProtocol?
    var isTopFive: Bool?
}

Everything inside the 'PromotionProtocol' is either a String or Int so that is fine. But I get the errors that the Class Promotion does not conform to Encodable and Decodable.