ProgressTextView | #Frontend Framework | progress TextView

 by   beiliubei Java Updated: 3 years ago - Current License: Apache-2.0

Download this library from

Build Applications

kandi X-RAY | ProgressTextView REVIEW AND RATINGS

![Smaller icon](https://github.com/beiliubei/ProgressTextView/raw/master/device-2014-08-13-104554.png "Title here").

kandi-support
Support

  • ProgressTextView has a low active ecosystem.
  • It has 26 star(s) with 11 fork(s).
  • It had no major release in the last 12 months.
  • It has a neutral sentiment in the developer community.

quality kandi
Quality

  • ProgressTextView has 0 bugs and 0 code smells.

security
Security

  • ProgressTextView has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ProgressTextView code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license
License

  • ProgressTextView is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

build
Reuse

  • ProgressTextView releases are not available. You will need to build from source code and install.
  • ProgressTextView has no build file. You will be need to create the build yourself to build the component from source.
  • ProgressTextView saves you 99 person hours of effort in developing the same functionality from scratch.
  • It has 253 lines of code, 21 functions and 10 files with 0 % test coverage
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA

kandi has reviewed ProgressTextView and discovered the below as its top functions. This is intended to give you an instant insight into ProgressTextView implemented functionality, and help decide if they suit your requirements.

  • region DrawText
  • Initializes the paints .
  • Calculate the rectF that should be used .
  • Override this method to handle an action item selection .
  • On createOptions menu menu .
  • Convert the pixels to pixels .
  • Sets the progress of the animation .
  • Sets the activity to be saved .

ProgressTextView Key Features

progress TextView

ProgressTextView examples and code snippets

  • How to make a progress bar influence what data is on UI using a room database?
  • Android app loads but crashes when SeekBar is released.
  • Android app doesn't show SQL result as a number

How to make a progress bar influence what data is on UI using a room database?

@Query("SELECT * FROM things_table WHERE thingAmount >:minValue ORDER BY thingDate ASC")
LiveData<List<ThingEntity>> getAllThings(int minValue);
public class DetailsFirstTabViewModel extends AndroidViewModel {
    private MutableLiveData<List<ThingEntity>> things = new MutableLiveData<>();

    ...

    public MutableLiveData<List<ThingEntity>> getThings() {
        return things;
    }

    public void getAllThings(int minValue) {
        things.postValue(repository.getAllThings(minValue).getValue());
    }
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.fragment_first_page_expense_details, container, false);

    ....

    //Observe things and update data accordingly 
    viewModel.getThings().observe(this, new Observer<List<ThingEntity>>() {
        // I wonder if the progress bar value could be passed here to call my repository
        @Override
        public void onChanged(List<ThingEntity> thingEntities) {

            //check null here and skip
            if(thingEntities != null) {
                for (ThingEntity thing : thingEntities) {
                    totalSum[0] = totalSum[0] + thing.getThingAmount();
                }
                textViewTotalSum.setText(String.valueOf(totalSum[0]));
                adapter.setThingEntityList(thingEntities);
                setThingEntities(thingEntities);
            }
        }
    });

    //Initially call with default min 0
    viewModel.getAllThings(0);

    return root;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {

    //Just call to fetch content with progressValue and update adapter inside onChanged
    viewModel.getAllThings(progressValue);
}
-----------------------
@Query("SELECT * FROM things_table WHERE thingAmount >:minValue ORDER BY thingDate ASC")
LiveData<List<ThingEntity>> getAllThings(int minValue);
public class DetailsFirstTabViewModel extends AndroidViewModel {
    private MutableLiveData<List<ThingEntity>> things = new MutableLiveData<>();

    ...

    public MutableLiveData<List<ThingEntity>> getThings() {
        return things;
    }

    public void getAllThings(int minValue) {
        things.postValue(repository.getAllThings(minValue).getValue());
    }
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.fragment_first_page_expense_details, container, false);

    ....

    //Observe things and update data accordingly 
    viewModel.getThings().observe(this, new Observer<List<ThingEntity>>() {
        // I wonder if the progress bar value could be passed here to call my repository
        @Override
        public void onChanged(List<ThingEntity> thingEntities) {

            //check null here and skip
            if(thingEntities != null) {
                for (ThingEntity thing : thingEntities) {
                    totalSum[0] = totalSum[0] + thing.getThingAmount();
                }
                textViewTotalSum.setText(String.valueOf(totalSum[0]));
                adapter.setThingEntityList(thingEntities);
                setThingEntities(thingEntities);
            }
        }
    });

    //Initially call with default min 0
    viewModel.getAllThings(0);

    return root;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {

    //Just call to fetch content with progressValue and update adapter inside onChanged
    viewModel.getAllThings(progressValue);
}
-----------------------
@Query("SELECT * FROM things_table WHERE thingAmount >:minValue ORDER BY thingDate ASC")
LiveData<List<ThingEntity>> getAllThings(int minValue);
public class DetailsFirstTabViewModel extends AndroidViewModel {
    private MutableLiveData<List<ThingEntity>> things = new MutableLiveData<>();

    ...

    public MutableLiveData<List<ThingEntity>> getThings() {
        return things;
    }

    public void getAllThings(int minValue) {
        things.postValue(repository.getAllThings(minValue).getValue());
    }
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.fragment_first_page_expense_details, container, false);

    ....

    //Observe things and update data accordingly 
    viewModel.getThings().observe(this, new Observer<List<ThingEntity>>() {
        // I wonder if the progress bar value could be passed here to call my repository
        @Override
        public void onChanged(List<ThingEntity> thingEntities) {

            //check null here and skip
            if(thingEntities != null) {
                for (ThingEntity thing : thingEntities) {
                    totalSum[0] = totalSum[0] + thing.getThingAmount();
                }
                textViewTotalSum.setText(String.valueOf(totalSum[0]));
                adapter.setThingEntityList(thingEntities);
                setThingEntities(thingEntities);
            }
        }
    });

    //Initially call with default min 0
    viewModel.getAllThings(0);

    return root;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {

    //Just call to fetch content with progressValue and update adapter inside onChanged
    viewModel.getAllThings(progressValue);
}
-----------------------
@Query("SELECT * FROM things_table WHERE thingAmount >:minValue ORDER BY thingDate ASC")
LiveData<List<ThingEntity>> getAllThings(int minValue);
public class DetailsFirstTabViewModel extends AndroidViewModel {
    private MutableLiveData<List<ThingEntity>> things = new MutableLiveData<>();

    ...

    public MutableLiveData<List<ThingEntity>> getThings() {
        return things;
    }

    public void getAllThings(int minValue) {
        things.postValue(repository.getAllThings(minValue).getValue());
    }
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.fragment_first_page_expense_details, container, false);

    ....

    //Observe things and update data accordingly 
    viewModel.getThings().observe(this, new Observer<List<ThingEntity>>() {
        // I wonder if the progress bar value could be passed here to call my repository
        @Override
        public void onChanged(List<ThingEntity> thingEntities) {

            //check null here and skip
            if(thingEntities != null) {
                for (ThingEntity thing : thingEntities) {
                    totalSum[0] = totalSum[0] + thing.getThingAmount();
                }
                textViewTotalSum.setText(String.valueOf(totalSum[0]));
                adapter.setThingEntityList(thingEntities);
                setThingEntities(thingEntities);
            }
        }
    });

    //Initially call with default min 0
    viewModel.getAllThings(0);

    return root;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {

    //Just call to fetch content with progressValue and update adapter inside onChanged
    viewModel.getAllThings(progressValue);
}

Android app loads but crashes when SeekBar is released.

progressTextView.setText(String.valueOf(progressChangedValue));

Android app doesn't show SQL result as a number

           double price = rs.getDouble("Hind");
           BigDecimal price = rs.getBigDecimal("Hind");
           long price = rs.getLong("Hind");
-----------------------
           double price = rs.getDouble("Hind");
           BigDecimal price = rs.getBigDecimal("Hind");
           long price = rs.getLong("Hind");
-----------------------
           double price = rs.getDouble("Hind");
           BigDecimal price = rs.getBigDecimal("Hind");
           long price = rs.getLong("Hind");
-----------------------
priceTextView.setText(prices.get(position).toString());
priceTextView.setText(String.format("%.0f", prices.get(position)));
-----------------------
priceTextView.setText(prices.get(position).toString());
priceTextView.setText(String.format("%.0f", prices.get(position)));

COMMUNITY DISCUSSIONS

Top Trending Discussions on ProgressTextView
  • How to make a progress bar influence what data is on UI using a room database?
  • mysql driver class not found exception
  • Android app loads but crashes when SeekBar is released.
  • Android app doesn't show SQL result as a number
Top Trending Discussions on ProgressTextView

QUESTION

How to make a progress bar influence what data is on UI using a room database?

Asked 2019-Dec-29 at 14:58

I am using a SQLite database with Room. I want the progress of a SeekBar to influence the data retrieved/shown on the user interface. I have come up with the following solution, but fear that it is not scalable. I think it would be better if the seekbar's progress value would query the database itself and return data--rather than looping over all the data retrieved and excluding or including the data given a condition.

public class DetailsFirstTabFragment extends Fragment {

    private DetailsFirstTabViewModel viewModel;
    private RecyclerView recentThings;
    private TextView progressTextView;
    final RecentThings adapter = new RecentThings();
    private List<ThingEntity> thingEntities;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        viewModel =
                ViewModelProviders.of(this).get(DetailsFirstTabViewModel.class);
    }

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

        View root = inflater.inflate(R.layout.fragment_first_page_expense_details, container, false);

        recentThings = root.findViewById(R.id.recycler_view_recent_things);
        recentThings.setLayoutManager(new LinearLayoutManager(getContext()));
        recentThings.setHasFixedSize(true);

        recentThings.setAdapter(adapter);

        final float[] totalSum = {0};
        final TextView textViewTotalSum = root.findViewById(R.id.textViewStuffTotalSum);

        SeekBar seekBar = root.findViewById(R.id.seekBarStuffDetails);
        seekBar.setOnSeekBarChangeListener(seekBarChangeListener);

        progressTextView = root.findViewById(R.id.textViewProgress);

        viewModel.getAllThings().observe(this, new Observer<List<ThingEntity>>() {
// I wonder if the progress bar value could be passed here to call my repository
            @Override
            public void onChanged(List<ThingEntity> thingEntities) {
                for (ThingEntity thing : thingEntities) {
                    totalSum[0] = totalSum[0] + thing.getThingAmount();
                }
                textViewTotalSum.setText(String.valueOf(totalSum[0]));
                adapter.setThingEntityList(thingEntities);
                setThingEntities(thingEntities);
            }
        });
        return root;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        Bundle args = getArguments();
    }

    public void setThingEntities(List<ThingsEntity> thingEntities) {
        this.thingEntities = thingEntities;
    }
    SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
        int progressValue = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            String progressText = "Date " + String.valueOf(progress);
            progressValue = progress;
            progressTextView.setText(progressText);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
