how to select the image from gallery by clicking on imageview on navigation drawer for user profile picture

I have created the navigation activity already,in which I want to make the image view on navigation drawer header as an user profile image.And the user selection of that image should done in gallery. I have searched a plenty of tutorials. I didn’t get solution.Either I need code for it or comment a matching tutorial for this situation.Anyone help me with this.

public class SecondActivity extends AppCompatActivity
    implements NavigationView.OnNavigationItemSelectedListener {
NavigationView navigationView = null;
Toolbar toolbar = null;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    DownloadFragment fragment = new DownloadFragment();
    android.support.v4.app.FragmentTransaction fragmentTransaction =
            getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.commit();
    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) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}

@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.second, menu);
    return (super.onCreateOptionsMenu(menu));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.id.chat) {

        startActivity(new Intent(SecondActivity.this, ChatFragment.class));
        return (true);
    } else if (item.getItemId() == R.id.upload) {
        startActivity(new Intent(SecondActivity.this, UploadFlash.class));
        return (true);
    } else if (item.getItemId() == R.id.download) {
        startActivity(new Intent(SecondActivity.this, DownloadFragment.class));
        return (true);
    } else if (item.getItemId() == R.id.action_settings) {
        startActivity(new Intent(SecondActivity.this, SettingsFragment.class));
        return (true);
    } else if (item.getItemId() == R.id.offline) {
        startActivity(new Intent(SecondActivity.this, OfflineNotesFragment.class));
        return (true);
    } else if (item.getItemId() == R.id.drawges) {
        startActivity(new Intent(SecondActivity.this, OfflineNotesFragment.class));
        return (true);
    }
    return (super.onOptionsItemSelected(item));
}


@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.chat) {
        // Handle the camera action
        ChatFragment fragment = new ChatFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();
    } else if (id == R.id.upload) {
        UploadFlash fragment = new UploadFlash();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();

    } else if (id == R.id.download) {
        DownloadFragment fragment = new DownloadFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();

    } else if (id == R.id.action_settings) {
        SettingsFragment fragment = new SettingsFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();
    } else if (id == R.id.offline) {
        OfflineNotesFragment fragment = new OfflineNotesFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();
    } else if (id == R.id.drawges) {
        DrawingFragment fragment = new DrawingFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

In Karate DSL, How do I verify the field names within the response without caring about what their values are

I could not find anything in the documentation regarding this but I am trying to verify the field names within a response. I do not care what their values are. What would be the proper way to do this using Karate DSL? My focus is on the response match below.

Given path ‘serviceRequests’, ‘tasks’
And param view = ‘short’
* header Authorization = ‘Bearer ‘ + Token
When method get
Then status 200
And match response == { page: ‘i-dont-care’, total: ‘i-dont-care’}

RecordTooLargeException in Kafka streams join

I have a KStream x KStream join which is breaking down with the following exception.

Exception in thread “my-clicks-and-recs-join-streams-4c903fb1-5938-4919-9c56-2c8043b86986-StreamThread-1" org.apache.kafka.streams.errors.StreamsException: Exception caught in process. taskId=0_15, processor=KSTREAM-SOURCE-0000000001, topic=my_outgoing_recs_prod, partition=15, offset=9248896
    at org.apache.kafka.streams.processor.internals.StreamTask.process(StreamTask.java:203)
    at org.apache.kafka.streams.processor.internals.StreamThread.processAndPunctuate(StreamThread.java:679)
    at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:557)
    at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:527)
Caused by: org.apache.kafka.streams.errors.StreamsException: task [0_15] exception caught when producing
    at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.checkForException(RecordCollectorImpl.java:136)
    at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.send(RecordCollectorImpl.java:87)
    at org.apache.kafka.streams.state.internals.StoreChangeLogger.logChange(StoreChangeLogger.java:59)
    at org.apache.kafka.streams.state.internals.ChangeLoggingSegmentedBytesStore.put(ChangeLoggingSegmentedBytesStore.java:59)
    at org.apache.kafka.streams.state.internals.MeteredSegmentedBytesStore.put(MeteredSegmentedBytesStore.java:105)
    at org.apache.kafka.streams.state.internals.RocksDBWindowStore.put(RocksDBWindowStore.java:107)
    at org.apache.kafka.streams.state.internals.RocksDBWindowStore.put(RocksDBWindowStore.java:100)
    at org.apache.kafka.streams.kstream.internals.KStreamJoinWindow$KStreamJoinWindowProcessor.process(KStreamJoinWindow.java:64)
    at org.apache.kafka.streams.processor.internals.ProcessorNode$1.run(ProcessorNode.java:47)
    at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:187)
    at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:133)
    at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:82)
    at org.apache.kafka.streams.processor.internals.SourceNode.process(SourceNode.java:80)
    at org.apache.kafka.streams.processor.internals.StreamTask.process(StreamTask.java:189)
    ... 3 more