// this is the current implementation. It simply loops over every thing queried from database and sends the result to the adapter for drawing on the UI.
            List<ThingEntity> shownThings = new ArrayList<>();
            for (ThingEntity entity : thingEntities) {
                if (entity.getThingAmount() > progressValue) {
                    shownThings.add(entity);
                }
            }
            adapter.setThingEntityList(shownThings);
        }
    };
}
@Dao
public interface ThingDao {
    @Insert
    void insert(ThingEntity thingEntity);

    @Update
    void update(ThingEntity thingEntity);

    @Delete
    void delete(ThingEntity thingEntity);

    @Query("DELETE FROM things_table")
    void deleteAllThings();

    @Query("SELECT * FROM things_table ORDER BY thingDate ASC")
    LiveData<List<ThingEntity>> getAllThings();
public class DetailsFirstTabViewModel extends AndroidViewModel {
    private LiveData<List<ThingEntity>> things;
    private ThingRepository repository;

    public DetailsFirstTabViewModel(@NonNull Application application) {
        super(application);
        repository = new ThingRepository(application);
    }

    public LiveData<List<ThingEntity>> getAllThingss() {
        return repository.getAllThings();
    }

    public void insertThing(ThingEntity thingEntity) {
        repository.insert(thingEntity);
    }

    public void deleteThing(ThingEntity thingEntity) {
        repository.delete(thingEntity);
    }

    public void deleteAllThings() {
        repository.deleteAllThings();
    }

    public void deleteThingById(int id) {
        repository.deleteThingById(id);
    }
}

After attempting the answer below, I have resulted in the following. Still unable to work.

Dao:

@Query("SELECT * FROM things_table WHERE thingAmount >:minValue ORDER BY thingDate ASC")
    LiveData<List<ThingEntity>> getSpecificThings(int minValue);

Repository:

public LiveData<List<ThingEntity>> getSpecifiedThings(int minValue) {
    specifiedThings = thingDao.getSpecificThings(minValue);
    Log.d(TAG, "getSpecifiedThings: " + specifiedThings.getValue()); // returns null
    return specifiedThings;
}

View Model:

private MutableLiveData<List<ThingEntity>> thingsList = new MutableLiveData<>();

public MutableLiveData<List<ThingEntity>> getThingsList() {
    return thingsList;
}

public void getSpecifiedThings(int minValue) {
    thingsList.postValue(repository.getSpecifiedThings(minValue).getValue());
}

Fragment:

public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        ....

        Log.d(TAG, "onStopTrackingTouch: " + viewModel.getAllThings().getValue()); // returns null
        viewModel.getSpecifiedThings(1); //this should retrieve every entity in my database

        viewModel.getThingsList().observe(this, new Observer<List<ThingEntity>>() {
            @Override
            public void onChanged(List<ThingEntity> thingEntities) {
                if (thingEntities != null) { // returns null
                    adapter.setThingEntityList(thingEntities);
                }
                Log.d(TAG, "onChanged: " + thingEntities); // returns null
            }
        });
    ....
}