Caused by: org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept.

I am joining a Click topic with a Recommendation topic. The Click objects are really small (less than a KB). Recommendation, on the other hand, might be big, occasionally bigger than 1 MB.

I Googled for the exception and found ( here) that I need to set max.request.size in the producer configs.

What I don’t understand is, where does the producer come into picture in the streams join? The topic in the exception above topic=my_outgoing_recs_prod is the recommendations topic, and not the final joined topic. Isn’t the streaming application supposed to just “consume” from it?

Nevertheless, I tried setting the property as config.put("max.request.size", "31457280");, which is 30MB. I don’t expect the recommendations record to exceed that limit. Still, the code is crashing.

I cannot change the configs in the Kafka cluster but, if needed, I can change the properties of the relevant topics in Kafka.

Could someone suggest what else I can try?

If nothing works, I am willing to ignore such oversizes messages. However, I don’t know a way of handling this RecordTooLargeException.

My code to perform the join is as follows.

KStreamBuilder builder = new KStreamBuilder();

KStream<String, byte[]> clicksStream = builder.stream(TopologyBuilder.AutoOffsetReset.LATEST, Serdes.String(), Serdes.ByteArray(), clicksTopic);
KStream<String, byte[]> recsStream = builder.stream(TopologyBuilder.AutoOffsetReset.LATEST, Serdes.String(), Serdes.ByteArray(), recsTopic);

KStream<String, ClickRec> join = clicksStream.join(
        recsStream,
        (click, recs) -> new ClickRec(click, recs),
        JoinWindows.of(windowMillis).until(3*windowMillis));

join.to(Serdes.String(), JoinSerdes.CLICK_SERDE, jointTopic);

KafkaStreams streams = new KafkaStreams(builder, config);
streams.cleanUp();
streams.start();

ClickRec is the joined object (which is far smaller than a Recommendation object and I don’t expect it to be bigger than a few KBs).

Where do I put a try...catch in the code above to recover from such occasionally oversized objects?

Jar file does not find sqlite data base path

I’m working on javaFx project ,I have a problem that when i run my project in netbeans every thing is well but when i run my jar file by using cmd i find this error :enter image description here

This my part of code to connect to database :

package Connection;

import java.sql.*;
import org.sqlite.SQLiteConfig;

/**
 *
 * @author Ala_Eddine
 */
public class Dbaconnection {

    private static Connection connection;