ThingEntity: ThingEntity:

@Entity(tableName = "things_table")
public class ThingEntity {
    @PrimaryKey(autoGenerate = true)
    private int id;

    private Date thingDate;
    private float thingAmount;
    private String classification;
    private String category;
    private String subcategory;
    private String placeName;
    private int placeCode;

    public ThingEntity(Date thingDate, float thingAmount, String classification,
                             String category, String subcategory, String placeName, int placeCode) {
        this.thingDate = thingDate;
        this.thingAmount = thingAmount;
        this.classification = classification;
        this.category = category;
        this.subcategory = subcategory;
        this.placeName = placeName;
        this.placeCode = placeCode;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public Date getThingDate() {
        return thingDate;
    }

    public float getThingAmount() {
        return thingAmount;
    }

    public String getClassification() {
        return classification;
    }

    public String getCategory() {
        return category;
    }

    public String getSubcategory() {
        return subcategory;
    }

    public String getPlaceName() {
        return placeName;
    }

    public int getPlaceCode() {
        return placeCode;
    }
}

ANSWER

Answered 2019-Dec-29 at 02:48

Change your dao's getAllThings to accept parameter

@Query("SELECT * FROM things_table WHERE thingAmount >:minValue ORDER BY thingDate ASC")
LiveData<List<ThingEntity>> getAllThings(int minValue);

Update your ViewModel and Repository as well to accept parameter

public class DetailsFirstTabViewModel extends AndroidViewModel {
    private MutableLiveData<List<ThingEntity>> things = new MutableLiveData<>();

    ...

    public MutableLiveData<List<ThingEntity>> getThings() {
        return things;
    }

    public void getAllThings(int minValue) {
        things.postValue(repository.getAllThings(minValue).getValue());
    }
}

Then from your fragment initially call with 0

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

    View root = inflater.inflate(R.layout.fragment_first_page_expense_details, container, false);

    ....

    //Observe things and update data accordingly 
    viewModel.getThings().observe(this, new Observer<List<ThingEntity>>() {
        // I wonder if the progress bar value could be passed here to call my repository
        @Override
        public void onChanged(List<ThingEntity> thingEntities) {

            //check null here and skip
            if(thingEntities != null) {
                for (ThingEntity thing : thingEntities) {
                    totalSum[0] = totalSum[0] + thing.getThingAmount();
                }
                textViewTotalSum.setText(String.valueOf(totalSum[0]));
                adapter.setThingEntityList(thingEntities);
                setThingEntities(thingEntities);
            }
        }
    });

    //Initially call with default min 0
    viewModel.getAllThings(0);

    return root;
}

And from onStopTrackingTouch call with progressValue

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

    //Just call to fetch content with progressValue and update adapter inside onChanged
    viewModel.getAllThings(progressValue);
}

Source https://stackoverflow.com/questions/59513674

QUESTION

mysql driver class not found exception

Asked 2019-Jan-29 at 14:03

I'm trying to use MySQL while learning Android, but this class not found exception occurs. I have imported the MySQL connecter jar file into my project, and I have set it up. I googled about the problem but only got a tomcat solution of the same problem but I still don't know how to solve this in Android.

 private class GetData extends AsyncTask<String,String,String> {

    String msg = "";
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    static final String DB_URL = "jdbc:mysql://"+
            DBStrings.DATABASE_URL +"/"+
            DBStrings.DATABASE_NAME;

    @Override
    protected void onPreExecute(){
    progressTextView.setText("Connecting to database");

    }

    @Override
    protected String doInBackground(String... strings) {
        Connection conn = null;
        Statement stmt = null;

        try {
            Class.forName(JDBC_DRIVER);
            conn = DriverManager.getConnection(DB_URL,DBStrings.USERNAME,DBStrings.PASSWORD);

            stmt = conn.createStatement();
            String sql = "SELECT * FROM medicine";
            ResultSet rs = stmt.executeQuery(sql);

            while(rs.next()){
                Integer ID = rs.getInt("ID");
                String name = rs.getString("Name");
                Integer date = rs.getInt("Date");
                medID.add(ID);
                names.add(name);
                medDate.add(date);

            }

            msg = "complete!";

            rs.close();
            stmt.close();
            conn.close();

        }catch (SQLException connERROR)
        {
            msg = "An exception was thrown for JDBC";
            connERROR.printStackTrace();
        }catch (ClassNotFoundException classERROR)
        {
            msg = "Class not found exception";
            classERROR.printStackTrace();
        }finally {

        }

        return null;
    }


}

ANSWER

Answered 2019-Jan-29 at 14:03

Don't use JDBC from an android device, just use J2EE servlets (simplest solution if you want to code in JAVA), and call these servlet from android through HTTP (you can use Retrofit Library to make these calls https://square.github.io/retrofit).

Source https://stackoverflow.com/questions/54422711

QUESTION

Android app loads but crashes when SeekBar is released.

Asked 2018-Nov-15 at 01:57

Sorry about what is likely a noob question. I am working on a simple android app that involves a seekbar.

The app runs, however, when I release the seekBar it causes my app to crash.

Im trying to set a textview when the seekbar is released, but instead of setting the textview, the app crashes.

I believe this is my issue. When I comment it out, I can drag the seekbar with no issues.

progressTextView.setText(progressChangedValue) ;

XML CODE

<SeekBar
    android:id="@+id/seekBar"
    android:layout_width="329dp"
    android:layout_height="32dp"
    android:layout_marginStart="29dp"
    android:layout_marginLeft="29dp"
    android:layout_marginEnd="26dp"
    android:layout_marginRight="26dp"
    android:layout_marginBottom="52dp"
    android:max="1000"
    android:progress="500" />

JAVA

SeekBar seeker = (SeekBar) findViewById(R.id.seekBar) ;
        progressTextView = (TextView)findViewById(R.id.seekBarLabel);




            seeker.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                int progressChangedValue = 0;
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                progressChangedValue = progress;
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                progressTextView.setText(progressChangedValue) ;
                }
            });