    public Dbaconnection() {
        try {
            Class.forName("org.sqlite.JDBC");
            SQLiteConfig config = new SQLiteConfig();
            config.enforceForeignKeys(true);
            connection = DriverManager.getConnection("jdbc:sqlite:src/DataBase/Beans/sqllite/Model/Data.db",config.toProperties());
            System.out.println("Connection accepted" + connection);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() throws SQLException {
        if (connection == null) {
            Dbaconnection dbaconnection = new Dbaconnection();
        }
        return connection;
    }

    public static void main(String[] args) throws SQLException {

        getConnection();

    }

}

And this is a location of database file :

enter image description here

Maven package org.apache.commons.codec.binary does not exist

Running:

mvn compile

Generates error:

package org.apache.commons.codec.binary does not exist

pom.xml includes:

  <dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.10</version>
  </dependency>

ls ~/.m2/repository/commons-codec/commons-codec/1.10

Returns:

commons-codec-1.10.jar
commons-codec-1.10.jar.sha1  
commons-codec-1.10.pom  
commons-codec-1.10.pom.sha1  
_remote.repositories

jar tvf commons-codec-1.10.jar | grep binary

Returns:

org/apache/commons/codec/binary/
org/apache/commons/codec/binary/Base32.class
org/apache/commons/codec/binary/Base32InputStream.class
org/apache/commons/codec/binary/Base32OutputStream.class
org/apache/commons/codec/binary/Base64.class
org/apache/commons/codec/binary/Base64InputStream.class
org/apache/commons/codec/binary/Base64OutputStream.class
org/apache/commons/codec/binary/BaseNCodec$Context.class
org/apache/commons/codec/binary/BaseNCodec.class
org/apache/commons/codec/binary/BaseNCodecInputStream.class
org/apache/commons/codec/binary/BaseNCodecOutputStream.class
org/apache/commons/codec/binary/BinaryCodec.class
org/apache/commons/codec/binary/CharSequenceUtils.class
org/apache/commons/codec/binary/Hex.class
org/apache/commons/codec/binary/StringUtils.class

Any suggestions regarding why mvn cannot resolve this package would be much appreciated.

FYI, just getting started with maven.

Thanks,

KevinC

Kotlin Android studio apk has stopped

I recently build simple calculator on Android Studio using Kotlin language, entire code is error free but I don’t know why app not working.
I tried on android Emulator with OS marshmallow and also tried on my Phone have OS Nougat, but same problem on both devices. error message “App has Stopped”.

Code:

package com.example.shafique_ur_rehman.kotlinfirstappsimplecalculator

     import android.support.v7.app.AppCompatActivity
     import android.os.Bundle
     import android.support.annotation.IntegerRes
     import android.view.View
     import android.widget.Button
     import android.widget.EditText
     import android.widget.TextView

    class MainActivity : AppCompatActivity() {

 override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    val result = findViewById(R.id.textViewResult) as TextView
    val button_plus = findViewById(R.id.button_plus) as Button
    val button_minus = findViewById(R.id.button_minus) as Button
    val button_multiply = findViewById(R.id.button_multiply) as Button
    val button_divid = findViewById(R.id.button_divid) as Button
    button_plus.setOnClickListener(View.OnClickListener { view ->
        result.text = (getNum1() + getNum2()).toString()
    })
    button_minus.setOnClickListener(View.OnClickListener { view ->
        result.text = (getNum1() - getNum2()).toString()
    })
    button_multiply.setOnClickListener(View.OnClickListener { view ->
        result.text = (getNum1() * getNum2()).toString()
    })
    button_divid.setOnClickListener(View.OnClickListener { view ->
        result.text = (getNum1() / getNum2()).toString()
    })

}

fun getNum1(): Int {
    val input_num1 = findViewById(R.id.editText1) as EditText
    return Integer.parseInt(input_num1.text.toString())
}

fun getNum2(): Int {
    val input_num2 = findViewById(R.id.editText2) as EditText
    return Integer.parseInt(input_num2.text.toString())
    }
     }

See the screenshot

Hibernate didn’t create table

I have 7 entity and I set hibernate.hbm2ddl.auto to crate-drop.when I run my web application this sentence would print for all tables

create table table_name….

.
all table will create except one.
this is my comments entity that hibernate didn’t create its table.

@Entity(name = "comments")
@Table(name = "COMMENTS")
public class Comments implements Serializable{
    @Id
    @Column(name = "ID",columnDefinition = "NUMBER")
    @SequenceGenerator(name = "COM_SEQ",sequenceName = "COM_SEQ",allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.AUTO,generator = "COM_SEQ")
    private Long id;
    @Column(name = "CONTENT",columnDefinition = "NCLOB")
    private String content;
    @Column(name = "date",columnDefinition = "NVARCHAR2(20)")
    private String date;
    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "USER_ID")
    public Person person;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "DOCTOR_ID")
    public Doctor doctor;

I didn’t understand why this happened?

Unsure of how to catch and reassign synthetic members in a class

I’m currently using the jacoco maven plugin in my project. I’ve written my unit tests using mockito. I’ve read the jacoco FAQs, the Google Groups page, and the Jacoco github issues threads about catching synthetic member fields in a Unit Test class and reassigning them as the jacoco injected object doesn’t know what to do with synthetic members.

However a great many of my unit tests are setup and mocked using the mockito framework, and I don’t think Jacoco likes the MockMvc object class. I think the class itself is implemented somehow using reflection which is causing jacoco to fail.

My error when I run mvn test is:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is my.project.submodule.controller.ControllerException: Unknown property '$jacocoData'

My code snippet that’s triggering this is:

mockMvc.perform(
            get("/api/substituteStuff"))
            .andExpect(jsonPath("$", hasSize(10)))
            .andExpect(status().isOk())

Cordova – No resource found that matches the given name ‘android:TextAppearance.Material.Widget.Button.Borderless.Colored’

I have a problem with newest SDK 26 I think.

> cordova build android --release
✖ Running command - failed!
[ERROR] An error occurred while running cordova build android --release (exit code 1):

        (truncated) ... PI.
        Note: Recompile with -Xlint:deprecation for details.
        :CordovaLib:processReleaseJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForRelease
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
        :CordovaLib:mergeReleaseJniLibFolders
        :CordovaLib:transformNative_libsWithMergeJniLibsForRelease
        :CordovaLib:transformNative_libsWithSyncJniLibsForRelease
        :CordovaLib:bundleRelease
        :prepareComAndroidSupportAnimatedVectorDrawable2540Library
        :prepareComAndroidSupportAppcompatV72540Library
        :prepareComAndroidSupportCustomtabs2540Library
        :prepareComAndroidSupportSupportCompat2540Library
        :prepareComAndroidSupportSupportCoreUi2540Library
        :prepareComAndroidSupportSupportCoreUtils2540Library
        :prepareComAndroidSupportSupportFragment2540Library
        :prepareComAndroidSupportSupportMediaCompat2540Library
        :prepareComAndroidSupportSupportV42540Library
        :prepareComAndroidSupportSupportVectorDrawable2540Library
        :prepareComCommit451PhotoView124Library
        :prepareComGithubErgoviaMobileAndroidTranscoderV0110R_ergoviaLibrary
        :prepareComGoogleAndroidGmsPlayServicesAnalytics1122Library
        :prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl1122Library
        :prepareComGoogleAndroidGmsPlayServicesBase1122Library
        :prepareComGoogleAndroidGmsPlayServicesBasement1122Library
        :prepareComGoogleAndroidGmsPlayServicesGcm1122Library
        :prepareComGoogleAndroidGmsPlayServicesIid1122Library
        :prepareComGoogleAndroidGmsPlayServicesLocation1122Library
        :prepareComGoogleAndroidGmsPlayServicesTagmanagerV4Impl1122Library
        :prepareComGoogleAndroidGmsPlayServicesTasks1122Library
        :prepareComOnesignalOneSignal362Library
        :prepareComPaypalSdkPaypalAndroidSdk2153Library
        :prepareIoCardAndroidSdk540Library
        :prepareMeLeolinShortcutBadger1118Library
        :prepareOrgApacheCordovaCordovaLib630ReleaseLibrary
        :prepareReleaseDependencies
        :compileReleaseAidl
        :compileReleaseRenderscript
        :generateReleaseBuildConfig
        :generateReleaseResValues
        :generateReleaseResources
        :mergeReleaseResources
        :processReleaseManifest
        :processReleaseResources/bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.


          FAILED

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':processReleaseResources'.
        > com.android.ide.common.process.ProcessException: Failed to execute aapt

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

        BUILD FAILED

        Total time: 1 mins 50.102 secs
        Error: /bitrise/src/platforms/android/gradlew: Command failed with exit code 1 Error output:
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

        /bitrise/src/platforms/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.



        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':processReleaseResources'.
        > com.android.ide.common.process.ProcessException: Failed to execute aapt

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I tried to specify higher target sdk. But it not works.

<preference name="android-minSdkVersion" value="18" />
<preference name="android-targetSdkVersion" value="25" />

Maybe its this v24 file problem? But how to solve?

values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.Button.Colored’.

Do you know how to fix? Thanks in Advance!

update variable every 1 second

hi i am new in java programming i have a big problem when i use timer or while loop for my program to show my variable and update it my program will stopped, not stopped working just nothing i cant do anything in my program my game is a easy game that we should got money from … ways and i want to show my money every x second. every second isn’t important for me just a code that not stop my program, here is my money code:

       static int money = 0;
       static int energy = 100;
       static String energyinfo = Integer.toString(energy);
       static String moneyinfo = Integer.toString(money);

       private void setmoneyenergy()
       {
            energyinfo = Integer.toString(energy);
            moneyinfo = Integer.toString(money);
            jenergy.setText(energyinfo);
            jmoney.setText(moneyinfo);
       }

while is in a button actionperformed

    while(true)
    {
       setpoolenergy();
    }