ANSWER

Answered 2018-Nov-15 at 01:57

You're passing an integer to setText(int), which is a resource id and does not exist in your case, so try changing it to a String or other types instead:

progressTextView.setText(String.valueOf(progressChangedValue));

Source https://stackoverflow.com/questions/53311324

QUESTION

Android app doesn't show SQL result as a number

Asked 2018-Jun-15 at 05:55

I've been developing an android app on Android Studio, and I've reached to the point where it's working, and I'm able to get data from my external SQL DB. The problem is, when I press Get Data button on my app, I get a number with a decimal point, and it ends with E12. For example, 8.41095645265E12. Yet, the number I entered into my database, is 8410376016789. The data type used for the specific column is int(255), PK, NN. I've tried switching it to varchar, and between PK and NN on my workbench, but it still remains. My guess is that it's not an SQL-related issue.

Here's my code for the activity

package com.example.manager.app;

import android.content.Context;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedHashMap;
import java.util.Map;

public class SeventhActivity extends AppCompatActivity {

ItemAdapter itemAdapter;
Context thisContext;
ListView myListView;
TextView progressTextView;
Map<String, Double> myprojectMap = new LinkedHashMap<String, Double>();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fourth);

    Resources res = getResources();
    myListView = (ListView) findViewById(R.id.myListView);
    progressTextView = (TextView) findViewById(R.id.progressTextView);
    thisContext = this;

    progressTextView.setText("");
    Button btn = (Button) findViewById(R.id.getDataButton);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            GetData retrieveData = new GetData();
            retrieveData.execute("");
        }
    });
}

private class GetData extends AsyncTask<String,String,String> {

    String msg = "";
    // JDBC Driver name and database URL
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    // Example 10.20.30.40:3306
    static final String DB_URL = "jdbc:mysql://" +
            DbStrings.DATABASE_URL + "/" +
            DbStrings.DATABASE_NAME;

    @Override
    protected void onPreExecute() {
        progressTextView.setText("Connecting to Database...");
    }

    @Override
    protected String doInBackground(String... strings) {

        Connection conn = null;
        Statement stmt = null;

        try {
            Class.forName(JDBC_DRIVER);
            conn = DriverManager.getConnection(DB_URL, DbStrings.USERNAME, DbStrings.PASSWORD);

            stmt = conn.createStatement();
            String sql = "SELECT * FROM mythisone.codes";
            ResultSet rs = stmt.executeQuery(sql);

            while (rs.next()) {
                String name = rs.getString("Toode");
                double price = rs.getDouble("Hind");

                myprojectMap.put(name, price);
            }

            msg = "Process complete.";

            rs.close();
            stmt.close();
            conn.close();

        } catch (SQLException connError) {
            msg = "An exception was thrown for JDBC.";
            connError.printStackTrace();
        } catch (ClassNotFoundException e) {
            msg = "A class not found exception was thrown.";
            e.printStackTrace();
        } finally {

            try {
                if (stmt != null) {
                    stmt.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }

            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }

        return null;
    }

    @Override
    protected void onPostExecute(String msg) {

        progressTextView.setText(this.msg);

        if (myprojectMap.size() >0) {

            itemAdapter = new ItemAdapter(thisContext, myprojectMap);
            myListView.setAdapter(itemAdapter);
        }

    }
}

} //END of MainActivity

Is there anything I left unnoticed? Thanks

ANSWER

Answered 2018-Jun-11 at 14:43

The number being returned is in scientific notation.

To look at converting to a regular int, see this question.

Source https://stackoverflow.com/questions/50800271

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

VULNERABILITIES

No vulnerabilities reported

INSTALL ProgressTextView

You can use ProgressTextView like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ProgressTextView component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

SUPPORT

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Implement ProgressTextView faster with kandi.

  • Use the support, quality, security, license, reuse scores and reviewed functions to confirm the fit for your project.
  • Use the, Q & A, Installation and Support guides to implement faster.

Discover Millions of Libraries and
Pre-built Use Cases on kandi